From 95601b139ba9d2585d13fc56a53305d067b9c489 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 30 Sep 2024 08:15:57 +0200 Subject: [PATCH] feat(priceDelta): refs #8030 new field zoneGeoFk Buyers need zone restriction field for the new component bonus Refs: #8030 --- db/routines/vn/procedures/catalog_componentCalculate.sql | 2 ++ db/versions/11271-blackMastic/00-firstScript.sql | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 db/versions/11271-blackMastic/00-firstScript.sql diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index d4ce88ca7..b49f7ad8a 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -41,8 +41,10 @@ BEGIN AND (pd.originFk IS NULL OR pd.originFk = i.originFk) AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk) AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk) + LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped) AND (pd.toDated IS NULL OR pd.toDated >= vShipped) + AND (pd.zoneGeoFk IS NULL OR address_getGeo(vAddressFk) BETWEEN zg.lft AND zg.rgt) GROUP BY i.id; CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice diff --git a/db/versions/11271-blackMastic/00-firstScript.sql b/db/versions/11271-blackMastic/00-firstScript.sql new file mode 100644 index 000000000..dcc8349a5 --- /dev/null +++ b/db/versions/11271-blackMastic/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL COMMENT 'Application area for the bonus component'; +ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;