From 1cd495df06984f6d43d5bd60f96cc765bd06649b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 09:25:33 +0100 Subject: [PATCH 1/3] fix: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 3b5ce5247..8c4015bc3 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -11,7 +11,7 @@ BEGIN */ DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; - DECLARE vExpenseFk INT; + DECLARE vExpenseFk VARCHAR(10); SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr From d0067c80967b9a8b20b0cb696922b89869fd756f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 11:30:10 +0100 Subject: [PATCH 2/3] ticket #167473 Hotfix --- db/routines/bs/procedures/ventas_contables_add.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 12b2738f3..9e2b75f6d 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -23,7 +23,7 @@ BEGIN ENGINE = MEMORY SELECT Id_Ticket FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + JOIN vn.invoiceOut io ON io.`ref` = t.Factura WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -47,12 +47,7 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk - + IF(e.empresa_grupo = e2.empresa_grupo - ,1 - ,IF(e2.empresa_grupo,2,0) - ) * 100000 - + tp.reino_id * 1000 as Gasto + , a.expenseFk gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna From 2b26153bfa597fcd84f200a292f03aa2daad672c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:52:04 +0100 Subject: [PATCH 3/3] refactor: refs #7018 Requested changes --- db/routines/bs/procedures/ventas_contables_add.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 9e2b75f6d..66c012a19 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -47,7 +47,12 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk gasto + , a.expenseFk + + IF(e.empresa_grupo = e2.empresa_grupo + ,1 + ,IF(e2.empresa_grupo,2,0) + ) * 100000 + + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna