merge P5-567
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# coding=UTF-8
|
||||
|
||||
""" Price formulas """
|
||||
|
||||
|
||||
def wallpaper_price(width, height, material_price, market, designer=None, reseller=None, inc_vat=True):
|
||||
m2_price = material_price
|
||||
|
||||
# add designer price premium
|
||||
if designer:
|
||||
m2_price *= (float(designer.pricepremium) / 100) + 1
|
||||
|
||||
# add reseller price premium
|
||||
if reseller:
|
||||
m2_price *= (float(reseller.pricepremium) / 100) + 1
|
||||
|
||||
# exchange to local currency
|
||||
m2_price *= market.exchange_rate
|
||||
|
||||
# multiply m2_price with market price adjustments
|
||||
m2_price *= market.price_adjustments
|
||||
|
||||
# calculate price per square meter
|
||||
sqm = (width / 100) * (height / 100)
|
||||
sqm = max(sqm, 1)
|
||||
price = sqm * m2_price
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
return round(price)
|
||||
|
||||
|
||||
def canvas_cm2_price(cm2):
|
||||
price_cm2_at_1cm2 = 0.224
|
||||
price_cm2_at_5000cm2 = 0.144
|
||||
price_cm2_at_10000cm2 = 0.096
|
||||
price_cm2_at_22500cm2 = 0.064
|
||||
|
||||
if cm2 <= 5000:
|
||||
diff = price_cm2_at_1cm2 - price_cm2_at_5000cm2
|
||||
discount = (diff / 5000) * cm2
|
||||
cm2_price = price_cm2_at_1cm2 - discount
|
||||
|
||||
elif cm2 > 5000 and cm2 <= 10000:
|
||||
diff = price_cm2_at_5000cm2 - price_cm2_at_10000cm2
|
||||
discount = (diff / 5000) * (cm2 - 5000)
|
||||
cm2_price = price_cm2_at_5000cm2 - discount
|
||||
|
||||
elif cm2 > 10000:
|
||||
diff = price_cm2_at_10000cm2 - price_cm2_at_22500cm2
|
||||
discount = (diff / 12500) * (cm2 - 10000)
|
||||
cm2_price = price_cm2_at_10000cm2 - discount
|
||||
|
||||
cm2_price = max(cm2_price, 0.064)
|
||||
return cm2_price
|
||||
|
||||
|
||||
def canvas_price(width, height, market, framed=True, designer=None, reseller=None, 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
|
||||
|
||||
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
|
||||
|
||||
# multiply price with market price adjustments
|
||||
price *= market.price_adjustments
|
||||
|
||||
# add vat
|
||||
if inc_vat:
|
||||
price *= market.vat
|
||||
|
||||
return round(price)
|
||||
Reference in New Issue
Block a user