refactor material prices

This commit is contained in:
Martin
2016-11-01 14:39:59 +01:00
parent bf9fc3ae5a
commit 0663bedc80
7 changed files with 79 additions and 51 deletions
+19 -8
View File
@@ -5,22 +5,33 @@ from api.lib.utils import round_half_up
from api.lib.limits import calculate_canvas_limits
def wallpaper_price(width, height, material_price, market, designer=None, reseller=None, inc_vat=True):
m2_price = material_price
def material_price(material, market, designer=None, reseller=None, inc_vat=True):
price = material.price
# add designer price premium
if designer:
m2_price *= (float(designer.pricepremium) / 100) + 1
price *= (float(designer.pricepremium) / 100) + 1
# add reseller price premium
if reseller:
m2_price *= (float(reseller.pricepremium) / 100) + 1
price *= (float(reseller.pricepremium) / 100) + 1
# exchange to local currency
m2_price *= market.exchange_rate
price *= market.exchange_rate
# multiply m2_price with market price adjustments
m2_price *= market.price_adjustments
price *= market.price_adjustments
# add vat
if inc_vat:
price *= market.vat
return round_half_up(price)
def wallpaper_price(width, height, material, market, designer=None, reseller=None, inc_vat=True):
m2_price = material_price(
material, market, designer, reseller, inc_vat=False)
# calculate price per square meter
sqm = (width / 100) * (height / 100)
@@ -140,14 +151,14 @@ def old_canvas_diy_frame_price(width, height, market, reseller=None, inc_vat=Tru
return round_half_up(price)
def old_canvas_price(width, height, material_price, market, framed=True, designer=None, reseller=None, inc_vat=True):
def old_canvas_price(width, height, material, market, framed=True, designer=None, reseller=None, inc_vat=True):
width, height = calculate_canvas_limits(width, height, framed)
# calculate square meter
sqm = (width / 100) * (height / 100)
sqm = max(sqm, 0.2) # sqm can never go below 0.2
# calculate price per square meter
price = sqm * material_price
price = sqm * material.price
if framed:
# todo: when product models are in place we should use stockproduct