From 978f68e7be42b0faf92d9ac5bc0bbaa2022ac95b Mon Sep 17 00:00:00 2001 From: Fringg Date: Thu, 12 Mar 2026 22:50:13 +0300 Subject: [PATCH] refactor: migrate recurrent and monitoring services to PricingEngine Mechanical re-point of calculate_renewal_price calls to use unified PricingEngine. Both services now get consistent pricing with correct discount formulas and server fallback behavior. --- app/services/monitoring_service.py | 11 ++++++----- app/services/recurrent_payment_service.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/services/monitoring_service.py b/app/services/monitoring_service.py index 3cd49fb0..78d2632b 100644 --- a/app/services/monitoring_service.py +++ b/app/services/monitoring_service.py @@ -1053,12 +1053,13 @@ class MonitoringService: autopay_period = 30 try: - renewal_cost = await self.subscription_service.calculate_renewal_price( - subscription, - autopay_period, - db, - user=user, + from app.services.pricing_engine import PricingEngine + + pricing_engine = PricingEngine() + pricing = await pricing_engine.calculate_renewal_price( + db, subscription, autopay_period, user=user, ) + renewal_cost = pricing.final_total except Exception as e: logger.error( 'Ошибка расчёта стоимости автопродления, пропускаем', diff --git a/app/services/recurrent_payment_service.py b/app/services/recurrent_payment_service.py index 9fc653e0..86a58c87 100644 --- a/app/services/recurrent_payment_service.py +++ b/app/services/recurrent_payment_service.py @@ -224,12 +224,13 @@ async def _process_single_subscription( autopay_period = 30 try: - renewal_cost = await subscription_service.calculate_renewal_price( - subscription, - autopay_period, - db, - user=user, + from app.services.pricing_engine import PricingEngine + + pricing_engine = PricingEngine() + pricing = await pricing_engine.calculate_renewal_price( + db, subscription, autopay_period, user=user, ) + renewal_cost = pricing.final_total except Exception as e: logger.error( 'Ошибка расчёта стоимости для рекуррентного платежа',