Include segment in price requests (#70)
This commit is contained in:
+17
-2
@@ -16,10 +16,14 @@ def wallpaper_m2_price_new(
|
|||||||
|
|
||||||
if own_image:
|
if own_image:
|
||||||
price_m2_incl_vat = get_own_image_wallpaper_m2_price(material_id, market.id)
|
price_m2_incl_vat = get_own_image_wallpaper_m2_price(material_id, market.id)
|
||||||
|
segment = "OWN-IMAGE"
|
||||||
else:
|
else:
|
||||||
price_m2_incl_vat = get_wallpaper_m2_price(product_id, material_id, market.id)
|
prices = get_wallpaper_m2_price(product_id, material_id, market.id)
|
||||||
|
price_m2_incl_vat = prices["price"]
|
||||||
|
segment = prices["segment"]
|
||||||
|
|
||||||
price_m2_excl_vat = price_m2_incl_vat / market.vat
|
price_m2_excl_vat = price_m2_incl_vat / market.vat
|
||||||
|
segment_price = price_m2_incl_vat
|
||||||
|
|
||||||
if inquiry:
|
if inquiry:
|
||||||
inquiry_premium = (float(inquiry.pricepremium) / 100) + 1
|
inquiry_premium = (float(inquiry.pricepremium) / 100) + 1
|
||||||
@@ -29,6 +33,8 @@ def wallpaper_m2_price_new(
|
|||||||
return {
|
return {
|
||||||
"incl_vat": price_m2_incl_vat,
|
"incl_vat": price_m2_incl_vat,
|
||||||
"excl_vat": price_m2_excl_vat,
|
"excl_vat": price_m2_excl_vat,
|
||||||
|
"segment": segment,
|
||||||
|
"segment_price": segment_price,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -93,6 +99,8 @@ def wallpaper_price_new(
|
|||||||
"excl_vat": price_excl_vat,
|
"excl_vat": price_excl_vat,
|
||||||
"m2_price_incl_vat": m2_prices["incl_vat"],
|
"m2_price_incl_vat": m2_prices["incl_vat"],
|
||||||
"m2_price_excl_vat": m2_prices["excl_vat"],
|
"m2_price_excl_vat": m2_prices["excl_vat"],
|
||||||
|
"segment": m2_prices["segment"],
|
||||||
|
"segment_price": m2_prices["incl_vat"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,17 +157,22 @@ def external_product_own_image_price(external_product_id, market):
|
|||||||
return {
|
return {
|
||||||
'incl_vat': price_incl_vat,
|
'incl_vat': price_incl_vat,
|
||||||
'excl_vat': price_excl_vat,
|
'excl_vat': price_excl_vat,
|
||||||
|
'segment': 'OWN-IMAGE',
|
||||||
|
'segment_price': price_incl_vat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def external_product_price_new(product_id, external_product_id, market):
|
def external_product_price_new(product_id, external_product_id, market):
|
||||||
price_incl_vat = get_external_product_price(product_id, external_product_id, market.id)
|
prices = get_external_product_price(product_id, external_product_id, market.id)
|
||||||
|
price_incl_vat = prices['price']
|
||||||
|
|
||||||
price_excl_vat = price_incl_vat / market.vat
|
price_excl_vat = price_incl_vat / market.vat
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'incl_vat': price_incl_vat,
|
'incl_vat': price_incl_vat,
|
||||||
'excl_vat': price_excl_vat,
|
'excl_vat': price_excl_vat,
|
||||||
|
'segment': prices['segment'],
|
||||||
|
'segment_price': price_incl_vat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,6 +247,8 @@ def inquiry_price_new(
|
|||||||
"excl_retouch_excl_vat": price_excl_retouch_excl_vat,
|
"excl_retouch_excl_vat": price_excl_retouch_excl_vat,
|
||||||
"m2_price_incl_vat": prices["m2_price_incl_vat"],
|
"m2_price_incl_vat": prices["m2_price_incl_vat"],
|
||||||
"m2_price_excl_vat": prices["m2_price_excl_vat"],
|
"m2_price_excl_vat": prices["m2_price_excl_vat"],
|
||||||
|
"segment": prices["segment"],
|
||||||
|
"segment_price": prices["segment_price"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+14
-6
@@ -6,10 +6,11 @@ from api.extensions import db
|
|||||||
def get_wallpaper_m2_price(product_id, material_id, market_id):
|
def get_wallpaper_m2_price(product_id, material_id, market_id):
|
||||||
sql = """
|
sql = """
|
||||||
select
|
select
|
||||||
price
|
price, ps.name
|
||||||
from
|
from
|
||||||
v_price_product_segments v
|
v_price_product_segments v
|
||||||
join prices_wallpaper_m2 p on v.segment_id = p.segment_id
|
join prices_wallpaper_m2 p on v.segment_id = p.segment_id
|
||||||
|
join price_segments ps on v.segment_id = ps.id
|
||||||
where
|
where
|
||||||
productid = :product_id and market_id = :market_id and material_id = :material_id
|
productid = :product_id and market_id = :market_id and material_id = :material_id
|
||||||
order by priority desc
|
order by priority desc
|
||||||
@@ -24,8 +25,11 @@ def get_wallpaper_m2_price(product_id, material_id, market_id):
|
|||||||
|
|
||||||
rows = result.fetchall()
|
rows = result.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
price = row[0]
|
[price, segment] = row
|
||||||
return float(price)
|
return {
|
||||||
|
"price": float(price),
|
||||||
|
"segment": segment,
|
||||||
|
}
|
||||||
|
|
||||||
raise Exception("Failed reading wallpaper m2 price")
|
raise Exception("Failed reading wallpaper m2 price")
|
||||||
|
|
||||||
@@ -33,10 +37,11 @@ def get_wallpaper_m2_price(product_id, material_id, market_id):
|
|||||||
def get_external_product_price(product_id, external_product_id, market_id):
|
def get_external_product_price(product_id, external_product_id, market_id):
|
||||||
sql = """
|
sql = """
|
||||||
select
|
select
|
||||||
price
|
price, price_segments.name
|
||||||
from
|
from
|
||||||
v_price_product_segments v
|
v_price_product_segments v
|
||||||
join prices_external_products p on v.segment_id = p.segment_id
|
join prices_external_products p on v.segment_id = p.segment_id
|
||||||
|
join price_segments on v.segment_id = price_segments.id
|
||||||
where
|
where
|
||||||
productid = :product_id and market_id = :market_id and external_product_id = :external_id
|
productid = :product_id and market_id = :market_id and external_product_id = :external_id
|
||||||
order by priority desc
|
order by priority desc
|
||||||
@@ -51,8 +56,11 @@ def get_external_product_price(product_id, external_product_id, market_id):
|
|||||||
|
|
||||||
rows = result.fetchall()
|
rows = result.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
price = row[0]
|
[price, segment] = row
|
||||||
return float(price)
|
return {
|
||||||
|
"price": float(price),
|
||||||
|
"segment": segment,
|
||||||
|
}
|
||||||
|
|
||||||
raise Exception("Failed reading external product price")
|
raise Exception("Failed reading external product price")
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ def wallpaper():
|
|||||||
"m2_price_excl_vat": prices["m2_price_excl_vat"],
|
"m2_price_excl_vat": prices["m2_price_excl_vat"],
|
||||||
"price": prices["incl_vat"],
|
"price": prices["incl_vat"],
|
||||||
"price_excl_vat": prices["excl_vat"],
|
"price_excl_vat": prices["excl_vat"],
|
||||||
|
"segment": prices["segment"],
|
||||||
|
"segment_price": prices["segment_price"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
@@ -183,6 +185,8 @@ def inquiry_wallpaper(inquiry, new_version=False):
|
|||||||
"inquiry_price_excl_vat": price["excl_vat"],
|
"inquiry_price_excl_vat": price["excl_vat"],
|
||||||
"inquiry_price_excl_retouch": price["excl_retouch_incl_vat"],
|
"inquiry_price_excl_retouch": price["excl_retouch_incl_vat"],
|
||||||
"inquiry_price_excl_retouch_excl_vat": price["excl_retouch_excl_vat"],
|
"inquiry_price_excl_retouch_excl_vat": price["excl_retouch_excl_vat"],
|
||||||
|
"segment": price["segment"],
|
||||||
|
"segment_price": price["segment_price"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
@@ -263,6 +267,8 @@ def inquiry_external_product(inquiry, external_id, new_version):
|
|||||||
"inquiry_price_excl_vat": result["excl_vat"],
|
"inquiry_price_excl_vat": result["excl_vat"],
|
||||||
"inquiry_price_excl_retouch": result["incl_vat"],
|
"inquiry_price_excl_retouch": result["incl_vat"],
|
||||||
"inquiry_price_excl_retouch_excl_vat": result["excl_vat"],
|
"inquiry_price_excl_retouch_excl_vat": result["excl_vat"],
|
||||||
|
"segment": result["segment"],
|
||||||
|
"segment_price": result["segment_price"],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -333,7 +339,9 @@ def external_product():
|
|||||||
{
|
{
|
||||||
"id": id,
|
"id": id,
|
||||||
"price": prices["incl_vat"],
|
"price": prices["incl_vat"],
|
||||||
"price_excl_vat": prices['excl_vat']
|
"price_excl_vat": prices["excl_vat"],
|
||||||
|
"segment": prices["segment"],
|
||||||
|
"segment_price": prices["segment_price"],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
return jsonify(data=data)
|
return jsonify(data=data)
|
||||||
|
|||||||
Reference in New Issue
Block a user