Include segment in price requests (#70)

This commit is contained in:
Fredrik Ringqvist
2023-05-12 09:22:33 +02:00
committed by GitHub
parent 4556155a84
commit ad36f31122
3 changed files with 40 additions and 9 deletions
+14 -6
View File
@@ -6,10 +6,11 @@ from api.extensions import db
def get_wallpaper_m2_price(product_id, material_id, market_id):
sql = """
select
price
price, ps.name
from
v_price_product_segments v
join prices_wallpaper_m2 p on v.segment_id = p.segment_id
join price_segments ps on v.segment_id = ps.id
where
productid = :product_id and market_id = :market_id and material_id = :material_id
order by priority desc
@@ -24,8 +25,11 @@ def get_wallpaper_m2_price(product_id, material_id, market_id):
rows = result.fetchall()
for row in rows:
price = row[0]
return float(price)
[price, segment] = row
return {
"price": float(price),
"segment": segment,
}
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):
sql = """
select
price
price, price_segments.name
from
v_price_product_segments v
join prices_external_products p on v.segment_id = p.segment_id
join price_segments on v.segment_id = price_segments.id
where
productid = :product_id and market_id = :market_id and external_product_id = :external_id
order by priority desc
@@ -51,8 +56,11 @@ def get_external_product_price(product_id, external_product_id, market_id):
rows = result.fetchall()
for row in rows:
price = row[0]
return float(price)
[price, segment] = row
return {
"price": float(price),
"segment": segment,
}
raise Exception("Failed reading external product price")