From 86931155712821e2a6e9a7c55acbe270892f8719 Mon Sep 17 00:00:00 2001 From: Capybara-z Date: Sat, 7 Feb 2026 22:48:30 +0300 Subject: [PATCH] fix preserve device/traffic limits on coupon --- handlers/coupons.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/handlers/coupons.py b/handlers/coupons.py index 1187be51..a3a8cec1 100644 --- a/handlers/coupons.py +++ b/handlers/coupons.py @@ -235,8 +235,11 @@ async def handle_key_extension( tariff = None if key.tariff_id: tariff = await get_tariff_by_id(session, key.tariff_id) - total_gb = int(tariff["traffic_limit"]) if tariff and tariff.get("traffic_limit") else 0 - device_limit = int(tariff["device_limit"]) if tariff and tariff.get("device_limit") else 0 + tariff_gb = int(tariff["traffic_limit"]) if tariff and tariff.get("traffic_limit") else 0 + tariff_devices = int(tariff["device_limit"]) if tariff and tariff.get("device_limit") else 0 + + total_gb = int(key.current_traffic_limit) if getattr(key, "current_traffic_limit", None) is not None else tariff_gb + device_limit = int(key.current_device_limit) if getattr(key, "current_device_limit", None) is not None else tariff_devices key_subgroup = None if tariff: