void reprintInvoices::sPrint() { 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; } QList<QTreeWidgetItem*> selected = _invoice->selectedItems(); for (int i = 0; i < selected.size(); i++) { XTreeWidgetItem *cursor = (XTreeWidgetItem*)selected[i]; for (int j = 0; j < _watermarks->topLevelItemCount(); j++) { q.prepare("SELECT findCustomerForm(:cust_id, 'I') AS _reportname;"); q.bindValue(":cust_id", cursor->altId()); q.exec(); if (q.first()) { ParameterList params; params.append("invchead_id", cursor->id()); params.append("showcosts", ((_watermarks->topLevelItem(j)->text(2) == tr("Yes")) ? "TRUE" : "FALSE") ); params.append("watermark", _watermarks->topLevelItem(j)->text(1)); orReport report(q.value("_reportname").toString(), params); if (report.isValid()) { if (report.print(&printer, setupPrinter)) setupPrinter = FALSE; else { report.reportError(this); orReport::endMultiPrint(&printer); return; } } else QMessageBox::critical( this, tr("Cannot Find Invoice Form"), tr( "The Invoice Form '%1' cannot be found.\n" "One or more of the selected Invoices cannot be printed until a Customer Form Assignment\n" "is updated to remove any references to this Invoice Form or this Invoice Form is created." ) .arg(q.value("_reportname").toString()) ); } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } if (_metrics->boolean("EnableBatchManager")) { // TODO: Check for EDI and handle submission to Batch here q.prepare("SELECT CASE WHEN (COALESCE(shipto_ediprofile_id, -2) = -2)" " THEN COALESCE(cust_ediprofile_id,-1)" " ELSE COALESCE(shipto_ediprofile_id,-2)" " END AS result," " COALESCE(cust_emaildelivery, false) AS custom" " FROM cust, invchead" " LEFT OUTER JOIN shipto" " ON (invchead_shipto_id=shipto_id)" " WHERE ((invchead_cust_id=cust_id)" " AND (invchead_id=:invchead_id)); "); q.bindValue(":invchead_id", cursor->id()); q.exec(); if(q.first()) { if(q.value("result").toInt() == -1) { if(q.value("custom").toBool()) { ParameterList params; params.append("invchead_id", cursor->id()); deliverInvoice newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } } else { ParameterList params; params.append("action_name", "TransmitInvoice"); params.append("invchead_id", cursor->id()); submitAction newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } } } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } orReport::endMultiPrint(&printer); _invoice->clearSelection(); _close->setText(tr("&Close")); _print->setEnabled(FALSE); }
void dspARApplications::sFillList() { if ( (_selectedCustomer->isChecked()) && (!_cust->isValid()) ) { QMessageBox::warning( this, tr("Select Customer"), tr("You must select a Customer whose A/R Applications you wish to view.") ); _cust->setFocus(); return; } if (!_dates->startDate().isValid()) { QMessageBox::critical( this, tr("Enter Start Date"), tr("You must enter a valid Start Date.") ); _dates->setFocus(); return; } if (!_dates->endDate().isValid()) { QMessageBox::critical( this, tr("Enter End Date"), tr("You must enter a valid End Date.") ); _dates->setFocus(); return; } if ( (!_cashReceipts->isChecked()) && (!_creditMemos->isChecked()) ) { QMessageBox::critical( this, tr("Select Document Type"), tr("You must indicate which Document Type(s) you wish to view.") ); _cashReceipts->setFocus(); return; } QString sql( "SELECT arapply_id, cust_number, cust_name," " formatDate(arapply_postdate) AS f_postdate," " arapply_source_doctype, arapply_fundstype, " " CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)" " ELSE arapply_refnumber" " END AS source," " arapply_target_doctype," " TEXT(arapply_target_docnumber) AS target," " formatMoney(arapply_applied) AS f_applied, arapply_applied " "FROM arapply, custinfo " "WHERE ( (arapply_cust_id=cust_id)" " AND (arapply_postdate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>)" " AND (arapply_source_doctype IN (" "<? if exists(\"creditMemos\") ?>" " <? if exists(\"cashReceipts\") ?>" " 'K', 'C', 'R' " " <? else ?>" " 'C', 'R' " " <? endif ?>" "<? else ?>" " 'K' " "<? endif ?>" "))" "<? if exists(\"cust_id\") ?>" " AND (cust_id=<? value(\"cust_id\") ?>)" "<? elseif exists(\"custtype_id\") ?>" " AND (cust_custtype_id=<? value(\"custtype_id\") ?>)" "<? elseif exists(\"custtype_pattern\") ?>" " AND (cust_custtype_id IN (SELECT custtype_id FROM custtype" " WHERE (custtype_code ~ <? value(\"custtype_id\") ?>)))" "<? endif ?>" ") " "ORDER BY arapply_postdate, source;" ); ParameterList params; if (_cashReceipts->isChecked()) params.append("cashReceipts"); if (_creditMemos->isChecked()) params.append("creditMemos"); params.append("startDate", _dates->startDate()); params.append("endDate", _dates->endDate()); if (_selectedCustomer->isChecked()) params.append("cust_id", _cust->id()); else if (_selectedCustomerType->isChecked()) params.append("custtype_id", _customerTypes->id()); else if (_customerTypePattern->isChecked()) params.append("custtype_pattern", _customerType->text()); MetaSQLQuery mql(sql); q = mql.toQuery(params); if (q.first()) { _arapply->clear(); double total = 0; XTreeWidgetItem* last = 0; do { QString fundstype = q.value("arapply_fundstype").toString(); QString doctype; if (q.value("arapply_source_doctype") == "C") doctype = tr("Credit Memo"); else if (q.value("arapply_source_doctype") == "R") doctype = tr("Cash Deposit"); else if (fundstype == "A") doctype = tr("AmEx"); else if (fundstype == "C") doctype = tr("Check"); else if (fundstype == "D") doctype = tr("Discover"); else if (fundstype == "K") doctype = tr("Cash"); else if (fundstype == "M") doctype = tr("M/C"); else if (fundstype == "R") doctype = tr("Other C/C"); else if (fundstype == "T") doctype = tr("Cert. Check"); else if (fundstype == "V") doctype = tr("Visa"); else if (fundstype == "W") doctype = tr("Wire Trans."); else if (fundstype == "O") doctype = tr("Other"); QString targetdoctype = q.value("arapply_target_doctype").toString(); if (targetdoctype == "D") targetdoctype = tr("Debit Memo"); else if (targetdoctype == "I") targetdoctype = tr("Invoice"); else if (targetdoctype == "K") targetdoctype = tr("A/P Check"); else targetdoctype = tr("Other"); last = new XTreeWidgetItem( _arapply, last, q.value("arapply_id").toInt(), q.value("cust_number"), q.value("cust_name"), q.value("f_postdate"), (q.value("arapply_source_doctype") == "C") ? "C/M" : ((q.value("arapply_source_doctype") == "R") ? "Cash Deposit" : fundstype), doctype, q.value("source"), q.value("arapply_target_doctype").toString(), targetdoctype, q.value("target"), q.value("f_applied") ); total += q.value("arapply_applied").toDouble(); } while (q.next()); last = new XTreeWidgetItem(_arapply, last, -1, "", tr("Total Applications:")); last->setText(9, formatMoney(total)); } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
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::None) { 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(), 0)); q.bindValue(":voitem_qty", _qtyToVoucher->toDouble()); q.bindValue(":voitem_freight", _freightToVoucher->localValue()); q.exec(); if (q.lastError().type() != QSqlError::None) { 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::None) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); reject(); return; } }
void dspCostedIndentedBOM::sFillList() { if (! _item->isValid()) return; MetaSQLQuery mql( "SELECT bomdata_bomwork_id AS id," " CASE WHEN bomdata_bomwork_parent_id = -1 AND " " bomdata_bomwork_id = -1 THEN" " -1" " ELSE bomdata_item_id" " END AS altid," " *," "<? if exists(\"useStandardCosts\") ?>" " bomdata_stdunitcost AS unitcost," " bomdata_stdextendedcost AS extendedcost, " "<? elseif exists(\"useActualCosts\") ?>" " bomdata_actunitcost AS unitcost," " bomdata_actextendedcost AS extendedcost, " "<? endif ?>" " 'qtyper' AS bomdata_qtyper_xtnumericrole," " 'percent' AS bomdata_scrap_xtnumericrole," " 'cost' AS unitcost_xtnumericrole," " 'cost' AS extendedcost_xtnumericrole," " CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN <? value(\"always\") ?> END AS bomdata_effective_qtdisplayrole," " CASE WHEN COALESCE(bomdata_expires, endOfTime()) <= endOfTime() THEN <? value(\"never\") ?> END AS bomdata_expires_qtdisplayrole," " CASE WHEN bomdata_expired THEN 'expired'" " WHEN bomdata_future THEN 'future'" " END AS qtforegroundrole," " bomdata_bomwork_level - 1 AS xtindentrole " "FROM indentedbom(<? value(\"item_id\") ?>," " <? value(\"revision_id\") ?>,0,0)"); ParameterList params; if (! setParams(params)) return; q = mql.toQuery(params); _bomitem->populate(q, true); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } q.prepare( "SELECT formatCost(SUM(bomdata_actextendedcost)) AS actextendedcost," " formatCost(SUM(bomdata_stdextendedcost)) AS stdextendedcost," " formatCost(actcost(:item_id)) AS actual," " formatCost(stdcost(:item_id)) AS standard " "FROM indentedbom(:item_id," " :revision_id,0,0)" "WHERE (bomdata_bomwork_level=1) " "GROUP BY actual, standard;" ); q.bindValue(":item_id", _item->id()); q.bindValue(":revision_id",_revision->id()); q.exec(); if (q.first()) { XTreeWidgetItem *last = new XTreeWidgetItem(_bomitem, -1, -1); last->setText(0, tr("Total Cost")); if(_useStandardCosts->isChecked()) last->setText(9, q.value("stdextendedcost").toString()); else last->setText(9, q.value("actextendedcost").toString()); last = new XTreeWidgetItem( _bomitem, -1, -1); last->setText(0, tr("Actual Cost")); last->setText(9, q.value("actual").toString()); last = new XTreeWidgetItem( _bomitem, -1, -1); last->setText(0, tr("Standard Cost")); last->setText(9, q.value("standard").toString()); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } _bomitem->expandAll(); }
void dspInventoryAvailabilityByCustomerType::sFillList() { _avail->clear(); QString sql( "SELECT itemsite_id, coitem_id," " cohead_id, cohead_number, (cust_number||'-'||cust_name) AS custname," " item_number, item_description, uom_name, item_picklist," " qoh, formatQty(qoh) AS f_qoh,sobalance," " formatQty(sobalance) AS f_sobalance," " formatQty(allocated) AS f_allocated," " ordered, formatQty(ordered) AS f_ordered," " (qoh + ordered - sobalance) AS woavail," "<? if exists(\"useReservationNetting\") ?>" " formatQty(coitem_qtyreserved) AS f_soavail," "<? else ?>" " formatQty(qoh + ordered - sobalance) AS f_soavail," "<? endif ?>" " (qoh + ordered - allocated) AS totalavail," " formatQty(qoh + ordered - allocated) AS f_totalavail," " atshipping,formatQty(atshipping) AS f_atshipping," " formatDate(coitem_scheddate) AS f_scheddate," " (coitem_qtyreserved > 0 AND sobalance > coitem_qtyreserved) AS partialreservation," " ((sobalance <> 0) and ((sobalance - coitem_qtyreserved) = 0)) AS fullreservation," " onpacklist," " reorderlevel " "<? if exists(\"showWoSupply\") ?>, " " wo_id," " wo_status," " wo_number," " wo_ordered," " formatQty(wo_ordered) AS f_wo_ordered," " formatDate(wo_startdate) AS f_wo_startdate, " " formatDate(wo_duedate) AS f_wo_duedate," " COALESCE(wo_latestart,false) AS wo_latestart," " COALESCE(wo_latedue,false) AS wo_latedue " "<? endif ?>" "FROM ( SELECT itemsite_id, coitem_id," " cohead_id, cohead_number, cust_number, cust_name," " item_number, (item_descrip1 || ' ' || item_descrip2) AS item_description," " uom_name, item_picklist," " noNeg(itemsite_qtyonhand) AS qoh," " noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance," " qtyAllocated(itemsite_id, coitem_scheddate) AS allocated," " qtyOrdered(itemsite_id, coitem_scheddate) AS ordered," " qtyatshipping(coitem_id) AS atshipping," " coitem_qtyreserved," " coitem_scheddate," " (pack_id IS NOT NULL) AS onpacklist," " CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel " "<? if exists(\"showWoSupply\") ?>, " " COALESCE(wo_id,-1) AS wo_id," " formatwonumber(wo_id) AS wo_number," " noNeg((wo_qtyord-wo_qtyrcv)) AS wo_ordered," " wo_status, wo_startdate, wo_duedate," " ((wo_startdate <= CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) AS wo_latestart," " (wo_duedate<=CURRENT_DATE) AS wo_latedue " "<? endif ?>" " FROM cohead " " LEFT OUTER JOIN pack" " ON (pack_head_type='SO' AND pack_head_id=cohead_id)," " cust, itemsite, item, uom, coitem, site() " "<? if exists(\"showWoSupply\") ?> " " LEFT OUTER JOIN wo" " ON ((coitem_itemsite_id=wo_itemsite_id)" " AND (wo_status IN ('E','R','I'))" " AND (wo_qtyord-wo_qtyrcv > 0)" " AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) > " " (SELECT itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))" "<? endif ?>" " WHERE ( (coitem_cohead_id=cohead_id)" " AND (coitem_itemsite_id=itemsite_id)" " AND (itemsite_warehous_id=warehous_id)" " AND (itemsite_item_id=item_id)" " AND (item_inv_uom_id=uom_id)" " AND (coitem_status NOT IN ('C', 'X'))" " AND (cohead_cust_id=cust_id)" "<? if exists(\"custtype_id\") ?>" " AND (cust_custtype_id=<? value(\"custtype_id\") ?>)" "<? elseif exists(\"custtype_pattern\") ?>" " AND (cust_custtype_id IN (SELECT custtype_id " " FROM custtype " " WHERE(custtype_code ~ <? value(\"custtype_pattern\") ?>)))" "<? endif ?>" ")) AS data " " <? if exists(\"onlyShowShortages\") ?>" "WHERE ( ((qoh + ordered - allocated) < 0)" " OR ((qoh + ordered - sobalance) < 0) ) " "<? endif ?>" "ORDER BY cohead_id, cohead_number, item_number" "<? if exists(\"showWoSupply\") ?> ," "wo_duedate" "<? endif ?>" ";"); ParameterList params; _custtype->appendValue(params); if (_onlyShowShortages->isChecked()) params.append("onlyShowShortages"); if (_showWoSupply->isChecked()) params.append("showWoSupply"); if (_useReservationNetting->isChecked()) params.append("useReservationNetting"); MetaSQLQuery mql(sql); q = mql.toQuery(params); if (q.first()) { XTreeWidgetItem *coitem = NULL, *cohead = NULL; XTreeWidgetItem *wo = NULL; int coitemid = -1; int coheadid = -1; do { if (coitemid != q.value("coitem_id").toInt()) { if(coheadid != q.value("cohead_id").toInt()) { coheadid = q.value("cohead_id").toInt(); cohead = new XTreeWidgetItem(_avail, cohead, coheadid, -2, q.value("cohead_number"), q.value("custname")); if(q.value("onpacklist").toBool()) cohead->setTextColor("green"); } coitemid = q.value("coitem_id").toInt(); coitem = new XTreeWidgetItem( cohead, coitem, q.value("itemsite_id").toInt(), q.value("coitem_id").toInt(), q.value("item_number"), q.value("item_description"), q.value("uom_name"), q.value("f_qoh"), q.value("f_sobalance"), q.value("f_allocated"), q.value("f_ordered"), q.value("f_soavail"), q.value("f_totalavail"), q.value("f_atshipping"), q.value("f_scheddate") ); if (q.value("qoh").toDouble() < 0) coitem->setTextColor(3, "red"); else if (q.value("qoh").toDouble() < q.value("reorderlevel").toDouble()) coitem->setTextColor(3, "orange"); if (q.value("woavail").toDouble() < 0.0) coitem->setTextColor(7, "red"); else if (q.value("woavail").toDouble() <= q.value("reorderlevel").toDouble()) coitem->setTextColor(7, "orange"); if (q.value("totalavail").toDouble() < 0.0) coitem->setTextColor(8, "red"); else if (q.value("totalavail").toDouble() <= q.value("reorderlevel").toDouble()) coitem->setTextColor(8, "orange"); if(_useReservationNetting->isChecked()) { if(q.value("partialreservation").toBool()) { coitem->setTextColor(0, "blue"); coitem->setTextColor(1, "blue"); coitem->setTextColor(7, "blue"); } else if(q.value("fullreservation").toBool()) { coitem->setTextColor(0, "green"); coitem->setTextColor(1, "green"); coitem->setTextColor(7, "green"); } } } if ((coitem) && (_showWoSupply->isChecked()) && (q.value("wo_id").toInt() != -1) ) { wo = new XTreeWidgetItem( coitem, wo, q.value("itemsite_id").toInt(),-1, q.value("wo_number"),"", q.value("wo_status"), "", "", "", q.value("f_wo_ordered"), q.value("f_wo_startdate"), q.value("f_wo_duedate"), "" ); if (q.value("wo_latestart").toBool()) wo->setTextColor(7, "red"); if (q.value("wo_latedue").toBool()) wo->setTextColor(8, "red"); } } while (q.next()); } if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } _avail->expandAll(); }
void dspSalesHistoryByParameterList::sFillList() { if (!checkParameters()) return; _sohist->clear(); MetaSQLQuery mql = mqlLoad(":/so/displays/SalesHistory.mql"); ParameterList params; _dates->appendValue(params); _warehouse->appendValue(params); _parameter->appendValue(params); params.append("orderByInvcdateItem"); q = mql.toQuery(params); if (q.first()) { double totalUnits = 0.0; double totalSales = 0.0; double totalCosts = 0.0; bool exchangeError = false; XTreeWidgetItem *last = 0; do { if (q.value("baseunitprice").toDouble() < 0.0) exchangeError = true; QString invoicedate = tr("Return"); if (q.value("cohist_invcdate").toString() != "") invoicedate = formatDate(q.value("cohist_invcdate").toDate()); last = new XTreeWidgetItem( _sohist, last, q.value("cohist_id").toInt(), q.value("cohist_ordernumber"), q.value("invoicenumber"), formatDate(q.value("cohist_orderdate").toDate()), invoicedate, q.value("item_number"), q.value("itemdescription"), formatQty(q.value("cohist_qtyshipped").toDouble()), formatSalesPrice(q.value("baseunitprice").toDouble()), formatMoney(q.value("baseextprice").toDouble()), formatCost(q.value("cohist_unitcost").toDouble()), formatMoney(q.value("extcost").toDouble()) ); totalUnits += q.value("cohist_qtyshipped").toDouble(); totalSales += q.value("baseextprice").toDouble(); totalCosts += q.value("extcost").toDouble(); } while (q.next()); XTreeWidgetItem *totals = new XTreeWidgetItem(_sohist, last, -1, QVariant(tr("Totals"))); totals->setText(6, formatQty(totalUnits)); totals->setText(EXTPRICE_COL, formatMoney(totalSales)); totals->setText(EXTCOST_COL, formatCost(totalCosts)); if ( (exchangeError) && (_showPrices->isChecked()) ) QMessageBox::warning( this, tr("Currency Exchange Rate Error"), tr("One or more of the Prices could not be converted to Base Currency.\n" "These Prices have been set to a negative value.") ); } }
void dspInventoryLocator::sFillList() { if (_item->isValid()) { QString sql( "SELECT itemloc_id, 1 AS type, warehous_code," " CASE WHEN (location_id IS NULL) THEN :na" " ELSE (formatLocationName(location_id) || '-' || firstLine(location_descrip))" " END AS locationname," " CASE WHEN (location_id IS NULL) THEN :na" " WHEN (location_netable) THEN :yes" " ELSE :no" " END AS netable," " CASE WHEN (itemsite_controlmethod NOT IN ('L', 'S')) THEN :na" " ELSE formatlotserialnumber(itemloc_ls_id)" " END AS lotserial," " CASE WHEN (itemsite_perishable) THEN formatDate(itemloc_expiration)" " ELSE :na" " END AS f_expiration," " CASE WHEN (itemsite_warrpurc) THEN formatDate(itemloc_warrpurc)" " ELSE :na" " END AS f_warranty," " CASE WHEN (itemsite_perishable) THEN (itemloc_expiration <= CURRENT_DATE)" " ELSE FALSE" " END AS expired," " CASE WHEN (itemsite_warrpurc) THEN (itemloc_warrpurc <= CURRENT_DATE)" " ELSE FALSE" " END AS warrantyexp," " formatQty(itemloc_qty) AS f_qoh " "FROM itemsite, warehous," " itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id) " "WHERE ( ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) )" " AND (itemloc_itemsite_id=itemsite_id)" " AND (itemsite_warehous_id=warehous_id)" " AND (itemsite_item_id=:item_id)" ); if (_warehouse->isSelected()) sql += " AND (itemsite_warehous_id=:warehous_id)"; sql += ") " "UNION SELECT itemsite_id, 2 AS type, warehous_code," " :na AS locationname," " :na AS netable," " :na AS lotserial," " :na AS f_expiration," " :na AS f_warranty," " FALSE AS expired," " FALSE AS warrantyexp," " formatQty(itemsite_qtyonhand) AS f_qoh " "FROM itemsite, warehous " "WHERE ( (NOT itemsite_loccntrl)" " AND (itemsite_controlmethod NOT IN ('L', 'S'))" " AND (itemsite_warehous_id=warehous_id)" " AND (itemsite_item_id=:item_id)"; if (_warehouse->isSelected()) sql += " AND (itemsite_warehous_id=:warehous_id)"; sql += ") " "ORDER BY warehous_code, locationname, lotserial;"; q.prepare(sql); q.bindValue(":yes", tr("Yes")); q.bindValue(":no", tr("No")); q.bindValue(":na", tr("N/A")); q.bindValue(":undefined", tr("Undefined")); q.bindValue(":item_id", _item->id()); _warehouse->bindValue(q); q.exec(); _itemloc->clear(); XTreeWidgetItem *last = 0; while (q.next()) { last = new XTreeWidgetItem( _itemloc, last, q.value("itemloc_id").toInt(), q.value("type").toInt(), q.value("warehous_code"), q.value("locationname"), q.value("netable"), q.value("lotserial"), q.value("f_expiration"), q.value("f_warranty"),q.value("f_qoh") ); if (q.value("expired").toBool() || q.value("warrantyexp").toBool()) last->setTextColor("red"); } } else _itemloc->clear(); }
void dspGLTransactions::sViewDocument() { XTreeWidgetItem * item = (XTreeWidgetItem*)_gltrans->currentItem(); if(0 == item) return; ParameterList params; if(item->rawValue("gltrans_doctype").toString() == "VO") { q.prepare("SELECT vohead_id, vohead_misc" " FROM vohead" " WHERE (vohead_number=:vohead_number)"); q.bindValue(":vohead_number", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; params.append("vohead_id", q.value("vohead_id").toInt()); params.append("mode", "view"); if(q.value("vohead_misc").toBool()) { miscVoucher *newdlg = new miscVoucher(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } else { voucher *newdlg = new voucher(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } } else if(item->rawValue("gltrans_doctype").toString() == "IN") { q.prepare("SELECT invchead_id" " FROM invchead" " WHERE (invchead_invcnumber=:invchead_invcnumber)"); q.bindValue(":invchead_invcnumber", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; invoice::viewInvoice(q.value("invchead_id").toInt()); } else if(item->rawValue("gltrans_doctype").toString() == "PO") { q.prepare("SELECT pohead_id" " FROM pohead" " WHERE (pohead_number=:pohead_number)"); q.bindValue(":pohead_number", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; params.append("pohead_id", q.value("pohead_id").toInt()); params.append("mode", "view"); purchaseOrder *newdlg = new purchaseOrder(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } else if(item->rawValue("gltrans_doctype").toString() == "SH") { q.prepare("SELECT shiphead_id" " FROM shiphead" " WHERE (shiphead_number=:shiphead_number)"); q.bindValue(":shiphead_number", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; params.append("shiphead_id", q.value("shiphead_id").toInt()); dspShipmentsByShipment *newdlg = new dspShipmentsByShipment(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } else if( (item->rawValue("gltrans_doctype").toString() == "CM") || (item->rawValue("gltrans_doctype").toString() == "DM") ) { if(item->rawValue("gltrans_source").toString() == "A/P") { q.prepare("SELECT apopen_id" " FROM apopen" " WHERE (apopen_docnumber=:docnumber)"); q.bindValue(":docnumber", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; params.append("mode", "view"); params.append("apopen_id", q.value("apopen_id").toInt()); apOpenItem newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } else if(item->rawValue("gltrans_source").toString() == "A/R") { q.prepare("SELECT aropen_id" " FROM aropen" " WHERE (aropen_docnumber=:docnumber)"); q.bindValue(":docnumber", item->rawValue("docnumber").toString()); q.exec(); if(!q.first()) return; params.append("mode", "view"); params.append("aropen_id", q.value("aropen_id").toInt()); arOpenItem newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } } else if(item->rawValue("gltrans_doctype").toString() == "SO") { QStringList docnumber = item->rawValue("docnumber").toString().split("-"); q.prepare("SELECT cohead_id" " FROM cohead" " WHERE (cohead_number=:docnumber)"); q.bindValue(":docnumber", docnumber[0]); q.exec(); if(q.first()) salesOrder::viewSalesOrder(q.value("cohead_id").toInt()); } else if(item->rawValue("gltrans_doctype").toString() == "WO") { QStringList docnumber = item->rawValue("docnumber").toString().split("-"); params.append("wo_number", docnumber[0]); dspWoHistoryByNumber *newdlg = new dspWoHistoryByNumber(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } else if(item->rawValue("gltrans_source").toString() == "I/M") { q.prepare("SELECT gltrans_misc_id" " FROM gltrans" " WHERE (gltrans_id=:gltrans_id)"); q.bindValue(":gltrans_id", item->id()); q.exec(); if(!q.first()) return; params.append("mode", "view"); params.append("invhist_id", q.value("gltrans_misc_id").toInt()); transactionInformation newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } }