public function exec(ARequest $request)
    {
        $result = new AResponse();
        $orderId = $request->getSaleOrderId();
        $datePaid = $request->getSaleOrderDatePaid();
        $items = $request->getOrderItems();
        /* for all items get PV data by warehouse */
        $orderTotal = 0;
        foreach ($items as $item) {
            $prodId = $item->getProductId();
            $stockId = $item->getStockId();
            $itemId = $item->getItemId();
            $pv = $this->daoStockItem->getPvByProductAndStock($prodId, $stockId);
            $qty = $item->getQuantity();
            $total = $pv * $qty;
            $eItem = new \Praxigento\Pv\Repo\Data\Sale\Item();
            $eItem->setItemRef($itemId);
            $eItem->setSubtotal($total);
            $eItem->setDiscount(0);
            $eItem->setTotal($total);
            $this->daoSaleItem->replace($eItem);
            $orderTotal += $total;
        }
        /* save order data */
        $eOrder = new \Praxigento\Pv\Repo\Data\Sale();
        $eOrder->setSaleRef($orderId);
        $eOrder->setSubtotal($orderTotal);
        $eOrder->setDiscount(0);
        $eOrder->setTotal($orderTotal);
        $eOrder->setDatePaid($datePaid);
        $this->daoSale->replace($eOrder);
        $result->markSucceed();
        return $result;

    }
public function exec(ARequest $request)
    {
        $result = new AResponse();
        $orderId = $request->getSaleOrderId();
        $datePaid = $request->getSaleOrderDatePaid();
        $items = $request->getOrderItems();
        /* for all items get PV data by warehouse */
        $orderTotal = 0;
        foreach ($items as $item) {
            $prodId = $item->getProductId();
            $stockId = $item->getStockId();
            $itemId = $item->getItemId();
            $pv = $this->daoStockItem->getPvByProductAndStock($prodId, $stockId);
            $qty = $item->getQuantity();
            $total = $pv * $qty;
            $eItem = new \Praxigento\Pv\Repo\Data\Sale\Item();
            $eItem->setItemRef($itemId);
            $eItem->setSubtotal($total);
            $eItem->setDiscount(0);
            $eItem->setTotal($total);
            $this->daoSaleItem->replace($eItem);
            $orderTotal += $total;
        }
        /* save order data */
        $eOrder = new \Praxigento\Pv\Repo\Data\Sale();
        $eOrder->setSaleRef($orderId);
        $eOrder->setSubtotal($orderTotal);
        $eOrder->setDiscount(0);
        $eOrder->setTotal($orderTotal);
        $eOrder->setDatePaid($datePaid);
        $this->daoSale->replace($eOrder);
        $result->markSucceed();
        return $result;

    }
public function exec ( ARequest $ request ) { $ result = new AResponse ( ) ; $ orderId = $ request -> getSaleOrderId ( ) ; $ datePaid = $ request -> getSaleOrderDatePaid ( ) ; $ items = $ request -> getOrderItems ( ) ; /* for all items get PV data by warehouse */ $ orderTotal = 0 ; foreach ( $ items as $ item ) { $ prodId = $ item -> getProductId ( ) ; $ stockId = $ item -> getStockId ( ) ; $ itemId = $ item -> getItemId ( ) ; $ pv = $ this -> daoStockItem -> getPvByProductAndStock ( $ prodId , $ stockId ) ; $ qty = $ item -> getQuantity ( ) ; $ total = $ pv * $ qty ; $ eItem = new \ Praxigento \ Pv \ Repo \ Data \ Sale \ Item ( ) ; $ eItem -> setItemRef ( $ itemId ) ; $ eItem -> setSubtotal ( $ total ) ; $ eItem -> setDiscount ( 0 ) ; $ eItem -> setTotal ( $ total ) ; $ this -> daoSaleItem -> replace ( $ eItem ) ; $ orderTotal += $ total ; } /* save order data */ $ eOrder = new \ Praxigento \ Pv \ Repo \ Data \ Sale ( ) ; $ eOrder -> setSaleRef ( $ orderId ) ; $ eOrder -> setSubtotal ( $ orderTotal ) ; $ eOrder -> setDiscount ( 0 ) ; $ eOrder -> setTotal ( $ orderTotal ) ; $ eOrder -> setDatePaid ( $ datePaid ) ; $ this -> daoSale -> replace ( $ eOrder ) ; $ result -> markSucceed ( ) ; return $ result ; }
Save PV data on sale order save.
@param ARequest $request
@return AResponse
Save PV data on sale order save .