From b6437b3d25cbf66260bb6e19c9eb8fe9b1408bc7 Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Mon, 17 Feb 2020 09:46:00 +0100 Subject: [PATCH] P5-4805 add framed print inquiries --- api/lib/prices.py | 11 +++++++++++ api/resources/prices.py | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/api/lib/prices.py b/api/lib/prices.py index 7d351d3..594ebfd 100644 --- a/api/lib/prices.py +++ b/api/lib/prices.py @@ -443,6 +443,7 @@ def inquiry_price( material = kwargs.get("material", inquiry.material) framed = kwargs.get("framed", inquiry.framed) hanger = kwargs.get("hanger", inquiry.hanger) + sku = kwargs.get("sku") reseller = kwargs.get("reseller", inquiry.dealer_store) if inquiry.product_group == "photo-wallpaper": @@ -481,6 +482,16 @@ def inquiry_price( rounded=False, inc_vat=False, ) + elif inquiry.product_group == "framed-print": + price = framed_print_price( + sku=sku, + market=inquiry.market, + designer=inquiry.designer, + reseller=reseller, + inquiry=inquiry, + 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 1db31b1..0b302e8 100644 --- a/api/resources/prices.py +++ b/api/resources/prices.py @@ -494,16 +494,53 @@ def inquiry_poster(inquiry): return data +def inquiry_framed_print(inquiry): + sku = request.args.get("sku", type=str) + data = { + "id": inquiry.id, + "group": "framed-print", + "retouch_price": inquiry.local_price_retouch(rounded=False, inc_vat=True), + "prices": [ + { + "inquiry_price_excl_retouch": inquiry_price( + inquiry, + sku=sku, + rounded=False, + inc_price_retouch=False, + inc_vat=True, + ), + "inquiry_price": inquiry_price( + inquiry, sku=sku, rounded=False, inc_vat=True + ), + "inquiry_price_excl_vat": inquiry_price( + inquiry, sku=sku, rounded=False, inc_vat=False + ), + "inquiry_price_excl_price_premium": inquiry_price( + inquiry, + sku=sku, + reseller=None, + inc_price_retouch=False, + rounded=False, + inc_vat=False, + ), + } + ], + } + + return data + + @mod.route("/inquiry/", methods=["GET"]) def inquiry(inquiry_id): inquiry = Inquiry.query.get_or_404(inquiry_id) - if inquiry.product_group == "photo-wallpaper": data = inquiry_wallpaper(inquiry) elif inquiry.product_group == "canvas": data = inquiry_canvas(inquiry) elif inquiry.product_group == "poster": data = inquiry_poster(inquiry) + elif inquiry.product_group == "framed-print": + data = inquiry_framed_print(inquiry) else: raise ValueError("Invalid group {}".format(inquiry.product_group))