fix: refs #8030 warehouse filter
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

Warehouse is also needed to make the filter

Refs: #8030
This commit is contained in:
Pako Natek 2024-09-24 09:05:30 +02:00
parent acabd3e154
commit fb7208d898
2 changed files with 12 additions and 7 deletions

View File

@ -30,10 +30,9 @@ BEGIN
ENGINE = MEMORY ENGINE = MEMORY
SELECT i.id itemFk, SELECT i.id itemFk,
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing,
pd.warehouseFk
FROM vn.item i 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 JOIN tmp.priceDelta pd
ON pd.itemTypeFk = i.typeFk ON pd.itemTypeFk = i.typeFk
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) 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) tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0)
FROM tmp.ticketComponentBase tcb FROM tmp.ticketComponentBase tcb
JOIN component c ON c.code = 'bonus' 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 -- RECOBRO
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)

View File

@ -1,6 +1,8 @@
-- vn.priceDelta definition -- 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, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`itemTypeFk` smallint(5) unsigned NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL,
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
@ -12,12 +14,14 @@ CREATE OR REPLACE TABLE vn.priceDelta (
`toDated` date DEFAULT NULL, `toDated` date DEFAULT NULL,
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost 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`), PRIMARY KEY (`id`),
KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_itemType_FK` (`itemTypeFk`),
KEY `priceDelta_ink_FK` (`inkFk`), KEY `priceDelta_ink_FK` (`inkFk`),
KEY `priceDelta_producer_FK` (`producerFk`), 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_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_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'; ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';