añadido facturas. faltan filtros pedidos

This commit is contained in:
2025-03-30 21:36:17 +02:00
parent f553641818
commit e1fa993fcd
10 changed files with 175 additions and 22 deletions

View File

@ -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.