billing: Show licenses_used and better renewal information on /billing.

This commit is contained in:
Rishi Gupta 2019-01-29 07:38:24 -08:00
parent 4ccbeeb4a9
commit 81745ba171
3 changed files with 9 additions and 2 deletions

View File

@ -427,6 +427,7 @@ class StripeTest(StripeTestCase):
self.assert_not_in_success_response(['Pay annually'], response)
for substring in [
'Zulip Standard', str(self.seat_count),
'You are using', '%s of %s licenses' % (self.seat_count, self.seat_count),
'Your plan will renew on', 'January 2, 2013', '$%s.00' % (80 * self.seat_count,),
'Visa ending in 4242',
'Update card']:
@ -510,6 +511,7 @@ class StripeTest(StripeTestCase):
self.assert_not_in_success_response(['Pay annually', 'Update card'], response)
for substring in [
'Zulip Standard', str(123),
'You are using', '%s of %s licenses' % (self.seat_count, 123),
'Your plan will renew on', 'January 2, 2013', '$9,840.00', # 9840 = 80 * 123
'Billed by invoice']:
self.assert_in_response(substring, response)

View File

@ -170,8 +170,8 @@ def billing_home(request: HttpRequest) -> HttpResponse:
}[plan.tier]
now = timezone_now()
last_ledger_entry = add_plan_renewal_to_license_ledger_if_needed(plan, now)
# TODO: this is not really correct; need to give the situation as of the "fillstate"
licenses = last_ledger_entry.licenses
licenses_used = get_seat_count(user.realm)
# Should do this in javascript, using the user's timezone
renewal_date = '{dt:%B} {dt.day}, {dt.year}'.format(dt=next_renewal_date(plan, now))
renewal_cents = renewal_amount(plan, now)
@ -196,6 +196,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
context.update({
'plan_name': plan_name,
'licenses': licenses,
'licenses_used': licenses_used,
'renewal_date': renewal_date,
'renewal_amount': '{:,.2f}'.format(renewal_cents / 100.),
'payment_method': payment_method,

View File

@ -31,10 +31,14 @@
<div class="tab-content">
<div class="tab-pane active" id="overview">
<p>Your current plan is <strong>{{ plan_name }}</strong>.</p>
<p>You are paying for <strong>{{ licenses }} users</strong>.</p>
<p>You are using <strong>{{ licenses_used }} of {{ licenses }} licenses</strong>.</p>
<p>
{% if renewal_amount %}
Your plan will renew on <strong>{{ renewal_date }}</strong> for
<strong>${{ renewal_amount }}</strong>.
{% else %}
Your plan ends on <strong>{{ renewal_date }}</strong>, and does not renew.
{% endif %}
</p>
</div>
<div class="tab-pane" id="payment-method" data-email="{{stripe_email}}" data-key="{{publishable_key}}">