P5-4394 add framed-prints price formulas

This commit is contained in:
Martin
2019-10-31 14:16:22 +01:00
parent 0dd8d619b4
commit 95a264af99
5 changed files with 132 additions and 0 deletions
+44
View File
@@ -296,6 +296,50 @@ def _price_for_poster_hanger_size(size):
raise ValueError("Invalid poster hanger size: {}".format(size))
def framed_print_price(
sku, market, designer=None, reseller=None, inquiry=None, rounded=True, inc_vat=True
):
sku_prices = {
"GLOBAL-CFP-12x12": 446,
"GLOBAL-CFP-11x14": 478,
"GLOBAL-CFP-12x16": 494,
"GLOBAL-CFP-16x20": 574,
"GLOBAL-CFP-20x20": 690,
"GLOBAL-CFP-18x24": 708,
"GLOBAL-CFP-20x28": 761,
"GLOBAL-CFP-24x32": 831,
"GLOBAL-CFP-28x28": 867,
"GLOBAL-CFP-24x36": 1035,
"GLOBAL-CFP-28x40": 1127,
}
if not sku in sku_prices:
raise ValueError("Invalid SKU number: {}".format(sku))
price = sku_prices[sku]
price *= market.price_adjustments
if designer:
price *= (float(designer.pricepremium) / 100) + 1
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
if inquiry:
price *= (float(inquiry.pricepremium) / 100) + 1
price *= market.exchange_rate
if inc_vat:
price *= market.vat
if rounded:
price = round_half_up(price)
return price
def inquiry_price(
inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, **kwargs
):
+34
View File
@@ -11,6 +11,7 @@ from api.lib.prices import (
canvas_frame_price,
poster_price,
poster_hanger_price,
framed_print_price,
m2_price,
inquiry_price,
)
@@ -239,6 +240,39 @@ def poster_hanger():
return jsonify(data=data)
@mod.route("/framed-print", methods=["GET"])
@validate_territory("territory")
def framed_print():
sku = request.args.get("sku", type=str)
market = market_model.from_territory(request.args.get("territory"))
reseller = get_reseller()
designer = get_designer()
data = [
{
"sku": sku,
"price": framed_print_price(
sku,
market,
designer=designer,
reseller=reseller,
rounded=False,
inc_vat=True,
),
"price_excl_vat": framed_print_price(
sku,
market,
designer=designer,
reseller=reseller,
rounded=False,
inc_vat=False,
),
}
]
return jsonify(data=data)
def get_inquiry_measurements(inquiry):
""" this function returns width and height to be used in the price calculations """