Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,12 +44,11 @@ def calculate_monthly_bill(tariff_data, load, daily_usage):
|
|
| 44 |
|
| 45 |
total_bill = 0
|
| 46 |
for slab in tariff_data:
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
upper_limit = float(slab_range[1]) if len(slab_range) > 1 else float('inf')
|
| 50 |
|
| 51 |
-
if monthly_consumption > lower_limit:
|
| 52 |
-
consumption_in_slab = min(monthly_consumption, upper_limit) - lower_limit
|
| 53 |
total_bill += consumption_in_slab * slab['rate']
|
| 54 |
|
| 55 |
return round(total_bill, 2)
|
|
|
|
| 44 |
|
| 45 |
total_bill = 0
|
| 46 |
for slab in tariff_data:
|
| 47 |
+
# Default to infinity for upper limit if not defined
|
| 48 |
+
upper_limit = slab['upper_limit'] if slab['upper_limit'] != float('inf') else monthly_consumption
|
|
|
|
| 49 |
|
| 50 |
+
if monthly_consumption > slab['lower_limit']:
|
| 51 |
+
consumption_in_slab = min(monthly_consumption, upper_limit) - slab['lower_limit']
|
| 52 |
total_bill += consumption_in_slab * slab['rate']
|
| 53 |
|
| 54 |
return round(total_bill, 2)
|