Retrieve max_quantity and check if quantity belongs to interval
This is because min_level was adjusted recently. Now we check if 500L and 1000L belongs to the given intervals, and we do not assum they are lower bounds of such intervals.
This commit is contained in:
11
fioul.py
11
fioul.py
@@ -20,6 +20,7 @@ def get_today_prices_from_internet():
|
|||||||
pricesZone {
|
pricesZone {
|
||||||
price
|
price
|
||||||
min_quantity
|
min_quantity
|
||||||
|
max_quantity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,8 +34,14 @@ def get_today_prices_from_internet():
|
|||||||
json_data = json_data["getProducts"][0]
|
json_data = json_data["getProducts"][0]
|
||||||
tax = float(json_data["tax"]["value"])
|
tax = float(json_data["tax"]["value"])
|
||||||
zones = json_data["pricesZone"]
|
zones = json_data["pricesZone"]
|
||||||
price_500 = next((x["price"] for x in zones if x["min_quantity"] == 500), None)
|
price_500 = next(
|
||||||
price_1000 = next((x["price"] for x in zones if x["min_quantity"] == 1000), None)
|
(x["price"] for x in zones if x["min_quantity"] <= 500 < x["max_quantity"]),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
price_1000 = next(
|
||||||
|
(x["price"] for x in zones if x["min_quantity"] <= 1000 < x["max_quantity"]),
|
||||||
|
None,
|
||||||
|
)
|
||||||
# apply tax
|
# apply tax
|
||||||
price_500 = price_500 * (100 + tax) / 100.0
|
price_500 = price_500 * (100 + tax) / 100.0
|
||||||
price_1000 = price_1000 * (100 + tax) / 100.0
|
price_1000 = price_1000 * (100 + tax) / 100.0
|
||||||
|
|||||||
Reference in New Issue
Block a user