P5-883 Add listprice to eSales export

This commit is contained in:
Rikard Bartholf
2016-12-09 13:21:26 +01:00
parent 0400556a2f
commit 6177546444
2 changed files with 97 additions and 0 deletions
+78
View File
@@ -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);
+19
View File
@@ -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;