From dcc7f9eb7279f189b97d67399414633d089b2fc1 Mon Sep 17 00:00:00 2001 From: VAQYBIN Date: Tue, 20 Jan 2026 00:51:05 +0500 Subject: [PATCH] =?UTF-8?q?fix(promo):=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=B4=D1=83=D0=B1=D0=BB=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=D0=BC=20=D1=81=D0=BA=D0=B8=D0=B4?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=B8=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=BC=D0=BE=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/subscription/payments_yookassa.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bot/handlers/user/subscription/payments_yookassa.py b/bot/handlers/user/subscription/payments_yookassa.py index 97475f1..807bcfd 100644 --- a/bot/handlers/user/subscription/payments_yookassa.py +++ b/bot/handlers/user/subscription/payments_yookassa.py @@ -78,22 +78,22 @@ async def _initiate_yk_payment( if not callback.message: return False - # NEW: Check for active discount and apply if exists - original_price = price_rub + # Check for active discount to save metadata (price already discounted from previous step) + original_price = None discount_amount = None active_promo_code_id = None if promo_code_service: active_discount = await active_discount_dal.get_active_discount(session, user_id) if active_discount: - final_price, discount_amount = promo_code_service.calculate_discounted_price( - price_rub, active_discount.discount_percentage - ) - price_rub = final_price + # Price is already discounted, calculate original price backwards + discount_pct = active_discount.discount_percentage + original_price = price_rub / (1 - discount_pct / 100) + discount_amount = original_price - price_rub active_promo_code_id = active_discount.promo_code_id logging.info( - f"Applying {active_discount.discount_percentage}% discount to YooKassa payment: " - f"{original_price} -> {price_rub}" + f"Recording {discount_pct}% discount for YooKassa payment: " + f"original {original_price:.2f} -> final {price_rub}" ) payment_description = (