Add price calculations in inches, minimum size on US is 1 sq ft (#76)

Co-authored-by: Anders Gustafsson <anders@photowall.se>
This commit is contained in:
Fredrik Ringqvist
2024-05-27 09:48:28 +02:00
committed by GitHub
co-authored by Anders Gustafsson
parent 5f9f6c90ed
commit ab912e32e4
2 changed files with 35 additions and 12 deletions
+14 -3
View File
@@ -80,13 +80,23 @@ def wallpaper_price_new(
height,
material,
market,
unit,
inquiry=None,
):
m2_prices = wallpaper_m2_price_new(product_id, material.id, market, inquiry)
if (unit == 'inch'):
width = width * 2.54
height = height * 2.54
sqm = (width / 100) * (height / 100)
min_sqm = 1
if (market.name == 'US'):
# On inch markets, minimum size is 1 sq feet (12x12 inch = 30.48x30.48 cm = 0.09290304 m2)
min_sqm = 0.09290304
else:
# Elsewhere, minimum size is 1 sq meter
min_sqm = 1
sqm = max(sqm, min_sqm)
@@ -207,6 +217,7 @@ def inquiry_price_new(
):
width = kwargs.get("width", inquiry.width)
height = kwargs.get("height", inquiry.height)
unit = kwargs.get("unit", None)
material = kwargs.get("material", inquiry.material)
external_id = kwargs.get("external_id")
@@ -220,9 +231,9 @@ def inquiry_price_new(
return prices
elif inquiry.product_group == "photo-wallpaper":
if is_own_image:
prices = wallpaper_price_new(None, width, height, material, inquiry.market, inquiry)
prices = wallpaper_price_new(None, width, height, material, inquiry.market, unit, inquiry)
else:
prices = wallpaper_price_new(product_id, width, height, material, inquiry.market, inquiry)
prices = wallpaper_price_new(product_id, width, height, material, inquiry.market, unit, inquiry)
else:
raise ValueError("Invalid product group: {}".format(inquiry.product_group))