From 2997c269e1582e69101733c963b6609943d47e13 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Sun, 12 Nov 2023 04:40:19 +0000 Subject: [PATCH] billing: Show breakdown of renewal amount if not fixed_price. --- corporate/views/billing_page.py | 19 ++++++++++++++++++- templates/corporate/billing.html | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/corporate/views/billing_page.py b/corporate/views/billing_page.py index 96a1c584e7..cf0cd1c52e 100644 --- a/corporate/views/billing_page.py +++ b/corporate/views/billing_page.py @@ -187,6 +187,21 @@ def billing_home( else: payment_method = "Billed by invoice" + fixed_price = ( + cents_to_dollar_string(plan.fixed_price) if plan.fixed_price is not None else None + ) + + billing_frequency = CustomerPlan.BILLING_SCHEDULES[plan.billing_schedule] + price_per_license_int = plan.price_per_license + if price_per_license_int is not None and billing_frequency == "Annual": + price_per_license_int = int(price_per_license_int / 12) + + price_per_license = ( + cents_to_dollar_string(price_per_license_int) + if price_per_license_int is not None + else None + ) + context.update( plan_name=plan.name, has_active_plan=True, @@ -204,7 +219,9 @@ def billing_home( stripe_email=stripe_customer.email, CustomerPlan=CustomerPlan, onboarding=onboarding, - billing_frequency=CustomerPlan.BILLING_SCHEDULES[plan.billing_schedule], + billing_frequency=billing_frequency, + fixed_price=fixed_price, + price_per_license=price_per_license, ) return render(request, "corporate/billing.html", context=context) diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html index d5da039b47..d48505281f 100644 --- a/templates/corporate/billing.html +++ b/templates/corporate/billing.html @@ -129,6 +129,9 @@ {% endif %}
Expected charge: ${{ renewal_amount }} + {% if not fixed_price %} + (${{ price_per_license }} x {{ licenses_at_next_renewal }} {{ 'user' if licenses_at_next_renewal == 1 else 'users' }} x {{ "1 month" if billing_frequency == "Monthly" else "12 months" }}) + {% endif %} {% endif %} {% else %} Your plan ends on {{ renewal_date }}, and does not renew.