mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizado el ver facturas en pedidos
This commit is contained in:
@ -23,6 +23,14 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
11 => "DAFEDIFF(days, NOW(), t3.fecha_vencimiento_at)",
|
||||
];
|
||||
|
||||
const SORTABLE_PEDIDOS = [
|
||||
1 => "t1.numero",
|
||||
2 => "t2.nombre",
|
||||
3 => "t1.estado",
|
||||
4 => "t1.fecha_factura_at",
|
||||
5 => "t1.total",
|
||||
];
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'pedido_id',
|
||||
@ -93,6 +101,30 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
public function getResourcePedidos($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, t2.nombre AS serie, t1.estado AS estado,
|
||||
DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at, t1.total AS total"
|
||||
);
|
||||
|
||||
$builder->join("series t2", "t2.id = t1.serie_id", "left");
|
||||
$builder->join("facturas_lineas t3", "t1.id = t3.factura_id", "left");
|
||||
$builder->join("facturas_pedidos_lineas t4", "t1.id = t4.factura_id", "left");
|
||||
$builder->join("pedidos_linea t5", "t4.pedido_linea_id = t5.id", "left");
|
||||
$builder->join("pedidos t6", "t5.pedido_id = t6.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t6.id", $pedido_id);
|
||||
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getCantidadLineaPedidoFacturada($linea_pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
Reference in New Issue
Block a user