Exemplo n.º 1
0
 public function getItemSum()
 {
     $num = stockAction::find()->select('SUM(qty)')->where(['item_id' => $this->item_id])->scalar();
     return $num;
 }
Exemplo n.º 2
0
 private function stock($item_id, $qty)
 {
     if (\app\helpers\Linet3Helper::getSetting('company.stock')) {
         // remove from stock.
         $stockAction = $this->docType->stockAction;
         if ($stockAction) {
             if ($this->docType->stockSwitch) {
                 //if has check box
                 if (!$this->stockSwitch) {
                     //if not checked
                     return;
                 }
             }
             $account_id = \app\models\User::getWarehouse($this->owner);
             $oppt_account_id = $this->account_id;
             if ((int) $this->oppt_account_id != 0) {
                 if ($this->doctype == 15) {
                     //only if transfer //mybe shuld be only if oppt_account_type==8 wherehouse
                     $account_id = $this->account_id;
                     $oppt_account_id = $this->oppt_account_id;
                 }
             }
             return stockAction::newTransaction($this->id, $account_id, $oppt_account_id, $item_id, $qty * $stockAction);
         }
     }
     return false;
 }