mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/chat'
Main See merge request jjimenez/safekat!284
This commit is contained in:
33
ci4/app/Models/Facturas/FacturaLineaModel.php
Normal file
33
ci4/app/Models/Facturas/FacturaLineaModel.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
|
||||
class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas_lineas';
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'factura_id',
|
||||
'pedido_impresion_id',
|
||||
'pedido_maquetacion_id',
|
||||
'descripcion',
|
||||
'cantidad',
|
||||
'precio_unidad',
|
||||
'iva',
|
||||
'base',
|
||||
'total_iva',
|
||||
'total',
|
||||
'data',
|
||||
'deleted_at',
|
||||
'user_update_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaLineaEntity";
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
public static $labelField = "id";
|
||||
}
|
||||
91
ci4/app/Models/Facturas/FacturaModel.php
Normal file
91
ci4/app/Models/Facturas/FacturaModel.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas';
|
||||
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.numero",
|
||||
2 => "t1.fecha_factura_at",
|
||||
3 => "t2.nombre",
|
||||
4 => "t1.base",
|
||||
5 => "t1.total",
|
||||
6 => "t1.pendiente",
|
||||
7 => "t1.creditoAsegurado",
|
||||
8 => "t1.estado",
|
||||
9 => "t1.estado_pago",
|
||||
10 => "t4.nombre",
|
||||
11 => "DAFEDIFF(days, NOW(), t3.fecha_vencimiento_at)",
|
||||
];
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'pedido_id',
|
||||
'factura_retificada_id',
|
||||
'factura_retificativa_id',
|
||||
'customer_id',
|
||||
'serie_id',
|
||||
'numero',
|
||||
'estado',
|
||||
'estado_pago',
|
||||
'fecha_factura_at',
|
||||
'notas',
|
||||
'base',
|
||||
'total',
|
||||
'pendiente',
|
||||
'total_pagos',
|
||||
'creditoAsegurado',
|
||||
'customer_nombre',
|
||||
'customer_address',
|
||||
'customer_cif',
|
||||
'customer_pais',
|
||||
'customer_cp',
|
||||
'customer_ciudad',
|
||||
'customer_provincia',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'user_created_id',
|
||||
'user_update_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, t1.fecha_factura_at AS fecha_factura_at,
|
||||
t2.nombre AS cliente, t1.base AS base, t1.total AS total, t1.pendiente AS pendiente,
|
||||
t1.creditoAsegurado AS creditoAsegurado, t1.estado AS estado, t1.estado_pago AS estado_pago,
|
||||
t4.nombre AS forma_pago, t3.fecha_vencimiento_at AS venciemento"
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
$builder->join("facturas_pagos t3", "t3.factura_id = t1.id", "left");
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
26
ci4/app/Models/Facturas/FacturaPagoModel.php
Normal file
26
ci4/app/Models/Facturas/FacturaPagoModel.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
class FacturaPagoModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas_pagos';
|
||||
|
||||
protected $allowedFields = [
|
||||
'factura_id',
|
||||
'notes',
|
||||
'fecha_pago_at',
|
||||
'fecha_vencimiento_at',
|
||||
'forma_pago_id',
|
||||
'total',
|
||||
'deleted_at',
|
||||
'user_update_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaPagoEntity";
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
public static $labelField = "id";
|
||||
}
|
||||
Reference in New Issue
Block a user