void taxDetail::sPopulate() { XSqlQuery taxPopulate; XSqlQuery popq; popq.prepare("SELECT taxtype_descrip from taxtype where taxtype_id=:taxtype_id;"); popq.bindValue(":taxtype_id", _taxType->id()); popq.exec(); if(popq.first()) _descrip->setText(popq.value("taxtype_descrip").toString()); else _descrip->setText("Unspecified"); QString sql; ParameterList params; params.append("order_id", _orderid); params.append("order_type", _ordertype); params.append("sense", _sense); if(_ordertype == "S" || _ordertype == "Q" || _ordertype == "I" || _ordertype == "B" || _ordertype == "RA" || _ordertype == "CM" || _ordertype == "PO" || _ordertype == "VO" || _ordertype == "VI" || _ordertype == "TO" || _ordertype == "PI" ) { params.append("display_type", _displayType); sql = "SELECT taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, " " round(sum(taxdetail_tax),2) * <? value('sense') ?> as taxdetail_tax, taxdetail_taxclass_sequence, 0 AS xtindentrole, " " 0 AS taxdetail_tax_xttotalrole, 'salesprice' AS taxdetail_tax_xtnumericrole " "FROM calculateTaxDetailSummary(<? value('order_type') ?>, <? value('order_id') ?>, <? value('display_type') ?>) " "GROUP BY taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, taxdetail_level, taxdetail_taxclass_sequence;"; } else if( _ordertype == "II" || _ordertype == "BI" || _ordertype == "CI" || _ordertype == "TI" || _ordertype == "AR" || _ordertype == "AP" ) sql = "SELECT taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, " " taxdetail_tax * <? value('sense') ?> AS taxdetail_tax, taxdetail_taxclass_sequence, taxdetail_level AS xtindentrole, " " 0 AS taxdetail_tax_xttotalrole, 'saleprice' AS taxdetail_tax_xtnumericrole " "FROM calculateTaxDetailLine(<? value('order_type') ?>, <? value('order_id') ?>); "; else { sCalculateTax(); return; } MetaSQLQuery mql(sql); taxPopulate = mql.toQuery(params); _taxcodes->clear(); _taxcodes->populate(taxPopulate); if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Tax Type Information"), taxPopulate, __FILE__, __LINE__)) { return; } }
creditMemoItem::creditMemoItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); #ifndef Q_WS_MAC _listPrices->setMaximumWidth(25); #endif connect(_discountFromSale, SIGNAL(editingFinished()), this, SLOT(sCalculateFromDiscount())); connect(_extendedPrice, SIGNAL(valueChanged()), this, SLOT(sCalculateTax())); connect(_item, SIGNAL(newId(int)), this, SLOT(sPopulateItemInfo())); connect(_warehouse, SIGNAL(newID(int)), this, SLOT(sPopulateItemsiteInfo())); connect(_listPrices, SIGNAL(clicked()), this, SLOT(sListPrices())); connect(_netUnitPrice, SIGNAL(valueChanged()), this, SLOT(sCalculateDiscountPrcnt())); connect(_netUnitPrice, SIGNAL(valueChanged()), this, SLOT(sCalculateExtendedPrice())); connect(_netUnitPrice, SIGNAL(idChanged(int)), this, SLOT(sPriceGroup())); connect(_qtyToCredit, SIGNAL(textChanged(const QString&)), this, SLOT(sCalculateExtendedPrice())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_taxLit, SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail())); connect(_taxType, SIGNAL(newID(int)), this, SLOT(sCalculateTax())); connect(_qtyUOM, SIGNAL(newID(int)), this, SLOT(sQtyUOMChanged())); connect(_pricingUOM, SIGNAL(newID(int)), this, SLOT(sPriceUOMChanged())); _mode = cNew; _cmitemid = -1; _cmheadid = -1; _custid = -1; _invoiceNumber = -1; _priceRatio = 1.0; _qtyShippedCache = 0.0; _shiptoid = -1; _taxzoneid = -1; _qtyinvuomratio = 1.0; _priceinvuomratio = 1.0; _invuomid = -1; _saved = false; _qtyToCredit->setValidator(omfgThis->qtyVal()); _qtyReturned->setValidator(omfgThis->qtyVal()); _qtyShipped->setPrecision(omfgThis->qtyVal()); _discountFromList->setPrecision(omfgThis->percentVal()); _discountFromSale->setValidator(new XDoubleValidator(-9999, 100, 2, this)); _taxType->setEnabled(_privileges->check("OverrideTax")); //If not multi-warehouse hide whs control if (!_metrics->boolean("MultiWhs")) { _warehouseLit->hide(); _warehouse->hide(); } adjustSize(); }
voucherItem::voucherItem(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) : XDialog(parent, name, modal, fl) { XSqlQuery voucherItem; setupUi(this); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_uninvoiced, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(sToggleReceiving(QTreeWidgetItem*))); connect(_uninvoiced, SIGNAL(populateMenu(QMenu*,XTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*, XTreeWidgetItem*))); connect(_freightToVoucher, SIGNAL(editingFinished()), this, SLOT(sCalculateTax())); connect(_freightToVoucher, SIGNAL(editingFinished()), this, SLOT(sFillList())); connect(_vodist, SIGNAL(populated()), this, SLOT(sCalculateTax())); connect(_taxtype, SIGNAL(newID(int)), this, SLOT(sCalculateTax())); connect(_taxLit, SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail())); _item->setReadOnly(true); _unitPrice->setPrecision(omfgThis->priceVal()); _extPrice->setPrecision(omfgThis->moneyVal()); _lineFreight->setPrecision(omfgThis->moneyVal()); _ordered->setValidator(omfgThis->qtyVal()); _received->setValidator(omfgThis->qtyVal()); _rejected->setValidator(omfgThis->qtyVal()); _uninvoicedReceived->setValidator(omfgThis->qtyVal()); _uninvoicedRejected->setValidator(omfgThis->qtyVal()); _qtyToVoucher->setValidator(omfgThis->qtyVal()); _amtToVoucher->setValidator(omfgThis->moneyVal()); _vodist->addColumn(tr("Cost Element"), -1, Qt::AlignLeft, true, "costelem_type"); _vodist->addColumn(tr("Amount"), _priceColumn, Qt::AlignRight,true, "vodist_amount"); _uninvoiced->addColumn(tr("Receipt/Reject"), -1, Qt::AlignCenter, true, "action"); _uninvoiced->addColumn(tr("Date"), _dateColumn, Qt::AlignCenter, true, "item_date"); _uninvoiced->addColumn(tr("Qty."), _qtyColumn, Qt::AlignRight, true, "qty"); _uninvoiced->addColumn(tr("Unit Price"), _moneyColumn,Qt::AlignRight, true, "unitprice"); _uninvoiced->addColumn(tr("Tagged"), _ynColumn, Qt::AlignCenter, true, "f_tagged"); }
void taxDetail::sPopulate() { XSqlQuery popq; popq.prepare("SELECT taxtype_descrip from taxtype where taxtype_id=:taxtype_id;"); popq.bindValue(":taxtype_id", _taxType->id()); popq.exec(); if(popq.first()) _descrip->setText(popq.value("taxtype_descrip").toString()); else _descrip->setText("Unspecified"); QString sql; ParameterList params; params.append("order_id", _orderid); params.append("order_type", _ordertype); params.append("sense", _sense); if(_ordertype == "S" || _ordertype == "Q" || _ordertype == "I" || _ordertype == "B" || _ordertype == "RA" || _ordertype == "CM" || _ordertype == "PO" || _ordertype == "VO" || _ordertype == "TO") { params.append("display_type", _displayType); sql = "SELECT taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, " " round(sum(taxdetail_tax),2) * <? value(\"sense\") ?> as taxdetail_tax, taxdetail_taxclass_sequence, 0 AS xtindentrole, " " 0 AS taxdetail_tax_xttotalrole, 'salesprice' AS taxdetail_tax_xtnumericrole " "FROM calculateTaxDetailSummary(<? value(\"order_type\") ?>, <? value(\"order_id\") ?>, <? value(\"display_type\") ?>) " "GROUP BY taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, taxdetail_level, taxdetail_taxclass_sequence;"; } else if( _ordertype == "II" || _ordertype == "BI" || _ordertype == "CI" || _ordertype == "TI" || _ordertype == "VI" || _ordertype == "AR" || _ordertype == "AP" ) sql = "SELECT taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, " " taxdetail_tax * <? value(\"sense\") ?> AS taxdetail_tax, taxdetail_taxclass_sequence, taxdetail_level AS xtindentrole, " " 0 AS taxdetail_tax_xttotalrole, 'saleprice' AS taxdetail_tax_xtnumericrole " "FROM calculateTaxDetailLine(<? value(\"order_type\") ?>, <? value(\"order_id\") ?>); "; else { sCalculateTax(); return; } MetaSQLQuery mql(sql); q = mql.toQuery(params); _taxcodes->clear(); _taxcodes->populate(q); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
void purchaseOrder::sFillList() { q.prepare( "SELECT poitem.*," " CASE WHEN(poitem_status='C') THEN :closed" " WHEN(poitem_status='U') THEN :unposted" " WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN :partial" " WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN :received" " WHEN(poitem_status='O') THEN :open" " ELSE poitem_status" " END AS poitemstatus," " CASE WHEN (itemsite_id IS NULL) THEN poitem_vend_item_number" " ELSE item_number" " END AS item_number," " CASE WHEN (itemsite_id IS NULL) THEN firstLine(poitem_vend_item_descrip)" " ELSE (item_descrip1 || ' ' || item_descrip2)" " END AS item_descrip," " (poitem_unitprice * poitem_qty_ordered) AS extprice, " " 'qty' AS poitem_qty_ordered_xtnumericrole," " 'purchprice' AS poitem_unitprice_xtnumericrole," " 'curr' AS extprice_xtnumericrole, " " poitem_vend_item_number, poitem_manuf_name, poitem_manuf_item_number " "FROM poitem LEFT OUTER JOIN" " ( itemsite JOIN item" " ON (itemsite_item_id=item_id) )" " ON (poitem_itemsite_id=itemsite_id) " "WHERE (poitem_pohead_id=:pohead_id) " "ORDER BY poitem_linenumber;" ); q.bindValue(":pohead_id", _poheadid); q.bindValue(":closed", tr("Closed")); q.bindValue(":unposted", tr("Unposted")); q.bindValue(":partial", tr("Partial")); q.bindValue(":received", tr("Received")); q.bindValue(":open", tr("Open")); q.exec(); _poitem->populate(q); sCalculateTax(); sCalculateTotals(); _poCurrency->setEnabled(_poitem->topLevelItemCount() == 0); _qecurrency->setEnabled(_poitem->topLevelItemCount() == 0); _qeitem->select(); }
voucherItem::voucherItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_uninvoiced, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(sToggleReceiving(QTreeWidgetItem*))); connect(_uninvoiced, SIGNAL(populateMenu(QMenu*,QTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*, QTreeWidgetItem*))); connect(_freightToVoucher, SIGNAL(lostFocus()), this, SLOT(sFillList())); connect(_vodist, SIGNAL(populated()), this, SLOT(sCalculateTax())); connect(_taxtype, SIGNAL(newID(int)), this, SLOT(sCalculateTax())); connect(_taxLit, SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail())); _item->setReadOnly(TRUE); _unitPrice->setPrecision(omfgThis->priceVal()); _extPrice->setPrecision(omfgThis->moneyVal()); _lineFreight->setPrecision(omfgThis->moneyVal()); _ordered->setValidator(omfgThis->qtyVal()); _received->setValidator(omfgThis->qtyVal()); _rejected->setValidator(omfgThis->qtyVal()); _uninvoicedReceived->setValidator(omfgThis->qtyVal()); _uninvoicedRejected->setValidator(omfgThis->qtyVal()); _qtyToVoucher->setValidator(omfgThis->qtyVal()); _vodist->addColumn(tr("Cost Element"), -1, Qt::AlignLeft, true, "costelem_type"); _vodist->addColumn(tr("Amount"), _priceColumn, Qt::AlignRight,true, "vodist_amount"); _uninvoiced->addColumn(tr("Receipt/Reject"), -1, Qt::AlignCenter, true, "action"); _uninvoiced->addColumn(tr("Date"), _dateColumn, Qt::AlignCenter, true, "item_date"); _uninvoiced->addColumn(tr("Qty."), _qtyColumn, Qt::AlignRight, true, "qty"); _uninvoiced->addColumn(tr("Tagged"), _ynColumn, Qt::AlignCenter, true, "f_tagged"); _rejectedMsg = tr("The application has encountered an error and must " "stop editing this Voucher Item.\n%1"); _inTransaction = TRUE; q.exec("BEGIN;"); //Lot's of things can happen in here that can cause problems if cancelled out. Let's make it easy to roll it back. }
taxDetail::taxDetail(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); connect(_amountA, SIGNAL(valueChanged()), this, SLOT(sCalculateTotal())); connect(_amountB, SIGNAL(valueChanged()), this, SLOT(sCalculateTotal())); connect(_amountC, SIGNAL(valueChanged()), this, SLOT(sCalculateTotal())); connect(_calculate, SIGNAL(clicked()), this, SLOT(sCalculateTax())); connect(_cancel, SIGNAL(clicked()), this, SLOT(sCancel())); connect(_taxCode, SIGNAL(newID(int)), this, SLOT(sCalculateTax())); connect(_taxCode, SIGNAL(newID(int)), this, SLOT(sPopulate())); _blankDetailDescriptions = false; clear(); _taxCodeInitialized = false; sCalculateTotal(); }
void selectOrderForBilling::sFreightChanged() { if (_cobmiscid != -1 && _freightCache != _freight->localValue()) { XSqlQuery taxq; taxq.prepare("UPDATE cobmisc SET " " cobmisc_freight=:freight " "WHERE (cobmisc_id=:cobmisc_id) "); taxq.bindValue(":cobmisc_id", _cobmiscid); taxq.bindValue(":freight", _freight->localValue()); taxq.exec(); if (taxq.lastError().type() != QSqlError::NoError) { systemError(this, taxq.lastError().databaseText(), __FILE__, __LINE__); return; } _freightCache = _freight->localValue(); sCalculateTax(); } }
void purchaseOrder::sTaxZoneChanged() { if (_poheadid == -1 ) { XSqlQuery taxq; taxq.prepare("UPDATE pohead SET " " pohead_taxzone_id=:taxzone_id, " "WHERE (pohead_id=:pohead_id) "); if (_taxZone->id() != -1) taxq.bindValue(":taxzone_id", _taxZone->id()); taxq.bindValue(":pohead_id", _poheadid); taxq.bindValue(":freight", _freight->localValue()); taxq.exec(); if (taxq.lastError().type() != QSqlError::NoError) { systemError(this, taxq.lastError().databaseText(), __FILE__, __LINE__); return; } sCalculateTax(); } }
void creditMemoItem::sCalculateExtendedPrice() { _extendedPrice->setLocalValue(((_qtyToCredit->toDouble() * _qtyinvuomratio) / _priceinvuomratio) * _netUnitPrice->localValue()); sCalculateTax(); }
transferOrderItem::transferOrderItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); connect(_cancel, SIGNAL(clicked()), this, SLOT(sCancel())); connect(_freight, SIGNAL(valueChanged()), this, SLOT(sCalculateTax())); connect(_freight, SIGNAL(valueChanged()), this, SLOT(sChanged())); connect(_item, SIGNAL(newId(int)), this, SLOT(sChanged())); connect(_item, SIGNAL(newId(int)), this, SLOT(sPopulateItemInfo(int))); connect(_next, SIGNAL(clicked()), this, SLOT(sNext())); connect(_notes, SIGNAL(textChanged()), this, SLOT(sChanged())); connect(_prev, SIGNAL(clicked()), this, SLOT(sPrev())); connect(_promisedDate,SIGNAL(newDate(const QDate&)), this, SLOT(sChanged())); connect(_qtyOrdered, SIGNAL(lostFocus()), this, SLOT(sDetermineAvailability())); connect(_qtyOrdered, SIGNAL(textChanged(const QString&)), this, SLOT(sChanged())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_scheduledDate, SIGNAL(newDate(const QDate&)), this, SLOT(sChanged())); connect(_scheduledDate, SIGNAL(newDate(const QDate&)), this, SLOT(sDetermineAvailability())); connect(_showAvailability, SIGNAL(toggled(bool)), this, SLOT(sDetermineAvailability())); connect(_showAvailability, SIGNAL(toggled(bool)), this, SLOT(sDetermineAvailability())); connect(_showIndented,SIGNAL(toggled(bool)), this, SLOT(sDetermineAvailability())); connect(_taxLit, SIGNAL(leftClickedURL(QString)), this, SLOT(sTaxDetail())); connect(_warehouse, SIGNAL(newID(int)), this, SLOT(sChanged())); connect(_warehouse, SIGNAL(newID(int)), this, SLOT(sDetermineAvailability())); connect(_inventoryButton, SIGNAL(toggled(bool)), this, SLOT(sHandleButton())); _modified = false; _canceling = false; _error = false; _originalQtyOrd = 0.0; _saved = false; _availabilityLastItemid = -1; _availabilityLastWarehousid = -1; _availabilityLastSchedDate = QDate(); _availabilityLastShow = false; _availabilityLastShowIndent = false; _availabilityQtyOrdered = 0.0; _item->setType(ItemLineEdit::cActive | (ItemLineEdit::cAllItemTypes_Mask ^ ItemLineEdit::cKit)); _item->addExtraClause( QString("(itemsite_active)") ); // ItemLineEdit::cActive doesn't compare against the itemsite record _availability->addColumn(tr("#"), _seqColumn, Qt::AlignCenter,true, "bomitem_seqnumber"); _availability->addColumn(tr("Item Number"),_itemColumn, Qt::AlignLeft, true, "item_number"); _availability->addColumn(tr("Description"), -1, Qt::AlignLeft, true, "item_descrip"); _availability->addColumn(tr("UOM"), _uomColumn, Qt::AlignCenter,true, "uom_name"); _availability->addColumn(tr("Pend. Alloc."),_qtyColumn, Qt::AlignRight, true, "pendalloc"); _availability->addColumn(tr("Total Alloc."),_qtyColumn, Qt::AlignRight, true, "totalalloc"); _availability->addColumn(tr("On Order"), _qtyColumn, Qt::AlignRight, true, "ordered"); _availability->addColumn(tr("QOH"), _qtyColumn, Qt::AlignRight, true, "qoh"); _availability->addColumn(tr("Availability"),_qtyColumn, Qt::AlignRight, true, "totalavail"); _itemchar = new QStandardItemModel(0, 2, this); _itemchar->setHeaderData( 0, Qt::Horizontal, tr("Name"), Qt::DisplayRole); _itemchar->setHeaderData( 1, Qt::Horizontal, tr("Value"), Qt::DisplayRole); _itemcharView->setModel(_itemchar); ItemCharacteristicDelegate * delegate = new ItemCharacteristicDelegate(this); _itemcharView->setItemDelegate(delegate); _qtyOrdered->setValidator(omfgThis->qtyVal()); _shippedToDate->setPrecision(omfgThis->qtyVal()); _onHand->setPrecision(omfgThis->qtyVal()); _allocated->setPrecision(omfgThis->qtyVal()); _unallocated->setPrecision(omfgThis->qtyVal()); _onOrder->setPrecision(omfgThis->qtyVal()); _available->setPrecision(omfgThis->qtyVal()); if (!_metrics->boolean("UsePromiseDate")) { _promisedDateLit->hide(); _promisedDate->hide(); } _comments->setType(Comments::TransferOrderItem); _captive = FALSE; _dstwhsid = -1; _itemsiteid = -1; _transwhsid = -1; _toheadid = -1; _taxzoneid = -1; adjustSize(); _inventoryButton->setEnabled(_showAvailability->isChecked()); _dependencyButton->setEnabled(_showAvailability->isChecked()); _availability->setEnabled(_showAvailability->isChecked()); _showIndented->setEnabled(_showAvailability->isChecked()); }
void selectOrderForBilling::sFillList() { _soitem->clear(); if (_so->isValid()) { QString sql( "SELECT coitem_id, formatSoLineNumber(coitem_id) AS linenumber," " item_number, iteminvpricerat(item_id) AS invpricerat," " warehous_code, coitem_price," " uom_name, coitem_qtyord, coitem_qtyshipped," " coitem_qtyreturned," " formatQty( ( SELECT COALESCE(SUM(coship_qty), 0)" " FROM coship " " WHERE ( (coship_coitem_id=coitem_id)" " AND (NOT coship_invoiced) ) )" " ) AS qtyatship," " ( SELECT COALESCE(SUM(cobill_qty), 0)" " FROM cobill, cobmisc " " WHERE ( (cobill_cobmisc_id=cobmisc_id)" " AND (cobill_coitem_id=coitem_id)" " AND (NOT cobmisc_posted) ) ) AS qtytobill," " round(( " " ( SELECT COALESCE(SUM(cobill_qty), 0)" " FROM cobill, cobmisc " " WHERE ( (cobill_cobmisc_id=cobmisc_id)" " AND (cobill_coitem_id=coitem_id)" " AND (NOT cobmisc_posted) ) ) * coitem_qty_invuomratio " " * ( coitem_price / coitem_price_invuomratio)), 2) AS extended, " " COALESCE((SELECT cobill_toclose" " FROM cobill, cobmisc " " WHERE ((cobill_cobmisc_id=cobmisc_id)" " AND (cobill_coitem_id=coitem_id)" " AND (NOT cobmisc_posted))" " ORDER BY cobill_toclose DESC" " LIMIT 1),FALSE) AS toclose, " " 'qty' AS coitem_qtyord_xtnumericrole, " " 'qty' AS coitem_qtyshipped_xtnumericrole, " " 'qty' AS coitem_qtyreturned_xtnumericrole, " " 'qty' AS qtyatship_xtnumericrole, " " 'qty' AS qtytobill_xtnumericrole, " " 'extprice' AS extended_xtnumericrole " "FROM coitem, itemsite, item, site(), uom " "WHERE ( (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)" " <? if exists(\"showOpenOnly\") ?>" " AND (coitem_status <> 'C')" " <? endif ?>" " AND (coitem_cohead_id=<? value(\"sohead_id\") ?>) ) " "ORDER BY coitem_linenumber, coitem_subnumber;" ); ParameterList params; if (!_showClosed->isChecked()) params.append("showOpenOnly"); params.append("sohead_id", _so->id()); MetaSQLQuery mql(sql); q = mql.toQuery(params); _soitem->populate(q); if (q.first()) { double subtotal = 0.0; do subtotal += q.value("extended").toDouble(); while (q.next()); _subtotal->setLocalValue(subtotal); } else { if (q.lastError().type() != QSqlError::NoError) systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); _subtotal->clear(); } sCalculateTax(); } }
purchaseOrderItem::purchaseOrderItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { XSqlQuery purchasepurchaseOrderItem; setupUi(this); #ifndef Q_WS_MAC _vendorItemNumberList->setMaximumWidth(25); #else _listPrices->setMinimumWidth(60); #endif _vendid = -1; _preferredWarehouseid = -1; _invVendUOMRatio = 1; _minimumOrder = 0; _orderMultiple = 0; _maxCost = 0.0; _dropship = false; _costmethod = ""; _captive = false; connect(_ordered, SIGNAL(editingFinished()), this, SLOT(sDeterminePrice())); connect(_inventoryItem, SIGNAL(toggled(bool)), this, SLOT(sInventoryItemToggled(bool))); connect(_item, SIGNAL(privateIdChanged(int)), this, SLOT(sFindWarehouseItemsites(int))); connect(_item, SIGNAL(newId(int)), this, SLOT(sPopulateItemInfo(int))); connect(_warehouse, SIGNAL(newID(int)), this, SLOT(sPopulateItemsiteInfo())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_vendorItemNumberList, SIGNAL(clicked()), this, SLOT(sVendorItemNumberSearch())); connect(_notesButton, SIGNAL(toggled(bool)), this, SLOT(sHandleButtons())); connect(_listPrices, SIGNAL(clicked()), this, SLOT(sVendorListPrices())); connect(_taxLit, SIGNAL(leftClickedURL(QString)), this, SLOT(sTaxDetail())); // new slot added for tax url // connect(_extendedPrice, SIGNAL(valueChanged()), this, SLOT(sCalculateTax())); // new slot added for price // connect(_taxtype, SIGNAL(newID(int)), this, SLOT(sCalculateTax())); // new slot added for taxtype // _bomRevision->setMode(RevisionLineEdit::Use); _bomRevision->setType("BOM"); _booRevision->setMode(RevisionLineEdit::Use); _booRevision->setType("BOO"); _parentwo = -1; _parentso = -1; _itemsrcid = -1; _taxzoneid = -1; // _taxzoneid added // _orderQtyCache = -1; _overriddenUnitPrice = false; _ordered->setValidator(omfgThis->qtyVal()); _project->setType(ProjectLineEdit::PurchaseOrder); if(!_metrics->boolean("UseProjects")) _project->hide(); _itemchar = new QStandardItemModel(0, 2, this); _itemchar->setHeaderData( 0, Qt::Horizontal, tr("Name"), Qt::DisplayRole); _itemchar->setHeaderData( 1, Qt::Horizontal, tr("Value"), Qt::DisplayRole); _itemcharView->setModel(_itemchar); ItemCharacteristicDelegate * delegate = new ItemCharacteristicDelegate(this); _itemcharView->setItemDelegate(delegate); _minOrderQty->setValidator(omfgThis->qtyVal()); _orderQtyMult->setValidator(omfgThis->qtyVal()); _received->setValidator(omfgThis->qtyVal()); _invVendorUOMRatio->setValidator(omfgThis->ratioVal()); purchasepurchaseOrderItem.exec("SELECT DISTINCT itemsrc_manuf_name FROM itemsrc ORDER BY 1;"); for (int i = 0; purchasepurchaseOrderItem.next(); i++) _manufName->append(i, purchasepurchaseOrderItem.value("itemsrc_manuf_name").toString()); _manufName->setId(-1); //If not multi-warehouse hide whs control if (!_metrics->boolean("MultiWhs")) { _warehouseLit->hide(); _warehouse->hide(); } //If not Revision Control, hide controls if (!_metrics->boolean("RevControl")) _tab->removeTab(_tab->indexOf(_revision)); adjustSize(); //TO DO: Implement later _taxRecoverable->hide(); }
enum SetResponse purchaseOrderItem::set(const ParameterList &pParams) { XSqlQuery purchaseet; XDialog::set(pParams); QVariant param; bool valid; bool haveQty = FALSE; bool haveDate = FALSE; param = pParams.value("vend_id", &valid); if (valid) _vendid = param.toInt(); param = pParams.value("warehous_id", &valid); if (valid) _preferredWarehouseid = param.toInt(); param = pParams.value("dropship", &valid); if (valid) _dropship = param.toBool(); param = pParams.value("parentWo", &valid); if (valid) _parentwo = param.toInt(); param = pParams.value("parentSo", &valid); if (valid) _parentso = param.toInt(); if (_metrics->boolean("CopyPRtoPOItem")) { param = pParams.value("pr_releasenote", &valid); if(valid) _notes->setText(param.toString()); } param = pParams.value("pohead_id", &valid); if (valid) { _poheadid = param.toInt(); purchaseet.prepare( "SELECT pohead_taxzone_id, pohead_number, pohead_orderdate, pohead_status, " // pohead_taxzone_id added " vend_id, vend_restrictpurch, pohead_curr_id " "FROM pohead, vendinfo " "WHERE ( (pohead_vend_id=vend_id)" " AND (pohead_id=:pohead_id) );" ); purchaseet.bindValue(":pohead_id", param.toInt()); purchaseet.exec(); if (purchaseet.first()) { _poNumber->setText(purchaseet.value("pohead_number").toString()); _poStatus = purchaseet.value("pohead_status").toString(); _unitPrice->setEffective(purchaseet.value("pohead_orderdate").toDate()); _unitPrice->setId(purchaseet.value("pohead_curr_id").toInt()); _taxzoneid=purchaseet.value("pohead_taxzone_id").toInt(); // added to pick up tax zone id. _tax->setEffective(purchaseet.value("pohead_orderdate").toDate()); _tax->setId(purchaseet.value("pohead_curr_id").toInt()); if (purchaseet.value("vend_restrictpurch").toBool()) { _item->setQuery( QString( "SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2," " (item_descrip1 || ' ' || item_descrip2) AS itemdescrip," " uom_name, item_type, item_config, item_active, item_upccode " "FROM item, itemsite, itemsrc, uom " "WHERE ( (itemsite_item_id=item_id)" " AND (itemsrc_item_id=item_id)" " AND (item_inv_uom_id=uom_id)" " AND (itemsite_active)" " AND (item_active)" " AND (itemsrc_active)" " AND (itemsrc_vend_id=%1) ) " "ORDER BY item_number" ) .arg(purchaseet.value("vend_id").toInt()) ); _item->setValidationQuery( QString( "SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2," " (item_descrip1 || ' ' || item_descrip2) AS itemdescrip," " uom_name, item_type, item_config, item_active, item_upccode " "FROM item, itemsite, itemsrc, uom " "WHERE ( (itemsite_item_id=item_id)" " AND (itemsrc_item_id=item_id)" " AND (item_inv_uom_id=uom_id)" " AND (itemsite_active)" " AND (item_active)" " AND (itemsrc_active)" " AND (itemsrc_vend_id=%1) " " AND (itemsite_item_id=:item_id) ) ") .arg(purchaseet.value("vend_id").toInt()) ); } else { _item->setType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cGeneralManufactured | ItemLineEdit::cTooling | ItemLineEdit::cActive); _item->setDefaultType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cActive); } } else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } } param = pParams.value("poitem_id", &valid); if (valid) { _poitemid = param.toInt(); purchaseet.prepare( "SELECT pohead_number, pohead_id " "FROM pohead, poitem " "WHERE ( (pohead_id=poitem_pohead_id) " " AND (poitem_id=:poitem_id) );" ); purchaseet.bindValue(":poitem_id", param.toInt()); purchaseet.exec(); if (purchaseet.first()) { _poNumber->setText(purchaseet.value("pohead_number").toString()); _poheadid = purchaseet.value("pohead_id").toInt(); } populate(); sCalculateTax(); } // connect here and not in the .ui to avoid timing issues at initialization connect(_unitPrice, SIGNAL(valueChanged()), this, SLOT(sPopulateExtPrice())); param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; _save->setEnabled(false); purchaseet.exec("SELECT NEXTVAL('poitem_poitem_id_seq') AS poitem_id;"); if (purchaseet.first()) _poitemid = purchaseet.value("poitem_id").toInt(); else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } if(_parentwo != -1) { purchaseet.prepare("SELECT wo_number" " FROM womatl JOIN wo ON (wo_id=womatl_wo_id)" " WHERE (womatl_id=:parentwo); "); purchaseet.bindValue(":parentwo", _parentwo); purchaseet.exec(); if(purchaseet.first()) { _so->setText(purchaseet.value("wo_number").toString()); _soLine->setText(""); } } if(_parentso != -1) { purchaseet.prepare( "INSERT INTO charass" " (charass_target_type, charass_target_id," " charass_char_id, charass_value) " "SELECT 'PI', :orderid, charass_char_id, charass_value" " FROM charass" " WHERE ((charass_target_type='SI')" " AND (charass_target_id=:soitem_id));"); purchaseet.bindValue(":orderid", _poitemid); purchaseet.bindValue(":soitem_id", _parentso); purchaseet.exec(); } purchaseet.prepare( "SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) AS _linenumber " "FROM poitem " "WHERE (poitem_pohead_id=:pohead_id);" ); purchaseet.bindValue(":pohead_id", _poheadid); purchaseet.exec(); if (purchaseet.first()) _lineNumber->setText(purchaseet.value("_linenumber").toString()); else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } _bomRevision->setEnabled(_privileges->boolean("UseInactiveRevisions")); _booRevision->setEnabled(_privileges->boolean("UseInactiveRevisions")); _comments->setId(_poitemid); _tab->setTabEnabled(_tab->indexOf(_demandTab), FALSE); } else if (param.toString() == "edit") { _mode = cEdit; _typeGroup->setEnabled(FALSE); } else if (param.toString() == "view") { _mode = cView; _typeGroup->setEnabled(FALSE); _vendorItemNumber->setEnabled(FALSE); _vendorItemNumberList->setEnabled(FALSE); _vendorDescrip->setEnabled(FALSE); _warehouse->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _ordered->setEnabled(FALSE); _unitPrice->setEnabled(FALSE); _freight->setEnabled(FALSE); _notes->setReadOnly(TRUE); _comments->setReadOnly(TRUE); _project->setEnabled(FALSE); _taxtype->setEnabled(FALSE); _taxRecoverable->setEnabled(FALSE); _bomRevision->setEnabled(FALSE); _booRevision->setEnabled(FALSE); _close->setText(tr("&Close")); _save->hide(); } } param = pParams.value("itemsite_id", &valid); if (valid) { _item->setItemsiteid(param.toInt()); _item->setEnabled(FALSE); _warehouse->setEnabled(FALSE); } param = pParams.value("itemsrc_id", &valid); if (valid) sPopulateItemSourceInfo(param.toInt()); param = pParams.value("qty", &valid); if (valid) { _ordered->setDouble((param.toDouble()/_invVendUOMRatio)); if (_item->isValid()) sDeterminePrice(); haveQty = TRUE; } param = pParams.value("dueDate", &valid); if (valid) { _dueDate->setDate(param.toDate()); haveDate = TRUE; } param = pParams.value("prj_id", &valid); if (valid) _project->setId(param.toInt()); if(_parentso != -1) { purchaseet.prepare("SELECT cohead_number, coitem_linenumber, coitem_prcost" " FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)" " WHERE (coitem_id=:parentso); "); purchaseet.bindValue(":parentso", _parentso); purchaseet.exec(); if(purchaseet.first()) { _so->setText(purchaseet.value("cohead_number").toString()); _soLine->setText(purchaseet.value("coitem_linenumber").toString()); if(purchaseet.value("coitem_prcost").toDouble() > 0) { _overriddenUnitPrice = true; _unitPrice->setLocalValue(purchaseet.value("coitem_prcost").toDouble()); sPopulateExtPrice(); } } } param = pParams.value("captive", &valid); if (valid) _captive = true; return NoError; }