diff --git a/fioul.py b/fioul.py index 1f892ab..5b52b5d 100755 --- a/fioul.py +++ b/fioul.py @@ -20,6 +20,7 @@ def get_today_prices_from_internet(): pricesZone { price min_quantity + max_quantity } } } @@ -33,8 +34,14 @@ def get_today_prices_from_internet(): json_data = json_data["getProducts"][0] tax = float(json_data["tax"]["value"]) zones = json_data["pricesZone"] - price_500 = next((x["price"] for x in zones if x["min_quantity"] == 500), None) - price_1000 = next((x["price"] for x in zones if x["min_quantity"] == 1000), None) + price_500 = next( + (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 price_500 = price_500 * (100 + tax) / 100.0 price_1000 = price_1000 * (100 + tax) / 100.0