mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido facturas. faltan filtros pedidos
This commit is contained in:
@ -145,6 +145,40 @@ class FacturaModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getSumatoriosFacturacionCliente($cliente_id = -1){
|
||||
|
||||
if($cliente_id == -1){
|
||||
return [
|
||||
'total_facturacion' => 0,
|
||||
'total_pendiente' => 0
|
||||
];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.total) as total')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_facturacion'] =
|
||||
round(floatval(($data && $data[0]->total != null) ? $data[0]->total : 0), 2);
|
||||
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.pendiente) as pendiente')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->where('f.estado_pago', 'pendiente')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_pendiente'] =
|
||||
round(floatval(($data && $data[0]->pendiente != null) ? $data[0]->pendiente : 0), 2);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
|
||||
Reference in New Issue
Block a user