rename material_price to m2_price
This commit is contained in:
+9
-17
@@ -5,24 +5,19 @@ from api.lib.utils import round_half_up
|
||||
from api.lib.limits import calculate_canvas_limits
|
||||
|
||||
|
||||
def material_price(material, market, designer=None, reseller=None, rounded=True, inc_vat=True):
|
||||
def m2_price(material, market, designer=None, reseller=None, rounded=True, inc_vat=True):
|
||||
""" calculates price per square meter """
|
||||
price = material.price
|
||||
|
||||
# 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
|
||||
|
||||
# multiply m2_price with market price adjustments
|
||||
price *= market.price_adjustments
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
@@ -33,10 +28,9 @@ def material_price(material, market, designer=None, reseller=None, rounded=True,
|
||||
|
||||
|
||||
def wallpaper_price(width, height, material, market, designer=None, reseller=None, rounded=True, inc_vat=True):
|
||||
m2_price = material_price(
|
||||
material, market, designer, reseller, rounded=rounded, inc_vat=False)
|
||||
price = m2_price(material, market, designer, reseller,
|
||||
rounded=rounded, inc_vat=False)
|
||||
|
||||
# calculate price per square meter
|
||||
sqm = (width / 100) * (height / 100)
|
||||
|
||||
if market.territory == "US":
|
||||
@@ -46,9 +40,8 @@ def wallpaper_price(width, height, material, market, designer=None, reseller=Non
|
||||
|
||||
sqm = max(sqm, min_sqm)
|
||||
|
||||
price = sqm * m2_price
|
||||
price *= sqm
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
@@ -159,14 +152,13 @@ def old_canvas_diy_frame_price(width, height, market, reseller=None, rounded=Tru
|
||||
|
||||
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)
|
||||
m2_price = material_price(
|
||||
material, market, designer, reseller, rounded=False, inc_vat=False)
|
||||
price = m2_price(material, market, designer, reseller,
|
||||
rounded=False, inc_vat=False)
|
||||
|
||||
# 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 * m2_price
|
||||
price *= sqm
|
||||
|
||||
if framed:
|
||||
# todo: when product models are in place we should use stockproduct
|
||||
|
||||
Reference in New Issue
Block a user