コード例 #1
0
ファイル: CashRegister.php プロジェクト: awme/stocket
 public static function onClosing()
 {
     $getLastOpen = Self::getLastOpen()->toArray();
     #$lastOpen['created_at']
     $lastOpen = $getLastOpen['created_at'];
     /**
      * Total de depositos
      * @var decimal
      */
     $deposites = Till::where('action', Self::getActionTrans('deposit'))->where('created_at', '>=', $lastOpen)->get()->toArray();
     $deposites = array_sum(array_column($deposites, 'cash'));
     /**
      * Total de Ventas
      * @var decimal
      */
     $cash_sales = Till::where('action', Self::getActionTrans('sale'))->where('created_at', '>=', $lastOpen)->get()->toArray();
     $cash_sales = array_sum(array_column($cash_sales, 'cash'));
     /**
      * Total de Ventas
      * @var decimal
      */
     $payable_sales = Till::where('action', Self::getActionTrans('sale'))->where('created_at', '>=', $lastOpen)->get()->toArray();
     $payable_sales = array_sum(array_column($payable_sales, 'payable'));
     /**
      * Total de Retiros
      * @var decimal
      */
     $withdrawals = Till::where('action', Self::getActionTrans('withdrawal'))->where('created_at', '>=', $lastOpen)->get()->toArray();
     $withdrawals = array_sum(array_column($withdrawals, 'cash'));
     $till = ['total_in_open_till' => $getLastOpen['till'], 'total_deposites' => $deposites, 'total_cash_sales' => $cash_sales, 'total_payable_sales' => $payable_sales, 'total_witdrawls' => $withdrawals, 'total_all_sales' => Calc::suma([$cash_sales, $payable_sales]), 'total_till' => Calc::resta([$cash_sales, $deposites, $getLastOpen['till']], [$withdrawals])];
     return (object) $till;
 }
コード例 #2
0
ファイル: Invoice.php プロジェクト: awme/stocket
 /**
  * [setStock description]
  * Descontar producto del stock Models\Product
  */
 public function setStock()
 {
     $items = $this->getItems();
     foreach ($items as $item => $attr) {
         $Product = Product::find($attr['product_id']);
         $Product->stock = Calc::resta([$Product->stock], [$attr['qty']]);
         $Product->save();
     }
 }