From 8e33c1b102bb2bab0648fe26c8b8bd79921cf37f Mon Sep 17 00:00:00 2001 From: Ruslan Getmansky Date: Wed, 6 Dec 2017 16:24:47 +0200 Subject: [PATCH] PW-865: Piterra bug fix --- api/lib/prices.py | 5 +++-- api/resources/prices.py | 6 ++++-- docs/prices.md | 2 ++ tests/lib/test_prices.py | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/lib/prices.py b/api/lib/prices.py index 73f32b1..e7aadf5 100644 --- a/api/lib/prices.py +++ b/api/lib/prices.py @@ -139,13 +139,14 @@ def inquiry_price(inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, * height = kwargs.get('height', inquiry.height) material = kwargs.get('material', inquiry.material) framed = kwargs.get('framed', inquiry.framed) + reseller = kwargs.get('reseller', inquiry.dealer_store) if inquiry.product_group == 'photo-wallpaper': price = wallpaper_price(width, height, material, inquiry.market, - designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, rounded=False, inc_vat=False) + designer=inquiry.designer, reseller=reseller, inquiry=inquiry, rounded=False, inc_vat=False) elif inquiry.product_group == 'canvas': price = canvas_price(width, height, inquiry.market, - designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, framed=framed, rounded=False, inc_vat=False) + designer=inquiry.designer, reseller=reseller, inquiry=inquiry, framed=framed, rounded=False, inc_vat=False) else: raise ValueError( 'Invalid product group: {}'.format(inquiry.product_group)) diff --git a/api/resources/prices.py b/api/resources/prices.py index e88bab3..beaad2d 100644 --- a/api/resources/prices.py +++ b/api/resources/prices.py @@ -144,7 +144,8 @@ def inquiry_wallpaper(inquiry): 'm2_price_excl_vat': m2_price(material, inquiry.market, designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, rounded=False, inc_vat=False), 'inquiry_price_excl_retouch': inquiry_price(inquiry, material=material, width=width, height=height, rounded=False, inc_price_retouch=False, inc_vat=True), 'inquiry_price': inquiry_price(inquiry, material=material, width=width, height=height, rounded=False, inc_vat=True), - 'inquiry_price_excl_vat': inquiry_price(inquiry, material=material, width=width, height=height, rounded=False, inc_vat=False) + 'inquiry_price_excl_vat': inquiry_price(inquiry, material=material, width=width, height=height, rounded=False, inc_vat=False), + 'inquiry_price_excl_price_premium': inquiry_price(inquiry, material=material, width=width, height=height, reseller=None, inc_price_retouch=False, rounded=False, inc_vat=False) }) data['prices'] = prices return data @@ -170,7 +171,8 @@ def inquiry_canvas(inquiry): 'height': height, 'inquiry_price_excl_retouch': inquiry_price(inquiry, material=material, width=width, height=height, framed=framed, rounded=False, inc_price_retouch=False, inc_vat=True), 'inquiry_price': inquiry_price(inquiry, material=material, width=width, height=height, framed=framed, rounded=False, inc_vat=True), - 'inquiry_price_excl_vat': inquiry_price(inquiry, material=material, width=width, height=height, framed=framed, rounded=False, inc_vat=False) + 'inquiry_price_excl_vat': inquiry_price(inquiry, material=material, width=width, height=height, framed=framed, rounded=False, inc_vat=False), + 'inquiry_price_excl_price_premium': inquiry_price(inquiry, material=material, width=width, height=height, reseller=None, inc_price_retouch=False, framed=framed, rounded=False, inc_vat=False) }) data['prices'] = prices diff --git a/docs/prices.md b/docs/prices.md index 9dd9ec8..5f8fcec 100644 --- a/docs/prices.md +++ b/docs/prices.md @@ -142,6 +142,7 @@ Sample response "inquiry_price": 3595.50219975, "inquiry_price_excl_retouch": 3595.50219975, "inquiry_price_excl_vat": 2876.4017598, + "inquiry_price_excl_price_premium": 2876.4017598, "m2_price": 268.72213750000003, "m2_price_excl_vat": 214.97771, "material": "standard-wallpaper", @@ -151,6 +152,7 @@ Sample response "inquiry_price": 3961.1464912499996, "inquiry_price_excl_retouch": 3961.1464912499996, "inquiry_price_excl_vat": 3168.9171929999998, + "inquiry_price_excl_price_premium": 3168.9171929999998, "m2_price": 296.04981250000003, "m2_price_excl_vat": 236.83985, "material": "premium-wallpaper", diff --git a/tests/lib/test_prices.py b/tests/lib/test_prices.py index a93f20d..77ba3b8 100644 --- a/tests/lib/test_prices.py +++ b/tests/lib/test_prices.py @@ -215,6 +215,9 @@ class TestPrice(unittest2.TestCase): inquiry, inc_price_retouch=False)) self.assertEqual(152, inquiry_price( inquiry, inc_price_retouch=False, material=premium_wallpaper)) + # test set reseller store to None to calculate inquiry price without reseller price premium + self.assertEqual(102, inquiry_price( + inquiry, inc_price_retouch=False, reseller=None)) def test_canvas_custom_inquiry_price(self): with mock.patch.object(Inquiry, 'market', sweden):