예제 #1
0
purchaseOrderItem::purchaseOrderItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

#ifndef Q_WS_MAC
  _vendorItemNumberList->setMaximumWidth(25);
#endif

  connect(_ordered, SIGNAL(lostFocus()), 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(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_ordered, SIGNAL(lostFocus()), this, SLOT(sUpdateVendorQty()));
  connect(_vendorItemNumberList, SIGNAL(clicked()), this, SLOT(sVendorItemNumberList()));
  connect(_notesButton, SIGNAL(toggled(bool)), this, SLOT(sHandleButtons()));

  _parentwo = -1;
  _parentso = -1;
  _itemsrcid = -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());

  q.exec("SELECT DISTINCT 1,itemsrc_manuf_name FROM itemsrc;");
  _manufName->populate(q);
  _manufName->setCurrentText("");

  //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->removePage(_tab->page(4));
   
  adjustSize();
}
예제 #2
0
purchaseOrderItem::purchaseOrderItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : QDialog(parent, name, modal, fl)
{
  setupUi(this);

#ifndef Q_WS_MAC
  _vendorItemNumberList->setMaximumWidth(25);
#endif

  connect(_ordered, SIGNAL(lostFocus()), this, SLOT(sDeterminePrice()));
  connect(_inventoryItem, SIGNAL(toggled(bool)), this, SLOT(sInventoryItemToggled(bool)));
  connect(_item, SIGNAL(newId(int)), this, SLOT(sPopulateItemSourceInfo(int)));
  connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_ordered, SIGNAL(lostFocus()), this, SLOT(sUpdateVendorQty()));
  connect(_vendorItemNumberList, SIGNAL(clicked()), this, SLOT(sVendorItemNumberList()));

  _parentwo = -1;
  _parentso = -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);

  //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->removePage(_tab->page(4));
   
  resize(minimumSize());
}
예제 #3
0
void purchaseOrderItem::sPopulateItemInfo(int pItemid)
{
  XSqlQuery item;
  
  if (pItemid != -1 && _mode == cNew)
  {
    if(_metrics->boolean("RequireStdCostForPOItem"))
    {
      item.prepare("SELECT stdCost(:item_id) AS result");
      item.bindValue(":item_id", pItemid);
      item.exec();
      if(item.first() && item.value("result").toDouble() == 0.0)
      {
        QMessageBox::critical( this, tr("Selected Item Missing Cost"),
                tr("<p>The selected item has no Std. Costing information. "
                   "Please see your controller to correct this situation "
                   "before continuing."));
        _item->setId(-1);
        return;
      }
    }
    
    item.prepare( "SELECT DISTINCT char_id, char_name,"
               "       COALESCE(b.charass_value, (SELECT c.charass_value FROM charass c WHERE ((c.charass_target_type='I') AND (c.charass_target_id=:item_id) AND (c.charass_default) AND (c.charass_char_id=char_id)) LIMIT 1)) AS charass_value"
               "  FROM charass a, char "
               "    LEFT OUTER JOIN charass b"
               "      ON (b.charass_target_type='PI'"
               "      AND b.charass_target_id=:poitem_id"
               "      AND b.charass_char_id=char_id) "
               " WHERE ( (a.charass_char_id=char_id)"
               "   AND   (a.charass_target_type='I')"
               "   AND   (a.charass_target_id=:item_id) ) "
               " ORDER BY char_name;" );
    item.bindValue(":item_id", pItemid);
    item.bindValue(":poitem_id", _poitemid);
    item.exec();
    int row = 0;
    QModelIndex idx;
    while(item.next())
    {
      _itemchar->insertRow(_itemchar->rowCount());
      idx = _itemchar->index(row, 0);
      _itemchar->setData(idx, item.value("char_name"), Qt::DisplayRole);
      _itemchar->setData(idx, item.value("char_id"), Qt::UserRole);
      idx = _itemchar->index(row, 1);
      _itemchar->setData(idx, item.value("charass_value"), Qt::DisplayRole);
      _itemchar->setData(idx, pItemid, Qt::UserRole);
      row++;
    }
    
    item.prepare("SELECT itemsrc_id "
                 "FROM itemsrc, pohead "
                 "WHERE ( (itemsrc_vend_id=pohead_vend_id)"
                 " AND (itemsrc_item_id=:item_id)"
                 " AND (pohead_id=:pohead_id) );" );
    item.bindValue(":item_id", pItemid);
    item.bindValue(":pohead_id", _poheadid);
    item.exec();
    if (item.size() == 1)
    {
      item.first();
      if (item.value("itemsrc_id").toInt() != _itemsrcid)
        sPopulateItemSourceInfo(item.value("itemsrc_id").toInt());
    }
    else if (item.size() > 1)
    {
      bool isCurrent = false;
      while (item.next())
      {
        if (item.value("itemsrc_id").toInt() == _itemsrcid)
          isCurrent = true;
      }
      if (!isCurrent)
      {
        _vendorItemNumber->clear();
        sVendorItemNumberList();
      }
    }
    else
    {
      _itemsrcid = -1;
  
      _vendorItemNumber->clear();
      _vendorDescrip->clear();
      _vendorUOM->setText(_item->uom());
      _uom->setText(_item->uom());
      _minOrderQty->clear();
      _orderQtyMult->clear();
      _invVendorUOMRatio->setDouble(1.0);
      _earliestDate->setDate(omfgThis->dbDate());
      _manufName->clear();
      _manufItemNumber->clear();
      _manufItemDescrip->clear();
  
      _invVendUOMRatio = 1;
      _minimumOrder = 0;
      _orderMultiple = 0;
    }
  }
}
예제 #4
0
void purchaseOrderItem::sPopulateItemInfo(int pItemid)
{
  XSqlQuery item;
  if (pItemid != -1 && _mode == cNew)
  {
      item.prepare("SELECT stdCost(item_id) AS stdcost, "
                   "       getItemTaxType(item_id, pohead_taxzone_id) AS taxtype_id, "
                   "       item_tax_recoverable, COALESCE(item_maxcost, 0.0) AS maxcost "
                   "FROM item, pohead "
                   "WHERE ( (item_id=:item_id) "
                   "  AND   (pohead_id=:pohead_id) );");
      item.bindValue(":item_id", pItemid);
      item.bindValue(":pohead_id", _poheadid);
      item.exec();

      if (item.first())
      {
          // Reset order qty cache
          _orderQtyCache = -1;

          if(_metrics->boolean("RequireStdCostForPOItem") && item.value("stdcost").toDouble() == 0.0)
          {
            QMessageBox::critical( this, tr("Selected Item Missing Cost"),
                    tr("<p>The selected item has no Std. Costing information. "
                       "Please see your controller to correct this situation "
                       "before continuing."));
            _item->setId(-1);
            return;
          }

        _taxtype->setId(item.value("taxtype_id").toInt());
        _taxRecoverable->setChecked(item.value("item_tax_recoverable").toBool());
        _maxCost = item.value("maxcost").toDouble();

        sPopulateItemsiteInfo();
        sPopulateItemChar();

        item.prepare("SELECT itemsrc_id "
                     "FROM itemsrc, pohead "
                     "WHERE ( (itemsrc_vend_id=pohead_vend_id)"
                     " AND (itemsrc_item_id=:item_id)"
                     " AND (:effective BETWEEN itemsrc_effective AND (itemsrc_expires - 1))"
                     " AND (itemsrc_active)"
                     " AND (pohead_id=:pohead_id) );" );
        item.bindValue(":item_id", pItemid);
        item.bindValue(":pohead_id", _poheadid);
        item.bindValue(":effective", _unitPrice->effective());
        item.exec();
        if (item.size() == 1)
        {
          item.first();

          if (item.value("itemsrc_id").toInt() != _itemsrcid)
            sPopulateItemSourceInfo(item.value("itemsrc_id").toInt());
        }
        else if (item.size() > 1)
        {
          bool isCurrent = false;
          while (item.next())
          {
            if (item.value("itemsrc_id").toInt() == _itemsrcid)
              isCurrent = true;
          }
          if (!isCurrent)
          {
            _vendorItemNumber->clear();
            sVendorItemNumberList();
          }
        }
        else
        {
          _itemsrcid = -1;

          _vendorItemNumber->clear();
          _vendorDescrip->clear();
          _vendorUOM->setText(_item->uom());
          _uom->setText(_item->uom());
          _minOrderQty->clear();
          _orderQtyMult->clear();
          _invVendorUOMRatio->setDouble(1.0);
          _earliestDate->setDate(omfgThis->dbDate());
          _manufName->setId(-1);
          _manufItemNumber->clear();
          _manufItemDescrip->clear();

          _invVendUOMRatio = 1;
          _minimumOrder = 0;
          _orderMultiple = 0;
        }
      }
  }
}
예제 #5
0
purchaseOrderItem::purchaseOrderItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

#ifndef Q_WS_MAC
  _vendorItemNumberList->setMaximumWidth(25);
#else
  _listPrices->setMinimumWidth(60);
#endif

  _invVendUOMRatio = 1;
  _minimumOrder = 0;
  _orderMultiple = 0;

  connect(_ordered, SIGNAL(lostFocus()), 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(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_vendorItemNumberList, SIGNAL(clicked()), this, SLOT(sVendorItemNumberList()));
  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 //

  _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());

  q.exec("SELECT DISTINCT itemsrc_manuf_name FROM itemsrc ORDER BY 1;");
  for (int i = 0; q.next(); i++)
    _manufName->append(i, q.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();
}