mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Preparada factura en PDF
This commit is contained in:
@ -54,6 +54,56 @@ class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourceResumenIVAsForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.iva,
|
||||
ROUND(SUM(t1.base), 2) AS base,
|
||||
ROUND(SUM(t1.total_iva), 2) AS total_iva,
|
||||
ROUND(SUM(t1.total), 2) AS total"
|
||||
)
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->groupBy('t1.iva')
|
||||
->orderBy('t1.iva', 'ASC'); // Ordena por iva en forma ascendente
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.factura_id AS factura_id,
|
||||
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.precio_unidad AS precio_unidad, 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,
|
||||
t6.cantidad AS cantidad_albaran"
|
||||
)
|
||||
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
|
||||
->join("presupuestos t3", "t3.id = t2.presupuesto_id", "left")
|
||||
->join("clientes t4", "t4.id = t3.cliente_id", "left")
|
||||
->join("albaranes t5", "t5.pedido_id = t2.pedido_id", "left")
|
||||
->join("albaranes_lineas t6", "t6.albaran_id = t5.id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function addFacturaPedidoLinea($factura_id, $pedido_linea_id, $cantidad)
|
||||
{
|
||||
$data = [
|
||||
|
||||
Reference in New Issue
Block a user