fix: traffic addon price mismatch — keyboard showed prorated, handler charged full month

Keyboard calculated: price * days_remaining / 30 (true proration)
Handler calculated: price * max(30, days_remaining) / 30 (always >= 30 days)

With 17 days remaining: keyboard showed 84₽, handler charged 149₽.

Fix: change calculate_prorated_price default min_charge_days from 30 to 1.
Now all callers (traffic, countries, servers, miniapp, auto-purchase)
use true proration matching the displayed price.
This commit is contained in:
Fringg
2026-04-29 10:42:10 +03:00
parent 1110d0c781
commit a88e3c80ad
+1 -1
View File
@@ -20,7 +20,7 @@ def calculate_months_from_days(days: int) -> int:
return max(1, round(days / 30))
def calculate_prorated_price(monthly_price: int, end_date: datetime, min_charge_days: int = 30) -> tuple[int, int]:
def calculate_prorated_price(monthly_price: int, end_date: datetime, min_charge_days: int = 1) -> tuple[int, int]:
"""Calculate prorated price based on remaining days.
Returns: