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

24 lines
621 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTax_afterUpsert`(vInvoiceInFk INT)
BEGIN
/**
* Triggered actions when a invoiceInTax is updated or inserted.
*
* @param vInvoiceInFk The invoiceIn id
*/
DECLARE vTaxRowLimit INT;
DECLARE vLines INT;
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
SELECT COUNT(*) INTO vLines
FROM invoiceInTax
2024-01-25 16:33:54 +00:00
WHERE invoiceInFk = vInvoiceInFk
AND (taxTypeSageFk OR transactionTypeSageFk);
IF vLines >= vTaxRowLimit THEN
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
END IF;
END$$
DELIMITER ;