refactor: refs #6875 Add restriction on vn.buy.packing field not null and > 0 #2047

Merged
guillermo merged 3 commits from 6875-packingNotNull into dev 2024-03-14 08:05:12 +00:00
3 changed files with 12 additions and 14 deletions
Showing only changes of commit 11dcb6e79f - Show all commits

View File

@ -175,7 +175,7 @@ BEGIN
LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN producer p ON p.id = i.producerFk
SET inv.buyingValue = b.buyingValue, SET inv.buyingValue = b.buyingValue,
inv.freightValue = b.freightValue, inv.freightValue = b.freightValue,
inv.packing = IFNULL(GREATEST(b.packing, 1), 1), inv.packing = b.packing,
inv.`grouping`= b.`grouping`, inv.`grouping`= b.`grouping`,
inv.groupingMode = b.groupingMode, inv.groupingMode = b.groupingMode,
inv.comissionValue = b.comissionValue, inv.comissionValue = b.comissionValue,

View File

@ -37,7 +37,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk ) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id 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; DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE 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 JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ; 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 UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk

View File

@ -1,12 +1,15 @@
-- Place your SQL code here
UPDATE vn.buy UPDATE vn.buy
SET packing = 1 SET packing = 1
WHERE packing IS NULL WHERE packing IS NULL
OR NOT packing OR packing <= 0;
UPDATE vn.itemShelving
SET packing = 1
WHERE packing IS NULL
guillermo marked this conversation as resolved Outdated

aprofitar per a posar el camp com a unsigned, ja que hi ha negatius, els valors actuals posarlos a uno, els mes recients son de agost.

aprofitar per a posar el camp com a unsigned, ja que hi ha negatius, els valors actuals posarlos a uno, els mes recients son de agost.
OR NOT packing;
ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); 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'; ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing';