Skip to content

Commit

Permalink
billing: Add an event_time argument to renewal_amount.
Browse files Browse the repository at this point in the history
  • Loading branch information
rishig committed Jan 29, 2019
1 parent a5324b6 commit 4ccbeeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions corporate/lib/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def next_invoice_date(plan: CustomerPlan) -> datetime:
periods += 1
return dt

def renewal_amount(plan: CustomerPlan) -> Optional[int]: # nocoverage: TODO
def renewal_amount(plan: CustomerPlan, event_time: datetime) -> Optional[int]: # nocoverage: TODO
if plan.fixed_price is not None:
return plan.fixed_price
last_ledger_entry = add_plan_renewal_to_license_ledger_if_needed(plan, timezone_now())
last_ledger_entry = add_plan_renewal_to_license_ledger_if_needed(plan, event_time)
if last_ledger_entry.licenses_at_next_renewal is None:
return None
assert(plan.price_per_license is not None) # for mypy
Expand Down Expand Up @@ -454,7 +454,7 @@ def estimate_annual_recurring_revenue_by_realm() -> Dict[str, int]: # nocoverag
status=CustomerPlan.ACTIVE).select_related('customer__realm'):
# TODO: figure out what to do for plans that don't automatically
# renew, but which probably will renew
renewal_cents = renewal_amount(plan) or 0
renewal_cents = renewal_amount(plan, timezone_now()) or 0
if plan.billing_schedule == CustomerPlan.MONTHLY:
renewal_cents *= 12
# TODO: Decimal stuff
Expand Down
2 changes: 1 addition & 1 deletion corporate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
licenses = last_ledger_entry.licenses
# 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)
renewal_cents = renewal_amount(plan, now)
# TODO: this is the case where the plan doesn't automatically renew
if renewal_cents is None: # nocoverage
renewal_cents = 0
Expand Down

0 comments on commit 4ccbeeb

Please sign in to comment.