billing: Show breakdown of renewal amount if not fixed_price.

This commit is contained in:
Aman Agrawal 2023-11-12 04:40:19 +00:00 committed by Tim Abbott
parent 17573cd1fb
commit 2997c269e1
2 changed files with 21 additions and 1 deletions

View File

@ -187,6 +187,21 @@ def billing_home(
else: else:
payment_method = "Billed by invoice" 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( context.update(
plan_name=plan.name, plan_name=plan.name,
has_active_plan=True, has_active_plan=True,
@ -204,7 +219,9 @@ def billing_home(
stripe_email=stripe_customer.email, stripe_email=stripe_customer.email,
CustomerPlan=CustomerPlan, CustomerPlan=CustomerPlan,
onboarding=onboarding, 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) return render(request, "corporate/billing.html", context=context)

View File

@ -129,6 +129,9 @@
{% endif %} {% endif %}
<br /> <br />
Expected charge: <strong>${{ renewal_amount }}</strong> Expected charge: <strong>${{ renewal_amount }}</strong>
{% 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 %} {% endif %}
{% else %} {% else %}
Your plan ends on <strong>{{ renewal_date }}</strong>, and does not renew. Your plan ends on <strong>{{ renewal_date }}</strong>, and does not renew.