From 2e01b6ee0a9ef4a3d187e7589e02a1d6d4a109c2 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 19 Feb 2024 09:55:54 +0100 Subject: [PATCH 1/2] refactor(packing): refs #6875 add restriction on vn.buy.packing field not null and > 0 --- db/routines/vn/procedures/inventoryMake.sql | 2 +- db/versions/10892-yellowGerbera/00-firstScript.sql | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/versions/10892-yellowGerbera/00-firstScript.sql diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index 0def763dc..abf185c9f 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -182,7 +182,7 @@ proc: BEGIN LEFT JOIN producer p ON p.id = i.producerFk SET inv.buyingValue = b.buyingValue, inv.freightValue = b.freightValue, - inv.packing = b.packing, + inv.packing = IFNULL(GREATEST(b.packing, 1), 1), inv.`grouping`= b.`grouping`, inv.groupingMode = b.groupingMode, inv.comissionValue = b.comissionValue, diff --git a/db/versions/10892-yellowGerbera/00-firstScript.sql b/db/versions/10892-yellowGerbera/00-firstScript.sql new file mode 100644 index 000000000..4df616f3a --- /dev/null +++ b/db/versions/10892-yellowGerbera/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here + +UPDATE vn.buy + SET packing = 1 + WHERE packing IS NULL + OR NOT packing + +ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); + +-- antes tenia '0=sin obligar 1=groping 2=packing' +ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing'; + From 11dcb6e79f22b187e5259216a0d2e1b46f85bb77 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Mar 2024 13:45:57 +0100 Subject: [PATCH 2/2] refactor: refs #6875 packing not null, negative or zero --- db/routines/vn/procedures/inventoryMake.sql | 2 +- db/routines/vn/procedures/inventory_repair.sql | 7 +------ .../10892-yellowGerbera/00-firstScript.sql | 17 ++++++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index 8788336ae..ed6a7fa43 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -175,7 +175,7 @@ BEGIN LEFT JOIN producer p ON p.id = i.producerFk SET inv.buyingValue = b.buyingValue, inv.freightValue = b.freightValue, - inv.packing = IFNULL(GREATEST(b.packing, 1), 1), + inv.packing = b.packing, inv.`grouping`= b.`grouping`, inv.groupingMode = b.groupingMode, inv.comissionValue = b.comissionValue, diff --git a/db/routines/vn/procedures/inventory_repair.sql b/db/routines/vn/procedures/inventory_repair.sql index ea65ac37d..93527d84b 100644 --- a/db/routines/vn/procedures/inventory_repair.sql +++ b/db/routines/vn/procedures/inventory_repair.sql @@ -37,7 +37,7 @@ BEGIN LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO'; + WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO'; DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk; CREATE TEMPORARY TABLE tmp.lastEntryOk @@ -94,11 +94,6 @@ BEGIN JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk SET b.price2 = eo.price2 WHERE b.price2 = 0 ; - UPDATE buy b - JOIN tmp.lastEntry lt ON lt.buyFk = b.id - JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk - SET b.packing = eo.packing WHERE b.packing = 0; - UPDATE buy b JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk diff --git a/db/versions/10892-yellowGerbera/00-firstScript.sql b/db/versions/10892-yellowGerbera/00-firstScript.sql index 4df616f3a..76c0cb46d 100644 --- a/db/versions/10892-yellowGerbera/00-firstScript.sql +++ b/db/versions/10892-yellowGerbera/00-firstScript.sql @@ -1,12 +1,15 @@ --- Place your SQL code here - UPDATE vn.buy - SET packing = 1 - WHERE packing IS NULL - OR NOT packing + SET packing = 1 + WHERE packing IS NULL + OR packing <= 0; + +UPDATE vn.itemShelving + SET packing = 1 + WHERE packing IS NULL + OR NOT packing; ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); +ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); --- antes tenia '0=sin obligar 1=groping 2=packing' +-- Antes tenia '0=sin obligar 1=groping 2=packing' (groping → grouping) ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing'; -