From f30a5a759767666f9778a7a887c13e179f4f9946 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 21 Feb 2024 13:13:28 +0100 Subject: [PATCH 1/2] refs #6626 invoiceInTax different transactions --- .../vn/procedures/invoiceInTax_afterUpsert.sql | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 77e989630..3a81cd531 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -8,6 +8,7 @@ BEGIN */ DECLARE vTaxRowLimit INT; DECLARE vLines INT; + DECLARE vHasDistinctTransactions INT; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; @@ -18,6 +19,18 @@ BEGIN IF vLines >= vTaxRowLimit THEN CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit)); - END IF; + END IF; + + SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions + FROM invoiceIn ii + JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + JOIN invoiceInSerial iis ON iis.code = ii.serial + WHERE ii.id = vInvoiceInFk + AND iis.taxAreaFk = 'CEE' + AND transactionTypeSageFk; + + IF vHasDistinctTransactions > 1 THEN + CALL util.throw ('This invoice does not allow diferent types of transactions'); + END IF; END$$ DELIMITER ; From 84270d29b8b875411e64ce8e9996406ecc83b900 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 21 Feb 2024 13:15:46 +0100 Subject: [PATCH 2/2] refs #6626 modify invoiceInTax --- db/routines/vn/procedures/invoiceInTax_afterUpsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 3a81cd531..60ec34696 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -30,7 +30,7 @@ BEGIN AND transactionTypeSageFk; IF vHasDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow diferent types of transactions'); + CALL util.throw ('This invoice does not allow different types of transactions'); END IF; END$$ DELIMITER ;