From da96b4c183ddb235677984dbee28f25543ff948c Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 8 Aug 2016 15:19:54 +0200 Subject: [PATCH] PW-349 change minium price for wallpaper on US to 2sqm --- api/lib/prices.py | 9 ++++++++- tests/test_price.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/lib/prices.py b/api/lib/prices.py index 7b5f9d8..24e7b13 100644 --- a/api/lib/prices.py +++ b/api/lib/prices.py @@ -22,7 +22,14 @@ def wallpaper_price(width, height, material_price, market, designer=None, resell # calculate price per square meter sqm = (width / 100) * (height / 100) - sqm = max(sqm, 1) + + if market.territory == "US": + min_sqm = 2 + else: + min_sqm = 1 + + sqm = max(sqm, min_sqm) + price = sqm * m2_price # add vat diff --git a/tests/test_price.py b/tests/test_price.py index ba6d0f3..480b1cf 100644 --- a/tests/test_price.py +++ b/tests/test_price.py @@ -14,6 +14,10 @@ denmark = market.from_territory('DK') denmark.price_adjustments = 1.185 denmark.exchange_rate = 0.799000 +us = market.from_territory('US') +us.price_adjustments = 1.05 +us.exchange_rate = 0.119800 + designer = DesignerFactory() designer.pricepremium = 17.647 reseller = ContractCustomerFactory(pricepremium=15) @@ -49,6 +53,10 @@ class TestPrice(unittest2.TestCase): self.assertEqual(154, wallpaper_price(width=100, height=100, material_price=236, market=sweden, reseller=ContractCustomerFactory(pricepremium=-47.74))) + def test_wallpaper_price_us(self): + self.assertEqual(59, wallpaper_price(width=100, height=100, + material_price=236, market=us), "Minium price for US is 2 sqm") + def test_canvas_cm2_price(self): self.assertEqual(0.22, canvas_cm2_price(250)) self.assertEqual(0.22384, canvas_cm2_price(10))