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, 'total')); /** * Total de Ventas de Parking * @var decimal */ $parking_sales = Till::where('action', Self::getActionTrans('sale'))->where('created_at', '>=', $lastOpen)->get()->toArray(); $parking_sales = array_sum(array_column($parking_sales, 'total')); /** * Total de Abonoso pagos * @var decimal */ $total_subs = Till::where('action', Self::getActionTrans('sale_subs'))->where('created_at', '>=', $lastOpen)->get()->toArray(); $total_subs = array_sum(array_column($total_subs, 'total')); /** * Total de Retiros * @var decimal */ $withdrawals = Till::where('action', Self::getActionTrans('withdrawal'))->where('created_at', '>=', $lastOpen)->get()->toArray(); $withdrawals = array_sum(array_column($withdrawals, 'total')); $till = ['total_deposites' => $deposites, 'total_parking_sales' => $parking_sales, 'total_subscription' => $total_subs, 'total_witdrawls' => $withdrawals, 'total_all_sales' => Calc::suma([$parking_sales, $total_subs]), 'total_income' => Calc::suma([$parking_sales, $total_subs, $deposites])]; $till['total_in_till'] = Calc::resta([$till['total_income']], [$withdrawals]); # lo que queda en caja con la suma total menos los depositos. return (object) $till; }