2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`invoiceInTax_afterUpsert`(vInvoiceInFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
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);
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
IF vLines >= vTaxRowLimit THEN
|
|
|
|
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
|
2024-02-21 12:13:28 +00:00
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|