fix: promo group discount applied to restricted tariffs in autopay
The pricing engine applied promo group discounts unconditionally, without checking if the tariff is available for the user's promo group. In autopay: user with VIP group (60% discount, restricted to Premium tariff) would get 60% off when auto-renewing a Basic tariff that their group should not cover. Fix: in _calculate_tariff_core, check tariff.is_available_for_promo_group before applying group discounts. If tariff is not available for the user's promo group, the discount is zeroed — subscription renews at full price. Protects ALL pricing paths (autopay, recurrent, manual).
This commit is contained in:
@@ -603,6 +603,9 @@ class PricingEngine:
|
||||
period_pct = 0
|
||||
devices_pct = 0
|
||||
promo_group = self.resolve_promo_group(user)
|
||||
# Only apply promo group discount if the tariff is available for this group
|
||||
if promo_group is not None and not tariff.is_available_for_promo_group(promo_group.id):
|
||||
promo_group = None
|
||||
if promo_group is not None:
|
||||
period_pct = promo_group.get_discount_percent('period', period_days)
|
||||
devices_pct = promo_group.get_discount_percent('devices', period_days)
|
||||
|
||||
Reference in New Issue
Block a user