PW-721 new canvas price formula
This commit is contained in:
+20
-67
@@ -54,7 +54,7 @@ def wallpaper_price(width, height, material, market, designer=None, reseller=Non
|
||||
|
||||
|
||||
def canvas_cm2_price(cm2):
|
||||
price_cm2_at_1cm2 = 0.224
|
||||
price_cm2_at_1cm2 = 0.2461
|
||||
price_cm2_at_5000cm2 = 0.144
|
||||
price_cm2_at_10000cm2 = 0.096
|
||||
price_cm2_at_22500cm2 = 0.064
|
||||
@@ -78,64 +78,30 @@ def canvas_cm2_price(cm2):
|
||||
return cm2_price
|
||||
|
||||
|
||||
def canvas_price(width, height, market, framed=True, designer=None, reseller=None, inc_vat=True):
|
||||
def canvas_price(width, height, market, framed=True, designer=None, reseller=None, inquiry=None, rounded=True, inc_vat=True):
|
||||
cm2 = width * height
|
||||
|
||||
# get the price per cm2
|
||||
cm2_price = canvas_cm2_price(cm2)
|
||||
|
||||
# calculate price for canvas with frame
|
||||
price = (cm2 * cm2_price)
|
||||
price = max(price, 396.8) # the price can never go below 396.8 SEK
|
||||
price = cm2 * cm2_price
|
||||
price = max(price, 341.4848) # the price can never go below 341.4848 SEK
|
||||
|
||||
if not framed:
|
||||
price *= 0.7
|
||||
|
||||
# add designer price premium
|
||||
if designer:
|
||||
price *= (float(designer.pricepremium) / 100) + 1
|
||||
|
||||
# add reseller price premium
|
||||
if reseller:
|
||||
price *= (float(reseller.pricepremium) / 100) + 1
|
||||
|
||||
# exchange to local currency
|
||||
price *= market.exchange_rate
|
||||
if inquiry:
|
||||
price *= (float(inquiry.pricepremium) / 100) + 1
|
||||
|
||||
# multiply price with market price adjustments
|
||||
price *= market.exchange_rate
|
||||
price *= market.price_adjustments
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
return round(price)
|
||||
|
||||
|
||||
def canvas_frame_price(width, height, stock_price, market, additional_price=None, reseller=None, rounded=True, inc_vat=True):
|
||||
width, height = calculate_canvas_limits(width, height, framed=True)
|
||||
circumference = (2 * width) + (2 * height)
|
||||
circumference = max(circumference, 170)
|
||||
|
||||
price = stock_price * circumference
|
||||
|
||||
# if width or height goes above this limit additional costs are added
|
||||
if additional_price:
|
||||
additional_price_limit = 120
|
||||
if width > additional_price_limit or height > additional_price_limit:
|
||||
price += additional_price
|
||||
|
||||
# exchange to local currency
|
||||
price *= market.exchange_rate
|
||||
|
||||
# multiply price with market price adjustments
|
||||
price *= market.price_adjustments
|
||||
|
||||
# add reseller price premium
|
||||
if reseller:
|
||||
price *= (float(reseller.pricepremium) / 100) + 1
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
@@ -145,33 +111,20 @@ def canvas_frame_price(width, height, stock_price, market, additional_price=None
|
||||
return price
|
||||
|
||||
|
||||
def old_canvas_diy_frame_price(width, height, market, reseller=None, rounded=True, inc_vat=True):
|
||||
# todo: when product models are in place we should use stockproduct ""Do it yourself frame""
|
||||
# instead of hardcoded values
|
||||
stock_price = 1.61084
|
||||
additional_price = 94.750000
|
||||
return canvas_frame_price(width, height, stock_price, market, additional_price, reseller=reseller, rounded=rounded, inc_vat=inc_vat)
|
||||
def canvas_frame_price(width, height, market, reseller=None, rounded=True, inc_vat=True):
|
||||
width, height = calculate_canvas_limits(width, height, framed=True)
|
||||
cm2 = width * height
|
||||
cm2_price = canvas_cm2_price(cm2)
|
||||
price = cm2 * cm2_price
|
||||
price = max(price, 317.44)
|
||||
price *= 0.65
|
||||
|
||||
if reseller:
|
||||
price *= (float(reseller.pricepremium) / 100) + 1
|
||||
|
||||
def old_canvas_price(width, height, material, market, framed=True, designer=None, reseller=None, inquiry=None, rounded=True, inc_vat=True):
|
||||
width, height = calculate_canvas_limits(width, height, framed)
|
||||
price = m2_price(material, market, designer, reseller,
|
||||
inquiry, rounded=False, inc_vat=False)
|
||||
price *= market.exchange_rate
|
||||
price *= market.price_adjustments
|
||||
|
||||
# calculate square meter
|
||||
sqm = (width / 100) * (height / 100)
|
||||
sqm = max(sqm, 0.2) # sqm can never go below 0.2
|
||||
price *= sqm
|
||||
|
||||
if framed:
|
||||
# todo: when product models are in place we should use stockproduct
|
||||
# "Canvasframe" instead of hardcoded values
|
||||
stock_price = 1.04230824
|
||||
additional_price = 94.750000
|
||||
price += canvas_frame_price(width, height, stock_price, market,
|
||||
additional_price=additional_price, reseller=reseller, rounded=False, inc_vat=False)
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
@@ -191,8 +144,8 @@ def inquiry_price(inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, *
|
||||
price = wallpaper_price(width, height, material, inquiry.market,
|
||||
designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, rounded=False, inc_vat=False)
|
||||
elif inquiry.product_group == 'canvas':
|
||||
price = old_canvas_price(width, height, material, inquiry.market,
|
||||
designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, framed=framed, rounded=False, inc_vat=False)
|
||||
price = canvas_price(width, height, inquiry.market,
|
||||
designer=inquiry.designer, reseller=inquiry.dealer_store, inquiry=inquiry, framed=framed, rounded=False, inc_vat=False)
|
||||
else:
|
||||
raise ValueError(
|
||||
'Invalid product group: {}'.format(inquiry.product_group))
|
||||
|
||||
Reference in New Issue
Block a user