From b8b055b86c8ed7c2b950cfbefbbabb8b6750d224 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 2 May 2024 08:00:44 +0200 Subject: [PATCH 1/8] hotFix(getBalance): date setHours to 0 --- modules/item/back/methods/item/getBalance.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index d4e2d0f74..20df8eeec 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -27,8 +27,12 @@ module.exports = Self => { const where = filter.where; const query = 'CALL vn.item_getBalance(?, ?, ?)'; - const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); - + let date; + if (where.date) { + date = new Date(where.date); + date.setHours(0, 0, 0, 0); + } + const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, date], myOptions); for (const entry of diary) if (entry.clientType === 'loses') entry.highlighted = true; From 77a1b4bb57cf0a7583a8daf558d285309e10d53c Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 2 May 2024 08:02:17 +0200 Subject: [PATCH 2/8] hotFix(getBalance): simplify --- modules/item/back/methods/item/getBalance.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 20df8eeec..770d8afbd 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -27,12 +27,11 @@ module.exports = Self => { const where = filter.where; const query = 'CALL vn.item_getBalance(?, ?, ?)'; - let date; if (where.date) { - date = new Date(where.date); - date.setHours(0, 0, 0, 0); + where.date = new Date(where.date); + where.date.setHours(0, 0, 0, 0); } - const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, date], myOptions); + const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); for (const entry of diary) if (entry.clientType === 'loses') entry.highlighted = true; From a00dd82f142412aca4a43fef15859a02feb67a26 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 2 May 2024 08:21:39 +0200 Subject: [PATCH 3/8] hotFix(getBalance): if null --- modules/item/back/methods/item/getBalance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 770d8afbd..207f8020f 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -27,7 +27,7 @@ module.exports = Self => { const where = filter.where; const query = 'CALL vn.item_getBalance(?, ?, ?)'; - if (where.date) { + if (where?.date) { where.date = new Date(where.date); where.date.setHours(0, 0, 0, 0); } From 7cb728432ab6a311b159615b8db72b9c35dc87af Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 2 May 2024 10:15:01 +0200 Subject: [PATCH 4/8] fix refs #6889 set originalQuantity to 0 --- db/routines/vn/procedures/collection_addItem.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/routines/vn/procedures/collection_addItem.sql b/db/routines/vn/procedures/collection_addItem.sql index c19d88684..b5bc91c67 100644 --- a/db/routines/vn/procedures/collection_addItem.sql +++ b/db/routines/vn/procedures/collection_addItem.sql @@ -52,6 +52,10 @@ BEGIN SELECT LAST_INSERT_ID() INTO vSaleFk; + UPDATE sale + SET originalQuantity = 0 + WHERE id = vSaleFk; + CALL sale_calculateComponent(vSaleFk, NULL); END$$ DELIMITER ; From 145a477a80ac6dd7b9075ca5fe30bf40e7e6ac09 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 2 May 2024 12:39:12 +0200 Subject: [PATCH 5/8] feat: refs #179918 entry delete isBooked --- db/routines/vn/procedures/clean.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index ed1569935..6552d84cb 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -131,7 +131,8 @@ BEGIN DELETE e FROM entry e - JOIN tEntryToDelete tmp ON tmp.id = e.id; + JOIN tEntryToDelete tmp ON tmp.id = e.id + WHERE e.isBooked = FALSE; -- borrar de route registros menores a 4 años CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete From 00eae3920b05e7ca7b7b2e7aa9693b59b4d4bd52 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 2 May 2024 13:33:25 +0200 Subject: [PATCH 6/8] feat: refs 179918 clean --- db/routines/vn/procedures/clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 6552d84cb..36ef85834 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -132,7 +132,7 @@ BEGIN DELETE e FROM entry e JOIN tEntryToDelete tmp ON tmp.id = e.id - WHERE e.isBooked = FALSE; + WHERE NOT e.isBooked; -- borrar de route registros menores a 4 años CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete From 0b4ac51749ea3dfba2a62e2263f27cea0d45682b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 6 May 2024 13:34:46 +0200 Subject: [PATCH 7/8] fix: Error workerTimeControl_direction Salix --- db/routines/vn/procedures/workerTimeControl_direction.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/workerTimeControl_direction.sql b/db/routines/vn/procedures/workerTimeControl_direction.sql index ce44b9703..f7a68e1e4 100644 --- a/db/routines/vn/procedures/workerTimeControl_direction.sql +++ b/db/routines/vn/procedures/workerTimeControl_direction.sql @@ -26,7 +26,7 @@ BEGIN FROM workerTimeControl WHERE userFk = vWorkerFk AND direction = 'middle' - AND timed BETWEEN vLastIn AND util.VN_NOW(); + AND timed BETWEEN vLastIn AND vTimed; DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; CREATE TEMPORARY TABLE tmp.workerTimeControlDirection From f9348b41ea34ebd7430059119656c33b87191ec6 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 6 May 2024 13:42:19 +0200 Subject: [PATCH 8/8] feat: #7109 inventoryType --- db/routines/vn/procedures/inventoryMake.sql | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index b7ea377d2..30bea6690 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -21,7 +21,7 @@ BEGIN SELECT id FROM warehouse WHERE isInventory; - + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; @@ -38,18 +38,18 @@ BEGIN INTO vMaxRecentInventories, vWarehouseOutFkInventory, vAgencyModeFkInventory - FROM inventoryConfig + FROM inventoryConfig LIMIT 1; - IF vDateLastInventory IS NULL + IF vDateLastInventory IS NULL OR vInventorySupplierFk IS NULL - OR vMaxRecentInventories IS NULL - OR vInventoryDate IS NULL + OR vMaxRecentInventories IS NULL + OR vInventoryDate IS NULL OR vWarehouseOutFkInventory IS NULL OR vAgencyModeFkInventory IS NULL THEN CALL util.throw('Some config parameters are not set'); END IF; - + START TRANSACTION; OPEN cWarehouses; @@ -77,7 +77,7 @@ BEGIN LIMIT 1; IF vTravelFk IS NULL THEN - INSERT INTO travel + INSERT INTO travel SET warehouseOutFk = vWarehouseOutFkInventory, warehouseInFk = vWarehouseFk, shipped = vInventoryDate, @@ -94,15 +94,16 @@ BEGIN SELECT id INTO vEntryFk FROM entry WHERE supplierFk = vInventorySupplierFk - AND travelFk = vTravelFk; + AND travelFk = vTravelFk + AND typeFk = 'inventory'; IF vEntryFk IS NULL THEN - INSERT INTO entry + INSERT INTO entry SET supplierFk = vInventorySupplierFk, isConfirmed = TRUE, isOrdered = TRUE, - travelFk = vTravelFk; - + travelFk = vTravelFk, + typeFk = 'inventory'; SELECT LAST_INSERT_ID() INTO vEntryFk; ELSE DELETE FROM buy WHERE entryFk = vEntryFk; @@ -224,15 +225,15 @@ BEGIN JOIN tInventory i2 ON i2.itemFk = i.id SET i.lastUsed = NOW() WHERE i2.quantity; - + DROP TEMPORARY TABLE tInventory; END LOOP; - + CLOSE cWarehouses; UPDATE config SET inventoried = vInventoryDate; - + CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete (INDEX(entryId)) ENGINE = MEMORY SELECT e.id entryId, @@ -252,7 +253,7 @@ BEGIN WHERE e.supplierFk = vInventorySupplierFk AND t.shipped IN (sub.shipped); - DELETE e + DELETE e FROM `entry` e JOIN tEntryToDelete tmp ON tmp.entryId = e.id;