From 6177546444705d9c1fbd214395f88ddcf950b69e Mon Sep 17 00:00:00 2001 From: Rikard Bartholf Date: Fri, 9 Dec 2016 13:21:26 +0100 Subject: [PATCH] P5-883 Add listprice to eSales export --- migrations/000.020.sql | 78 ++++++++++++++++++++++++++++++++++++++++++ migrations/000.021.sql | 19 ++++++++++ 2 files changed, 97 insertions(+) create mode 100644 migrations/000.020.sql create mode 100644 migrations/000.021.sql diff --git a/migrations/000.020.sql b/migrations/000.020.sql new file mode 100644 index 0000000..5bc65b7 --- /dev/null +++ b/migrations/000.020.sql @@ -0,0 +1,78 @@ +DROP MATERIALIZED VIEW IF EXISTS v_esales_printproduct; +CREATE MATERIALIZED VIEW v_esales_printproduct AS +SELECT main.id, + main.product_id, + main.path, + main.article_number, + main.title, + main.group_id, + main.group_name, + main.type_id, + main.type_name, + main.price, + CASE main.group_id + -- Minimum canvas price without frame + WHEN 2 THEN main.price * 0.2 + ELSE main.price + END AS list_price, + main.image, + main.thumbnail, + main.width, + main.height, + CASE + WHEN main.width::integer > main.height::integer THEN 'landscape'::text + WHEN main.width::integer < main.height::integer THEN 'portrait'::text + ELSE 'square'::text + END AS orientation + FROM ( + SELECT pp.printid AS id, + pp.productid AS product_id, + (SELECT path FROM "product-products" WHERE productid = pp.productid LIMIT 1) AS path, + ( + SELECT value FROM "product-products_fields" WHERE productid = pp.productid + AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = 'artNo' LIMIT 1) + ) AS article_number, + ( + SELECT value FROM "product-products_fields" WHERE productid = pp.productid + AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = 'name' LIMIT 1) + ) AS title, + pp.groupid AS group_id, + ( + SELECT "group" + FROM "product-groups" + WHERE groupid = pp.groupid + LIMIT 1 + ) AS group_name, + pp.typeid AS type_id, + ( + SELECT type + FROM "product-types" + WHERE typeid = pp.typeid + LIMIT 1 + ) AS type_name, + ( + ( + SELECT min(price) AS min + FROM "product-printprices" + WHERE groupid = pp.groupid + ) * COALESCE( + ( + SELECT 1 + designers.pricepremium / 100 + FROM designers + WHERE designers.designerid = ( + SELECT designerid FROM "product-products" WHERE productid = pp.productid LIMIT 1) + ), 1) + ) AS price, + ('//images.photowall.com/products/' || pp.productid) || '.jpg' AS image, + ('//images.photowall.com/products/' || pp.productid) || '.jpg?w=80' AS thumbnail, + (SELECT value FROM "product-products_fields" WHERE productid = pp.productid AND fieldid = 5 LIMIT 1) AS width, + (SELECT value FROM "product-products_fields" WHERE productid = pp.productid AND fieldid = 3 LIMIT 1) AS height + FROM "product-printproducts" pp + ) main; + +-- DROP INDEX v_categorytree_i18n_id_locale_id; +CREATE UNIQUE INDEX v_esales_printproduct_id + ON v_esales_printproduct (id); + +CREATE INDEX v_esales_printproduct_product_id + ON v_esales_printproduct (product_id); diff --git a/migrations/000.021.sql b/migrations/000.021.sql new file mode 100644 index 0000000..fad299d --- /dev/null +++ b/migrations/000.021.sql @@ -0,0 +1,19 @@ +-- P5-883 +UPDATE "i18n-territories" SET vat = 1; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'SE'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'DK'; +UPDATE "i18n-territories" SET vat = 1.24 WHERE iso2char = 'FI'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'NO'; +UPDATE "i18n-territories" SET vat = 1.20 WHERE iso2char = 'GB'; +UPDATE "i18n-territories" SET vat = 1.19 WHERE iso2char = 'DE'; +UPDATE "i18n-territories" SET vat = 1.21 WHERE iso2char = 'NL'; +UPDATE "i18n-territories" SET vat = 1.20 WHERE iso2char = 'AT'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'FR'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'ES'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'PL'; +UPDATE "i18n-territories" SET vat = 1.25 WHERE iso2char = 'LT'; +-- All EU countries, except those above, should have vat set to 1.25 +UPDATE "i18n-territories" + SET vat = 1.25 + WHERE iso2char IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','EU','FI','FR','GB','GR','HU','IE','IT','LT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK', 'HR') + AND vat = 1;