Spaces:
Runtime error
Runtime error
Delete current_pricing.py
Browse files- current_pricing.py +0 -48
current_pricing.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
from datetime import datetime, timedelta
|
| 2 |
-
|
| 3 |
-
def calculate_live_parking(log_in_time, log_out_time, hourly_price):
|
| 4 |
-
# ูู ู
ููุด ููุช ุฏุฎูู
|
| 5 |
-
if not log_in_time:
|
| 6 |
-
return "0h 0m", float(hourly_price)
|
| 7 |
-
|
| 8 |
-
# ูุดูู ุงูู Timezone ูู ู
ูุฌูุฏ
|
| 9 |
-
if log_in_time.tzinfo:
|
| 10 |
-
log_in_time = log_in_time.replace(tzinfo=None)
|
| 11 |
-
|
| 12 |
-
# =======================================================
|
| 13 |
-
# ๐ก ุงูุชุนุฏูู ุงูุณุญุฑู: ูู ูุนุฏ ูุงูู ููุง ูุซุจุช ุงูููุชุ
|
| 14 |
-
# =======================================================
|
| 15 |
-
if log_out_time:
|
| 16 |
-
# ูู ููู ููุช ุฎุฑูุฌ (ูุนูู ุงูุฎููุฉ ู
ุด NULL)ุ ูุซุจุช ุงูุญุณุจุฉ ุนููู
|
| 17 |
-
if log_out_time.tzinfo:
|
| 18 |
-
log_out_time = log_out_time.replace(tzinfo=None)
|
| 19 |
-
end_time = log_out_time
|
| 20 |
-
else:
|
| 21 |
-
# ูู ุงูุฎููุฉ ูุณู NULLุ ูุญุณุจ ุนูู ุชูููุช ุฏูููุชู (Live)
|
| 22 |
-
end_time = datetime.utcnow() + timedelta(hours=3)
|
| 23 |
-
# =======================================================
|
| 24 |
-
|
| 25 |
-
# ูุญุณุจ ุงููุฑู ุจูููู
ุจุงูุฏูุงุฆู
|
| 26 |
-
delta = end_time - log_in_time
|
| 27 |
-
total_minutes = int(delta.total_seconds() // 60)
|
| 28 |
-
|
| 29 |
-
if total_minutes <= 0:
|
| 30 |
-
return "0h 0m", float(hourly_price)
|
| 31 |
-
|
| 32 |
-
hours = total_minutes // 60
|
| 33 |
-
mins = total_minutes % 60
|
| 34 |
-
|
| 35 |
-
# ูุฌูุฒ ุงูููุช ูู Text
|
| 36 |
-
time_str = f"{hours}h {mins}m"
|
| 37 |
-
|
| 38 |
-
# ููุฌูู ุงูุญุณุงุจ: ูุณุฑ ุงูู 30 ุฏูููุฉ ุจุณุงุนุฉ
|
| 39 |
-
billed_hours = hours
|
| 40 |
-
if mins >= 30:
|
| 41 |
-
billed_hours += 1
|
| 42 |
-
|
| 43 |
-
billed_hours = max(1, billed_hours)
|
| 44 |
-
|
| 45 |
-
# ุญุณุงุจ ุงูุณุนุฑ ุงูููุงุฆู
|
| 46 |
-
final_price = billed_hours * float(hourly_price)
|
| 47 |
-
|
| 48 |
-
return time_str, final_price
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|