void voucher::sPopulateDistributed() { if (_poNumber->isValid()) { q.prepare( "SELECT (COALESCE(dist,0) + COALESCE(freight,0)) AS distrib" " FROM (SELECT SUM(COALESCE(voitem_freight,0)) AS freight" " FROM voitem" " WHERE (voitem_vohead_id=:vohead_id)) AS data1, " " (SELECT SUM(COALESCE(vodist_amount, 0)) AS dist" " FROM vodist" " WHERE (vodist_vohead_id=:vohead_id)) AS data2;" ); q.bindValue(":vohead_id", _voheadid); q.exec(); if (q.first()) { _amountDistributed->setLocalValue(q.value("distrib").toDouble()); sPopulateBalanceDue(); } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } }
miscVoucher::miscVoucher(QWidget* parent, const char* name, Qt::WFlags fl) : XMainWindow(parent, name, fl) { setupUi(this); connect(_amountDistributed, SIGNAL(valueChanged()), this, SLOT(sPopulateBalanceDue())); connect(_amountToDistribute, SIGNAL(valueChanged()), this, SLOT(sPopulateBalanceDue())); connect(_amountToDistribute, SIGNAL(effectiveChanged(const QDate&)), this, SLOT(sFillMiscList())); connect(_amountToDistribute, SIGNAL(idChanged(int)), this, SLOT(sFillMiscList())); connect(_amountToDistribute, SIGNAL(valueChanged()), this, SLOT(sPopulateBalanceDue())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDeleteMiscDistribution())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEditMiscDistribution())); connect(_invoiceDate, SIGNAL(newDate(const QDate&)), this, SLOT(sPopulateDistDate())); connect(_invoiceDate, SIGNAL(newDate(const QDate&)), this, SLOT(sPopulateDueDate())); connect(_new, SIGNAL(clicked()), this, SLOT(sNewMiscDistribution())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_voucherNumber, SIGNAL(lostFocus()), this, SLOT(sHandleVoucherNumber())); _terms->setType(XComboBox::APTerms); _miscDistrib->addColumn(tr("Account"), -1, Qt::AlignLeft ); _miscDistrib->addColumn(tr("Amount"), _moneyColumn, Qt::AlignRight ); }
void voucher::sPopulateDistributed() { if (_poNumber->isValid()) { q.prepare( "SELECT (COALESCE(dist,0) + COALESCE(freight,0)) AS distrib" " FROM (SELECT SUM(COALESCE(voitem_freight,0)) AS freight" " FROM voitem" " WHERE (voitem_vohead_id=:vohead_id)) AS data1, " " (SELECT SUM(COALESCE(vodist_amount, 0)) AS dist" " FROM vodist" " WHERE (vodist_vohead_id=:vohead_id)) AS data2;" ); q.bindValue(":vohead_id", _voheadid); q.exec(); if (q.first()) { _amountDistributed->setLocalValue(q.value("distrib").toDouble()); sPopulateBalanceDue(); } } }
/* * Constructs a voucher as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * */ voucher::voucher(QWidget* parent, const char* name, Qt::WFlags fl) : XMainWindow(parent, name, fl) { setupUi(this); (void)statusBar(); // signals and slots connections connect(_poList, SIGNAL(clicked()), this, SLOT(sPoList())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_distributions, SIGNAL(clicked()), this, SLOT(sDistributions())); connect(_distributeline, SIGNAL(clicked()), this, SLOT(sDistributeLine())); connect(_clear, SIGNAL(clicked()), this, SLOT(sClear())); connect(_distributeall, SIGNAL(clicked()), this, SLOT(sDistributeAll())); connect(_voucherNumber, SIGNAL(lostFocus()), this, SLOT(sHandleVoucherNumber())); connect(_poNumber, SIGNAL(vendAddress1Changed(const QString&)), _vendAddress1, SLOT(setText(const QString&))); connect(_poNumber, SIGNAL(newId(int)), this, SLOT(sFillList())); connect(_poitem, SIGNAL(itemSelected(int)), _distributions, SLOT(animateClick())); connect(_poitem, SIGNAL(valid(bool)), _distributions, SLOT(setEnabled(bool))); connect(_amountToDistribute, SIGNAL(valueChanged()), this, SLOT(sPopulateBalanceDue())); connect(_miscDistrib, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool))); connect(_new, SIGNAL(clicked()), this, SLOT(sNewMiscDistribution())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEditMiscDistribution())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDeleteMiscDistribution())); connect(_miscDistrib, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); connect(_miscDistrib, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool))); connect(_invoiceDate, SIGNAL(newDate(const QDate&)), this, SLOT(sPopulateDistDate())); connect(_poNumber, SIGNAL(vendAddress2Changed(const QString&)), _vendAddress2, SLOT(setText(const QString&))); connect(_invoiceDate, SIGNAL(newDate(const QDate&)), this, SLOT(sPopulateDueDate())); connect(_poNumber, SIGNAL(newId(int)), this, SLOT(sPopulatePoInfo())); connect(_poNumber, SIGNAL(vendNameChanged(const QString&)), _vendName, SLOT(setText(const QString&))); connect(_poitem, SIGNAL(populateMenu(QMenu*,QTreeWidgetItem*,int)), this, SLOT(sPopulateMenu(QMenu*))); connect(_amountToDistribute, SIGNAL(idChanged(int)), _amountDistributed, SLOT(setId(int))); connect(_amountToDistribute, SIGNAL(idChanged(int)), _balance, SLOT(setId(int))); connect(_amountToDistribute, SIGNAL(idChanged(int)), this, SLOT(sFillList())); connect(_distributionDate, SIGNAL(newDate(const QDate&)), _amountToDistribute, SLOT(setEffective(const QDate&))); connect(_amountToDistribute, SIGNAL(effectiveChanged(const QDate&)), _amountDistributed, SLOT(setEffective(const QDate&))); connect(_amountToDistribute, SIGNAL(effectiveChanged(const QDate&)), _balance, SLOT(setEffective(const QDate&))); connect(_amountDistributed, SIGNAL(valueChanged()), this, SLOT(sPopulateBalanceDue())); statusBar()->hide(); #ifndef Q_WS_MAC _poList->setMaximumWidth(25); #endif _terms->setType(XComboBox::APTerms); _poNumber->setType(cPOOpen); _poitem->addColumn(tr("#"), _whsColumn, Qt::AlignCenter ); _poitem->addColumn(tr("Status"), _uomColumn, Qt::AlignCenter ); _poitem->addColumn(tr("Item Number"), _itemColumn, Qt::AlignLeft ); _poitem->addColumn(tr("UOM"), _uomColumn, Qt::AlignCenter ); _poitem->addColumn(tr("Vend. Item #"), -1, Qt::AlignLeft ); _poitem->addColumn(tr("UOM"), _uomColumn, Qt::AlignCenter ); _poitem->addColumn(tr("Ordered"), _qtyColumn, Qt::AlignRight ); _poitem->addColumn(tr("Invoiced"), _qtyColumn, Qt::AlignRight, false ); _poitem->addColumn(tr("Uninvoiced"), _qtyColumn, Qt::AlignRight ); _poitem->addColumn(tr("Rejected"), _qtyColumn, Qt::AlignRight ); _poitem->addColumn(tr("Amount"), _moneyColumn, Qt::AlignRight ); _poitem->addColumn(tr("PO Unit Price"), _moneyColumn, Qt::AlignRight ); _poitem->addColumn(tr("PO Ext Price"), _moneyColumn, Qt::AlignRight ); _poitem->addColumn(tr("PO Line Freight"), _moneyColumn, Qt::AlignRight ); _miscDistrib->addColumn(tr("Account"), -1, Qt::AlignLeft ); _miscDistrib->addColumn(tr("Amount"), _moneyColumn, Qt::AlignRight ); }