salix/db/routines/vn/procedures/invoiceOutListByCompany.sql

28 lines
752 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE)
BEGIN
SELECT
c.socialName as RazonSocial,
c.fi as NIF,
io.ref as Factura,
io.serial as Serie,
io.issued as Fecha,
io.amount as Importe,
c.id as Id_Cliente,
iot.taxableBase as Base,
pgc.rate as Tipo,
iot.vat as Cuota,
pgc.name as Concepto
FROM vn.invoiceOut io
JOIN vn.invoiceOutTax iot ON iot.invoiceOutFk = io.id
JOIN vn.client c ON c.id = io.clientFk
JOIN vn.pgc ON pgc.code = iot.pgcFk
WHERE io.companyFk = vCompany
AND io.issued BETWEEN vStarted AND vEnded
ORDER BY io.ref DESC;
END$$
DELIMITER ;