コード例 #1
0
void issueLineToShipping::sIssue()
{
  if (_qtyToIssue->toDouble() <= 0)
  {
    XMessageBox::message( (isShown() ? this : parentWidget()), QMessageBox::Warning, tr("Invalid Quantity to Issue to Shipping"),
                          tr(  "<p>Please enter a non-negative, non-zero value to indicate the amount "
                               "of Stock you wish to Issue to Shipping for this Order Line." ),
                          QString::null, QString::null, _snooze );
    _qtyToIssue->setFocus();
    return;
  }

  if(_requireInventory || ("SO" == _ordertype && _metrics->boolean("EnableSOReservations")))
  {
    q.prepare("SELECT sufficientInventoryToShipItem(:ordertype, :orderitemid, :orderqty) AS result;");
    q.bindValue(":ordertype",   _ordertype);
    q.bindValue(":orderitemid", _itemid);
//    if(!_requireInventory)
      q.bindValue(":orderqty",  _qtyToIssue->toDouble());
    q.exec();
    if (q.first())
    {
      int result = q.value("result").toInt();
      if (result < 0)
      {
        ParameterList errp;
        if (_ordertype == "SO")
          errp.append("soitem_id", _itemid);
        else if (_ordertype == "TO")
          errp.append("toitem_id", _itemid);

        QString errs = "<? if exists(\"soitem_id\") ?>"
            "SELECT item_number, warehous_code "
            "  FROM coitem, item, itemsite, whsinfo "
            " WHERE ((coitem_itemsite_id=itemsite_id)"
            "   AND  (itemsite_item_id=item_id)"
            "   AND  (itemsite_warehous_id=warehous_id)"
            "   AND  (coitem_id=<? value(\"soitem_id\") ?>));"
            "<? elseif exists(\"toitem_id\")?>"
            "SELECT item_number, tohead_srcname AS warehous_code "
            "  FROM toitem, tohead, item "
            " WHERE ((toitem_item_id=item_id)"
            "   AND  (toitem_tohead_id=tohead_id)"
            "   AND  (toitem_id=<? value(\"toitem_id\") ?>));"
            "<? endif ?>" ;
        MetaSQLQuery errm(errs);
        q = errm.toQuery(errp);
        if (! q.first() && q.lastError().type() != QSqlError::None)
            systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        systemError(this,
              storedProcErrorLookup("sufficientInventoryToShipItem",
                  result)
              .arg(q.value("item_number").toString())
              .arg(q.value("warehous_code").toString()), __FILE__, __LINE__);
        return;
      }
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }

  // check to see if we are over issuing
  ParameterList params;
  if (_ordertype == "SO")
    params.append("soitem_id", _itemid);
  else if (_ordertype == "TO")
    params.append("toitem_id", _itemid);
  params.append("qty", _qtyToIssue->toDouble());

  QString sql = "<? if exists(\"soitem_id\") ?>"
	    "SELECT (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) <"
	    "           (COALESCE(SUM(shipitem_qty), 0) + <? value(\"qty\") ?>)) AS overship"
            "  FROM coitem LEFT OUTER JOIN"
            "        ( shipitem JOIN shiphead"
            "          ON ( (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) )"
            "        ) ON  (shipitem_orderitem_id=coitem_id)"
            " WHERE (coitem_id=<? value(\"soitem_id\") ?>)"
            " GROUP BY coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned;"
	    "<? elseif exists(\"toitem_id\") ?>"
	    "SELECT (noNeg(toitem_qty_ordered - toitem_qty_shipped) <"
	    "           (COALESCE(SUM(shipitem_qty), 0) + <? value(\"qty\") ?>)) AS overship"
            "  FROM toitem LEFT OUTER JOIN"
            "        ( shipitem JOIN shiphead"
            "          ON ( (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) )"
            "        ) ON  (shipitem_orderitem_id=toitem_id)"
            " WHERE (toitem_id=<? value(\"toitem_id\") ?>)"
            " GROUP BY toitem_qty_ordered, toitem_qty_shipped;"
	    "<? endif ?>"
	    ;
  MetaSQLQuery mql(sql);
  q = mql.toQuery(params);
  if (q.next() && q.value("overship").toBool())
  {
    if(XMessageBox::message( (isShown() ? this : parentWidget()) , QMessageBox::Question, tr("Inventory Overshipped"),
        tr("<p>You have selected to ship more inventory than required. Do you want to continue?"),
        tr("Yes"), tr("No"), _snooze, 0, 1) == 1)
      return;
  }
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  XSqlQuery rollback;
  rollback.prepare("ROLLBACK;");

  XSqlQuery issue;
  issue.exec("BEGIN;");
  issue.prepare("SELECT issueToShipping(:ordertype, :lineitem_id, :qty, 0, :ts) AS result;");
  issue.bindValue(":ordertype",   _ordertype);
  issue.bindValue(":lineitem_id", _itemid);
  issue.bindValue(":qty",         _qtyToIssue->toDouble());
  issue.bindValue(":ts",          _transTS);
  issue.exec();

  if (issue.first())
  {
    int result = issue.value("result").toInt();
    if (result < 0)
    {
      rollback.exec();
      systemError( this, storedProcErrorLookup("issueToShipping", result),
		  __FILE__, __LINE__);
      return;
    }
    else
    {
      if (distributeInventory::SeriesAdjust(result, this) == XDialog::Rejected)
      {
        rollback.exec();
        QMessageBox::information( this, tr("Issue to Shipping"), tr("Issue Canceled") );
        return;
      }
      
      issue.exec("COMMIT;");
      accept();
    }
  }
  else if (issue.lastError().type() != QSqlError::None)
  {
    rollback.exec();
    systemError(this, issue.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
コード例 #2
0
void printShippingForm::sHandleShipment()
{
  if (_shipment->isValid())
  {
    ParameterList params;
    MetaSQLQuery mql = mqlLoad(":/sr/forms/printShippingForm/HandleShipment.mql");
    params.append("shiphead_id", _shipment->id());
    if (_metrics->boolean("MultiWhs"))
      params.append("MultiWhs");
    if (_so->isValid())
      params.append("sohead_id", _so->id());
    if (_to->isValid())
      params.append("tohead_id", _to->id());
    q = mql.toQuery(params);

    if (q.first())
    {
      int orderid = q.value("order_id").toInt();
      if (q.value("shiphead_order_type").toString() == "SO" && _so->id() != orderid)
      {
	_to->setId(-1);
	_so->setId(orderid);
      }
      else if (q.value("shiphead_order_type").toString() == "TO" && _to->id() != orderid)
      {
	_so->setId(-1);
	_to->setId(orderid);
      }

      _shipToName->setText(q.value("shipto").toString());
      _shipToAddr1->setText(q.value("addr1").toString());
      _shippingForm->setId(q.value("shipform_id").toInt());
      _shipchrg->setId(q.value("shiphead_shipchrg_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    else if (_so->isValid())
    {
      _so->setId(-1);
      sHandleShipment();
    }
    else if (_to->isValid())
    {
      _to->setId(-1);
      sHandleShipment();
    }
    else
    {
      QMessageBox::critical(this, tr("Could not find data"),
			    tr("<p>Could not find a Sales Order or "
			       "Transfer Order for this Shipment."));

      depopulate();
    }
  }
  else
  {
    depopulate();
  }
}
コード例 #3
0
void postCreditMemos::sPost()
{
  q.exec( "SELECT cmhead_printed, COUNT(*) AS number "
          "FROM ( SELECT cmhead_id, cmhead_printed "
          "       FROM cmhead "
          "       WHERE (NOT cmhead_posted) ) AS data "
          "WHERE (checkCreditMemoSitePrivs(cmhead_id)) "
          "GROUP BY cmhead_printed;" );
  if (q.first())
  {
    int printed   = 0;
    int unprinted = 0;

    do
    {
      if (q.value("cmhead_printed").toBool())
        printed = q.value("number").toInt();
      else
        unprinted = q.value("number").toInt();
    }
    while (q.next());

    if ( ( (unprinted) && (!printed) ) && (!_postUnprinted->isChecked()) )
    {
      QMessageBox::warning( this, tr("No Credit Memos to Post"),
                            tr( "Although there are unposted Credit Memos, there are no unposted Credit Memos that have been printed.\n"
                                "You must manually print these Credit Memos or select 'Post Unprinted Credit Memos' before these Credit Memos\n"
                                "may be posted." ) );
      _postUnprinted->setFocus();
      return;
    }
  }
  else
  {
    QMessageBox::warning( this, tr("No Credit Memos to Post"),
                          tr("There are no Credit Memos, printed or not, to post.\n" ) );
    _close->setFocus();
    return;
  }

  q.exec("SELECT fetchJournalNumber('AR-CM') AS result");
  if (!q.first())
  {
    systemError(this, tr("A System Error occurred at %1::%2.")
                      .arg(__FILE__)
                      .arg(__LINE__) );
    return;
  }

  int journalNumber = q.value("result").toInt();
  
  XSqlQuery rollback;
  rollback.prepare("ROLLBACK;");

  q.exec("BEGIN;");	// because of possible lot, serial, or location distribution cancelations
  q.prepare("SELECT postCreditMemos(:postUnprinted, :journalNumber) AS result;");
  q.bindValue(":postUnprinted", QVariant(_postUnprinted->isChecked()));
  q.bindValue(":journalNumber", journalNumber);
  q.exec();
  if (q.first())
  {
    int result = q.value("result").toInt();

    if (result == -5)
    {
      rollback.exec();
      QMessageBox::critical( this, tr("Cannot Post one or more Credit Memos"),
                             tr( "The G/L Account Assignments for one or more of the Credit Memos that you are trying to post are not\n"
                                 "configured correctly.  Because of this, G/L Transactions cannot be posted for these Credit Memos.\n"
                                 "You must contact your Systems Administrator to have this corrected before you may\n"
                                 "post these Credit Memos." ) );
      return;
    }
    else if (result < 0)
    {
      rollback.exec();
      systemError( this, tr("A System Error occurred at postCreditMemos::%1, Error #%2.")
                         .arg(__LINE__)
                         .arg(q.value("result").toInt()) );
      return;
    }
    else if (distributeInventory::SeriesAdjust(q.value("result").toInt(), this) == XDialog::Rejected)
    {
      rollback.exec();
      QMessageBox::information( this, tr("Post Credit Memos"), tr("Transaction Canceled") );
      return;
    }

    q.exec("COMMIT;");

    if (_printJournal->isChecked())
    {
      ParameterList params;
      params.append("journalNumber", journalNumber);

      orReport report("CreditMemoJournal", params);
      if (report.isValid())
        report.print();
      else
        report.reportError(this);
    }
  }
  else
  {
    rollback.exec();
    systemError( this, tr("A System Error occurred at postCreditMemos::%1.")
                       .arg(__LINE__) );
    return;
  }

  omfgThis->sCreditMemosUpdated();

  accept();
}
コード例 #4
0
ファイル: voucherItem.cpp プロジェクト: Wushaowei001/xtuple-1
void voucherItem::sFillList()
{
  q.prepare( "SELECT vodist_id,"
             "       COALESCE(costelem_type, :none) AS costelem_type,"
             "       vodist_amount, 'currval' AS vodist_amount_xtnumericrole "
             "FROM vodist "
             "     LEFT OUTER JOIN costelem ON (vodist_costelem_id=costelem_id) "
             "WHERE ( (vodist_poitem_id=:poitem_id)"
             " AND (vodist_vohead_id=:vohead_id) );" );
  q.bindValue(":none", tr("None"));
  q.bindValue(":poitem_id", _poitemid);
  q.bindValue(":vohead_id", _voheadid);
  q.exec();
  _vodist->populate(q);
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }

  // Display the total distributed amount
  q.prepare( "SELECT SUM(vodist_amount) AS totalamount "
             "FROM vodist "
             "WHERE ( (vodist_vohead_id=:vohead_id)"
             " AND (vodist_poitem_id=:poitem_id) );" );
  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":poitem_id", _poitemid);
  q.exec();
  if (q.first())
    _totalDistributed->setLocalValue(q.value("totalamount").toDouble() + _tax->localValue() + 
					_freightToVoucher->localValue());
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }
          
  // Fill univoiced receipts list
  q.prepare( "SELECT porecv_id AS item_id, 1 AS item_type, :receiving AS action,"
             "       porecv_date AS item_date,"
             "       porecv_qty AS qty, 'qty' AS qty_xtnumericrole,"
             "       formatBoolYN(porecv_vohead_id=:vohead_id) AS f_tagged,"
             "       0 AS qty_xttotalrole "
             "FROM porecv "
             "WHERE ( (NOT porecv_invoiced)"
             " AND ((porecv_vohead_id IS NULL) OR (porecv_vohead_id=:vohead_id))"
             " AND (porecv_poitem_id=:poitem_id) ) "

             "UNION "
             "SELECT poreject_id AS item_id, 2 AS item_type, :reject AS action,"
             "       poreject_date AS item_date,"
             "       poreject_qty * -1 AS qty, 'qty', "
             "       formatBoolYN(poreject_vohead_id=:vohead_id) AS f_tagged,"
             "       0 AS qty_xttotalrole "
             "FROM poreject "
             "WHERE ( (poreject_posted)"
             " AND (NOT poreject_invoiced)"
             " AND ((poreject_vohead_id IS NULL) OR (poreject_vohead_id=:vohead_id))"
             " AND (poreject_poitem_id=:poitem_id) );" );
  q.bindValue(":receiving", tr("Receiving"));
  q.bindValue(":reject", tr("Reject"));
  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":poitem_id", _poitemid);
  q.exec();
  _uninvoiced->populate(q, true);
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }
 }
コード例 #5
0
enum SetResponse printShippingForm::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("cosmisc_id", &valid);	// deprecated
  if (valid)
  {
    _shipment->setId(param.toInt());
    q.prepare( "SELECT cohead_id, cohead_shiptoname, cohead_shiptoaddress1, cosmisc_shipchrg_id,"
               "       COALESCE(cosmisc_shipform_id, cohead_shipform_id) AS shipform_id "
               "FROM cosmisc, cohead "
               "WHERE ( (cosmisc_cohead_id=cohead_id)"
               " AND (cosmisc_id=:cosmisc_id) );" );
    q.bindValue(":cosmisc_id", _shipment->id());
    q.exec();
    if (q.first())
    {
      _captive = TRUE;

      _so->setId(q.value("cohead_id").toInt());
      _so->setEnabled(FALSE);

      _shipToName->setText(q.value("cohead_shiptoname").toString());
      _shipToAddr1->setText(q.value("cohead_shiptoaddress1").toString());
      _shippingForm->setId(q.value("shipform_id").toInt());
      _shipchrg->setId(q.value("cosmisc_shipchrg_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
    _print->setFocus();
  }

  param = pParams.value("shiphead_id", &valid);
  if (valid)
  {
    int orderid = -1;
    QString ordertype;

    _shipment->setId(param.toInt());
    q.prepare( "SELECT shiphead_order_id, shiphead_order_type,"
	       "       shiphead_shipchrg_id, shiphead_shipform_id "
	       "FROM shiphead "
	       "WHERE (shiphead_id=:shiphead_id);" );
    q.bindValue(":shiphead_id", _shipment->id());
    q.exec();
    if (q.first())
    {
      ordertype = q.value("shiphead_order_type").toString();
      orderid = q.value("shiphead_order_id").toInt();
      if (! q.value("shiphead_shipform_id").isNull())
	_shippingForm->setId(q.value("shiphead_shipform_id").toInt());
      _shipchrg->setId(q.value("shiphead_shipchrg_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }

    ParameterList headp;
    if (ordertype == "SO")
    {
      headp.append("sohead_id", orderid);
      _to->setId(-1);
      _so->setId(orderid);
    }
    else if (ordertype == "TO")
    {
      headp.append("tohead_id", orderid);
      _so->setId(-1);
      _to->setId(orderid);
    }

    QString heads = "<? if exists(\"sohead_id\") ?>"
		  "SELECT cohead_id AS order_id, cohead_shiptoname AS shipto,"
		  "      cohead_shiptoaddress1 AS addr1,"
		  "      cohead_shipform_id AS shipform_id "
		  "FROM cohead "
		  "WHERE (cohead_id=<? value(\"sohead_id\") ?>);"
		  "<? elseif exists(\"tohead_id\") ?>"
		  "SELECT tohead_id AS order_id, tohead_destname AS shipto,"
		  "      tohead_destaddress1 AS addr1,"
		  "      tohead_shipform_id AS shipform_id "
		  "FROM tohead "
		  "WHERE (tohead_id=<? value(\"tohead_id\") ?>);"
		  "<? endif ?>"
		  ;
    MetaSQLQuery headm(heads);
    XSqlQuery headq = headm.toQuery(headp);
    if (headq.first())
    {
      _captive = TRUE;

      _shipToName->setText(headq.value("shipto").toString());
      _shipToAddr1->setText(headq.value("addr1").toString());
      if (_shippingForm->id() <= 0)
	_shippingForm->setId(headq.value("shipform_id").toInt());

      _so->setEnabled(false);
      _to->setEnabled(false);
    }
    else if (headq.lastError().type() != QSqlError::None)
    {
      systemError(this, headq.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
    _print->setFocus();
  }

  return NoError;
}
コード例 #6
0
enum SetResponse shipTo::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("cust_id", &valid);
  if (valid)
    _custid = param.toInt();

  param = pParams.value("shipto_id", &valid);
  if (valid)
  {
    _shiptoid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      XSqlQuery cust;
      cust.prepare( "SELECT cust_number, cust_name, cust_taxzone_id, "
                 "       cust_salesrep_id, cust_shipform_id, cust_shipvia, "
                 "       crmacct_id "
                 "FROM custinfo "
                 "  JOIN crmacct ON (cust_id=crmacct_cust_id) "
                 "WHERE (cust_id=:cust_id);" );
      cust.bindValue(":cust_id", _custid);
      cust.exec();
      if (cust.first())
      {
        _custNum->setText(cust.value("cust_number").toString());
        _custName->setText(cust.value("cust_name").toString());
        _salesRep->setId(cust.value("cust_salesrep_id").toInt());
        _shipform->setId(cust.value("cust_shipform_id").toInt());
        _taxzone->setId(cust.value("cust_taxzone_id").toInt());
        _contact->setSearchAcct(cust.value("crmacct_id").toInt());

	//  Handle the free-form Ship Via
        _shipVia->setId(-1);
        QString shipvia = cust.value("cust_shipvia").toString().trimmed();
        if (shipvia.length())
        {
          for (int counter = 0; counter < _shipVia->count(); counter++)
            if (_shipVia->text(counter) == shipvia)
              _shipVia->setCurrentIndex(counter);

          if (_shipVia->id() == -1)
          {
            _shipVia->insertItem(shipvia);
            _shipVia->setCurrentIndex(_shipVia->count() - 1);
          }
        }
      }
      if (cust.lastError().type() != QSqlError::NoError)
      {
	systemError(this, cust.lastError().databaseText(), __FILE__, __LINE__);
	return UndefinedError;
      }

      _shipToNumber->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _shipToNumber->setEnabled(FALSE);
      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _shipToNumber->setEnabled(FALSE);
      _active->setEnabled(FALSE);
      _default->setEnabled(FALSE);
      _name->setEnabled(FALSE);
      _contact->setEnabled(FALSE);
      _address->setEnabled(FALSE);
      _salesRep->setEnabled(FALSE);
      _commission->setEnabled(FALSE);
      _shipZone->setEnabled(FALSE);
      _taxzone->setEnabled(FALSE);
      _shipVia->setEnabled(FALSE);
      _shipform->setEnabled(FALSE);
      _shipchrg->setEnabled(FALSE);
      _shiplabel->setEnabled(FALSE);
      _comments->setEnabled(FALSE);
      _shippingComments->setEnabled(FALSE);
      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
    }
  }

  return NoError;
}
コード例 #7
0
ファイル: voucherItem.cpp プロジェクト: Wushaowei001/xtuple-1
void voucherItem::sSave()
{
  if (_qtyToVoucher->toDouble() <= 0.0)
  {
    QMessageBox::critical( this, tr("Cannot Save Voucher Item"),
                           tr("You must enter a postive Quantity to Voucher before saving this Voucher Item") );
    _qtyToVoucher->setFocus();
    return;
  }

  // Check to make sure there is at least distribution for this Voucher Item
  q.prepare( "SELECT vodist_id "
             "FROM vodist "
             "WHERE ( (vodist_vohead_id=:vohead_id)"
             " AND (vodist_poitem_id=:poitem_id) ) "
             "LIMIT 1;" );
  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":poitem_id", _poitemid);
  q.exec();
  if (!q.first())
  {
    QMessageBox::critical( this, tr("Cannot Save Voucher Item"),
                           tr("You must make at least one distribution for this Voucher Item before you may save it.") );
    return;
  }
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }

  // Check for vendor matching requirement
  q.prepare( "SELECT vend_id "
             " FROM vendinfo,pohead,poitem "
	     " WHERE (	(vend_id=pohead_vend_id) "
	     " AND (pohead_id=poitem_pohead_id) "
	     " AND (poitem_id=:poitem_id) "
	     " AND (vend_match) ); " );
  q.bindValue(":poitem_id", _poitemid);
  q.exec();
  if (q.first())
  {
    q.prepare( "SELECT formatMoney(poitem_unitprice * :voitem_qty) AS f_povalue FROM poitem "
		" WHERE ((poitem_unitprice * :voitem_qty) <> "
		" (SELECT SUM(vodist_amount) "
		"	FROM vodist " 
		"       WHERE ( (vodist_vohead_id=:vohead_id) "
		"       AND (vodist_poitem_id=:poitem_id) ) )"
		" AND (poitem_id=:poitem_id) ); " );
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", _poitemid);
    q.bindValue(":voitem_qty", _qtyToVoucher->toDouble());
    q.exec();
  	if (q.first())
    {
    QString msg;
    msg = "The P/O value of ";
    msg.append( q.value("f_povalue").toString() );
    msg.append( " does not match the total distributed value.\nInvoice matching is required for this vendor.\nStop and correct?" );
    if ( QMessageBox::warning( this, tr("Invoice Value Mismatch"), msg, tr("Yes"), tr("No"), QString::null ) != 1 )
          return;
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }

  // Update the qty vouchered
  q.prepare( "UPDATE voitem "
             "SET voitem_close=:voitem_close,"
             "    voitem_freight=:voitem_freight, "
			 "    voitem_taxtype_id=:voitem_taxtype_id "
             "WHERE (voitem_id=:voitem_id);"
             "UPDATE vodist "
             "SET vodist_qty=:qty "
             "WHERE ((vodist_vohead_id=:vohead_id)"
             " AND (vodist_poitem_id=:poitem_id) );" );
  q.bindValue(":qty", _qtyToVoucher->toDouble());
  q.bindValue(":poitem_id", _poitemid);
  q.bindValue(":voitem_id", _voitemid);
  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":voitem_close", QVariant(_closePoitem->isChecked()));
  q.bindValue(":voitem_freight", _freightToVoucher->localValue());
  if (_taxtype->id() != -1)
    q.bindValue(":voitem_taxtype_id", _taxtype->id());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }
  q.exec("COMMIT;");
  
  _inTransaction = FALSE;
  accept();
}
コード例 #8
0
void printPurchaseOrder::sPrint()
{
  q.prepare("SELECT pohead_saved FROM pohead WHERE pohead_id=:pohead_id");
  q.bindValue(":pohead_id", _po->id());
  q.exec();
  if(q.first() && (q.value("pohead_saved").toBool() == false))
  {
    QMessageBox::warning( this, tr("Cannot Print P/O"),
      tr("The Purchase Order you are trying to print has not been completed.\n"
         "Please wait until the Purchase Order has been completely saved.") );
    return;
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  QPrinter  *printer = new QPrinter(QPrinter::HighResolution);
  bool      setupPrinter = TRUE;
  bool userCanceled = false;
  if (orReport::beginMultiPrint(printer, userCanceled) == false)
  {
    if(!userCanceled)
      systemError(this, tr("Could not initialize printing system for multiple reports."));
    return;
  }

  if (_vendorCopy->isChecked())
  {
    ParameterList params;
    params.append("pohead_id", _po->id());
    params.append("title", "Vendor Copy");

    orReport report("PurchaseOrder", params);
    if (report.isValid() && report.print(printer, setupPrinter))
      setupPrinter = FALSE;
    else
    {
      report.reportError(this);
      return;
    }
  }

  if (_internalCopy->isChecked())
  {
    for (int counter = _numOfCopies->value(); counter; counter--)
    {
      ParameterList params;

      params.append("pohead_id", _po->id());
      params.append("title", QString("Internal Copy #%1").arg(counter));

      orReport report("PurchaseOrder", params);

      if (report.isValid() && report.print(printer, setupPrinter))
          setupPrinter = FALSE;
      else
      {
        report.reportError(this);
	orReport::endMultiPrint(printer);
	return;
      }
    }
  }
  orReport::endMultiPrint(printer);

  q.prepare( "UPDATE pohead "
             "SET pohead_printed=TRUE "
             "WHERE (pohead_id=:pohead_id);" );
  q.bindValue(":pohead_id", _po->id());
  q.exec();
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if (_captive)
    accept();
  else
  {
    _po->setId(-1);
    _po->setFocus();
  }
}
コード例 #9
0
void dspPoItemsByDate::sFillList()
{
  _poitem->clear();

  QString sql( "SELECT pohead_id, poitem_id, pohead_number,"
               "       CASE WHEN (itemsite_id IS NULL) THEN ( SELECT warehous_code"
               "                                              FROM warehous"
               "                                              WHERE (pohead_warehous_id=warehous_id) )"
               "            ELSE ( SELECT warehous_code"
               "                   FROM warehous"
               "                   WHERE (itemsite_warehous_id=warehous_id) )"
               "       END AS warehousecode,"
	       "       poitem_status,"
               "       CASE WHEN(poitem_status='C') THEN <? value(\"closed\") ?>"
               "            WHEN(poitem_status='U') THEN <? value(\"unposted\") ?>"
               "            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN <? value(\"partial\") ?>"
               "            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered=(poitem_qty_received-poitem_qty_returned))) THEN <? value(\"received\") ?>"
               "            WHEN(poitem_status='O') THEN <? value(\"open\") ?>"
               "            ELSE poitem_status"
               "       END AS poitemstatus,"
               "       vend_name,"
               "       formatDate(poitem_duedate) AS f_duedate,"
               "       COALESCE(item_number, (<? value(\"nonInv\") ?> || poitem_vend_item_number)) AS itemnumber,"
               "       COALESCE(item_descrip1, firstLine(poitem_vend_item_descrip)) AS itemdescrip,"
               "       COALESCE(uom_name, poitem_vend_uom) AS itemuom,"
               "       formatQty(poitem_qty_ordered) AS f_qtyordered,"
               "       formatQty(poitem_qty_received) AS f_qtyreceived,"
               "       formatQty(poitem_qty_returned) AS f_qtyreturned,"
               "       (poitem_duedate < CURRENT_DATE) AS late "
               "FROM pohead, vend,"
               "     poitem LEFT OUTER JOIN"
               "     ( itemsite JOIN item"
               "       ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))"
               "     ON (poitem_itemsite_id=itemsite_id) "
               "WHERE ((poitem_pohead_id=pohead_id)"
               " AND (pohead_vend_id=vend_id)"
               " AND (poitem_duedate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>)"
	       "<? if exists(\"warehous_id\") ?>"
	       " AND (((itemsite_id IS NULL) AND"
	       "       (pohead_warehous_id=<? value(\"warehous_id\") ?>)) OR"
	       "      ((itemsite_id IS NOT NULL) AND"
	       "       (itemsite_warehous_id=<? value(\"warehous_id\") ?>)))"
	       "<? endif ?>"
	       "<? if exists(\"agentUsername\") ?>"
	       " AND (pohead_agent_username=<? value(\"agentUsername\") ?>)"
	       "<? endif ?>"
	       "<? if exists(\"openItems\") ?>"
	       " AND (poitem_status='O')"
	       "<? endif ?>"
	       "<? if exists(\"closedItems\") ?>"
	       " AND (poitem_status='C')"
	       "<? endif ?>"
	       ") "
	       "ORDER BY poitem_duedate;" );

  ParameterList params;
  setParams(params);

  MetaSQLQuery mql(sql);
  q = mql.toQuery(params);
  if (q.first())
  {
    XTreeWidgetItem *last = 0;
    do
    {
      last = new XTreeWidgetItem(_poitem, last,
				 q.value("pohead_id").toInt(),
				 q.value("poitem_id").toInt(),
				 q.value("pohead_number"),
				 q.value("warehousecode"),
				 q.value("poitemstatus"), q.value("vend_name"),
				 q.value("f_duedate"), q.value("itemnumber"), 
				 q.value("itemdescrip"), q.value("itemuom"),
				 q.value("f_qtyordered"),
				 q.value("f_qtyreceived"),
				 q.value("f_qtyreturned") );
      last->setText(POITEM_STATUS_COL, q.value("poitem_status").toString());
      if (q.value("late").toBool())
        last->setTextColor(4, "red");
    }
    while (q.next());
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
コード例 #10
0
void unpostedInvoices::sPost()
{
  bool changeDate = false;
  QDate newDate = QDate::currentDate();

  if (_privileges->check("ChangeARInvcDistDate"))
  {
    getGLDistDate newdlg(this, "", TRUE);
    newdlg.sSetDefaultLit(tr("Invoice Date"));
    if (newdlg.exec() == XDialog::Accepted)
    {
      newDate = newdlg.date();
      changeDate = (newDate.isValid());
    }
    else
      return;
  }

  int journal = -1;
  q.exec("SELECT fetchJournalNumber('AR-IN') AS result;");
  if (q.first())
  {
    journal = q.value("result").toInt();
    if (journal < 0)
    {
      systemError(this, storedProcErrorLookup("fetchJournalNumber", journal), __FILE__, __LINE__);
      return;
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  XSqlQuery xrate;
  xrate.prepare("SELECT curr_rate "
		"FROM curr_rate, invchead "
		"WHERE ((curr_id=invchead_curr_id)"
		"  AND  (invchead_id=:invchead_id)"
		"  AND  (invchead_invcdate BETWEEN curr_effective AND curr_expires));");
  // if SUM becomes dependent on curr_id then move XRATE before it in the loop
  XSqlQuery sum;
  sum.prepare("SELECT invoicetotal(:invchead_id) AS subtotal;");

  XSqlQuery rollback;
  rollback.prepare("ROLLBACK;");

  XSqlQuery post;
  post.prepare("SELECT postInvoice(:invchead_id, :journal) AS result;");

  XSqlQuery setDate;
  setDate.prepare("UPDATE invchead SET invchead_gldistdate=:distdate "
		  "WHERE invchead_id=:invchead_id;");

  QList<XTreeWidgetItem*> selected = _invchead->selectedItems();
  QList<XTreeWidgetItem*> triedToClosed;

  for (int i = 0; i < selected.size(); i++)
  {
    if (checkSitePrivs(((XTreeWidgetItem*)(selected[i]))->id()))
    {
      int id = ((XTreeWidgetItem*)(selected[i]))->id();

      if (changeDate)
      {
        setDate.bindValue(":distdate",    newDate);
        setDate.bindValue(":invchead_id", id);
        setDate.exec();
        if (setDate.lastError().type() != QSqlError::NoError)
        {
	      systemError(this, setDate.lastError().databaseText(), __FILE__, __LINE__);
        }
      }
    }
  }

  bool tryagain = false;
  do {
    for (int i = 0; i < selected.size(); i++)
    {
      if (checkSitePrivs(((XTreeWidgetItem*)(selected[i]))->id()))
      {
        int id = ((XTreeWidgetItem*)(selected[i]))->id();

        sum.bindValue(":invchead_id", id);
        if (sum.exec() && sum.first() && sum.value("subtotal").toDouble() == 0)
        {
	      if (QMessageBox::question(this, tr("Invoice Has Value 0"),
		      		  tr("Invoice #%1 has a total value of 0.\n"
			     	     "Would you like to post it anyway?")
				    .arg(selected[i]->text(0)),
				  QMessageBox::Yes,
				  QMessageBox::No | QMessageBox::Default)
	      == QMessageBox::No)
	        continue;
        }
        else if (sum.lastError().type() != QSqlError::NoError)
        {
	      systemError(this, sum.lastError().databaseText(), __FILE__, __LINE__);
	      continue;
        }
        else if (sum.value("subtotal").toDouble() != 0)
        {
	      xrate.bindValue(":invchead_id", id);
	      xrate.exec();
	      if (xrate.lastError().type() != QSqlError::NoError)
	      {
	        systemError(this, tr("System Error posting Invoice #%1\n%2")
			            .arg(selected[i]->text(0))
			            .arg(xrate.lastError().databaseText()),
		                __FILE__, __LINE__);
	        continue;
	      }
	      else if (!xrate.first() || xrate.value("curr_rate").isNull())
	      {
	        systemError(this, tr("Could not post Invoice #%1 because of a missing exchange rate.")
						.arg(selected[i]->text(0)));
	        continue;
	      }
        }

        q.exec("BEGIN;");	// because of possible lot, serial, or location distribution cancelations
        post.bindValue(":invchead_id", id);
        post.bindValue(":journal",     journal);
        post.exec();
        if (post.first())
        {
	      int result = post.value("result").toInt();
	      if (result < 0)
              {
                rollback.exec();
                systemError(this, storedProcErrorLookup("postInvoice", result),
		            __FILE__, __LINE__);
              }
              else if (distributeInventory::SeriesAdjust(result, this) == XDialog::Rejected)
              {
                rollback.exec();
                QMessageBox::information( this, tr("Post Invoices"), tr("Transaction Canceled") );
                return;
              }

              q.exec("COMMIT;");
        }
        // contains() string is hard-coded in stored procedure
        else if (post.lastError().databaseText().contains("post to closed period"))
        {
            if (changeDate)
              triedToClosed = selected;
            else
              triedToClosed.append(selected[i]);
      }
      else if (post.lastError().type() != QSqlError::NoError)
      {
        rollback.exec();
        systemError(this, tr("A System Error occurred posting Invoice #%1.\n%2")
                    .arg(selected[i]->text(0))
                        .arg(post.lastError().databaseText()),
                        __FILE__, __LINE__);
      }
    }

    if (triedToClosed.size() > 0)
    {
      failedPostList newdlg(this, "", true);
      newdlg.sSetList(triedToClosed, _invchead->headerItem(), _invchead->header());
      tryagain = (newdlg.exec() == XDialog::Accepted);
      selected = triedToClosed;
      triedToClosed.clear();
      }
    }
  } while (tryagain);

  if (_printJournal->isChecked())
  {
    ParameterList params;
    params.append("journalNumber", journal);

    orReport report("SalesJournal", params);
    if (report.isValid())
      report.print();
    else
      report.reportError(this);
  }

  omfgThis->sInvoicesUpdated(-1, TRUE);
}
コード例 #11
0
void postInvoices::sPost()
{
  q.exec( "SELECT invchead_printed, COUNT(*) AS number "
          "FROM ( "
          "  SELECT * FROM invchead WHERE NOT (invchead_posted)) AS data "
          "WHERE (checkInvoiceSitePrivs(invchead_id)) "
          "GROUP BY invchead_printed;" );
  if (q.first())
  {
    int printed   = 0;
    int unprinted = 0;

    do
    {
      if (q.value("invchead_printed").toBool())
        printed = q.value("number").toInt();
      else
        unprinted = q.value("number").toInt();
    }
    while (q.next());

    if ( ( (unprinted) && (!printed) ) && (!_postUnprinted->isChecked()) )
    {
      QMessageBox::warning( this, tr("No Invoices to Post"),
                            tr( "Although there are unposted Invoices, there are no unposted Invoices that have been printed.\n"
                                "You must manually print these Invoices or select 'Post Unprinted Invoices' before these Invoices\n"
                                "may be posted." ) );
      _postUnprinted->setFocus();
      return;
    }
  }
  else
  {
    QMessageBox::warning( this, tr("No Invoices to Post"),
                          tr("There are no Invoices, printed or not, to post.\n" ) );
    _close->setFocus();
    return;
  }

  bool inclZero = false;
  q.exec("SELECT COUNT(invchead_id) AS numZeroInvcs "
         "FROM invchead "
         "WHERE ( (NOT invchead_posted) "
         "  AND   (invoiceTotal(invchead_id) <= 0.0) "
         "  AND   (checkInvoiceSitePrivs(invchead_id)) );");
  if (q.first() && q.value("numZeroInvcs").toInt() > 0)
  {
    int toPost = QMessageBox::question(this, tr("Invoices for 0 Amount"),
				       tr("There are %1 invoices with a total value of 0.\n"
					  "Would you like to post them?")
					 .arg(q.value("numZeroInvcs").toString()),
				       tr("Post All"), tr("Post Only Non-0"),
				       tr("Cancel"), 1, 2);
    if (toPost == 2)
      return;
    else if (toPost == 1)
      inclZero = false;
    else
      inclZero = true;
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  q.prepare("SELECT postInvoices(:postUnprinted, :inclZero) AS result;");
  q.bindValue(":postUnprinted", QVariant(_postUnprinted->isChecked()));
  q.bindValue(":inclZero",      inclZero);
  q.exec();
  if (q.first())
  {
    int result = q.value("result").toInt();

    if (result == -5)
    {
      QMessageBox::critical( this, tr("Cannot Post one or more Invoices"),
                             tr( "The G/L Account Assignments for one or more of the Invoices that you are trying to post are not\n"
                                 "configured correctly.  Because of this, G/L Transactions cannot be posted for these Invoices.\n"
                                 "You must contact your Systems Administrator to have this corrected before you may\n"
                                 "post these Invoices." ) );
      return;
    }
    else if (result < 0)
    {
      systemError( this, tr("A System Error occurred at %1::%2, Error #%3.")
                         .arg(__FILE__)
                         .arg(__LINE__)
                         .arg(q.value("result").toInt()) );
      return;
    }


    omfgThis->sInvoicesUpdated(-1, TRUE);
    omfgThis->sSalesOrdersUpdated(-1);

    if (_printJournal->isChecked())
    {
      ParameterList params;
      params.append("journalNumber", result);

      orReport report("SalesJournal", params);
      if (report.isValid())
        report.print();
      else
        report.reportError(this);
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError( this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  accept();
}
コード例 #12
0
bool itemSource::sSave()
{
  if (!_item->isValid())
  {
    QMessageBox::critical( this, tr("Cannot Save Item Source"),
                           tr( "You must select an Item that this Item Source represents\n"
                               "before you may save this Item Source." ) );
    _item->setFocus();
    return false;
  }

  if (!_vendor->isValid())
  {
    QMessageBox::critical( this, tr("Cannot Save Item Source"),
                           tr( "You must select this Vendor that this Item Source is sold by\n"
                               "before you may save this Item Source." ) );
    _item->setFocus();
    return false;
  }

  if(_mode == cNew)
  {
    q.prepare( "SELECT itemsrc_id "
               "  FROM itemsrc "
               " WHERE ((itemsrc_item_id=:item_id) "
               "   AND (itemsrc_vend_id=:vend_id) ) ");
    q.bindValue(":item_id", _item->id());
    q.bindValue(":vend_id", _vendor->id());
    q.exec();
    if(q.first())
    {
      QMessageBox::critical( this, tr("Cannot Save Item Source"),
                            tr("An Item Source already exists for the Item Number and Vendor you have specified.\n"));
      return false;
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return false;
    }
  }

  if (_vendorUOM->text().length() == 0)
  {
    QMessageBox::critical( this, tr("Cannot Save Item Source"),
                          tr( "You must indicate the Unit of Measure that this Item Source is sold in\n"
                               "before you may save this Item Source." ) );
    _vendorUOM->setFocus();
    return false;
  }

  if (_invVendorUOMRatio->toDouble() == 0.0)
  {
    QMessageBox::critical( this, tr("Cannot Save Item Source"),
                          tr( "You must indicate the Ratio of Inventory to Vendor Unit of Measures\n"
                               "before you may save this Item Source." ) );
    _invVendorUOMRatio->setFocus();
    return false;
  }

  if (_mode == cNew)
    q.prepare( "INSERT INTO itemsrc "
               "( itemsrc_id, itemsrc_item_id, itemsrc_active, itemsrc_vend_id,"
               "  itemsrc_vend_item_number, itemsrc_vend_item_descrip,"
               "  itemsrc_vend_uom, itemsrc_invvendoruomratio,"
               "  itemsrc_minordqty, itemsrc_multordqty,"
               "  itemsrc_leadtime, itemsrc_ranking,"
               "  itemsrc_comments ) "
               "VALUES "
               "( :itemsrc_id, :itemsrc_item_id, :itemsrc_active, :itemsrc_vend_id,"
               "  :itemsrc_vend_item_number, :itemsrc_vend_item_descrip,"
               "  :itemsrc_vend_uom, :itemsrc_invvendoruomratio,"
               "  :itemsrc_minordqty, :itemsrc_multordqty,"
               "  :itemsrc_leadtime, :itemsrc_ranking,"
               "  :itemsrc_comments );" );
  if (_mode == cEdit)
    q.prepare( "UPDATE itemsrc "
               "SET itemsrc_active=:itemsrc_active,"
               "    itemsrc_vend_item_number=:itemsrc_vend_item_number,"
               "    itemsrc_vend_item_descrip=:itemsrc_vend_item_descrip,"
               "    itemsrc_vend_uom=:itemsrc_vend_uom,"
               "    itemsrc_invvendoruomratio=:itemsrc_invvendoruomratio,"
               "    itemsrc_minordqty=:itemsrc_minordqty, itemsrc_multordqty=:itemsrc_multordqty,"
               "    itemsrc_leadtime=:itemsrc_leadtime, itemsrc_ranking=:itemsrc_ranking,"
               "    itemsrc_comments=:itemsrc_comments "
               "WHERE (itemsrc_id=:itemsrc_id);" );

  q.bindValue(":itemsrc_id", _itemsrcid);
  q.bindValue(":itemsrc_item_id", _item->id());
  q.bindValue(":itemsrc_active", QVariant(_active->isChecked(), 0));
  q.bindValue(":itemsrc_vend_id", _vendor->id());
  q.bindValue(":itemsrc_vend_item_number", _vendorItemNumber->text());
  q.bindValue(":itemsrc_vend_item_descrip", _vendorItemDescrip->text());
  q.bindValue(":itemsrc_vend_uom", _vendorUOM->text().stripWhiteSpace());
  q.bindValue(":itemsrc_invvendoruomratio", _invVendorUOMRatio->toDouble());
  q.bindValue(":itemsrc_minordqty", _minOrderQty->toDouble());
  q.bindValue(":itemsrc_multordqty", _multOrderQty->toDouble());
  q.bindValue(":itemsrc_leadtime", _leadTime->text().toInt());
  q.bindValue(":itemsrc_ranking", _vendorRanking->value());
  q.bindValue(":itemsrc_comments", _notes->text().stripWhiteSpace());
  q.exec();
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return false;
  }

  if (_captive)
  {
    _mode = cEdit;
    _item->setReadOnly(TRUE);
    _vendor->setEnabled(FALSE);
    _vendorList->hide();
    _captive = false;
  }
  else
    done(_itemsrcid);
    
  return true;
}
コード例 #13
0
enum SetResponse itemSource::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("itemsrc_id", &valid);
  if (valid)
  {
    _itemsrcid = param.toInt();
    populate();
  }

  param = pParams.value("item_id", &valid);
  if (valid)
  {
    _item->setId(param.toInt());
    _item->setEnabled(FALSE);
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      q.exec("SELECT NEXTVAL('itemsrc_itemsrc_id_seq') AS _itemsrc_id;");
      if (q.first())
        _itemsrcid = q.value("_itemsrc_id").toInt();
      else if (q.lastError().type() != QSqlError::None)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return UndefinedError;
      }
      _captive = true;
      
      connect(_itemsrcp, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_itemsrcp, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
      connect(_itemsrcp, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));

      _item->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      connect(_itemsrcp, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_itemsrcp, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
      connect(_itemsrcp, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));

      _item->setReadOnly(TRUE);
      _vendor->setEnabled(FALSE);
      _vendorList->hide();

      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _item->setReadOnly(TRUE);
      _active->setEnabled(FALSE);
      _vendor->setEnabled(FALSE);
      _vendorList->hide();
      _vendorItemNumber->setEnabled(FALSE);
      _vendorItemDescrip->setEnabled(FALSE);
      _vendorUOM->setEnabled(FALSE);
      _invVendorUOMRatio->setEnabled(FALSE);
      _vendorRanking->setEnabled(FALSE);
      _minOrderQty->setEnabled(FALSE);
      _multOrderQty->setEnabled(FALSE);
      _leadTime->setEnabled(FALSE);
      _notes->setEnabled(FALSE);
      _add->setEnabled(FALSE);
      _delete->setEnabled(FALSE);
      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
    }
  }

  return NoError;
}
コード例 #14
0
void issueLineToShipping::populate()
{
  ParameterList itemp;
  if (_ordertype == "SO")
    itemp.append("soitem_id", _itemid);
  else if (_ordertype == "TO")
    itemp.append("toitem_id", _itemid);
  itemp.append("ordertype", _ordertype);

  // TODO: make this an orderitem select
  QString sql = "<? if exists(\"soitem_id\") ?>"
		"SELECT cohead_number AS order_number,"
		"       itemsite_item_id AS item_id,"
		"       warehous_code, uom_name,"
		"       coitem_qtyord AS qtyordered,"
    "       coitem_qtyshipped AS qtyshipped,"
    "       coitem_qtyreturned AS qtyreturned,"
		"       noNeg(coitem_qtyord - coitem_qtyshipped +"
		"             coitem_qtyreturned) AS balance "
		"FROM cohead, coitem, itemsite, item, warehous, uom "
		"WHERE ((coitem_cohead_id=cohead_id)"
		"  AND  (coitem_itemsite_id=itemsite_id)"
		"  AND  (coitem_status <> 'X')"
                "  AND  (coitem_qty_uom_id=uom_id)"
		"  AND  (itemsite_item_id=item_id)"
		"  AND  (itemsite_warehous_id=warehous_id)"
		"  AND  (coitem_id=<? value(\"soitem_id\") ?>) );"
		"<? elseif exists(\"toitem_id\") ?>"
		"SELECT tohead_number AS order_number,"
		"       toitem_item_id AS item_id,"
		"       warehous_code, toitem_uom AS uom_name,"
		"       toitem_qty_ordered AS qtyordered,"
		"       toitem_qty_shipped AS qtyshipped,"
		"       0 AS qtyreturned,"
		"       noNeg(toitem_qty_ordered -"
		"             toitem_qty_shipped) AS balance "
		"FROM tohead, toitem, warehous, item "
		"WHERE ((toitem_tohead_id=tohead_id)"
		"  AND  (toitem_status <> 'X')"
		"  AND  (tohead_src_warehous_id=warehous_id)"
		"  AND  (toitem_id=<? value(\"toitem_id\") ?>) );"
		"<? endif ?>";

  MetaSQLQuery itemm(sql);
  XSqlQuery itemq = itemm.toQuery(itemp);

  if (itemq.first())
  {
    _orderNumber->setText(itemq.value("order_number").toString());
    _item->setId(itemq.value("item_id").toInt());
    _warehouse->setText(itemq.value("warehous_code").toString());
    _shippingUOM->setText(itemq.value("uom_name").toString());
    _qtyOrdered->setDouble(itemq.value("qtyordered").toDouble());
    _qtyShipped->setDouble(itemq.value("qtyshipped").toDouble());
    _qtyReturned->setDouble(itemq.value("qtyreturned").toDouble());
    _balance->setDouble(itemq.value("balance").toDouble());
  }
  else if (itemq.lastError().type() != QSqlError::None)
  {
    systemError(this, itemq.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  ParameterList shipp;
  shipp.append("ordertype", _ordertype);
  shipp.append("orderitem_id", _itemid);

  sql = "SELECT shiphead_id AS misc_id,"
        "       SUM(shipitem_qty) AS qtyatship "
        "FROM shiphead, shipitem "
        "WHERE ((shipitem_shiphead_id=shiphead_id)"
        "  AND  (NOT shiphead_shipped)"
        "  AND  (shiphead_order_type=<? value(\"ordertype\") ?>)"
        "  AND  (shipitem_orderitem_id=<? value(\"orderitem_id\") ?>) ) "
        "GROUP BY shiphead_id;" ;

  MetaSQLQuery shipm(sql);
  XSqlQuery shipq = shipm.toQuery(shipp);

  if (shipq.first())
  {
    _shipment->setType(_ordertype);
    _shipment->setId(shipq.value("misc_id").toInt());
    _qtyAtShip->setDouble(shipq.value("qtyatship").toDouble());
  }
  else if (shipq.lastError().type() != QSqlError::None)
  {
    systemError( this, shipq.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if (_qtyAtShip->toDouble() == 0.0)
    _qtyToIssue->setDouble(itemq.value("balance").toDouble());
}
コード例 #15
0
void shipTo::sSave()
{
  XSqlQuery rollback;
  rollback.prepare("ROLLBACK;");

  if (! q.exec("BEGIN"))
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if (saveContact(_contact) < 0)
  {
    rollback.exec();
    _contact->setFocus();
    return;
  }

  int saveResult = _address->save(AddressCluster::CHECK);
  if (-2 == saveResult)
  {
    int answer = QMessageBox::question(this,
		    tr("Question Saving Address"),
		    tr("<p>There are multiple uses of this Ship-To "
		       "Address. What would you like to do?"),
		    tr("Change This One"),
		    tr("Change Address for All"),
		    tr("Cancel"),
		    2, 2);
    if (0 == answer)
      saveResult = _address->save(AddressCluster::CHANGEONE);
    else if (1 == answer)
      saveResult = _address->save(AddressCluster::CHANGEALL);
  }
  if (saveResult < 0)	// not else-if: this is error check for CHANGE{ONE,ALL}
  {
    systemError(this, tr("<p>There was an error saving this address (%1). "
			 "Check the database server log for errors.")
		      .arg(saveResult), __FILE__, __LINE__);
    rollback.exec();
    _address->setFocus();
    return;
  }

  if (_mode == cNew)
  {
    q.exec("SELECT NEXTVAL('shipto_shipto_id_seq') AS shipto_id;");
    if (q.first())
      _shiptoid = q.value("shipto_id").toInt();
    else if (q.lastError().type() != QSqlError::NoError)
    {
      rollback.exec();
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    q.prepare( "INSERT INTO shiptoinfo "
               "( shipto_id, shipto_cust_id, shipto_active, shipto_default,"
               "  shipto_num, shipto_name, shipto_cntct_id, shipto_commission,"
               "  shipto_comments, shipto_shipcomments,"
               "  shipto_taxzone_id, shipto_salesrep_id, shipto_shipzone_id,"
               "  shipto_shipvia, shipto_shipform_id, shipto_shipchrg_id, "
	       "  shipto_addr_id, shipto_labelform_id ) "
               "VALUES "
               "( :shipto_id, :shipto_cust_id, :shipto_active, :shipto_default,"
               "  :shipto_num, :shipto_name, :shipto_cntct_id, :shipto_commission,"
               "  :shipto_comments, :shipto_shipcomments,"
               "  :shipto_taxzone_id, :shipto_salesrep_id, :shipto_shipzone_id,"
               "  :shipto_shipvia, :shipto_shipform_id, :shipto_shipchrg_id, "
	       "  :shipto_addr_id, :shipto_labelform_id );" );
  }
  else if (_mode == cEdit)
    q.prepare( "UPDATE shiptoinfo "
               "SET shipto_active=:shipto_active, shipto_default=:shipto_default,"
               "    shipto_name=:shipto_name, shipto_cntct_id=:shipto_cntct_id,"
               "    shipto_commission=:shipto_commission,"
               "    shipto_comments=:shipto_comments, shipto_shipcomments=:shipto_shipcomments,"
               "    shipto_taxzone_id=:shipto_taxzone_id, shipto_salesrep_id=:shipto_salesrep_id, shipto_shipzone_id=:shipto_shipzone_id,"
               "    shipto_shipvia=:shipto_shipvia, shipto_shipform_id=:shipto_shipform_id, shipto_shipchrg_id=:shipto_shipchrg_id,"
	       "    shipto_addr_id=:shipto_addr_id,"
               "    shipto_labelform_id=:shipto_labelform_id "
               "WHERE (shipto_id=:shipto_id);" );

  q.bindValue(":shipto_id", _shiptoid);
  q.bindValue(":shipto_active", QVariant(_active->isChecked()));
  q.bindValue(":shipto_default", QVariant(_default->isChecked()));
  q.bindValue(":shipto_cust_id", _custid);
  q.bindValue(":shipto_num", _shipToNumber->text().trimmed());
  q.bindValue(":shipto_name", _name->text());
  if (_contact->id() > 0)
    q.bindValue(":shipto_cntct_id", _contact->id());
  if (_address->id() > 0)
    q.bindValue(":shipto_addr_id", _address->id());
  q.bindValue(":shipto_commission", (_commission->toDouble() / 100));
  q.bindValue(":shipto_comments", _comments->toPlainText());
  q.bindValue(":shipto_shipcomments", _shippingComments->toPlainText());
  q.bindValue(":shipto_shipvia", _shipVia->currentText());
  if (_taxzone->isValid())
    q.bindValue(":shipto_taxzone_id",  _taxzone->id());
  if (_salesRep->id() != -1)
    q.bindValue(":shipto_salesrep_id", _salesRep->id());
  if (_shipZone->isValid())
    q.bindValue(":shipto_shipzone_id", _shipZone->id());
  if (_shipform->id() != -1)
    q.bindValue(":shipto_shipform_id", _shipform->id());
  if (_shiplabel->id() != -1)
    q.bindValue(":shipto_labelform_id", _shiplabel->id());
  if (_shipchrg->id() != -1)
  q.bindValue(":shipto_shipchrg_id", _shipchrg->id());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    rollback.exec();
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  q.exec("COMMIT;");

  done(_shiptoid);
}
コード例 #16
0
configureCC::configureCC(QWidget* parent, const char* name, bool /*modal*/, Qt::WFlags fl)
    : XAbstractConfigure(parent, fl)
{
  setupUi(this);

  if (name)
    setObjectName(name);

  connect(_anDuplicateWindow, SIGNAL(valueChanged(int)), this, SLOT(sDuplicateWindow(int)));
  connect(_ccCompany, SIGNAL(currentIndexChanged(int)), this, SLOT(sCCCompanyChanged(int)));

  _enableChargePreauth->setVisible(false);
  _enableCredit->setVisible(false);

  // these ids must match the pages in the stack widget
  _ccCompany->append(0, "Authorize.Net", "AN");
  _ccCompany->append(1, "YourPay",       "YP");
  _ccCompany->append(2, "CyberSource",   "CS");
  _ccCompany->append(3, "External",      "EXT");
  if (_metrics->boolean("CCEnablePaymentech"))
    _ccCompany->append(4, "Paymentech",  "PT");

  ConfigCyberSourceProcessor *cs = new ConfigCyberSourceProcessor(this);
  _configcclist.append(cs);
  _ccWidgetStack->insertWidget(_ccWidgetStack->indexOf(_externalStack), cs);

  _ccAccept->setChecked(_metrics->boolean("CCAccept"));
  _ccTest->setChecked(_metrics->boolean("CCTest"));
  _ccValidDays->setValue(_metrics->value("CCValidDays").toInt());
  
  _ccCompany->setCurrentIndex(_ccCompany->findText(_metrics->value("CCCompany")));
  _ccWidgetStack->setCurrentIndex(_ccCompany->currentIndex());
  sCCCompanyChanged(_ccCompany->currentIndex());

  _ccServer->setText(_metrics->value("CCServer"));
  _ccPort->setText(_metrics->value("CCPort"));

  _ccUseProxyServer->setChecked(_metrics->boolean("CCUseProxyServer"));
  _ccProxyServer->setText(_metrics->value("CCProxyServer"));
  _ccProxyPort->setText(_metrics->value("CCProxyPort"));

  XSqlQuery ccbankq("SELECT * FROM ccbank;");
  ccbankq.exec();
  while (ccbankq.next())
  {
    if (ccbankq.value("ccbank_ccard_type").toString() == "A")
      _amexBank->setId(ccbankq.value("ccbank_bankaccnt_id").toInt());
    else if (ccbankq.value("ccbank_ccard_type").toString() == "D")
      _discoverBank->setId(ccbankq.value("ccbank_bankaccnt_id").toInt());
    else if (ccbankq.value("ccbank_ccard_type").toString() == "M")
      _mastercardBank->setId(ccbankq.value("ccbank_bankaccnt_id").toInt());
    /* TODO: wait until we support paypal?
    else if (ccbankq.value("ccbank_ccard_type").toString() == "P")
      _paypalBank->setId(ccbankq.value("ccbank_bankaccnt_id").toInt());
    */
    else if (ccbankq.value("ccbank_ccard_type").toString() == "V")
      _visaBank->setId(ccbankq.value("ccbank_bankaccnt_id").toInt());
  }
  if (ccbankq.lastError().type() != QSqlError::NoError)
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);

  if (_metrics->value("CCANVer").isEmpty())
    _anVersion->setItemText(0, "3.1");
  else
    _anVersion->setItemText(0, _metrics->value("CCANVer"));
  _anDelim->setText(_metrics->value("CCANDelim"));
  _anEncap->setText(_metrics->value("CCANEncap"));
  _anDuplicateWindow->setValue(_metrics->value("CCANDuplicateWindow").toInt());

  _anMD5Hash->setText(_metrics->value("CCANMD5Hash"));
  _anMD5HashSetOnGateway->setChecked(_metrics->boolean("CCANMD5HashSetOnGateway"));
  _anMD5HashWarn->setChecked(_metrics->value("CCANMD5HashAction") == "W");
  _anMD5HashFail->setChecked(_metrics->value("CCANMD5HashAction") == "F");
  
  if (_metrics->value("CCANCurrency") == "TRANS")
    _anCurrTransaction->setChecked(true);
  else if (! _metrics->value("CCANCurrency").isEmpty())
  {
    _anCurrFixed->setChecked(true);
    _anCurrFixedValue->setId(_metrics->value("CCANCurrency").toInt());
  }

  _anUsingWellsFargoSecureSource->setChecked(_metrics->boolean("CCANWellsFargoSecureSource"));

  _ccYPWinPathPEM->setText(_metrics->value("CCYPWinPathPEM"));
  _ccYPLinPathPEM->setText(_metrics->value("CCYPLinPathPEM"));
  _ccYPMacPathPEM->setText(_metrics->value("CCYPMacPathPEM"));
  _ccYPLinkShield->setChecked(_metrics->boolean("CCYPLinkShield"));
  _ccYPLinkShieldMax->setValue(_metrics->value("CCYPLinkShieldMax").toInt());

  _confirmPreauth->setChecked(_metrics->boolean("CCConfirmPreauth"));
  _confirmCharge->setChecked(_metrics->boolean("CCConfirmCharge"));
  _confirmChargePreauth->setChecked(_metrics->boolean("CCConfirmChargePreauth"));
  _confirmCredit->setChecked(_metrics->boolean("CCConfirmCredit"));

  _enablePreauth->setChecked(_metrics->boolean("CCEnablePreauth"));
  _enableCharge->setChecked(_metrics->boolean("CCEnableCharge"));
  _enableChargePreauth->setChecked(_metrics->boolean("CCEnableChargePreauth"));
  _enableCredit->setChecked(_metrics->boolean("CCEnableCredit"));

  _printReceipt->setChecked(_metrics->boolean("CCPrintReceipt"));

  _cvvRequired->setChecked(_metrics->boolean("CCRequireCVV"));
  QString str = _metrics->value("CCCVVCheck");
  if (str == "F")
    _cvvReject->setChecked(true);
  else if (str == "W")
    _cvvWarn->setChecked(true);
  else // if (str == "X")
    _cvvNone->setChecked(true);

  str = _metrics->value("CCCVVErrors");
  _cvvNotMatch->setChecked(str.contains("N"));
  _cvvNotProcessed->setChecked(str.contains("P"));
  _cvvNotOnCard->setChecked(str.contains("S"));
  _cvvInvalidIssuer->setChecked(str.contains("U"));

  str = _metrics->value("CCAvsCheck");
  if (str == "F")
    _avsReject->setChecked(true);
  else if (str == "W")
    _avsWarn->setChecked(true);
  else // if (str == "X")
    _avsNone->setChecked(true);

  str = _metrics->value("CCAvsAddr");
  _avsAddrNotMatch->setChecked(str.contains("N"));
  _avsAddrNotAvail->setChecked(str.contains("X"));

  str = _metrics->value("CCAvsZIP");
  _avsZIPNotMatch->setChecked(str.contains("N"));
  _avsZIPNotAvail->setChecked(str.contains("X"));

  str = _metrics->value("CCTestResult");
  if (str == "F")
    _testsAllFail->setChecked(true);
  else if (str == "S")
    _testsSomeFail->setChecked(true);
  else // if (str == "P")
    _testsAllPass->setChecked(true);

  if (0 != _metricsenc)
  {
    _ccLogin->setText(_metricsenc->value("CCLogin"));
    _ccPassword->setText(_metricsenc->value("CCPassword"));
    _ccProxyLogin->setText(_metricsenc->value("CCProxyLogin"));
    _ccProxyPassword->setText(_metricsenc->value("CCProxyPassword"));
    _ccYPStoreNum->setText(_metricsenc->value("CCYPStoreNum"));
    _ccPTDivisionNumber->setText(_metricsenc->value("CCPTDivisionNumber"));
    _anMD5Hash->setText(_metricsenc->value("CCANMD5Hash"));
  }
  else
  {
    _ccLogin->setEnabled(false);
    _ccPassword->setEnabled(false);
    _ccProxyLogin->setEnabled(false);
    _ccProxyPassword->setEnabled(false);
    _ccYPStoreNum->setEnabled(false);
    _ccPTDivisionNumber->setEnabled(false);
    _anMD5Hash->setEnabled(false);
  }

  sDuplicateWindow(_anDuplicateWindow->value());

  XAbstractConfigure *encryption = new configureEncryption(this);
  if (encryption)
  {
    encryption->setObjectName("_encryption");
    _keyPage->layout()->addWidget(encryption);
    QPushButton *encbutton = encryption->findChild<QPushButton*>("_save");
    if (encbutton)
      encbutton->hide();
    encbutton = encryption->findChild<QPushButton*>("_close");
    if (encbutton)
      encbutton->hide();
    encryption->show();
  }
  else if (_metricsenc == 0)
    QMessageBox::critical( this, tr("Cannot Read Configuration"),
		    tr("<p>Cannot read encrypted information from database."));
}
コード例 #17
0
void shipTo::populate()
{
  q.prepare( "SELECT cust_number, cust_name, shipto_active, shipto_default,"
             "       shipto_cust_id,"
             "       shipto_num, shipto_name, shipto_cntct_id,"
             "       shipto_shipvia, shipto_commission,"
             "       shipto_comments, shipto_shipcomments,"
             "       COALESCE(shipto_salesrep_id,-1) AS shipto_salesrep_id, shipto_taxzone_id, COALESCE(shipto_shipzone_id,-1) AS shipto_shipzone_id,"
             "       COALESCE(shipto_shipform_id,-1) AS shipto_shipform_id, shipto_shipchrg_id,"
	     "       shipto_addr_id, shipto_labelform_id,"
             "       crmacct_id "
             "FROM shiptoinfo "
             "  LEFT OUTER JOIN cust ON (shipto_cust_id=cust_id) "
             "  LEFT OUTER JOIN crmacct ON (cust_id=crmacct_cust_id) "
             "WHERE (shipto_id=:shipto_id);" );
  q.bindValue(":shipto_id", _shiptoid);
  q.exec();
  if (q.first())
  {
    double commission = q.value("shipto_commission").toDouble();
    _custid = q.value("shipto_cust_id").toInt();
    _custNum->setText(q.value("cust_number").toString());
    _custName->setText(q.value("cust_name").toString());
    _active->setChecked(q.value("shipto_active").toBool());
    _default->setChecked(q.value("shipto_default").toBool());
    _shipToNumber->setText(q.value("shipto_num"));
    _name->setText(q.value("shipto_name"));
    _contact->setId(q.value("shipto_cntct_id").toInt());
    _contact->setSearchAcct(q.value("crmacct_id").toInt());
    _comments->setText(q.value("shipto_comments").toString());
    _shippingComments->setText(q.value("shipto_shipcomments").toString());
    _taxzone->setId(q.value("shipto_taxzone_id").toInt());
    _shipZone->setId(q.value("shipto_shipzone_id").toInt());
    _shipform->setId(q.value("shipto_shipform_id").toInt());
    _shipchrg->setId(q.value("shipto_shipchrg_id").toInt());
    _shiplabel->setId(q.value("shipto_labelform_id").toInt());
    _address->setId(q.value("shipto_addr_id").toInt());

    //  Handle the free-form Ship Via
    _shipVia->setCurrentIndex(-1);
    QString shipvia = q.value("shipto_shipvia").toString();
    if (shipvia.trimmed().length() != 0)
    {
      for (int counter = 0; counter < _shipVia->count(); counter++)
        if (_shipVia->text(counter) == shipvia)
          _shipVia->setCurrentIndex(counter);

      if (_shipVia->id() == -1)
      {
        _shipVia->insertItem(shipvia);
        _shipVia->setCurrentIndex(_shipVia->count() - 1);
      }
    }

    _salesRep->setId(q.value("shipto_salesrep_id").toInt());
    _commission->setDouble(commission * 100);

    emit populated();
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
コード例 #18
0
bool configureCC::sSave()
{
  emit saving();

  _metrics->set("CCAccept",          _ccAccept->isChecked());
  _metrics->set("CCTest",            _ccTest->isChecked());
  _metrics->set("CCValidDays",       _ccValidDays->value());
  _metrics->set("CCCompany",         _ccCompany->currentText());
  _metrics->set("CCServer",          _ccServer->text());
  _metrics->set("CCPort",            _ccPort->text());
  _metrics->set("CCUseProxyServer",  _ccUseProxyServer->isChecked());
  _metrics->set("CCProxyServer",     _ccProxyServer->text());
  _metrics->set("CCProxyPort",       _ccProxyPort->text());

  XSqlQuery ccbankq;
  ccbankq.prepare("SELECT setCCBankAccnt(:cctype, :bankaccnt_id) AS result;");

  ccbankq.bindValue(":cctype", "A");
  if (_amexBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _amexBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _amexBank->setFocus();
    return false;
  }

  ccbankq.bindValue(":cctype", "D");
  if (_discoverBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _discoverBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _discoverBank->setFocus();
    return false;
  }

  ccbankq.bindValue(":cctype", "M");
  if (_mastercardBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _mastercardBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _mastercardBank->setFocus();
    return false;
  }

  /*
  ccbankq.bindValue(":cctype", "P");
  if (_paypalBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _paypalBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _paypalBank->setFocus();
    return false;
  }
  */

  ccbankq.bindValue(":cctype", "V");
  if (_visaBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _visaBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _visaBank->setFocus();
    return false;
  }

  _metrics->set("CCANVer",               _anVersion->currentText());
  _metrics->set("CCANDelim",             _anDelim->text());
  _metrics->set("CCANEncap",             _anEncap->text());
  _metrics->set("CCANDuplicateWindow",   _anDuplicateWindow->cleanText());
  _metrics->set("CCANMD5HashSetOnGateway", _anMD5HashSetOnGateway->isChecked());
  if (_anMD5HashWarn->isChecked())
    _metrics->set("CCANMD5HashAction", QString("W"));
  else if (_anMD5HashFail->isChecked())
    _metrics->set("CCANMD5HashAction", QString("F"));

  if (_anCurrFixed->isChecked())
    _metrics->set("CCANCurrency", _anCurrFixedValue->id());
  else // if (_anCurrTransaction->isChecked())
    _metrics->set("CCANCurrency", QString("TRANS"));
  _metrics->set("CCANWellsFargoSecureSource", _anUsingWellsFargoSecureSource->isChecked());

  _metrics->set("CCYPWinPathPEM",    _ccYPWinPathPEM->text());
  _metrics->set("CCYPLinPathPEM",    _ccYPLinPathPEM->text());
  _metrics->set("CCYPMacPathPEM",    _ccYPMacPathPEM->text());
  _metrics->set("CCYPLinkShield",    _ccYPLinkShield->isChecked());
  _metrics->set("CCYPLinkShieldMax", _ccYPLinkShieldMax->text());

  _metrics->set("CCConfirmPreauth",       _confirmPreauth->isChecked());
  _metrics->set("CCConfirmCharge",        _confirmCharge->isChecked());
  _metrics->set("CCConfirmChargePreauth", _confirmChargePreauth->isChecked());
  _metrics->set("CCConfirmCredit",        _confirmCredit->isChecked());

  _metrics->set("CCEnablePreauth",       _enablePreauth->isChecked());
  _metrics->set("CCEnableCharge",        _enableCharge->isChecked());
  _metrics->set("CCEnableChargePreauth", _enableChargePreauth->isChecked());
  _metrics->set("CCEnableCredit",        _enableCredit->isChecked());

  _metrics->set("CCPrintReceipt",        _printReceipt->isChecked());

  _metrics->set("CCRequireCVV", _cvvRequired->isChecked());
  if(_cvvNone->isChecked())
    _metrics->set("CCCVVCheck", QString("X"));
  else if(_cvvWarn->isChecked())
    _metrics->set("CCCVVCheck", QString("W"));
  else if(_cvvReject->isChecked())
    _metrics->set("CCCVVCheck", QString("F"));

  if(_avsNone->isChecked())
    _metrics->set("CCAvsCheck", QString("X"));
  else if(_avsWarn->isChecked())
    _metrics->set("CCAvsCheck", QString("W"));
  else if(_avsReject->isChecked())
    _metrics->set("CCAvsCheck", QString("F"));

  QString str;
  if (_cvvNotMatch->isChecked())
    str += "N";
  if (_cvvNotProcessed->isChecked())
    str += "P";
  if (_cvvNotOnCard->isChecked())
    str += "S";
  if (_cvvInvalidIssuer->isChecked())
    str += "U";
  _metrics->set("CCCVVErrors", str);

  if (_avsAddrNotMatch->isChecked() && _avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("NX"));
  else if (_avsAddrNotMatch->isChecked())
    _metrics->set("CCAvsAddr", QString("N"));
  else if (_avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("X"));

  if (_avsZIPNotMatch->isChecked() && _avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("NX"));
  else if (_avsZIPNotMatch->isChecked())
    _metrics->set("CCAvsZIP", QString("N"));
  else if (_avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("X"));

  if(_testsAllFail->isChecked())
    _metrics->set("CCTestResult", QString("F"));
  else if(_testsSomeFail->isChecked())
    _metrics->set("CCTestResult", QString("S"));
  else if(_testsAllPass->isChecked())
    _metrics->set("CCTestResult", QString("P"));

  _metrics->load();

  if (0 != _metricsenc)
  {
    _metricsenc->set("CCLogin",         _ccLogin->text());
    _metricsenc->set("CCPassword",      _ccPassword->text());
    _metricsenc->set("CCProxyLogin",    _ccProxyLogin->text());
    _metricsenc->set("CCProxyPassword", _ccProxyPassword->text());
    _metricsenc->set("CCYPStoreNum",    _ccYPStoreNum->text());
    _metricsenc->set("CCPTDivisionNumber", _ccPTDivisionNumber->text());
    _metricsenc->set("CCANMD5Hash",     _anMD5Hash->text());

    _metricsenc->load();
  }

  for (int i = 0; i < _configcclist.size(); i++)
    if (! _configcclist.at(i)->sSave())
      return false;

  if (_ccAccept->isChecked())
  {
    CreditCardProcessor *cardproc =
        CreditCardProcessor::getProcessor(_ccCompany->currentText());
    if (! cardproc)
    {
      QMessageBox::warning(this, tr("Error getting Credit Card Processor"),
                           tr("<p>Internal error finding the right Credit Card "
                              "Processor. The application saved what it could "
                              "but you should re-open this window and double-"
                              "check all of the settings before continuing."));
    }
    else if (cardproc && cardproc->testConfiguration() != 0)
    {
      if (QMessageBox::question(this, tr("Invalid Credit Card Configuration"),
                                tr("<p>The configuration has been saved but "
                                   "at least one configuration option appears "
                                   "to be invalid:<p>%1"
                                   "<p>Would you like to fix it now?")
        .arg(cardproc->errorMsg()),
        QMessageBox::Yes | QMessageBox::Default,
        QMessageBox::No) == QMessageBox::Yes)
        return false;
    }
  }

  configureEncryption *encryption = _keyPage->findChild<configureEncryption*>("_encryption");
  if (encryption && ! encryption->sSave())
    return false;

  return true;
}
コード例 #19
0
void customerFormAssignment::sSave()
{
  int custtypeid   = -1;
  QString custtype = ""; 

  if (_selectedCustomerType->isChecked())
    custtypeid = _customerTypes->id();
  else if (_customerTypePattern->isChecked())
    custtype = _customerType->text().trimmed();

  q.prepare("SELECT custform_id"
            "  FROM custform"
            " WHERE((custform_id != :custform_id)"
            "   AND (custform_custtype = :custform_custtype)"
            "   AND (custform_custtype_id=:custform_custtype_id))");
  q.bindValue(":custform_id", _custformid);
  q.bindValue(":custform_custtype", custtype);
  q.bindValue(":custform_custtype_id", custtypeid);
  q.exec();
  if(q.first())
  {
    QMessageBox::critical(this, tr("Duplicate Entry"),
      tr("The Customer Type specified is already in the database.") );
    return;
  }

  if (_mode == cNew)
  {
    q.exec("SELECT NEXTVAL('custform_custform_id_seq') AS _custformid");
    if (q.first())
      _custformid = q.value("_custformid").toInt();
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    q.prepare( "INSERT INTO custform "
               "( custform_id, custform_custtype, custform_custtype_id,"
               "  custform_invoice_report_name, custform_creditmemo_report_name,"
               "  custform_statement_report_name, custform_quote_report_name,"
               "   custform_packinglist_report_name, custform_sopicklist_report_name ) "
               "VALUES "
               "( :custform_id, :custform_custtype, :custform_custtype_id,"
               "  :custform_invoice_report_name, :custform_creditmemo_report_name,"
               "  :custform_statement_report_name, :custform_quote_report_name,"
               "  :custform_packinglist_report_name, :custform_sopicklist_report_name );" );
  }
  else if (_mode == cEdit)
    q.prepare( "UPDATE custform "
               "SET custform_custtype=:custform_custtype, custform_custtype_id=:custform_custtype_id,"
               "    custform_invoice_report_name=:custform_invoice_report_name,"
               "    custform_creditmemo_report_name=:custform_creditmemo_report_name,"
               "    custform_statement_report_name=:custform_statement_report_name,"
               "    custform_quote_report_name=:custform_quote_report_name,"
               "    custform_packinglist_report_name=:custform_packinglist_report_name,"
	       "    custform_sopicklist_report_name=:custform_sopicklist_report_name "
               "WHERE (custform_id=:custform_id);" );

  q.bindValue(":custform_id", _custformid);
  q.bindValue(":custform_custtype", custtype);
  q.bindValue(":custform_custtype_id", custtypeid);
  q.bindValue(":custform_invoice_report_name", _invoiceForm->code());
  q.bindValue(":custform_creditmemo_report_name", _creditMemoForm->code());
  q.bindValue(":custform_statement_report_name", _statementForm->code());
  q.bindValue(":custform_quote_report_name", _quoteForm->code());
  q.bindValue(":custform_packinglist_report_name", _packingListForm->code());
  q.bindValue(":custform_sopicklist_report_name", _soPickListForm->code());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  done(_custformid);
}
コード例 #20
0
void dspWoOperationsByWorkCenter::sFillList()
{
  _wooper->clear();

  q.prepare( "SELECT wrkcnt_descrip, warehous_code "
             "FROM wrkcnt, warehous "
             "WHERE ( (wrkcnt_warehous_id=warehous_id)"
             " AND (wrkcnt_id=:wrkcnt_id) );" );
  q.bindValue(":wrkcnt_id", _wrkcnt->id());
  q.exec();
  if (q.first())
  {
    _description->setText(q.value("wrkcnt_descrip").toString());
    _warehouse->setText(q.value("warehous_code").toString());
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  QString sql( "SELECT wooper_id, wooper_wo_id, formatWoNumber(wo_id) AS wonumber, formatDate(wooper_scheduled) AS f_scheduled, item_number, wooper_seqnumber,"
               "       CASE WHEN (wooper_stdopn_id <> -1) THEN ( SELECT stdopn_number FROM stdopn WHERE (stdopn_id=wooper_stdopn_id) )"
               "            ELSE ''"
               "       END AS stdoper,"
               "       (wooper_descrip1 || ' ' || wooper_descrip2) AS descrip,"
               "       CASE WHEN (wooper_sucomplete) THEN :complete"
               "            ELSE formatTime(noNeg(wooper_sutime - wooper_suconsumed))"
               "       END AS setupremain,"
               "       CASE WHEN (wooper_rncomplete) THEN :complete"
               "            ELSE formatTime(noNeg(wooper_rntime - wooper_rnconsumed))"
               "       END AS runremain,"
               "       formatQty(noNeg(wo_qtyord - wooper_qtyrcv)) AS qtyremain, uom_name,"
               "       CASE WHEN(wo_ordtype='M') THEN :mrp"
               "            WHEN(wo_ordtype='P') THEN :mps"
               "            WHEN(wo_ordtype='S') THEN (:so||'-'||formatSoNumber(wo_ordid))"
               "            WHEN(wo_ordtype='W') THEN (:wo||'-'||formatWoNumber(wo_ordid))"
               "            WHEN(wo_ordtype IS NULL OR wo_ordtype='') THEN :manual"
               "            ELSE wo_ordtype"
               "       END AS source,"
               "       (date(wooper_scheduled) < CURRENT_DATE) AS overdue "
               "FROM wooper, wo, itemsite, item, uom "
               "WHERE ( (wooper_wo_id=wo_id)"
               " AND (wo_itemsite_id=itemsite_id)"
               " AND (itemsite_item_id=item_id)"
               " AND (item_inv_uom_id=uom_id)"
               " AND (DATE(wooper_scheduled) BETWEEN :startDate AND :endDate)"
               " AND (wooper_wrkcnt_id=:wrkcnt_id)" );

  if (_loadOnly->isChecked())
    sql += " AND ( ((wooper_sutime - wooper_suconsumed) > 0) OR ((wooper_rntime - wooper_rnconsumed) > 0) )";

  sql += ") "
         "ORDER BY wooper_scheduled, wo_number, wo_subnumber, wooper_seqnumber;";

  q.prepare(sql);
  _dates->bindValue(q);
  q.bindValue(":complete", tr("Complete"));
  q.bindValue(":wrkcnt_id", _wrkcnt->id());
  q.bindValue(":mrp", tr("MRP"));
  q.bindValue(":mps", tr("MPS"));
  q.bindValue(":so", tr("SO"));
  q.bindValue(":wo", tr("WO"));
  q.bindValue(":manual", tr("Manual"));
  q.exec();

  XTreeWidgetItem * last = 0;
  while(q.next())
  {
    last = new XTreeWidgetItem(_wooper, last, q.value("wooper_id").toInt(),
                             q.value("wooper_wo_id").toInt(),
                             q.value("source"),
                             q.value("wonumber"), q.value("f_scheduled"),
                             q.value("item_number"), q.value("wooper_seqnumber"),
                             q.value("stdoper"), q.value("descrip"),
                             q.value("setupremain"), q.value("runremain"),
                             q.value("qtyremain"), q.value("uom_name") );
    if(q.value("overdue").toBool())
      last->setTextColor("red");
  }
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
コード例 #21
0
ファイル: voucherItem.cpp プロジェクト: Wushaowei001/xtuple-1
void voucherItem::sToggleReceiving(QTreeWidgetItem *pItem)
{
  double n;
  QString s;
  XTreeWidgetItem* item = (XTreeWidgetItem*)pItem;
  if(item->id() == -1)
    return;
  if (item->text(3) == "Yes")
  {
    item->setText(3, "No");
    if (item->text(0) == "Receiving")
    {
    	n = _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(item->text(2));
    	n = n - _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(s.setNum(n));

      n = _uninvoicedReceived->toDouble();
      _uninvoicedReceived->setText(item->text(2));
      n = n + _uninvoicedReceived->toDouble();
      _uninvoicedReceived->setText(s.setNum(n));
    }
    else
    {
    	n = _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(item->text(2));
    	n = n - _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(s.setNum(n));

      n = _uninvoicedRejected->toDouble();
      _uninvoicedRejected->setText(item->text(2));
      n = n + _rejected->toDouble();
      _uninvoicedRejected->setText(s.setNum(n));
    }
  }
  else 
  {
    item->setText(3, "Yes");
    if (item->text(0) == "Receiving")
    {
    	n = _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(item->text(2));
    	n = n + _qtyToVoucher->toDouble();
    	_qtyToVoucher->setText(s.setNum(n));

      n = _uninvoicedReceived->toDouble();
      _uninvoicedReceived->setText(item->text(2));
      n = n - _uninvoicedReceived->toDouble();
      _uninvoicedReceived->setText(s.setNum(n));
    }
    else
    {
      n = _qtyToVoucher->toDouble();
      _qtyToVoucher->setText(item->text(2));
      n = n + _qtyToVoucher->toDouble();
      _qtyToVoucher->setText(s.setNum(n));

      n = _uninvoicedRejected->toDouble();
      _uninvoicedRejected->setText(item->text(2));
      n = n + _uninvoicedRejected->toDouble();
      _uninvoicedRejected->setText(s.setNum(n));
    }
  }

  // Check PO Close flag

  if ( ((_ordered->toDouble() <= (_received->toDouble() - _rejected->toDouble()))) && (_uninvoicedReceived->toDouble() == 0) && (_uninvoicedRejected->toDouble() == 0) )
        _closePoitem->setChecked(true);
  else
	_closePoitem->setChecked(false);
  
  // Save the voitem information
  if (_voitemid != -1)
  {
    q.prepare( "UPDATE voitem "
               "SET voitem_qty=:voitem_qty "
               "WHERE (voitem_id=:voitem_id);" );
    q.bindValue(":voitem_id", _voitemid);
  }
  else
  {
  // Get next voitem id
    q.prepare("SELECT NEXTVAL('voitem_voitem_id_seq') AS voitemid");
    q.exec();
    if (q.first())
      _voitemid = (q.value("voitemid").toInt());
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return;
    }
    
    q.prepare( "INSERT INTO voitem "
               "(voitem_id, voitem_vohead_id, voitem_poitem_id, voitem_close, voitem_qty, voitem_freight) "
               "VALUES "
               "(:voitem_id, :vohead_id, :poitem_id, :voitem_close, :voitem_qty, :voitem_freight);" );
  }

  q.bindValue(":voitem_id", _voitemid);
  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":poitem_id", _poitemid);
  q.bindValue(":voitem_close", QVariant(_closePoitem->isChecked()));
  q.bindValue(":voitem_qty", _qtyToVoucher->toDouble());
  q.bindValue(":voitem_freight", _freightToVoucher->localValue());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }
  
  // Update the receipt record
  if (item->text(3) == "Yes")
  {
    if (item->altId() == 1)
      q.prepare( "UPDATE recv "
                 "SET recv_vohead_id=:vohead_id,recv_voitem_id=:voitem_id "
                 "WHERE (recv_id=:target_id);" );
    else if (item->altId() == 2)
      q.prepare( "UPDATE poreject "
                 "SET poreject_vohead_id=:vohead_id,poreject_voitem_id=:voitem_id "
                 "WHERE (poreject_id=:target_id);" );
  }
  else
  {
    if (item->altId() == 1)
      q.prepare( "UPDATE recv "
                 "SET recv_vohead_id=NULL,recv_voitem_id=NULL "
                 "WHERE ((recv_id=:target_id)"
                 "  AND  (recv_vohead_id=:vohead_id));" );
    else if (item->altId() == 2)
      q.prepare( "UPDATE poreject "
                 "SET poreject_vohead_id=NULL,poreject_voitem_id=NULL "
                 "WHERE ((poreject_id=:target_id)"
                 "  AND  (poreject_vohead_id=:vohead_id));" );
  }

  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":voitem_id", _voitemid);
  q.bindValue(":target_id", item->id());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                __FILE__, __LINE__);
    reject();
    return;
  }

}
コード例 #22
0
ファイル: selectPayment.cpp プロジェクト: chengzhou/qt-client
void selectPayment::sSave()
{
    XSqlQuery selectSave;
    QList<GuiErrorCheck> errors;
    errors << GuiErrorCheck(_selected->isZero(), _selected,
                            tr("<p>You must specify an amount greater than zero. "
                               "If you want to clear this approval you may do so "
                               "from the screen you selected this payment from.") )
           << GuiErrorCheck((_selected->localValue() + _discountAmount->localValue()) > (_amount->localValue() + 0.0000001), _selected,
                            tr("You must specify an amount smaller than or equal to the Balance.") )
           << GuiErrorCheck(_bankaccnt->id() == -1, _bankaccnt,
                            tr("<p>You must select a Bank Account from which this Payment is to be paid.") )
           ;

    if (GuiErrorCheck::reportErrors(this, tr("Cannot Approve for Payment"), errors))
        return;

    selectSave.prepare("SELECT bankaccnt_curr_id, currConcat(bankaccnt_curr_id) AS currAbbr "
                       "FROM bankaccnt "
                       "WHERE bankaccnt_id = :accntid;");
    selectSave.bindValue(":accntid", _bankaccnt->id());
    selectSave.exec();
    if (selectSave.first())
    {
        if (selectSave.value("bankaccnt_curr_id").toInt() != _selected->id())
        {
            int response = QMessageBox::question(this,
                                                 tr("Currencies Do Not Match"),
                                                 tr("<p>The currency selected for this payment "
                                                    "(%1) is not the same as the currency for the "
                                                    "Bank Account (%2). Would you like to use "
                                                    "this Bank Account anyway?")
                                                 .arg(_selected->currAbbr())
                                                 .arg(selectSave.value("currAbbr").toString()),
                                                 QMessageBox::Yes,
                                                 QMessageBox::No | QMessageBox::Default);
            if (response == QMessageBox::No)
            {
                _bankaccnt->setFocus();
                return;
            }
        }
    }
    else
    {
        systemError(this, selectSave.lastError().databaseText(), __FILE__, __LINE__);
        return;
    }

    selectSave.prepare("SELECT selectPayment(:apopen_id, :bankaccnt_id,"
                       "                     :docdate, :curr_id,"
                       "                     :amount, :discount ) AS result;");
    selectSave.bindValue(":apopen_id", _apopenid);
    selectSave.bindValue(":amount", _selected->localValue());
    selectSave.bindValue(":bankaccnt_id", _bankaccnt->id());
    selectSave.bindValue(":curr_id", _selected->id());
    selectSave.bindValue(":docdate", _docDate->date());
    selectSave.bindValue(":discount", _discountAmount->localValue());
    selectSave.exec();
    if (selectSave.first())
    {
        int result = selectSave.value("result").toInt();
        if (result < 0)
        {
            systemError(this, storedProcErrorLookup("selectPayment", result),
                        __FILE__, __LINE__);
            return;
        }
    }
    else
    {
        ErrorReporter::error(QtCriticalMsg, this, tr("Select Payment"),
                             selectSave, __FILE__, __LINE__);
        return;
    }

    omfgThis->sPaymentsUpdated(_bankaccnt->id(), _apselectid, true);

    done (_apselectid);
}
コード例 #23
0
ファイル: voucherItem.cpp プロジェクト: Wushaowei001/xtuple-1
enum SetResponse voucherItem::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("curr_id", &valid);
  if (valid)
  {
    _freightToVoucher->setId(param.toInt());
	_tax->setId(param.toInt());
  }

  param = pParams.value("effective", &valid);
  if (valid)
  {
	_freightToVoucher->setEffective(param.toDate());
	_tax->setEffective(param.toDate());
  }

  param = pParams.value("vohead_id", &valid);
  if (valid)
  {
    _voheadid = param.toInt();
    q.prepare("SELECT vohead_taxzone_id "
	          "FROM vohead "
	          "WHERE (vohead_id = :vohead_id);");
    q.bindValue(":vohead_id", _voheadid);
    q.exec();
    if (q.first())
      _taxzoneid = q.value("vohead_taxzone_id").toInt();
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
	else
	  _taxzoneid = -1;
  }
  else
    _voheadid = -1;

  param = pParams.value("poitem_id", &valid);
  if (valid)
  {
    _poitemid = param.toInt();

    q.prepare( "SELECT pohead_number, poitem_linenumber, poitem_taxtype_id, "
               "       COALESCE(itemsite_id, -1) AS itemsiteid,"
               "       poitem_vend_item_number, poitem_vend_uom, poitem_vend_item_descrip,"
               "       poitem_duedate,"
               "       poitem_qty_ordered,"
               "       poitem_qty_received,"
               "       poitem_qty_returned,"
               "       ( SELECT COALESCE(SUM(porecv_qty), 0)"
               "                    FROM porecv"
               "                    WHERE ( (porecv_posted)"
               "                     AND (NOT porecv_invoiced)"
       	       "                     AND (porecv_vohead_id IS NULL)"
               "                     AND (porecv_poitem_id=poitem_id) ) ) AS f_received,"
               "       ( SELECT COALESCE(SUM(poreject_qty), 0)"
               "                    FROM poreject"
               "                    WHERE ( (poreject_posted)"
               "                     AND (NOT poreject_invoiced)"
               "                     ANd (poreject_vohead_id IS NULL)"
               "                     AND (poreject_poitem_id=poitem_id) ) ) AS f_rejected,"
               "       poitem_unitprice,"
               "       poitem_unitprice * poitem_qty_ordered AS f_extprice,"
               "       poitem_freight "
               "FROM pohead, "
	       " poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) "
           "WHERE ( (poitem_pohead_id=pohead_id)"
               " AND (poitem_id=:poitem_id) );" );
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
    {
      _poNumber->setText(q.value("pohead_number").toString());
      _lineNumber->setText(q.value("poitem_linenumber").toString());
      _vendItemNumber->setText(q.value("poitem_vend_item_number").toString());
      _vendUOM->setText(q.value("poitem_vend_uom").toString());
      _vendDescription->setText(q.value("poitem_vend_item_descrip").toString());
      _dueDate->setDate(q.value("poitem_duedate").toDate());
      _ordered->setText(q.value("poitem_qty_ordered").toDouble());
      _received->setText(q.value("poitem_qty_received").toDouble());
      _rejected->setText(q.value("poitem_qty_returned").toDouble());
      _uninvoicedReceived->setText(q.value("f_received").toDouble());
      _uninvoicedRejected->setText(q.value("f_rejected").toDouble());
      _unitPrice->setText(q.value("poitem_unitprice").toDouble());
      _extPrice->setText(q.value("f_extprice").toDouble());
      _lineFreight->setText(q.value("poitem_freight").toDouble());
	  _taxtype->setId(q.value("poitem_taxtype_id").toInt());
      if (q.value("itemsiteid") != -1)
        _item->setItemsiteid(q.value("itemsiteid").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
  }
  else
    _poitemid = -1;

  if ( (_voheadid != -1) && (_poitemid != -1) )
  {
    q.prepare( "SELECT voitem_id, voitem_close, voitem_taxtype_id, "
               "       voitem_qty,"
               "       voitem_freight "
               "FROM voitem "
               "WHERE ( (voitem_vohead_id=:vohead_id)"
               " AND (voitem_poitem_id=:poitem_id) );" );
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
    {
      _voitemid = q.value("voitem_id").toInt();
      _closePoitem->setChecked(q.value("voitem_close").toBool());
      _qtyToVoucher->setText(q.value("voitem_qty").toDouble());
      _freightToVoucher->setLocalValue(q.value("voitem_freight").toDouble());
      _taxtype->setId(q.value("voitem_taxtype_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
    else
    {
      _voitemid = -1;
      _closePoitem->setChecked(FALSE);
      _qtyToVoucher->clear();
      _freightToVoucher->clear();
    }

	q.prepare( "SELECT SUM(COALESCE(taxhist_tax, 0.00)) AS taxamt "
	           "FROM voitem LEFT OUTER JOIN voitemtax "
			   " ON (voitem_id = taxhist_parent_id) "
               "WHERE ( (voitem_vohead_id=:vohead_id)"
               " AND (voitem_poitem_id=:poitem_id) );" );
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
	  _tax->setLocalValue(q.value("taxamt").toDouble());
	else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
    else
      _tax->clear();
  }

  sFillList();
  _saved = TRUE;
  return NoError;
}
コード例 #24
0
void applyAPCreditMemo::populate()
{
  q.prepare( "SELECT apopen_vend_id, apopen_docnumber, apopen_docdate,"
             "       (apopen_amount - apopen_paid) AS available, apopen_curr_id, "
             "       COALESCE(SUM(currToCurr(apcreditapply_curr_id,"
	     "				apopen_curr_id, apcreditapply_amount, "
	     "				CURRENT_DATE)), 0) AS f_applied "
             "FROM apopen LEFT OUTER JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) "
             "WHERE (apopen_id=:apopen_id) "
             "GROUP BY apopen_vend_id, apopen_docnumber, apopen_docdate,"
             "         apopen_curr_id, apopen_amount, apopen_paid;" );
  q.bindValue(":apopen_id", _apopenid);
  q.exec();
  if (q.first())
  {
    _vend->setId(q.value("apopen_vend_id").toInt());
    _docDate->setDate(q.value("apopen_docdate").toDate(), true);
    _available->setId(q.value("apopen_curr_id").toInt());
    _available->setLocalValue(q.value("available").toDouble());
    _applied->setLocalValue(q.value("f_applied").toDouble());
    _balance->setLocalValue(_available->localValue() - _applied->localValue());
    _docNumber->setText(q.value("apopen_docnumber").toString());
  
    _cachedAmount = q.value("available").toDouble();
  }
  else if (q.lastError().type() != QSqlError::NoError)
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);

  q.prepare( "SELECT apopen_id,"
             "       CASE WHEN (apopen_doctype='V') THEN :voucher"
             "            WHEN (apopen_doctype='D') THEN :debitMemo"
             "       END AS doctype,"
             "       apopen_docnumber,"
             "       apopen_docdate, apopen_duedate,"
             "       (apopen_amount - apopen_paid - COALESCE(selected,0.0) -"
             "          COALESCE(prepared,0.0)) AS openamount,"
	     "       currConcat(apopen_curr_id) AS opencurrabbr, "
             "       apcreditapply_amount, "
	     "       currConcat(apcreditapply_curr_id) AS appliedcurrabbr,"
             "       'curr' AS openamount_xtnumericrole,"
             "       'curr' AS apcreditapply_amount_xtnumericrole"
             "  FROM apopen LEFT OUTER JOIN apcreditapply "
             "         ON ( (apcreditapply_source_apopen_id=:parentApopenid) AND (apcreditapply_target_apopen_id=apopen_id) ) "
             "       LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id,"
             "                             SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected"
             "                        FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id)"
             "                       GROUP BY apopen_id) AS sub1"
             "         ON (apopen_id=selected_apopen_id)"
             "       LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id,"
             "                               SUM(currToCurr(checkitem_curr_id, apopen_curr_id, checkitem_amount + checkitem_discount, checkitem_docdate)) AS prepared"
             "                          FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)"
             "                                     JOIN apopen ON (checkitem_apopen_id=apopen_id)"
             "                         WHERE ((NOT checkhead_posted)"
             "                           AND  (NOT checkhead_void))"
             "                         GROUP BY apopen_id) AS sub2"
             "         ON (prepared_apopen_id=apopen_id)"
             " WHERE ( (apopen_doctype IN ('V', 'D'))"
             "   AND   (apopen_open)"
             "   AND   ((apopen_amount - apopen_paid - COALESCE(selected,0.0) - COALESCE(prepared,0.0)) > 0.0)"
             "   AND   (apopen_vend_id=:vend_id) ) "
             " ORDER BY apopen_duedate, apopen_docnumber;" );
  q.bindValue(":parentApopenid", _apopenid);
  q.bindValue(":vend_id", _vend->id());
  q.bindValue(":voucher", tr("Voucher"));
  q.bindValue(":debitMemo", tr("D/M"));
  q.exec();
  _apopen->populate(q);
  if (q.lastError().type() != QSqlError::NoError)
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
}
コード例 #25
0
void printShippingForm::sPrint()
{
  _print->setFocus();

  if (!_shipment->isValid())
  {
    QMessageBox::warning(this, tr("Shipment Number Required"),
			       tr("<p>You must enter a Shipment Number.") );
    _shipment->setFocus();
    return;
  }

  if (_shippingForm->id() == -1)
  {
    QMessageBox::warning( this, tr("Cannot Print Shipping Form"),
                          tr("<p>You must select a Shipping Form to print.") );
    _shippingForm->setFocus();
    return;
  }

  q.prepare("SELECT report_name "
	    "FROM shipform, report "
	    "WHERE ((shipform_report_id=report_id)"
	    " AND (shipform_id=:shipform_id) );" );
  q.bindValue(":shipform_id", _shippingForm->id());
  q.exec();
  if (q.first())
  {
    QPrinter printer(QPrinter::HighResolution);
    bool     setupPrinter = TRUE;
    bool userCanceled = false;

    if (orReport::beginMultiPrint(&printer, userCanceled) == false)
    {
      if(!userCanceled)
        systemError(this, tr("Could not initialize printing system for multiple reports."));
      return;
    }

    for (int counter = 0; counter < _shipformWatermarks->topLevelItemCount(); counter++ )
    {
      QTreeWidgetItem *cursor = _shipformWatermarks->topLevelItem(counter);
      ParameterList params;
      params.append("cosmisc_id",  _shipment->id()); // for backwards compat
      params.append("shiphead_id", _shipment->id());
      params.append("watermark",   cursor->text(1));
      params.append("shipchrg_id", _shipchrg->id());

      if (_metrics->boolean("MultiWhs"))
	params.append("MultiWhs");

      if (cursor->text(2) == tr("Yes"))
        params.append("showcosts");

      orReport report(q.value("report_name").toString(), params);
      if (report.print(&printer, setupPrinter))
        setupPrinter = FALSE;
      else
      {
        report.reportError(this);
	orReport::endMultiPrint(&printer);
        return;
      }
    }
    orReport::endMultiPrint(&printer);

    q.prepare( "UPDATE shiphead "
               "SET shiphead_sfstatus='P' "
               "WHERE (shiphead_id=:shiphead_id);" );
    q.bindValue(":shiphead_id", _shipment->id());
    q.exec();
    if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    if (_captive)
      accept();
    else
    {
      _shipment->setId(-1);
      _so->setId(-1);
      _to->setId(-1);
      _so->setEnabled(true);
      _to->setEnabled(true);
      _so->setFocus();
    }
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
    systemError(this, tr("<p>The Shipping Head Record cannot be found for the "
			 "selected order."));
}
コード例 #26
0
configureSO::configureSO(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_invoiceNumOfCopies, SIGNAL(valueChanged(int)), this, SLOT(sHandleInvoiceCopies(int)));
  connect(_creditMemoNumOfCopies, SIGNAL(valueChanged(int)), this, SLOT(sHandleCreditMemoCopies(int)));
  connect(_invoiceWatermarks, SIGNAL(itemSelected(int)), this, SLOT(sEditInvoiceWatermark()));
  connect(_creditLimit,          SIGNAL(editingFinished()), this, SLOT(sEditCreditLimit()));
  connect(_creditMemoWatermarks, SIGNAL(itemSelected(int)), this, SLOT(sEditCreditMemoWatermark()));
  connect(_askUpdatePrice, SIGNAL(toggled(bool)), _ignoreCustDisc, SLOT(setEnabled(bool)));

  _invoiceWatermarks->addColumn( tr("Copy #"),      _dateColumn, Qt::AlignCenter );
  _invoiceWatermarks->addColumn( tr("Watermark"),   -1,          Qt::AlignLeft   );
  _invoiceWatermarks->addColumn( tr("Show Prices"), _dateColumn, Qt::AlignCenter );

  _creditMemoWatermarks->addColumn( tr("Copy #"),      _dateColumn, Qt::AlignCenter );
  _creditMemoWatermarks->addColumn( tr("Watermark"),   -1,          Qt::AlignLeft   );
  _creditMemoWatermarks->addColumn( tr("Show Prices"), _dateColumn, Qt::AlignCenter );

  _nextSoNumber->setValidator(omfgThis->orderVal());
  _nextQuNumber->setValidator(omfgThis->orderVal());
  _nextRaNumber->setValidator(omfgThis->orderVal());
  _nextCmNumber->setValidator(omfgThis->orderVal());
  _nextInNumber->setValidator(omfgThis->orderVal());
  _creditLimit->setValidator(omfgThis->moneyVal());

  QString metric = _metrics->value("CONumberGeneration");
  if (metric == "M")
    _orderNumGeneration->setCurrentIndex(0);
  else if (metric == "A")
    _orderNumGeneration->setCurrentIndex(1);
  else if (metric == "O")
    _orderNumGeneration->setCurrentIndex(2);

  metric = _metrics->value("QUNumberGeneration");
  if (metric == "M")
    _quoteNumGeneration->setCurrentIndex(0);
  else if (metric == "A")
    _quoteNumGeneration->setCurrentIndex(1);
  else if (metric == "O")
    _quoteNumGeneration->setCurrentIndex(2);
  else if (metric == "S")
    _quoteNumGeneration->setCurrentIndex(3);

  metric = _metrics->value("CMNumberGeneration");
  if (metric == "M")
    _creditMemoNumGeneration->setCurrentIndex(0);
  else if (metric == "A")
    _creditMemoNumGeneration->setCurrentIndex(1);
  else if (metric == "O")
    _creditMemoNumGeneration->setCurrentIndex(2);
  else if (metric == "S")
    _creditMemoNumGeneration->setCurrentIndex(3);

  metric = _metrics->value("InvcNumberGeneration");
  if (metric == "M")
    _invoiceNumGeneration->setCurrentIndex(0);
  else if (metric == "A")
    _invoiceNumGeneration->setCurrentIndex(1);
  else if (metric == "O")
    _invoiceNumGeneration->setCurrentIndex(2);

  metric = _metrics->value("InvoiceDateSource");
  if (metric == "scheddate")
    _invcScheddate->setChecked(true);
  else if (metric == "shipdate")
    _invcShipdate->setChecked(true);
  else
    _invcCurrdate->setChecked(true);

  q.exec( "SELECT sonumber.orderseq_number AS sonumber,"
          "       qunumber.orderseq_number AS qunumber,"
          "       cmnumber.orderseq_number AS cmnumber,"
          "       innumber.orderseq_number AS innumber "
          "FROM orderseq AS sonumber,"
          "     orderseq AS qunumber,"
          "     orderseq AS cmnumber,"
          "     orderseq AS innumber "
          "WHERE ( (sonumber.orderseq_name='SoNumber')"
          " AND (qunumber.orderseq_name='QuNumber')"
          " AND (cmnumber.orderseq_name='CmNumber')"
          " AND (innumber.orderseq_name='InvcNumber') );" );
  if (q.first())
  {
    _nextSoNumber->setText(q.value("sonumber"));
    _nextQuNumber->setText(q.value("qunumber"));
    _nextCmNumber->setText(q.value("cmnumber"));
    _nextInNumber->setText(q.value("innumber"));
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  _allowDiscounts->setChecked(_metrics->boolean("AllowDiscounts"));
  _allowASAP->setChecked(_metrics->boolean("AllowASAPShipSchedules"));
  _customerChangeLog->setChecked(_metrics->boolean("CustomerChangeLog"));
  _salesOrderChangeLog->setChecked(_metrics->boolean("SalesOrderChangeLog"));
  _restrictCreditMemos->setChecked(_metrics->boolean("RestrictCreditMemos"));
  _autoSelectForBilling->setChecked(_metrics->boolean("AutoSelectForBilling"));
  _saveAndAdd->setChecked(_metrics->boolean("AlwaysShowSaveAndAdd"));
  _firmAndAdd->setChecked(_metrics->boolean("FirmSalesOrderPackingList"));
  _priceOverride->setChecked(_metrics->boolean("DisableSalesOrderPriceOverride"));
  _autoAllocateCM->setChecked(_metrics->boolean("AutoAllocateCreditMemos"));
  _hideSOMiscChrg->setChecked(_metrics->boolean("HideSOMiscCharge"));
  _enableSOShipping->setChecked(_metrics->boolean("EnableSOShipping"));
  _printSO->setChecked(_metrics->boolean("DefaultPrintSOOnSave"));
  _enablePromiseDate->setChecked(_metrics->boolean("UsePromiseDate"));
  _calcFreight->setChecked(_metrics->boolean("CalculateFreight"));
  _includePkgWeight->setChecked(_metrics->boolean("IncludePackageWeight"));

  _invoiceNumOfCopies->setValue(_metrics->value("InvoiceCopies").toInt());
  if (_invoiceNumOfCopies->value())
  {
    for (int counter = 0; counter < _invoiceWatermarks->topLevelItemCount(); counter++)
    {
      _invoiceWatermarks->topLevelItem(counter)->setText(1, _metrics->value(QString("InvoiceWatermark%1").arg(counter)));
      _invoiceWatermarks->topLevelItem(counter)->setText(2, ((_metrics->value(QString("InvoiceShowPrices%1").arg(counter)) == "t") ? tr("Yes") : tr("No")));
    }
  }

  _creditMemoNumOfCopies->setValue(_metrics->value("CreditMemoCopies").toInt());
  if (_invoiceNumOfCopies->value())
  {
    for (int counter = 0; counter < _creditMemoWatermarks->topLevelItemCount(); counter++)
    {
      _creditMemoWatermarks->topLevelItem(counter)->setText(1, _metrics->value(QString("CreditMemoWatermark%1").arg(counter)));
      _creditMemoWatermarks->topLevelItem(counter)->setText(2, ((_metrics->value(QString("CreditMemoShowPrices%1").arg(counter)) == "t") ? tr("Yes") : tr("No")));
    }
  }

  _shipform->setId(_metrics->value("DefaultShipFormId").toInt());
  _shipvia->setId(_metrics->value("DefaultShipViaId").toInt());

  if (_metrics->value("DefaultBalanceMethod") == "B")
    _balanceMethod->setCurrentIndex(0);
  else if (_metrics->value("DefaultBalanceMethod") == "O")
    _balanceMethod->setCurrentIndex(1);

  _custtype->setId(_metrics->value("DefaultCustType").toInt());
  _salesrep->setId(_metrics->value("DefaultSalesRep").toInt());
  _terms->setId(_metrics->value("DefaultTerms").toInt());

  _partial->setChecked(_metrics->boolean("DefaultPartialShipments"));
  _backorders->setChecked(_metrics->boolean("DefaultBackOrders"));
  _freeFormShiptos->setChecked(_metrics->boolean("DefaultFreeFormShiptos"));

  _creditLimit->setText(_metrics->value("SOCreditLimit"));
  _creditRating->setText(_metrics->value("SOCreditRate"));

  if (_metrics->value("soPriceEffective") == "OrderDate")
    _priceOrdered->setChecked(true);
  else if (_metrics->value("soPriceEffective") == "ScheduleDate")
    _priceScheduled->setChecked(true);

  if(_metrics->value("UpdatePriceLineEdit").toInt() == 1)
    _dontUpdatePrice->setChecked(true);
  else if (_metrics->value("UpdatePriceLineEdit").toInt() == 2)
    _askUpdatePrice->setChecked(true);
  else if(_metrics->value("UpdatePriceLineEdit").toInt() == 3)
    _updatePrice->setChecked(true);
  _ignoreCustDisc->setChecked(_askUpdatePrice->isChecked() && _metrics->boolean("IgnoreCustDisc"));

  this->setWindowTitle("Sales Configuration");

  //Set status of Returns Authorization based on context
  if(_metrics->value("Application") == "PostBooks")
  {
    _authNumGenerationLit->setVisible(false);
    _returnAuthorizationNumGeneration->setVisible(false);
    _nextRaNumberLit->setVisible(false);
    _nextRaNumber->setVisible(false);
    _tab->removePage(_tab->page(3));
    _enableReturns->setChecked(false);
    _enableReservations->hide();
    _enableReservations->setChecked(false);
    _locationGroup->hide();
    _locationGroup->setChecked(false);
    _lowest->setChecked(false);
    _highest->setChecked(false);
    _alpha->setChecked(false);
  }
  else
  {
    q.exec("SELECT rahead_id FROM rahead LIMIT 1;");
    if (q.first())
      _enableReturns->setCheckable(false);
    else
      _enableReturns->setChecked(_metrics->boolean("EnableReturnAuth"));

    q.exec( "SELECT ranumber.orderseq_number AS ranumber "
            "FROM orderseq AS ranumber "
            "WHERE (ranumber.orderseq_name='RaNumber');" );
    if (q.first())
    {
      _nextRaNumber->setText(q.value("ranumber"));
    }
    else
      _nextRaNumber->setText("10000");

    metric = _metrics->value("RANumberGeneration");
    if (metric == "M")
      _returnAuthorizationNumGeneration->setCurrentIndex(0);
    else if (metric == "A")
      _returnAuthorizationNumGeneration->setCurrentIndex(1);
    else if (metric == "O")
      _returnAuthorizationNumGeneration->setCurrentIndex(2);

    metric = _metrics->value("DefaultRaDisposition");
    if (metric == "C")
      _disposition->setCurrentIndex(0);
    else if (metric == "R")
      _disposition->setCurrentIndex(1);
    else if (metric == "P")
      _disposition->setCurrentIndex(2);
    else if (metric == "V")
      _disposition->setCurrentIndex(3);
    else if (metric == "M")
      _disposition->setCurrentIndex(4);

    if (_metrics->value("DefaultRaTiming") == "R")
      _timing->setCurrentIndex(1);

    metric = _metrics->value("DefaultRaCreditMethod");
    if (metric == "N")
      _creditBy->setCurrentIndex(0);
    else if (metric == "M")
      _creditBy->setCurrentIndex(1);
    else if (metric == "K")
      _creditBy->setCurrentIndex(2);
    else if (metric == "C")
      _creditBy->setCurrentIndex(3);

    _returnAuthChangeLog->setChecked(_metrics->boolean("ReturnAuthorizationChangeLog"));
    _printRA->setChecked(_metrics->boolean("DefaultPrintRAOnSave"));

    _enableReservations->setChecked(_metrics->boolean("EnableSOReservations"));

    _locationGroup->setChecked(_metrics->boolean("EnableSOReservationsByLocation"));
    if(_metrics->value("SOReservationLocationMethod").toInt() == 1)
      _lowest->setChecked(true);
    else if (_metrics->value("SOReservationLocationMethod").toInt() == 2)
      _highest->setChecked(true);
    else if(_metrics->value("SOReservationLocationMethod").toInt() == 3)
      _alpha->setChecked(true);
  }
  adjustSize();
}
コード例 #27
0
void incidentCategory::sSave()
{
  if(_name->text().length() == 0)
  {
    QMessageBox::critical(this, tr("Category Name Required"),
      tr("You must enter a Category Name to continue.") );
    _name->setFocus();
    return;
  }

  if (_mode == cNew)
  {
    q.exec("SELECT NEXTVAL('incdtcat_incdtcat_id_seq') AS _incdtcat_id");
    if (q.first())
      _incdtcatId = q.value("_incdtcat_id").toInt();
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    q.prepare( "INSERT INTO incdtcat "
               "(incdtcat_id, incdtcat_name, incdtcat_order, incdtcat_descrip, incdtcat_ediprofile_id)"
               " VALUES "
               "(:incdtcat_id, :incdtcat_name, :incdtcat_order, :incdtcat_descrip, :incdtcat_ediprofile_id );" );
  }
  else if (_mode == cEdit)
  {
    q.prepare( "SELECT incdtcat_id "
               "FROM incdtcat "
               "WHERE ( (UPPER(incdtcat_name)=UPPER(:incdtcat_name))"
               " AND (incdtcat_id<>:incdtcat_id) );" );
    q.bindValue(":incdtcat_id", _incdtcatId);
    q.bindValue(":incdtcat_name", _name->text());
    q.exec();
    if (q.first())
    {
      QMessageBox::warning( this, tr("Cannot Save Incident Category"),
                            tr("You may not rename this Incident Category with "
			       "the entered value as it is in use by another "
			       "Incident Category.") );
      return;
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    q.prepare( "UPDATE incdtcat "
               "SET incdtcat_name=:incdtcat_name, "
	       "    incdtcat_order=:incdtcat_order, "
	       "    incdtcat_descrip=:incdtcat_descrip, "
               "    incdtcat_ediprofile_id=:incdtcat_ediprofile_id "
               "WHERE (incdtcat_id=:incdtcat_id);" );
  }

  q.bindValue(":incdtcat_id", _incdtcatId);
  q.bindValue(":incdtcat_name", _name->text());
  q.bindValue(":incdtcat_order", _order->value());
  q.bindValue(":incdtcat_descrip", _descrip->toPlainText());
  if (_ediprofile->id() != -1)
    q.bindValue(":incdtcat_ediprofile_id", _ediprofile->id());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  done(_incdtcatId);
}
コード例 #28
0
void configureSO::sSave()
{
  const char *numberGenerationTypes[] = { "M", "A", "O", "S" };
  const char *dispositionTypes[] = { "C", "R", "P", "V", "M" };
  const char *creditMethodTypes[] = { "N", "M", "K", "C" };

  if ( (_metrics->boolean("EnableSOReservationsByLocation")) &&
       (!_locationGroup->isChecked()) )
  {
    if (QMessageBox::warning(this, tr("Reserve by Location Disabled"),
                             tr("<p>All existing location reservations will be removed. Are you sure you want to continue?"),
                             QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No)
    {
      return;
    }
    else
    {
      q.prepare("DELETE FROM itemlocrsrv "
                " WHERE (itemlocrsrv_source='SO');");
      q.exec();
    }	
  }

  _metrics->set("AllowDiscounts", _allowDiscounts->isChecked());
  _metrics->set("AllowASAPShipSchedules", _allowASAP->isChecked());
  _metrics->set("CustomerChangeLog", _customerChangeLog->isChecked());
  _metrics->set("SalesOrderChangeLog", _salesOrderChangeLog->isChecked());
  _metrics->set("RestrictCreditMemos", _restrictCreditMemos->isChecked());
  _metrics->set("AutoSelectForBilling", _autoSelectForBilling->isChecked());
  _metrics->set("AlwaysShowSaveAndAdd", _saveAndAdd->isChecked());
  _metrics->set("FirmSalesOrderPackingList", _firmAndAdd->isChecked());
  _metrics->set("DisableSalesOrderPriceOverride", _priceOverride->isChecked());
  _metrics->set("AutoAllocateCreditMemos", _autoAllocateCM->isChecked());
  _metrics->set("HideSOMiscCharge", _hideSOMiscChrg->isChecked());
  _metrics->set("EnableSOShipping", _enableSOShipping->isChecked());
  _metrics->set("CONumberGeneration", QString(numberGenerationTypes[_orderNumGeneration->currentIndex()]));
  _metrics->set("QUNumberGeneration", QString(numberGenerationTypes[_quoteNumGeneration->currentIndex()]));
  _metrics->set("CMNumberGeneration", QString(numberGenerationTypes[_creditMemoNumGeneration->currentIndex()]));
  _metrics->set("InvcNumberGeneration", QString(numberGenerationTypes[_invoiceNumGeneration->currentIndex()]));
  _metrics->set("DefaultShipFormId", _shipform->id());
  _metrics->set("DefaultShipViaId", _shipvia->id());
  _metrics->set("DefaultCustType", _custtype->id());
  _metrics->set("DefaultSalesRep", _salesrep->id());
  _metrics->set("DefaultTerms", _terms->id());
  _metrics->set("DefaultPartialShipments", _partial->isChecked());
  _metrics->set("DefaultBackOrders", _backorders->isChecked());
  _metrics->set("DefaultFreeFormShiptos", _freeFormShiptos->isChecked());
  _metrics->set("DefaultPrintSOOnSave", _printSO->isChecked());
  _metrics->set("UsePromiseDate", _enablePromiseDate->isChecked());
  _metrics->set("CalculateFreight", _calcFreight->isChecked());
  _metrics->set("IncludePackageWeight", _includePkgWeight->isChecked());
  _metrics->set("EnableReturnAuth", _enableReturns->isChecked());
  _metrics->set("EnableSOReservations", _enableReservations->isChecked());

  _metrics->set("EnableSOReservationsByLocation", _locationGroup->isChecked());
  //SOReservationLocationMethod are three Options Either 
  // Lowest quantity first,
  // Highest quantity first,
  // Alpha by Location Name
  if(_lowest->isChecked())
    _metrics->set("SOReservationLocationMethod", 1);
  else if (_highest->isChecked())
    _metrics->set("SOReservationLocationMethod", 2);
  else if(_alpha->isChecked())
    _metrics->set("SOReservationLocationMethod", 3);

  _metrics->set("SOCreditLimit", _creditLimit->text());
  _metrics->set("SOCreditRate", _creditRating->text());

  if (_priceOrdered->isChecked())
    _metrics->set("soPriceEffective", QString("OrderDate"));
  else if (_priceScheduled->isChecked())
    _metrics->set("soPriceEffective", QString("ScheduleDate"));
  else
    _metrics->set("soPriceEffective", QString("CurrentDate"));

  //UpdatePriceLineEdit are three Options Either 
  // Don't Update price
  // Ask to Update Price,
  // Update Price
  if(_dontUpdatePrice->isChecked())
    _metrics->set("UpdatePriceLineEdit", 1);
  else if (_askUpdatePrice->isChecked())
    _metrics->set("UpdatePriceLineEdit", 2);
  else if(_updatePrice->isChecked())
    _metrics->set("UpdatePriceLineEdit", 3);
  _metrics->set("IgnoreCustDisc", _askUpdatePrice->isChecked() && _ignoreCustDisc->isChecked());

  if(_invcScheddate->isChecked())
    _metrics->set("InvoiceDateSource", QString("scheddate"));
  else if(_invcShipdate->isChecked())
    _metrics->set("InvoiceDateSource", QString("shipdate"));
  else
    _metrics->set("InvoiceDateSource", QString("currdate"));

  _metrics->set("InvoiceCopies", _invoiceNumOfCopies->value());
  if (_invoiceNumOfCopies->value())
  {
    for (int counter = 0; counter < _invoiceWatermarks->topLevelItemCount(); counter++ )
    {
      _metrics->set(QString("InvoiceWatermark%1").arg(counter),  _invoiceWatermarks->topLevelItem(counter)->text(1));
      _metrics->set(QString("InvoiceShowPrices%1").arg(counter), _invoiceWatermarks->topLevelItem(counter)->text(2) == tr("Yes"));
    }
  }

  _metrics->set("CreditMemoCopies", _creditMemoNumOfCopies->value());
  if (_creditMemoNumOfCopies->value())
  {
    for (int counter = 0; counter < _creditMemoWatermarks->topLevelItemCount(); counter++)
    {
      _metrics->set(QString("CreditMemoWatermark%1").arg(counter), _creditMemoWatermarks->topLevelItem(counter)->text(1));
      _metrics->set(QString("CreditMemoShowPrices%1").arg(counter), (_creditMemoWatermarks->topLevelItem(counter)->text(2) == tr("Yes")));
    }
  }

  switch (_balanceMethod->currentIndex())
  {
  case 0:
    _metrics->set("DefaultBalanceMethod", QString("B"));
    break;

  case 1:
    _metrics->set("DefaultBalanceMethod", QString("O"));
    break;
  }

  q.prepare( "SELECT setNextSoNumber(:sonumber), setNextQuNumber(:qunumber),"
             "       setNextCmNumber(:cmnumber), setNextInvcNumber(:innumber);" );
  q.bindValue(":sonumber", _nextSoNumber->text().toInt());
  q.bindValue(":qunumber", _nextQuNumber->text().toInt());
  q.bindValue(":cmnumber", _nextCmNumber->text().toInt());
  q.bindValue(":innumber", _nextInNumber->text().toInt());
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if (_enableReturns->isChecked() || !_enableReturns->isCheckable())
  {
    _metrics->set("DefaultRaDisposition", QString(dispositionTypes[_disposition->currentIndex()]));
    if (_timing->currentIndex() == 0)
      _metrics->set("DefaultRaTiming", QString("I"));
    else
      _metrics->set("DefaultRaTiming", QString("R"));
    _metrics->set("DefaultRaCreditMethod", QString(creditMethodTypes[_creditBy->currentIndex()]));
    _metrics->set("ReturnAuthorizationChangeLog", _returnAuthChangeLog->isChecked());
    _metrics->set("DefaultPrintRAOnSave", _printRA->isChecked());
    _metrics->set("RANumberGeneration", QString(numberGenerationTypes[_returnAuthorizationNumGeneration->currentIndex()]));

    q.prepare( "SELECT setNextRaNumber(:ranumber);" );
    q.bindValue(":ranumber", _nextRaNumber->text().toInt());
    q.exec();
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
  _metrics->set("EnableReturnAuth", (_enableReturns->isChecked() || !_enableReturns->isCheckable()));

  _metrics->load();

  accept();
}
コード例 #29
0
void lotSerialSequence::sSave()
{
  _number->setText(_number->text().trimmed().toUpper());
  if (_number->text().length() == 0)
  {
    QMessageBox::information( this, tr("Invalid Sequence"),
                              tr("You must enter a valid Code for this Sequence.") );
    _number->setFocus();
    return;
  }

  if (_mode == cNew)
  {
    if (sCheck())
    {
      QMessageBox::warning( this, tr("Cannot Save Sequence"),
                            tr("This Sequence number already exists.  You have been placed in edit mode.") );
      return;
    }

    q.exec("SELECT NEXTVAL('lsseq_lsseq_id_seq') AS lsseq_id");
    if (q.first())
      _lsseqid = q.value("lsseq_id").toInt();
    else
    {
      systemError(this, tr("A System Error occurred at %1::%2.")
                        .arg(__FILE__)
                        .arg(__LINE__) );
      return;
    }

    q.prepare( "INSERT INTO lsseq "
               "( lsseq_id, lsseq_number) "
               "VALUES "
               "( :lsseq_id, :lsseq_number);");
  }
  else if (_mode == cEdit)
    q.prepare("SELECT lsseq_id"
              "  FROM lsseq"
              " WHERE((lsseq_id != :lsseq_id)"
              " AND (lsseq_number = :lsseq_number));");

  q.bindValue(":lsseq_id", _lsseqid);
  q.bindValue(":lsseq_number", _number->text());
  q.exec();
  if(q.first())
  {
    QMessageBox::warning( this, tr("Cannot Save Sequence Number"),
                          tr("You may not rename this Sequence number with the entered name as it is in use by another Planner code.") );
    _number->setFocus();
    return;
  }

  q.prepare( "UPDATE lsseq "
             "SET lsseq_number=:lsseq_number, lsseq_descrip=:lsseq_descrip,"
             "    lsseq_prefix=:lsseq_prefix,lsseq_seqlen=:lsseq_seqlen, "
             "    lsseq_suffix=:lsseq_suffix "
             "WHERE (lsseq_id=:lsseq_id);"
             "SELECT setval(:sequence, :next_value - 1);");

  q.bindValue(":lsseq_id", _lsseqid);
  q.bindValue(":lsseq_number", _number->text());
  q.bindValue(":lsseq_descrip", _description->text().trimmed());
  q.bindValue(":lsseq_prefix", _prefix->text());
  q.bindValue(":lsseq_seqlen", _length->value());
  q.bindValue(":lsseq_suffix", _suffix->text());
  q.bindValue(":next_value", _nextValue->text());
  q.bindValue(":sequence", QString("lsseq_number_seq_%1").arg(_lsseqid));
  q.exec();

  done(_lsseqid);
}
コード例 #30
0
void department::sSave()
{
  QString number = _number->text().trimmed().toUpper();

  if (number.isEmpty())
  {
    QMessageBox::critical(this, tr("Cannot Save Department"),
                          tr("You must enter a Department Number"));
    _number->setFocus();
    return;
  }
  if (_name->text().trimmed().isEmpty())
  {
    QMessageBox::critical(this, tr("Cannot Save Department"),
                          tr("You must enter a Department Name"));
    _name->setFocus();
    return;
  }

  q.prepare("SELECT dept_id"
            "  FROM dept"
            " WHERE((dept_id != :dept_id)"
            "   AND (dept_number=:dept_number));");
  q.bindValue(":dept_id", _deptid);
  q.bindValue(":dept_number", number);
  q.exec();
  if(q.first())
  {
    QMessageBox::critical(this, tr("Cannpt Save Department"),
                          tr("The Number you entered already exists. Please choose a different Number."));
    return;
  }
  
  if (_mode == cNew)
  {
    q.exec("SELECT NEXTVAL('dept_dept_id_seq') AS dept_id;");
    if (q.first())
      _deptid =  q.value("dept_id").toInt();
    else
    {
      systemError(this, tr("A System Error occurred at %1::%2\n\n%3")
                          .arg(__FILE__)
                          .arg(__LINE__)
                          .arg(q.lastError().databaseText()));
      return;
    }
    q.prepare("INSERT INTO dept ( dept_id,  dept_number,  dept_name ) "
              "       VALUES    (:dept_id, :dept_number, :dept_name );");
  }
  else if (_mode == cEdit)
  {
    q.prepare("UPDATE dept "
              "SET dept_id=:dept_id, "
              "    dept_number=:dept_number, "
              "    dept_name=:dept_name "
              "WHERE (dept_id=:dept_id);");
  }
  q.bindValue(":dept_id",        _deptid);
  q.bindValue(":dept_number",        number);
  q.bindValue(":dept_name",        _name->text().trimmed());

  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, tr("A System Error occurred at %1::%2\n\n%3")
                        .arg(__FILE__)
                        .arg(__LINE__)
                        .arg(q.lastError().databaseText()));
    return;
  }

  done(_deptid);
}