/** * Recalculate */ public function onRecalculate($recordId = null, $context = null) { $Invoice = new Invoice(); $Invoice->saleId = $recordId; $Invoice->opRecalculate(); $this->vars['invoice'] = $Invoice->get(); $this->vars['invoiceStatus'] = Sale::find($recordId)->status; $this->asExtension('FormController')->update($recordId, $context); }
/** * [getProfit] * Ingresos totales de ventas del mes corriente * @return float [data] */ public function getProfit() { # $current_year = date('Y').'-01-01 00:00:00'; $current_month = date('Y-m') . '-01 00:00:00'; # $current_week = date("Y-m-d", strtotime('-1 week')).' 00:00:00'; # $current_day = date('Y-m-d').' 00:00:00';*/ $profit = array_column(Sale::where('created_at', '>=', $current_month)->where('status', 'closed')->get()->toArray(), 'total'); return array_sum($profit); }
public function setTotal() { $Sale = Sale::find($this->saleId); $Sale->total = $this->opTotal(); $Sale->save(); }