terminado el flujo completo de facturas, incluyendo cambio en el texto de pedidos y facturas cuando no tiene factura validada

This commit is contained in:
2025-04-12 17:47:36 +02:00
parent 8912606c9a
commit 89531f1a1b
11 changed files with 119 additions and 5 deletions

View File

@ -39,7 +39,7 @@ class FacturaLineaModel extends \App\Models\BaseModel {
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.iva AS iva,
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id,
t3.total_aceptado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
t3.total_aceptado_revisado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
t6.cantidad AS cantidad_albaran"
)
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")

View File

@ -145,6 +145,27 @@ class FacturaModel extends \App\Models\BaseModel
return $builder;
}
public function presupuestoHasFacturaValidada($presupuesto_id = null)
{
if ($presupuesto_id == null) {
return false;
}
$result = $this->db->table($this->table . " t1")
->select("t1.id")
->join("facturas_lineas t2", "t2.factura_id = t1.id", "left")
->join("pedidos_linea t3", "t2.pedido_linea_impresion_id = t3.id", "left")
->where("t3.presupuesto_id", $presupuesto_id)
->where("t1.deleted_at IS NULL")
->where("t2.deleted_at IS NULL")
->where("t1.estado", "validada")
->get()
->getResultObject();
return !empty($result);
}
public function getSumatoriosFacturacionCliente($cliente_id = -1){
if($cliente_id == -1){

View File

@ -36,6 +36,8 @@ class PedidoLineaModel extends \App\Models\BaseModel
"user_updated_id",
"created_at",
"updated_at",
"cantidad",
"descripcion",
];
protected $returnType = "App\Entities\Pedidos\PedidoLineaEntity";

View File

@ -117,15 +117,28 @@ class PedidoModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t2.presupuesto_id"
"t2.presupuesto_id, t3.total_aceptado, t2.descripcion, t2.cantidad"
);
$builder->where("t1.id", $pedido_id);
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
$model_presupuesto = model("App\Models\Presupuestos\PresupuestoModel");
$lineasPresupuesto = [];
foreach ($builder->get()->getResultObject() as $row) {
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
if($row->descripcion == null){
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
}
else{
$presupuesto = (object) [
'numero' => $row->presupuesto_id,
'unidades' => $row->cantidad,
'total' => $row->total_aceptado,
'concepto' => $row->descripcion,
];
array_push($lineasPresupuesto, $presupuesto);
}
}
$builder->groupBy("t1.id");