예제 #1
0
void reconcileBankaccount::sChecksToggleCleared()
{
  XTreeWidgetItem *item = (XTreeWidgetItem*)_checks->currentItem();

  if(0 == item)
    return;

  _checks->scrollToItem(item);

  q.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid) AS cleared");
  q.bindValue(":bankrecid", _bankrecid);
  q.bindValue(":sourceid", item->id());
  if(item->altId()==1)
    q.bindValue(":source", "GL");
  else if(item->altId()==2)
    q.bindValue(":source", "AD");
  q.exec();
  if(q.first())
    item->setText(0, (q.value("cleared").toBool() ? tr("Yes") : tr("No") ));
  else
  {
    populate();
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
}
예제 #2
0
void dspBacklogByCustomer::sPopulateMenu(QMenu *pMenu)
{
  bool hasParents     = FALSE;
  bool hasChildren    = FALSE;
  QList<XTreeWidgetItem*> selected = _soitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    XTreeWidgetItem *cursor = (XTreeWidgetItem*)(selected[i]);
    if ( (cursor->altId() == -1) && (!hasParents) )
      hasParents = TRUE;

    if ( (cursor->altId() != -1) && (!hasChildren) )
      hasChildren = TRUE;
  }

  int menuItem;

  if (selected.size() == 1)
  {
    menuItem = pMenu->insertItem(tr("Edit Order..."), this, SLOT(sEditOrder()), 0);
    if (!_privileges->check("MaintainSalesOrders"))
      pMenu->setItemEnabled(menuItem, FALSE);

    menuItem = pMenu->insertItem(tr("View Order..."), this, SLOT(sViewOrder()), 0);
    if ((!_privileges->check("MaintainSalesOrders")) && (!_privileges->check("ViewSalesOrders")))
      pMenu->setItemEnabled(menuItem, FALSE);

    if (hasChildren)
    {
      pMenu->insertSeparator();

      menuItem = pMenu->insertItem(tr("Edit Item..."), this, SLOT(sEditItem()), 0);
      if (!_privileges->check("MaintainSalesOrders"))
        pMenu->setItemEnabled(menuItem, FALSE);

      menuItem = pMenu->insertItem(tr("View Item..."), this, SLOT(sViewItem()), 0);
      if ((!_privileges->check("MaintainSalesOrders")) && (!_privileges->check("ViewSalesOrders")))
        pMenu->setItemEnabled(menuItem, FALSE);
    }
  }

  if (hasParents)
  {
    pMenu->insertSeparator();

    menuItem = pMenu->insertItem(tr("Print Packing List..."), this, SLOT(sPrintPackingList()), 0);
    if (!_privileges->check("PrintPackingLists"))
      pMenu->setItemEnabled(menuItem, FALSE);

    menuItem = pMenu->insertItem(tr("Add to Packing List Batch..."), this, SLOT(sAddToPackingListBatch()), 0);
    if (!_privileges->check("MaintainPackingListBatch"))
      pMenu->setItemEnabled(menuItem, FALSE);
  }
}
예제 #3
0
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected)
{
  int menuItem;

  XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected;
  if (item->id() != -1)
  {
    menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0);
    if (!_privileges->check("EditSalesHistory"))
      pMenu->setItemEnabled(menuItem, FALSE);

    pMenu->insertItem(tr("View A/P Open..."), this, SLOT(sView()), 0);

    menuItem = pMenu->insertItem(tr("View G/L Series..."), this, SLOT(sViewGLSeries()), 0);
    if (!_privileges->check("ViewGLTransactions"))
      pMenu->setItemEnabled(menuItem, FALSE);

    if(item->altId() == -1 && item->text(1)==tr("Voucher"))
    {
      menuItem = pMenu->insertItem(tr("View Voucher..."), this, SLOT(sViewVoucher()), 0);
      if (!_privileges->check("ViewVouchers"))
        pMenu->setItemEnabled(menuItem, FALSE);

      if(item->rawValue("amount")==item->rawValue("balance"))
      {
        pMenu->insertSeparator();
  
        menuItem = pMenu->insertItem(tr("Void"), this, SLOT(sVoidVoucher()), 0);
        if (!_privileges->check("MaintainAPMemos"))
          pMenu->setItemEnabled(menuItem, FALSE);
      }
    } 
  }
}
int XTreeWidgetItemProto::altId() const
{
  XTreeWidgetItem *item = qscriptvalue_cast<XTreeWidgetItem*>(thisObject());
  if (item)
    return item->altId();
  return -1;
}
예제 #5
0
void selectPayments::sClear()
{
  bool update = FALSE;
  QList<XTreeWidgetItem*> list = _apopen->selectedItems();
  XTreeWidgetItem * cursor = 0;
  q.prepare("SELECT clearPayment(:apopen_id) AS result;");
  for(int i = 0; i < list.size(); i++)
  {
    cursor = (XTreeWidgetItem*)list.at(i);
    q.bindValue(":apopen_id", cursor->altId());
    q.exec();
    if (q.first())
    {
      int result = q.value("result").toInt();
      if (result < 0)
      {
	systemError(this, cursor->text(0) + " " + cursor->text(2) + "\n" +
			  storedProcErrorLookup("clearPayment", result),
		    __FILE__, __LINE__);
	return;
      }
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    update = TRUE;
  }

  if(update)
    omfgThis->sPaymentsUpdated(-1, -1, TRUE);
}
예제 #6
0
void selectPayments::sClear()
{
  XSqlQuery selectClear;
  bool update = false;
  QList<XTreeWidgetItem*> list = _apopen->selectedItems();
  XTreeWidgetItem * cursor = 0;
  selectClear.prepare("SELECT clearPayment(:apopen_id) AS result;");
  for(int i = 0; i < list.size(); i++)
  {
    cursor = (XTreeWidgetItem*)list.at(i);
    selectClear.bindValue(":apopen_id", cursor->altId());
    selectClear.exec();
    if (selectClear.first())
    {
      int result = selectClear.value("result").toInt();
      if (result < 0)
      {
        ErrorReporter::error(QtCriticalMsg, this, cursor->text(0) + " " + cursor->text(2) + "\n" +
                               tr(" Error Clearing Payment Information"),
                               storedProcErrorLookup("clearPayment", result),
                               __FILE__, __LINE__);
        return;
      }
    }
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Clearing Payment Information"),
                                  selectClear, __FILE__, __LINE__))
    {
      return;
    }
    update = true;
  }

  if(update)
    omfgThis->sPaymentsUpdated(-1, -1, true);
}
예제 #7
0
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected, int)
{
  QAction *menuItem;

  XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected;
  if (item->id() != -1)
  {
    menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit()));
    menuItem->setEnabled(_privileges->check("EditAPOpenItem"));

    pMenu->addAction(tr("View A/P Open..."), this, SLOT(sView()));

    menuItem = pMenu->addAction(tr("View G/L Series..."), this, SLOT(sViewGLSeries()));
    menuItem->setEnabled(_privileges->check("ViewGLTransactions"));

    if(item->altId() == -1 && item->text(1)==tr("Voucher"))
    {
      menuItem = pMenu->addAction(tr("View Voucher..."), this, SLOT(sViewVoucher()));
      menuItem->setEnabled(_privileges->check("ViewVouchers") || _privileges->check("MaintainVouchers"));

      if(item->rawValue("amount")==item->rawValue("balance"))
      {
        pMenu->addSeparator();
  
        menuItem = pMenu->addAction(tr("Void"), this, SLOT(sVoidVoucher()));
        menuItem->setEnabled(_privileges->check("VoidPostedVouchers"));
      }
    } 
  }
}
예제 #8
0
void reprintCreditMemos::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 = _cmhead->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    XTreeWidgetItem *cursor = (XTreeWidgetItem*)selected[i];
    for (int j = 0; j < _watermarks->topLevelItemCount(); j++)
    {
      QTreeWidgetItem *watermark = _watermarks->topLevelItem(j);
      q.prepare("SELECT findCustomerForm(:cust_id, 'C') AS _reportname;");
      q.bindValue(":cust_id", cursor->altId());
      q.exec();
      if (q.first())
      {
	ParameterList params;
	params.append("cmhead_id", cursor->id());
	params.append("showcosts", ((watermark->text(2) == tr("Yes")) ? "TRUE" : "FALSE") );
	params.append("watermark", watermark->text(1));

	orReport report(q.value("_reportname").toString(), params);
	if (report.isValid())
	{
	  if (report.print(&printer, setupPrinter))
	      setupPrinter = FALSE;
	  else
	  {
	    orReport::endMultiPrint(&printer);
	    return;
	  }
	}
	else
	  QMessageBox::critical(this, tr("Cannot Find Credit Memo Form"),
				tr("<p>The Invoice Form '%1' cannot be found. "
                                   "One or more of the selected Credit Memos "
                                   "cannot be printed until a Customer Form "
                                   "Assignment is updated to remove any "
                                   "references to this Credit Memo Form or "
                                   "this Credit Memo Form is created." )
				 .arg(q.value("_reportname").toString()) );
      }
    }
  }
  orReport::endMultiPrint(&printer);

  _cmhead->clearSelection();
  _close->setText(tr("&Close"));
  _print->setEnabled(FALSE);
}
예제 #9
0
int itemSourceSearch::expcatId()
{
  XTreeWidgetItem * item = (XTreeWidgetItem*)_itemsrc->currentItem();
  if(item)
  {
    if(item->altId() == 2)
      return item->id();
  }
  return -1;
}
예제 #10
0
void fixSerial::sFixAll()
{
  QList<XTreeWidgetItem*> all = _serial->findItems("", Qt::MatchContains);
  for (int i = 0; i < all.size(); i++)
  {
    XTreeWidgetItem *currItem = static_cast<XTreeWidgetItem*>(all[i]);
    if (currItem->altId() > 0)
      fixOne(currItem);
  }
  sFillList();
}
예제 #11
0
void itemSite::sToggleRestricted()
{
  XTreeWidgetItem * locitem = static_cast<XTreeWidgetItem*>(_restricted->currentItem());
  if(0 == locitem)
    return;

  if(-1 != locitem->altId())
  {
    q.prepare("DELETE FROM locitem WHERE (locitem_id=:locitem_id); ");
    q.bindValue(":locitem_id", locitem->altId());
    q.exec();
  }
  else
  {
    q.prepare("INSERT INTO locitem(locitem_location_id, locitem_item_id) VALUES (:location_id, :item_id);");
    q.bindValue(":location_id", locitem->id());
    q.bindValue(":item_id", _item->id());
    q.exec();
  }

  sFillRestricted();
}
void reconcileBankaccount::sChecksToggleCleared()
{
  XSqlQuery reconcileChecksToggleCleared;
  XTreeWidgetItem *item = (XTreeWidgetItem*)_checks->currentItem();

  if(0 == item)
    return;

  _checks->scrollToItem(item);

  double rate = item->rawValue("doc_exchrate").toDouble();
  double baseamount = item->rawValue("base_amount").toDouble();
  double amount = item->rawValue("amount").toDouble();
  
  if (_allowEdit->isChecked() && item->text(0) != tr("Yes"))
  {
    ParameterList params;
    params.append("transtype", "check");
    params.append("bankaccntid", _bankaccnt->id());
    params.append("bankrecid", _bankrecid);
    params.append("sourceid", item->id());
    if(item->altId()==1)
      params.append("source", "GL");
    else if(item->altId()==2)
      params.append("source", "SL");
    else if(item->altId()==3)
      params.append("source", "AD");
    toggleBankrecCleared newdlg(this, "", TRUE);
    newdlg.set(params);
    newdlg.exec();
    populate();
  }
  else
  {
    reconcileChecksToggleCleared.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid, :currrate, :amount) AS cleared");
    reconcileChecksToggleCleared.bindValue(":bankrecid", _bankrecid);
    reconcileChecksToggleCleared.bindValue(":sourceid", item->id());
    if(item->altId()==1)
      reconcileChecksToggleCleared.bindValue(":source", "GL");
    else if(item->altId()==2)
      reconcileChecksToggleCleared.bindValue(":source", "SL");
    else if(item->altId()==3)
      reconcileChecksToggleCleared.bindValue(":source", "AD");
    reconcileChecksToggleCleared.bindValue(":currrate", rate);
    reconcileChecksToggleCleared.bindValue(":amount", amount);
    reconcileChecksToggleCleared.exec();
    if(reconcileChecksToggleCleared.first())
      item->setText(0, (reconcileChecksToggleCleared.value("cleared").toBool() ? tr("Yes") : tr("No") ));
    else
    {
      populate();
      if (reconcileChecksToggleCleared.lastError().type() != QSqlError::NoError)
      {
        systemError(this, reconcileChecksToggleCleared.lastError().databaseText(), __FILE__, __LINE__);
        return;
      }
    }
  }
}
예제 #13
0
void dspFinancialReport::sCollapsed( QTreeWidgetItem * item )
{
  for (int i = 0; i < item->childCount(); i++)
  {
    XTreeWidgetItem *child = (XTreeWidgetItem*)item->child(i);
    if(child->altId() == -1)
    {
      for (int i = 1; i < _layout->columnCount(); i++)
        item->setText(i, child->text(i));
      return;
    }
  }
}
예제 #14
0
void dspBacklogByCustomer::sPrintPackingList()
{
  QList<XTreeWidgetItem*> selected = _soitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    XTreeWidgetItem *cursor = (XTreeWidgetItem*)(selected[i]);
    if (cursor->altId() == -1)
    {
      ParameterList params;
      params.append("sohead_id", cursor->id());

      printPackingList newdlg(this, "", TRUE);
      newdlg.set(params);
      newdlg.exec();
    }
  }
}
QString XTreeWidgetItemProto::toString() const
{
  QString returnVal = QString("XTreeWidgetItem");
  XTreeWidgetItem *item = qscriptvalue_cast<XTreeWidgetItem*>(thisObject());
  if (item)
  {
    QStringList data;
    for (int i = 0; i < item->columnCount(); i++)
      data << item->text(i);
    returnVal += QString("(id = %1, altId = %2, data = [%3])")
      .arg(item->id()).arg(item->altId()).arg(data.join(", "));
  }
  else
    returnVal += "(unknown)";

  return "[" + returnVal + "]";
}
예제 #16
0
void dspBacklogByCustomer::sAddToPackingListBatch()
{
  QList<XTreeWidgetItem*> selected = _soitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    XTreeWidgetItem *cursor = (XTreeWidgetItem*)(selected[i]);
    if (cursor->altId() == -1)
    {
      q.prepare("SELECT addToPackingListBatch(:sohead_id) AS result;");
      q.bindValue(":sohead_id", cursor->id());
      q.exec();
      if (q.lastError().type() != QSqlError::NoError)
      {
	systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	return;
      }
    }
  }
}
예제 #17
0
void financialLayout::sFillList()
{
  XSqlQuery financialFillList;
  int pId = -1, pType = -1;

  XTreeWidgetItem * item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
  {
    pId = item->id();
    pType = item->altId();
  }

  _layout->clear();
  _lastStack.clear();
  _last = 0;
  if (_adHoc->isChecked())
  {
    insertFlGroupAdHoc(-1, "", 0, pId, pType);
  }
  else
  {
    insertFlGroup(-1, "", 0, pId, pType);
   }
  _layout->expandAll();

  item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
    _layout->scrollToItem(item);

  financialFillList.prepare ("SELECT flcol_id, flcol_name, flcol_descrip "
             " FROM flcol "
             " WHERE flcol_flhead_id=:flhead_id "
             " ORDER BY flcol_name, flcol_descrip; ");
  financialFillList.bindValue(":flhead_id", _flheadid);
  financialFillList.exec();
  _layouts->populate(financialFillList);
  if (financialFillList.lastError().type() != QSqlError::NoError)
  {
    systemError(this, financialFillList.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
예제 #18
0
void dspGLSeries::sPopulateMenu(QMenu * pMenu)
{
  int menuItem;

  bool reversible = false;
  XTreeWidgetItem * item = (XTreeWidgetItem*)_gltrans->currentItem();
  if(0 != item)
  {
    if(item->altId() != -1)
      item = (XTreeWidgetItem*)item->parent();
    if(0 != item)
    {
      if(item->text(3) == "ST" || item->text(3) == "JE")
        reversible = true;
    }
  }

  menuItem = pMenu->insertItem(tr("Reverse Journal..."), this, SLOT(sReverse()), 0);
  if (!reversible || !_privileges->check("PostStandardJournals"))
    pMenu->setItemEnabled(menuItem, false);
}
예제 #19
0
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected)
{
  int menuItem;

  XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected;
  if (item->id() != -1)
  {
    menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0);
    if (!_privleges->check("EditSalesHistory"))
      pMenu->setItemEnabled(menuItem, FALSE);

    pMenu->insertItem(tr("View..."), this, SLOT(sView()), 0);

    if(item->altId() == -1 && item->text(1)==tr("Voucher") && item->text(6)==item->text(7))
    {
      menuItem = pMenu->insertItem(tr("Void"), this, SLOT(sVoidVoucher()), 0);
      if (!_privleges->check("MaintainAPMemos"))
        pMenu->setItemEnabled(menuItem, FALSE);
    } 
  }
}
예제 #20
0
void financialLayout::sFillList()
{
  int pId = -1, pType = -1;

  XTreeWidgetItem * item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
  {
    pId = item->id();
    pType = item->altId();
  }

  _layout->clear();
  _lastStack.clear();
  _last = 0;
  if (_adHoc->isChecked())
  {
    insertFlGroupAdHoc(-1, "", 0, pId, pType);
  }
  else
  {
    insertFlGroup(-1, "", 0, pId, pType);
   }
  _layout->expandAll();

  item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
    _layout->scrollToItem(item);

// fill Column layouts
  _layouts->clear();
  q.prepare ("SELECT flcol_id, flcol_name, flcol_descrip "
             " FROM flcol "
             " WHERE flcol_flhead_id=:flhead_id "
             " ORDER BY flcol_name, flcol_descrip; ");
  q.bindValue(":flhead_id", _flheadid);
  q.exec();
  if (q.first())
    _layouts->populate(q);
}
예제 #21
0
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;
  }

}
void reconcileBankaccount::sReceiptsToggleCleared()
{
  XSqlQuery reconcileReceiptsToggleCleared;
  XTreeWidgetItem *item = (XTreeWidgetItem*)_receipts->currentItem();
  XTreeWidgetItem *child = 0;
  bool setto = true;

  if(0 == item)
    return;

  _receipts->scrollToItem(item);

  if(item->altId() == 9)
  {
    setto = item->text(0) == tr("No");
    for (int i = 0; i < item->childCount(); i++)
    {
      child = item->child(i);
      if(child->text(0) != (setto ? tr("Yes") : tr("No")))
      {
        double rate = QLocale().toDouble(child->text(6));
        double baseamount = QLocale().toDouble(child->text(7));
        double amount = QLocale().toDouble(child->text(8));

        if (_allowEdit->isChecked() && child->text(0) != tr("Yes"))
        {
          ParameterList params;
          params.append("transtype", "receipt");
          params.append("bankaccntid", _bankaccnt->id());
          params.append("bankrecid", _bankrecid);
          params.append("sourceid", child->id());
          if(child->altId()==1)
            params.append("source", "GL");
          else if(child->altId()==2)
            params.append("source", "SL");
          else if(child->altId()==3)
            params.append("source", "AD");
          toggleBankrecCleared newdlg(this, "", TRUE);
          newdlg.set(params);
          newdlg.exec();
        }
        else
        {
          reconcileReceiptsToggleCleared.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid, :currrate, :amount) AS cleared");
          reconcileReceiptsToggleCleared.bindValue(":bankrecid", _bankrecid);
          reconcileReceiptsToggleCleared.bindValue(":sourceid", child->id());
          if(child->altId()==1)
            reconcileReceiptsToggleCleared.bindValue(":source", "GL");
          else if(child->altId()==2)
            reconcileReceiptsToggleCleared.bindValue(":source", "SL");
          else if(child->altId()==3)
            reconcileReceiptsToggleCleared.bindValue(":source", "AD");
          reconcileReceiptsToggleCleared.bindValue(":currrate", rate);
          reconcileReceiptsToggleCleared.bindValue(":amount", amount);
          reconcileReceiptsToggleCleared.exec();
          if(reconcileReceiptsToggleCleared.first())
            child->setText(0, (reconcileReceiptsToggleCleared.value("cleared").toBool() ? tr("Yes") : tr("No") ));
          else if (reconcileReceiptsToggleCleared.lastError().type() != QSqlError::NoError)
          {
            systemError(this, reconcileReceiptsToggleCleared.lastError().databaseText(), __FILE__, __LINE__);
            return;
          }
        }
      }
    }
    item->setText(0, (setto ? tr("Yes") : tr("No")));
    populate();
  }
  else
  {
    double rate = QLocale().toDouble(item->text(6));
    double baseamount = QLocale().toDouble(item->text(7));
    double amount = QLocale().toDouble(item->text(8));
    
    if (_allowEdit->isChecked() && item->text(0) != tr("Yes"))
    {
      ParameterList params;
      params.append("transtype", "receipt");
      params.append("bankaccntid", _bankaccnt->id());
      params.append("bankrecid", _bankrecid);
      params.append("sourceid", item->id());
      if(item->altId()==1)
        params.append("source", "GL");
      else if(item->altId()==2)
        params.append("source", "SL");
      else if(item->altId()==3)
        params.append("source", "AD");
      toggleBankrecCleared newdlg(this, "", TRUE);
      newdlg.set(params);
      newdlg.exec();
      populate();
    }
    else
    {
      reconcileReceiptsToggleCleared.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid, :currrate, :amount) AS cleared");
      reconcileReceiptsToggleCleared.bindValue(":bankrecid", _bankrecid);
      reconcileReceiptsToggleCleared.bindValue(":sourceid", item->id());
      if(item->altId()==1)
        reconcileReceiptsToggleCleared.bindValue(":source", "GL");
      else if(item->altId()==2)
        reconcileReceiptsToggleCleared.bindValue(":source", "SL");
      else if(item->altId()==3)
        reconcileReceiptsToggleCleared.bindValue(":source", "AD");
      reconcileReceiptsToggleCleared.bindValue(":currrate", rate);
      reconcileReceiptsToggleCleared.bindValue(":amount", amount);
      reconcileReceiptsToggleCleared.exec();
      if(reconcileReceiptsToggleCleared.first())
      {
        item->setText(0, (reconcileReceiptsToggleCleared.value("cleared").toBool() ? tr("Yes") : tr("No") ));

        item = (XTreeWidgetItem*)item->QTreeWidgetItem::parent();
        if(item != 0 && item->altId() == 9)
        {
          setto = true;
          for (int i = 0; i < item->childCount(); i++)
          {
            setto = (setto && (item->child(i)->text(0) == tr("Yes")));
          }
          item->setText(0, (setto ? tr("Yes") : tr("No")));
        }
      }
      else
      {
        populate();
        if (reconcileReceiptsToggleCleared.lastError().type() != QSqlError::NoError)
        {
          systemError(this, reconcileReceiptsToggleCleared.lastError().databaseText(), __FILE__, __LINE__);
          return;
        }
      }
    }
  }
}
예제 #23
0
void reconcileBankaccount::sReceiptsToggleCleared()
{
  XTreeWidgetItem *item = (XTreeWidgetItem*)_receipts->currentItem();
  XTreeWidgetItem *child = 0;
  bool setto = true;

  if(0 == item)
    return;

  _receipts->scrollToItem(item);
  if(item->altId() == 3)
  {
    setto = item->text(0) == tr("No");
    for (int i = 0; i < item->childCount(); i++)
    {
      child = item->child(i);
      if(child->text(0) != (setto ? tr("Yes") : tr("No")))
      {
        q.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid) AS cleared");
        q.bindValue(":bankrecid", _bankrecid);
        q.bindValue(":sourceid", child->id());
        if(child->altId()==1)
          q.bindValue(":source", "GL");
        else if(child->altId()==2)
          q.bindValue(":source", "AD");
        q.exec();
        if(q.first())
          child->setText(0, (q.value("cleared").toBool() ? tr("Yes") : tr("No") ));
	else if (q.lastError().type() != QSqlError::NoError)
	{
	  systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }
    }
    item->setText(0, (setto ? tr("Yes") : tr("No")));
  }
  else
  {
    q.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid) AS cleared");
    q.bindValue(":bankrecid", _bankrecid);
    q.bindValue(":sourceid", item->id());
    if(item->altId()==1)
      q.bindValue(":source", "GL");
    else if(item->altId()==2)
      q.bindValue(":source", "AD");
    q.exec();
    if(q.first())
    {
      item->setText(0, (q.value("cleared").toBool() ? tr("Yes") : tr("No") ));

      item = (XTreeWidgetItem*)item->QTreeWidgetItem::parent();
      if(item != 0 && item->altId() == 3)
      {
        setto = true;
	for (int i = 0; i < item->childCount(); i++)
        {
          setto = (setto && (item->child(i)->text(0) == tr("Yes")));
        }
        item->setText(0, (setto ? tr("Yes") : tr("No")));
      }
    }
    else
    {
      populate();
      if (q.lastError().type() != QSqlError::NoError)
      {
	systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	return;
      }
    }
  }
}
/*
  TODO: refactor printChecks/printChecksReview so that printChecks
	hands printChecksReview a list of checks to be reviewed
	instead of populating printChecksReview directly.  Then
	printChecksReview could populate its GUI from this list.
	This will allow printChecksReview to have real error reporting
	and recovery: requery the db for the entire passed-in list
	and show the current state of each check so the user can
	decide what to reprocess if there were errors.
*/
void printChecksReview::sComplete()
{
  XSqlQuery checkPrint;
  checkPrint.prepare( "SELECT markCheckAsPrinted(:check_id) AS result;");

  XSqlQuery checkVoid;
  checkVoid.prepare( "SELECT voidCheck(:check_id) AS result;" );

  XSqlQuery checkReplace;
  checkReplace.prepare( "SELECT replaceVoidedCheck(:check_id) AS result;" );

  // no returns in the loop: process as much as possible, regardless of errors
  for (int i = 0; i < _checks->topLevelItemCount(); i++)
  {
    XTreeWidgetItem *cursor = (XTreeWidgetItem*)(_checks->topLevelItem(i));

    switch(cursor->altId())
    {
      case ActionPrinted:
        checkPrint.bindValue(":check_id", cursor->id());
        checkPrint.exec();
	if (checkPrint.first())
	{
	  int result = checkPrint.value("result").toInt();
	  if (result < 0)
	    systemError(this, storedProcErrorLookup("markCheckPrinted", result), __FILE__, __LINE__);
	}
	else if (checkPrint.lastError().type() != QSqlError::NoError)
	  systemError(this, checkPrint.lastError().databaseText(), __FILE__, __LINE__);
        break;
      case ActionVoided:
        checkVoid.bindValue(":check_id", cursor->id());
        checkVoid.exec();
	if (checkVoid.first())
	{
	  int result = checkVoid.value("result").toInt();
	  if (result < 0)
	    systemError(this, storedProcErrorLookup("voidCheck", result), __FILE__, __LINE__);
	}
	else if (checkVoid.lastError().type() != QSqlError::NoError)
	  systemError(this, checkVoid.lastError().databaseText(), __FILE__, __LINE__);
        break;
      case ActionReplaced:
        checkVoid.bindValue(":check_id", cursor->id());
        checkVoid.exec();
	if (checkVoid.first())
	{
	  int result = checkVoid.value("result").toInt();
	  if (result < 0)
	    systemError(this, storedProcErrorLookup("voidCheck", result), __FILE__, __LINE__);
	}
	else if (checkVoid.lastError().type() != QSqlError::NoError)
	  systemError(this, checkVoid.lastError().databaseText(), __FILE__, __LINE__);
        checkReplace.bindValue(":check_id", cursor->id());
        checkReplace.exec();
	if (checkReplace.first())
	{
	  int result = checkReplace.value("result").toInt();
	  if (result < 0)
	    systemError(this, storedProcErrorLookup("replaceVoidedCheck", result), __FILE__, __LINE__);
	}
	else if (checkReplace.lastError().type() != QSqlError::NoError)
	  systemError(this, checkReplace.lastError().databaseText(), __FILE__, __LINE__);
        break;
    }
  }
  // TODO: after refactoring, handle any errors in the loop here and *return*

  close();
}
예제 #25
0
void dspWoEffortByUser::sFillList()
{
  _wotc->clear();

  if ((_user->isValid()) && (_dates->allValid()))
  {
    QString sql( "SELECT wotc_id, wo_id, formatWONumber(wo_id) AS wonumber,"
		 " wo_status, wo_priority, warehous_code,"
                 " formatDateTime(wotc_timein) AS timein,"
                 " formatDateTime(wotc_timeout) AS timeout,"
		 " wooper_seqnumber || ' - ' || wooper_descrip1 || ' - ' || wooper_descrip2 AS wooper,"
		 " formatInterval(wotcTime(wotc_id)) AS wotcTime "
                 "FROM wo, itemsite, warehous, wotc, wooper "
                 "WHERE ((wo_itemsite_id=itemsite_id)"
                 " AND (itemsite_warehous_id=warehous_id)"
		 " AND (wotc_wooper_id=wooper_id)"
		 " AND (wotc_wo_id=wo_id)"
		 " AND (wotc_usr_id=:usr_id)"
                 " AND (wo_startdate BETWEEN :startDate AND :endDate)) "
		 "UNION "
		 "SELECT wotc_id, wo_id, formatWONumber(wo_id) AS wonumber,"
		 " wo_status, wo_priority, warehous_code,"
                 " formatDateTime(wotc_timein) AS timein,"
                 " formatDateTime(wotc_timeout) AS timeout,"
		 " CAST(wooperpost_seqnumber AS TEXT) AS wooper,"
		 " formatInterval(wotcTime(wotc_id)) AS wotcTime "
                 "FROM wo, itemsite, warehous, wotc LEFT OUTER JOIN"
		 "     wooperpost ON (wooperpost_wotc_id=wotc_id) "
                 "WHERE ((wo_itemsite_id=itemsite_id)"
                 " AND (itemsite_warehous_id=warehous_id)"
		 " AND (wotc_wooper_id IS NULL)"
		 " AND (wotc_wo_id=wo_id)"
		 " AND (wotc_usr_id=:usr_id)"
                 " AND (wo_startdate BETWEEN :startDate AND :endDate)) "
		 "ORDER BY wonumber, timein, timeout;");

    q.prepare(sql);
    _dates->bindValue(q);
    q.bindValue(":usr_id", _user->id());
    q.exec();

    XTreeWidgetItem *last = 0;
    while (q.next() && (q.lastError().type() == QSqlError::NoError))
    {
      last = new XTreeWidgetItem(_wotc, last,
			       q.value("wotc_id").toInt(), q.value("wo_id").toInt(),
			       q.value("wonumber"),    q.value("wo_status"),
			       q.value("wo_priority"), q.value("warehous_code"),
			       q.value("wooper"),      q.value("timein"),
			       q.value("timeout"),     q.value("wotcTime"));
    }
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    XSqlQuery total;
    total.prepare("SELECT formatInterval(woTime(:wotc_wo_id, :wotc_usr_id)) AS total;");
    for (int i = 0; i < _wotc->topLevelItemCount(); i++)
    {
      last = _wotc->topLevelItem(i);
      if ((i == _wotc->topLevelItemCount() - 1) ||
	  last->altId() != ((XTreeWidgetItem*)(_wotc->topLevelItem(i + 1)))->altId())
      {
	total.bindValue(":wotc_wo_id",  last->altId());
	total.bindValue(":wotc_usr_id", _user->id());
	total.exec();
	if (total.first())
	{
	  last = new XTreeWidgetItem(_wotc, last, -1, last->altId(),
				   last->text(0), last->text(1), last->text(2),
				   last->text(3), tr("Total"), "", "",
				   total.value("total"));
	  i++;
	}
	else if (total.lastError().type() != QSqlError::NoError)
	{
	  systemError(this, total.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }
    } 
  }
}
예제 #26
0
void voucherItem::sToggleReceiving(QTreeWidgetItem *pItem)
{
    XSqlQuery voucherToggleReceiving;
    double vch = 0;
    double amt = 0;
    double rcv = 0;
    double rej = 0;

    QString s;
    XTreeWidgetItem* item = (XTreeWidgetItem*)pItem;
    if(item->id() == -1)
        return;

    // TODO: translation
    if (item->text(4) == "Yes")
        item->setText(4, "No");
    else
        item->setText(4, "Yes");

    for (int i = 0; i < _uninvoiced->topLevelItemCount(); i++)
    {
        XTreeWidgetItem *item = _uninvoiced->topLevelItem(i);
        double pp  = item->data(3, Xt::RawRole).toDouble();
        double qty = item->data(2, Xt::RawRole).toDouble();

        if (item->text(4) == "Yes")
        {
            vch = vch + qty;
            amt = amt + (qty * pp);
        }
        else
        {
            if (item->text(0) == "Receiving")
            {
                rcv = rcv + qty;
            }
            else
            {
                rej = rej + qty;
            }
        }
    }
    _qtyToVoucher->setDouble(vch);
    _amtToVoucher->setDouble(amt);
    _uninvoicedReceived->setDouble(rcv);
    _uninvoicedRejected->setDouble(rej);

    // Check PO Close flag

    if ( ((_ordered->toDouble() <= (_received->toDouble() - _rejected->toDouble()))) && (_uninvoicedReceived->toDouble() == 0) && (_uninvoicedRejected->toDouble() == 0) )
        _closePoitem->setChecked(true);
    else
        _closePoitem->setChecked(false);

    // Update the receipt record
    if (item->text("f_tagged") == "Yes")
    {
        if (item->altId() == 1)
            voucherToggleReceiving.prepare( "UPDATE recv "
                                            "SET recv_vohead_id=:vohead_id "
                                            "WHERE (recv_id=:target_id);" );
        else if (item->altId() == 2)
            voucherToggleReceiving.prepare( "UPDATE poreject "
                                            "SET poreject_vohead_id=:vohead_id,poreject_voitem_id=:voitem_id "
                                            "WHERE (poreject_id=:target_id);" );
    }
    else
    {
        if (item->altId() == 1)
            voucherToggleReceiving.prepare( "UPDATE recv "
                                            "SET recv_vohead_id=NULL "
                                            "WHERE ((recv_id=:target_id)"
                                            "  AND  (recv_vohead_id=:vohead_id));" );
        else if (item->altId() == 2)
            voucherToggleReceiving.prepare( "UPDATE poreject "
                                            "SET poreject_vohead_id=NULL,poreject_voitem_id=NULL "
                                            "WHERE ((poreject_id=:target_id)"
                                            "  AND  (poreject_vohead_id=:vohead_id));" );
    }

    voucherToggleReceiving.bindValue(":vohead_id", _voheadid);
    voucherToggleReceiving.bindValue(":voitem_id", _voitemid);
    voucherToggleReceiving.bindValue(":target_id", item->id());
    voucherToggleReceiving.exec();
    if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Voucher Item Information"),
                             voucherToggleReceiving, __FILE__, __LINE__))
    {
        reject();
        return;
    }

}
예제 #27
0
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);
}