24 lines
624 B
SQL
24 lines
624 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`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
|
|
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 ;
|