コード例 #1
0
void voucher::sClear()
{
    QList<QTreeWidgetItem*> selected = _poitem->selectedItems();
    for (int i = 0; i < selected.size(); i++)
    {
        QString sql( "DELETE FROM vodist "
             "  WHERE ((vodist_poitem_id=:poitem_id) "
             "  AND (vodist_vohead_id=:vohead_id)); "

             "  UPDATE recv SET recv_vohead_id=NULL, recv_voitem_id=NULL "
             "  WHERE ((recv_vohead_id=:vohead_id) "
             "  AND (recv_order_type='PO') "
             "  AND (recv_orderitem_id=:poitem_id)); "

             "  DELETE FROM voitem "
             "  WHERE ((voitem_poitem_id=:poitem_id) "
             "  AND (voitem_vohead_id=:vohead_id)); "

             "  UPDATE poreject SET poreject_vohead_id=NULL, poreject_voitem_id=NULL "
             "  WHERE ((poreject_vohead_id=:vohead_id) "
             "  AND (poreject_poitem_id=:poitem_id)); " );
        q.prepare(sql);
        q.bindValue(":vohead_id", _voheadid);
        q.bindValue(":poitem_id", ((XTreeWidgetItem*)(selected[i]))->id());
        q.exec();

        if (q.lastError().type() != QSqlError::NoError)
        {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return;
        }
     }
  sFillList();
  sPopulateDistributed();
}
コード例 #2
0
void voucher::populate()
{
  XSqlQuery vohead;
  vohead.prepare( "SELECT vohead_number, vohead_pohead_id, vohead_terms_id,"
                  "       vohead_distdate, vohead_docdate, vohead_duedate,"
                  "       vohead_invcnumber, vohead_reference,"
                  "       vohead_1099, vohead_amount, vohead_curr_id "
                  "FROM vohead "
                  "WHERE (vohead_id=:vohead_id);" );
  vohead.bindValue(":vohead_id", _voheadid);
  vohead.exec();
  if (vohead.first())
  {
    _voucherNumber->setText(vohead.value("vohead_number").toString());
    _poNumber->setId(vohead.value("vohead_pohead_id").toInt());
    _terms->setId(vohead.value("vohead_terms_id").toInt());
    _amountToDistribute->set(vohead.value("vohead_amount").toDouble(),
			     vohead.value("vohead_curr_id").toInt(),
			     vohead.value("vohead_docdate").toDate(), false);

    _distributionDate->setDate(vohead.value("vohead_distdate").toDate(), true);
    _invoiceDate->setDate(vohead.value("vohead_docdate").toDate());
    _dueDate->setDate(vohead.value("vohead_duedate").toDate());
    _invoiceNum->setText(vohead.value("vohead_invcnumber").toString());
    _reference->setText(vohead.value("vohead_reference").toString());
    _flagFor1099->setChecked(vohead.value("vohead_1099").toBool());

    sFillList();
    sFillMiscList();
    sPopulateDistributed();
  }
}
コード例 #3
0
void voucher::sDistributeAll()
{
  _poitem->selectAll();
  QList<QTreeWidgetItem*> selected = _poitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    q.prepare("SELECT distributeVoucherLine(:vohead_id,:poitem_id,:curr_id) "
              "AS result;");
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", ((XTreeWidgetItem*)(selected[i]))->id());
    q.bindValue(":curr_id", _amountToDistribute->id());
    q.exec();
    if (q.first())
    {
      int result = q.value("result").toInt();
      if (result < 0)
        systemError(this,
                    storedProcErrorLookup("distributeVoucherLine", result),
                    __FILE__, __LINE__);
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
  sFillList();
  sPopulateDistributed();
}
コード例 #4
0
void voucher::sDeleteMiscDistribution()
{
  q.prepare( "DELETE FROM vodist "
             "WHERE (vodist_id=:vodist_id);" );
  q.bindValue(":vodist_id", _miscDistrib->id());
  q.exec();
  sFillMiscList();
  sPopulateDistributed();
}
コード例 #5
0
void voucher::sDistributions()
{
  QList<QTreeWidgetItem*> selected = _poitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
      ParameterList params;
      params.append("mode", "new");
      params.append("vohead_id", _voheadid);
      params.append("poitem_id",  ((XTreeWidgetItem*)(selected[i]))->id());
      params.append("curr_id", _amountToDistribute->id());
      params.append("effective", _amountToDistribute->effective());

      voucherItem newdlg(this, "", TRUE);
      newdlg.set(params);
      if (newdlg.exec() == QDialog::Rejected)
      {
//Remove distributions and reset tags if new voitem was not saved
        q.prepare( "DELETE FROM vodist "
                      "WHERE ( (vodist_vohead_id=:vohead_id) "
              " AND (vodist_poitem_id=:poitem_id) "
              " AND NOT EXISTS "
              "       (SELECT * FROM voitem "
              "       WHERE ( (voitem_poitem_id=:poitem_id) "
              "       AND (voitem_vohead_id=:vohead_id) ) ) ); "

              "UPDATE recv SET recv_vohead_id=NULL,recv_invoiced=false "
              " WHERE ((recv_vohead_id=:vohead_id) "
              " AND (recv_orderitem_id=:poitem_id)  "
              " AND (recv_order_type = 'PO')"
              " AND NOT EXISTS "
              "       (SELECT * FROM voitem "
              "       WHERE ( (voitem_poitem_id=:poitem_id) "
              "       AND (voitem_vohead_id=:vohead_id) ) ) ); "

              "UPDATE poreject SET poreject_vohead_id=NULL,poreject_invoiced=false "
              " WHERE ((poreject_vohead_id=:vohead_id) "
              " AND (poreject_poitem_id=:poitem_id) "
              " AND NOT EXISTS "
              "       (SELECT * FROM voitem "
              "       WHERE ( (voitem_poitem_id=:poitem_id) "
              "       AND (voitem_vohead_id=:vohead_id) ) ) ); " );
         q.bindValue(":vohead_id", _voheadid);
         q.bindValue(":poitem_id",  ((XTreeWidgetItem*)(selected[i]))->id());
         q.exec();
    }
  }
  sFillList();
  sPopulateDistributed();

}
コード例 #6
0
void voucher::sEditMiscDistribution()
{
  ParameterList params;
  params.append("mode", "edit");
  params.append("vodist_id", _miscDistrib->id());
  params.append("curr_id", _amountToDistribute->id());
  params.append("curr_effective", _amountToDistribute->effective());

  voucherMiscDistrib newdlg(this, "", TRUE);
  newdlg.set(params);
  if (newdlg.exec() != XDialog::Rejected)
  {
    sFillMiscList();
    sPopulateDistributed();
  }
}
コード例 #7
0
void voucher::sDeleteMiscDistribution()
{
  saveDetail();
  q.prepare( "DELETE FROM voheadtax "
             "WHERE (taxhist_parent_id=:vohead_id) "
			 " AND  (taxhist_taxtype_id=getadjustmenttaxtypeid()) "
			 " AND  (taxhist_tax_id = (SELECT vodist_tax_id FROM vodist WHERE (vodist_id=:vodist_id))); "
	         "DELETE FROM vodist "
             "WHERE (vodist_id=:vodist_id);");

  q.bindValue(":vohead_id", _voheadid);
  q.bindValue(":vodist_id", _miscDistrib->id());
  q.exec();
  sFillMiscList();
  sPopulateDistributed();
}
コード例 #8
0
void voucher::sNewMiscDistribution()
{
  ParameterList params;
  params.append("mode", "new");
  params.append("vohead_id", _voheadid);
  params.append("curr_id", _amountToDistribute->id());
  params.append("curr_effective", _amountToDistribute->effective());
  params.append("amount", _balance->localValue());

  voucherMiscDistrib newdlg(this, "", TRUE);
  newdlg.set(params);
  if (newdlg.exec() != XDialog::Rejected)
  {
    sFillMiscList();
    sPopulateDistributed();
  }
}
コード例 #9
0
void voucher::populate()
{
  XSqlQuery vohead;
  vohead.prepare( "SELECT vohead_number, vohead_pohead_id, vohead_taxzone_id, vohead_terms_id,"
                  "       vohead_distdate, vohead_docdate, vohead_duedate,"
                  "       vohead_invcnumber, vohead_reference,"
                  "       vohead_1099, vohead_amount, vohead_curr_id, vohead_notes "
                  "FROM vohead "
                  "WHERE (vohead_id=:vohead_id);" );
  vohead.bindValue(":vohead_id", _voheadid);
  vohead.exec();
  if (vohead.first())
  {
    _voucherNumber->setText(vohead.value("vohead_number").toString());
    _poNumber->setId(vohead.value("vohead_pohead_id").toInt(), "PO");
    _taxzone->setId(vohead.value("vohead_taxzone_id").toInt());
    _terms->setId(vohead.value("vohead_terms_id").toInt());
    _amountToDistribute->set(vohead.value("vohead_amount").toDouble(),
			     vohead.value("vohead_curr_id").toInt(),
			     vohead.value("vohead_docdate").toDate(), false);

    _distributionDate->setDate(vohead.value("vohead_distdate").toDate(), true);
    _invoiceDate->setDate(vohead.value("vohead_docdate").toDate());
    _dueDate->setDate(vohead.value("vohead_duedate").toDate());
    _invoiceNum->setText(vohead.value("vohead_invcnumber").toString());
    _reference->setText(vohead.value("vohead_reference").toString());
    _flagFor1099->setChecked(vohead.value("vohead_1099").toBool());
    _notes->setText(vohead.value("vohead_notes").toString());

    sFillList();
    sFillMiscList();
    sPopulateDistributed();
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
コード例 #10
0
void voucher::sDistributeAll()
{
  _poitem->selectAll();
  QList<QTreeWidgetItem*> selected = _poitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
    QString sql ( "SELECT distributevoucherline(:vohead_id,:poitem_id,:curr_id) AS result" );
    q.prepare(sql);
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", ((XTreeWidgetItem*)(selected[i]))->id());
    q.bindValue(":curr_id", _amountToDistribute->id());
    q.exec();


    if (q.first())
    {
          if (q.value("result").toInt() == -2)
                QMessageBox::warning( this, tr("Zero Amount"),
                              tr( "<p>Distribution would result in zero quantity and amount.\n"
                                  "Please distribute manually." ) );
          else if (q.value("result").toInt() == -3)
                QMessageBox::warning( this, tr("Different Currencies"),
                              tr( "<p>The purchase order and voucher have different currencies.\n"
                                  "Please distribute manually." ) );
          else if (q.value("result").toInt() == -4)
          QMessageBox::warning( this, tr("Negative Amount"),
                              tr( "<p>Distribution would result in a negative amount.\n"
                                  "Please distribute manually." ) );
          else if (q.value("result").toInt() == -5)
          QMessageBox::warning( this, tr("Multiple Cost Elements"),
                              tr( "<p>Item has multiple cost elements.\n"
                                  "Please distribute manually." ) );
    }
  }
  sFillList();
  sPopulateDistributed();

}
コード例 #11
0
void voucher::sDistributions()
{
  QList<QTreeWidgetItem*> selected = _poitem->selectedItems();
  for (int i = 0; i < selected.size(); i++)
  {
      ParameterList params;
      params.append("mode", "new");
      params.append("vohead_id", _voheadid);
      params.append("poitem_id",  ((XTreeWidgetItem*)(selected[i]))->id());
      params.append("curr_id", _amountToDistribute->id());
      params.append("effective", _amountToDistribute->effective());

      voucherItem newdlg(this, "", TRUE);
      newdlg.set(params);
      if (newdlg.exec() == XDialog::Rejected)
      {
        // nothing to do:
        // voucherItem wraps itself in a transaction and rolls back on reject
    }
  }
  sFillList();
  sPopulateDistributed();
}