Example #1
0
 /**
  * creating a PO Item
  * 
  * @param PurchaseOrder $po
  * @param Product       $product
  * @param double        $unitPrice
  * @param int           $qty
  * @param string        $supplierItemCode
  * @param string        $supplierId
  * @param string        $description
  * @param double        $totalPrice
  * 
  * @return PurchaseOrderItem
  */
 public static function create(PurchaseOrder $po, Product $product, $unitPrice = '0.0000', $qty = 1, $totalPrice = null, $receivedQty = 0)
 {
     $entity = new PurchaseOrderItem();
     $msg = 'created POI for PO(' . $po->getPurchaseOrderNo() . ') with Product(SKU=' . $product->getSku() . ') unitPrice=' . $unitPrice . ', qty=' . $qty;
     $entity->setPurchaseOrder($po)->setProduct($product)->setUnitPrice($unitPrice)->setQty($qty)->setReceivedQty($receivedQty)->setTotalPrice(trim($totalPrice) !== '' ? $totalPrice : $unitPrice * $qty)->save()->addLog($msg, Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__);
     $po->addLog($msg, Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__);
     return $entity;
 }