From fd139b28a2c45cc3fbd2e01707fb83fbabf57c71 Mon Sep 17 00:00:00 2001 From: Fringg Date: Thu, 5 Mar 2026 09:30:27 +0300 Subject: [PATCH] fix: abs() for transaction amounts in admin notifications and subscription events - send_subscription_purchase_notification: abs(transaction.amount_kopeks) when no explicit amount_kopeks passed - send_subscription_renewal_notification: abs(transaction.amount_kopeks) for SubscriptionEvent storage - Prevents negative amounts in admin Telegram messages and SubscriptionEvent records --- app/services/admin_notification_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/admin_notification_service.py b/app/services/admin_notification_service.py index 7cd2862e..e8d64e5f 100644 --- a/app/services/admin_notification_service.py +++ b/app/services/admin_notification_service.py @@ -403,7 +403,7 @@ class AdminNotificationService: ) -> bool: try: total_amount = ( - amount_kopeks if amount_kopeks is not None else (transaction.amount_kopeks if transaction else 0) + amount_kopeks if amount_kopeks is not None else (abs(transaction.amount_kopeks) if transaction else 0) ) await self._record_subscription_event( @@ -846,7 +846,7 @@ class AdminNotificationService: user=user, subscription=subscription, transaction=transaction, - amount_kopeks=transaction.amount_kopeks, + amount_kopeks=abs(transaction.amount_kopeks), message='Subscription renewed', occurred_at=transaction.completed_at or transaction.created_at, extra={