From 477fb7ded944fe37bacd00ad2d87a50ac8e0fda1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 14:27:54 +0100 Subject: [PATCH 1/2] feat: refs #8149 Group by CuentaIvaRepercutido --- db/routines/vn/procedures/invoiceIn_booking.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 36189afcc..cfe3adb0b 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -219,7 +219,7 @@ BEGIN ) eWithheld ON TRUE WHERE tii.taxTypeSageFk IS NOT NULL AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21')) - GROUP BY tii.PorcentajeIva, tii.expenseFk; + GROUP BY tii.CuentaIvaRepercutido; -- Línea iva inversor sujeto pasivo INSERT INTO XDiario( @@ -284,7 +284,7 @@ BEGIN AND NOT(tii.isVies AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk AND tii.taxCode = 'nonTaxable') - GROUP BY tii.PorcentajeIva, tii.expenseFk; + GROUP BY tii.CuentaIvaRepercutido; -- Actualización del registro original UPDATE invoiceIn ii -- 2.40.1 From 4ab2d7fd09c8e67edfe2c523b42b5ada07460b33 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 22 Nov 2024 12:59:24 +0100 Subject: [PATCH 2/2] feat: refs #8149 Group by CuentaIvaRepercutido --- db/routines/sage/procedures/invoiceIn_add.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index 0898d6810..1d411cfd0 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -26,7 +26,7 @@ BEGIN DECLARE vCursor CURSOR FOR SELECT it.taxableBase, - CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), + CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, it.taxTypeSageFk, @@ -39,7 +39,8 @@ BEGIN JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk LEFT JOIN vn.dua d ON d.id = vInvoiceInFk WHERE i.id = vInvoiceInFk - AND d.id IS NULL; + AND d.id IS NULL + GROUP BY it.taxTypeSageFk; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -- 2.40.1