|
1 | | -# Copyright (c) 2025, DjaoDjin inc. |
| 1 | +# Copyright (c) 2026, DjaoDjin inc. |
2 | 2 | # All rights reserved. |
3 | 3 | # |
4 | 4 | # Redistribution and use in source and binary forms, with or without |
@@ -179,8 +179,7 @@ def get_cart_options(subscription, created_at=None, |
179 | 179 | coupon_discount_amount = 0 |
180 | 180 | if coupon: |
181 | 181 | coupon_discount_amount = coupon.get_discount_amount( |
182 | | - prorated_amount=prorated_amount, |
183 | | - period_amount=plan.period_amount) |
| 182 | + amount=full_amount, period_amount=plan.period_amount) |
184 | 183 | discount_by_types[coupon.discount_type] = coupon.discount_value |
185 | 184 | amount = max(full_amount - coupon_discount_amount, 0) |
186 | 185 |
|
@@ -220,24 +219,24 @@ def get_cart_options(subscription, created_at=None, |
220 | 219 | prorated_amount + advance_discount.full_periods_amount) |
221 | 220 | advance_discount_amount = advance_discount.get_discount_amount( |
222 | 221 | prorated_amount=prorated_amount) |
| 222 | + amount = full_amount - advance_discount_amount |
223 | 223 | discount_by_types = {} |
224 | 224 | discount_by_types[advance_discount.discount_type] = \ |
225 | 225 | advance_discount.discount_value |
226 | | - coupon_discount_amount = 0 |
227 | 226 | if coupon: |
228 | 227 | coupon_discount_amount = coupon.get_discount_amount( |
229 | | - prorated_amount=prorated_amount, |
230 | | - period_amount=plan.period_amount, |
231 | | - advance_amount=(advance_discount.full_periods_amount |
232 | | - - plan.period_amount)) |
| 228 | + amount=amount, period_amount=plan.period_amount) |
| 229 | + amount = max(amount - coupon_discount_amount, 0) |
233 | 230 | if coupon.discount_type in discount_by_types: |
234 | | - discount_by_types[coupon.discount_type] += \ |
235 | | - coupon.discount_value |
| 231 | + if coupon.discount_type == Coupon.PERCENTAGE: |
| 232 | + discount_by_types[coupon.discount_type] = ( |
| 233 | + full_amount - amount) * 10000 // full_amount |
| 234 | + else: |
| 235 | + discount_by_types[coupon.discount_type] += \ |
| 236 | + coupon.discount_value |
236 | 237 | else: |
237 | 238 | discount_by_types[coupon.discount_type] = \ |
238 | 239 | coupon.discount_value |
239 | | - amount = (full_amount - advance_discount_amount |
240 | | - - coupon_discount_amount) |
241 | 240 | if amount <= 0: |
242 | 241 | continue # never allow to be completely free here. |
243 | 242 | nb_periods = ( |
|
0 commit comments