P5-3247 add price calculations for poster inquiries

This commit is contained in:
Martin
2019-05-14 09:25:30 +02:00
parent 2d9ace0b9b
commit 35a7c3798d
5 changed files with 48 additions and 1 deletions
+4
View File
@@ -264,6 +264,7 @@ def inquiry_price(inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, *
height = kwargs.get('height', inquiry.height)
material = kwargs.get('material', inquiry.material)
framed = kwargs.get('framed', inquiry.framed)
hanger = kwargs.get('hanger', inquiry.hanger)
reseller = kwargs.get('reseller', inquiry.dealer_store)
if inquiry.product_group == 'photo-wallpaper':
@@ -272,6 +273,9 @@ def inquiry_price(inquiry, inc_price_retouch=True, rounded=True, inc_vat=True, *
elif inquiry.product_group == 'canvas':
price = canvas_price(width, height, inquiry.market,
designer=inquiry.designer, reseller=reseller, inquiry=inquiry, framed=framed, rounded=False, inc_vat=False)
elif inquiry.product_group == 'poster':
price = poster_price(width, height, inquiry.market,
designer=inquiry.designer, reseller=reseller, inquiry=inquiry, hanger=hanger, rounded=False, inc_vat=False)
else:
raise ValueError(
'Invalid product group: {}'.format(inquiry.product_group))
+1 -1
View File
@@ -20,7 +20,7 @@ class Inquiry(db.Model):
dealer_store_id = db.Column('dealer_store', db.Integer, db.ForeignKey(
'contract_customers.contractcustomerid'))
dealer_store = db.relationship('ContractCustomer', uselist=False)
framed = db.Column(db.Integer, default=0, nullable=False)
hanger = db.Column(db.String)
materialid = db.Column(db.Integer, db.ForeignKey(
'product-materials.materialid'), default=1, nullable=False)
material = db.relationship('Material', uselist=False)
+28
View File
@@ -226,6 +226,32 @@ def inquiry_canvas(inquiry):
return data
def inquiry_poster(inquiry):
width, height = get_inquiry_measurements(inquiry)
data = {
'id': inquiry.id,
'group': 'poster',
'retouch_price': inquiry.local_price_retouch(rounded=False, inc_vat=True)
}
prices = []
for hanger in [True, False]:
prices.append({
'hanger': hanger,
'width': width,
'height': height,
'inquiry_price_excl_retouch': inquiry_price(inquiry, width=width, height=height, hanger=hanger, rounded=False, inc_price_retouch=False, inc_vat=True),
'inquiry_price': inquiry_price(inquiry, width=width, height=height, hanger=hanger, rounded=False, inc_vat=True),
'inquiry_price_excl_vat': inquiry_price(inquiry, width=width, height=height, hanger=hanger, rounded=False, inc_vat=False),
'inquiry_price_excl_price_premium': inquiry_price(inquiry, width=width, height=height, hanger=hanger, reseller=None, inc_price_retouch=False, rounded=False, inc_vat=False)
})
data['prices'] = prices
return data
@mod.route('/inquiry/<int:inquiry_id>', methods=["GET"])
def inquiry(inquiry_id):
inquiry = Inquiry.query.get_or_404(inquiry_id)
@@ -234,6 +260,8 @@ def inquiry(inquiry_id):
data = inquiry_wallpaper(inquiry)
elif inquiry.product_group == 'canvas':
data = inquiry_canvas(inquiry)
elif inquiry.product_group == 'poster':
data = inquiry_poster(inquiry)
else:
raise ValueError('Invalid group {}'.format(inquiry.product_group))