Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * [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);
 }
Exemplo n.º 3
0
 public function setTotal()
 {
     $Sale = Sale::find($this->saleId);
     $Sale->total = $this->opTotal();
     $Sale->save();
 }