Addon reset warning on renewal / Fix daily stats report cron
This commit is contained in:
+5
-13
@@ -76,19 +76,11 @@ def register_periodic_tasks() -> None:
|
||||
AUDIT_DRAIN_TRIGGER,
|
||||
)
|
||||
|
||||
if process_budget > 0:
|
||||
periodic_task_manager.register_cron_task(
|
||||
"daily_stats_report",
|
||||
scheduled_stats_report_process_runner,
|
||||
DAILY_STATS_REPORT_TRIGGER,
|
||||
execution_mode="process",
|
||||
)
|
||||
else:
|
||||
periodic_task_manager.register_cron_task(
|
||||
"daily_stats_report",
|
||||
scheduled_stats_report,
|
||||
DAILY_STATS_REPORT_TRIGGER,
|
||||
)
|
||||
periodic_task_manager.register_cron_task(
|
||||
"daily_stats_report",
|
||||
scheduled_stats_report,
|
||||
DAILY_STATS_REPORT_TRIGGER,
|
||||
)
|
||||
|
||||
if process_budget > 0:
|
||||
periodic_task_manager.register_cron_task(
|
||||
|
||||
@@ -34,6 +34,7 @@ from database.tariffs import create_subgroup_hash, find_subgroup_by_hash, get_ta
|
||||
from handlers.buttons import BACK, MAIN_MENU, MY_SUB, PAYMENT
|
||||
from handlers.payments.fast_payment_flow import try_fast_payment_flow
|
||||
from handlers.texts import (
|
||||
ADDON_RESET_PLAN_WARNING,
|
||||
DISCOUNT_OFFER_MESSAGE,
|
||||
DISCOUNT_OFFER_STEP2,
|
||||
DISCOUNT_OFFER_STEP3,
|
||||
@@ -244,11 +245,25 @@ async def process_callback_renew_key(callback_query: CallbackQuery, state: FSMCo
|
||||
)
|
||||
discount_message = DISCOUNT_OFFER_MESSAGE.format(offer_text=offer_text, time_left=time_left)
|
||||
|
||||
addon_warning = ""
|
||||
_cur_dev = record.get("current_device_limit")
|
||||
_sel_dev = record.get("selected_device_limit")
|
||||
_cur_trf = record.get("current_traffic_limit")
|
||||
_sel_trf = record.get("selected_traffic_limit")
|
||||
_addon_parts: list[str] = []
|
||||
if _cur_dev is not None and _sel_dev is not None and int(_cur_dev) > int(_sel_dev):
|
||||
_addon_parts.append(f"+{int(_cur_dev) - int(_sel_dev)} устройств")
|
||||
if _cur_trf is not None and _sel_trf is not None and int(_cur_trf) > int(_sel_trf):
|
||||
_addon_parts.append(f"+{int(_cur_trf) - int(_sel_trf)} ГБ")
|
||||
if _addon_parts:
|
||||
addon_warning = ADDON_RESET_PLAN_WARNING.format(addons=", ".join(_addon_parts))
|
||||
|
||||
response_message = (
|
||||
PLAN_SELECTION_MSG.format(
|
||||
balance=balance,
|
||||
expiry_date=datetime.utcfromtimestamp(expiry_time / 1000).strftime("%Y-%m-%d %H:%M:%S"),
|
||||
)
|
||||
+ addon_warning
|
||||
+ discount_message
|
||||
)
|
||||
|
||||
@@ -515,6 +530,10 @@ async def process_callback_renew_plan(callback_query: CallbackQuery, state: FSMC
|
||||
renew_new_expiry_time=new_expiry_time,
|
||||
config_selected_device_limit=config_selected_devices,
|
||||
config_selected_traffic_gb=config_selected_traffic_gb,
|
||||
renew_current_device_limit=record.get("current_device_limit"),
|
||||
renew_selected_device_limit=record.get("selected_device_limit"),
|
||||
renew_current_traffic_limit=record.get("current_traffic_limit"),
|
||||
renew_selected_traffic_limit=record.get("selected_traffic_limit"),
|
||||
)
|
||||
|
||||
from handlers.tariffs.buy.key_tariffs import start_tariff_config
|
||||
|
||||
Binary file not shown.
@@ -15,6 +15,7 @@ from database.notifications import check_hot_lead_discount
|
||||
from handlers.buttons import BACK, CONFIG_PAY_BUTTON_TEXT, MAIN_MENU, PAYMENT
|
||||
from handlers.payments.fast_payment_flow import try_fast_payment_flow
|
||||
from handlers.texts import (
|
||||
ADDON_RESET_CONFIG_WARNING,
|
||||
CONFIG_SCREEN_TEMPLATE,
|
||||
CREATING_CONNECTION_MSG,
|
||||
DEFAULT_LIMIT_LABEL,
|
||||
@@ -471,10 +472,25 @@ async def render_user_config_screen(
|
||||
else:
|
||||
choice_text = ", ".join(choice_parts)
|
||||
|
||||
addon_warning_text = ""
|
||||
if data.get("renew_mode") == "renew":
|
||||
_rc_dev = data.get("renew_current_device_limit")
|
||||
_rs_dev = data.get("renew_selected_device_limit")
|
||||
_rc_trf = data.get("renew_current_traffic_limit")
|
||||
_rs_trf = data.get("renew_selected_traffic_limit")
|
||||
_addon_parts: list[str] = []
|
||||
if _rc_dev is not None and _rs_dev is not None and int(_rc_dev) > int(_rs_dev):
|
||||
_addon_parts.append(f"+{int(_rc_dev) - int(_rs_dev)} устройств")
|
||||
if _rc_trf is not None and _rs_trf is not None and int(_rc_trf) > int(_rs_trf):
|
||||
_addon_parts.append(f"+{int(_rc_trf) - int(_rs_trf)} ГБ")
|
||||
if _addon_parts:
|
||||
addon_warning_text = ADDON_RESET_CONFIG_WARNING.format(addons=", ".join(_addon_parts))
|
||||
|
||||
text = CONFIG_SCREEN_TEMPLATE.format(
|
||||
base=base_text,
|
||||
choice=choice_text,
|
||||
price=price_text,
|
||||
addon_warning=addon_warning_text,
|
||||
)
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user