PW-570 inquiry price calculations

This commit is contained in:
Martin
2016-11-19 16:38:37 +01:00
parent 980aa8f88b
commit 4679dd2bbe
9 changed files with 371 additions and 15 deletions
+43 -5
View File
@@ -5,7 +5,7 @@ from api.lib.utils import round_half_up
from api.lib.limits import calculate_canvas_limits
def m2_price(material, market, designer=None, reseller=None, rounded=True, inc_vat=True):
def m2_price(material, market, designer=None, reseller=None, inquiry=None, rounded=True, inc_vat=True):
""" calculates price per square meter """
price = material.price
@@ -15,6 +15,9 @@ def m2_price(material, market, designer=None, reseller=None, rounded=True, inc_v
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
if inquiry:
price *= (float(inquiry.pricepremium) / 100) + 1
price *= market.exchange_rate
price *= market.price_adjustments
@@ -27,9 +30,9 @@ def m2_price(material, market, designer=None, reseller=None, rounded=True, inc_v
return price
def wallpaper_price(width, height, material, market, designer=None, reseller=None, rounded=True, inc_vat=True):
def wallpaper_price(width, height, material, market, designer=None, reseller=None, inquiry=None, rounded=True, inc_vat=True):
price = m2_price(material, market, designer, reseller,
rounded=rounded, inc_vat=False)
inquiry, rounded=rounded, inc_vat=False)
sqm = (width / 100) * (height / 100)
@@ -150,10 +153,10 @@ def old_canvas_diy_frame_price(width, height, market, reseller=None, rounded=Tru
return canvas_frame_price(width, height, stock_price, market, additional_price, reseller=reseller, rounded=rounded, inc_vat=inc_vat)
def old_canvas_price(width, height, material, market, framed=True, designer=None, reseller=None, inc_vat=True):
def old_canvas_price(width, height, material, market, framed=True, designer=None, reseller=None, inquiry=None, inc_vat=True):
width, height = calculate_canvas_limits(width, height, framed)
price = m2_price(material, market, designer, reseller,
rounded=False, inc_vat=False)
inquiry, rounded=False, inc_vat=False)
# calculate square meter
sqm = (width / 100) * (height / 100)
@@ -173,3 +176,38 @@ def old_canvas_price(width, height, material, market, framed=True, designer=None
price *= market.vat
return round_half_up(price)
def inquiry_price(inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, **kwargs):
width = kwargs.get('width', inquiry.width)
height = kwargs.get('height', inquiry.height)
material = kwargs.get('material', inquiry.material)
framed = kwargs.get('framed', inquiry.framed)
if inquiry.product_group == 'photo-wallpaper':
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, inc_vat=False)
else:
raise ValueError(
'Invalid product group: {}'.format(inquiry.product_group))
effect_price = inquiry.price_effect
if effect_price:
price += float(effect_price)
if inc_price_retouch:
retouch_price = inquiry.local_price_retouch(
rounded=False, inc_vat=False)
if retouch_price:
price += retouch_price
if inc_vat:
price *= inquiry.market.vat
if rounded:
price = round_half_up(price)
return price