From fb7208d898278a5e6806b04d51512e26ad19f8b9 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 09:05:30 +0200 Subject: [PATCH] fix: refs #8030 warehouse filter Warehouse is also needed to make the filter Refs: #8030 --- .../vn/procedures/catalog_componentCalculate.sql | 9 +++++---- db/versions/11258-silverTulip/00-firstScript.sql | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 0b131d7a9..f13675e4b 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -30,10 +30,9 @@ BEGIN ENGINE = MEMORY SELECT i.id itemFk, SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, - SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing + SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, + pd.warehouseFk FROM vn.item i - JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk - JOIN buy b ON b.id = lb.buy_id JOIN tmp.priceDelta pd ON pd.itemTypeFk = i.typeFk AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) @@ -138,7 +137,9 @@ BEGIN tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0) FROM tmp.ticketComponentBase tcb JOIN component c ON c.code = 'bonus' - JOIN tPriceDelta tpd ON tpd.itemFk = tcb.itemFk; + JOIN tPriceDelta tpd + ON tpd.itemFk = tcb.itemFk + AND tpd.warehouseFk = tcb.warehouseFk; -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index 753c279c0..6f0f1906a 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -1,6 +1,8 @@ -- vn.priceDelta definition -CREATE OR REPLACE TABLE vn.priceDelta ( +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.`priceDelta` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', @@ -12,12 +14,14 @@ CREATE OR REPLACE TABLE vn.priceDelta ( `toDated` date DEFAULT NULL, `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', - `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_ink_FK` (`inkFk`), KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file