2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(
|
2024-03-14 07:36:19 +00:00
|
|
|
vDuaFk INT
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
2024-02-15 09:04:15 +00:00
|
|
|
/**
|
2024-03-14 07:36:19 +00:00
|
|
|
* Borra los valores de duaTax y sus vctos. y los vuelve a
|
|
|
|
* crear en base a la tabla duaEntry.
|
2024-02-15 09:04:15 +00:00
|
|
|
*
|
|
|
|
* @param vDuaFk Id del dua a recalcular
|
|
|
|
*/
|
|
|
|
DECLARE vDone BOOL DEFAULT FALSE;
|
2024-01-15 11:31:03 +00:00
|
|
|
DECLARE vInvoiceInFk INT;
|
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
DECLARE vInvoices CURSOR FOR
|
|
|
|
SELECT DISTINCT invoiceInFk
|
|
|
|
FROM entry e
|
|
|
|
JOIN duaEntry de ON de.entryFk = e.id
|
|
|
|
WHERE de.duaFk = vDuaFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
OPEN vInvoices;
|
|
|
|
l: LOOP
|
|
|
|
SET vDone = FALSE;
|
|
|
|
FETCH vInvoices INTO vInvoiceInFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
IF vDone THEN
|
|
|
|
LEAVE l;
|
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-03-14 07:36:19 +00:00
|
|
|
CALL invoiceInTax_recalc(vInvoiceInFk);
|
2024-01-15 11:31:03 +00:00
|
|
|
CALL invoiceInDueDay_recalc(vInvoiceInFk);
|
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
END LOOP;
|
|
|
|
CLOSE vInvoices;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|