mirror of https://github.com/zulip/zulip.git
billing: Refactor renewal_amount to return 0 instead of None.
This commit is contained in:
parent
447ae77b24
commit
03d21c6317
|
@ -110,12 +110,12 @@ def next_invoice_date(plan: CustomerPlan) -> datetime:
|
||||||
periods += 1
|
periods += 1
|
||||||
return dt
|
return dt
|
||||||
|
|
||||||
def renewal_amount(plan: CustomerPlan, event_time: datetime) -> Optional[int]: # nocoverage: TODO
|
def renewal_amount(plan: CustomerPlan, event_time: datetime) -> int: # nocoverage: TODO
|
||||||
if plan.fixed_price is not None:
|
if plan.fixed_price is not None:
|
||||||
return plan.fixed_price
|
return plan.fixed_price
|
||||||
last_ledger_entry = add_plan_renewal_to_license_ledger_if_needed(plan, event_time)
|
last_ledger_entry = add_plan_renewal_to_license_ledger_if_needed(plan, event_time)
|
||||||
if last_ledger_entry.licenses_at_next_renewal is None:
|
if last_ledger_entry.licenses_at_next_renewal is None:
|
||||||
return None
|
return 0
|
||||||
assert(plan.price_per_license is not None) # for mypy
|
assert(plan.price_per_license is not None) # for mypy
|
||||||
return plan.price_per_license * last_ledger_entry.licenses_at_next_renewal
|
return plan.price_per_license * last_ledger_entry.licenses_at_next_renewal
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ def estimate_annual_recurring_revenue_by_realm() -> Dict[str, int]: # nocoverag
|
||||||
status=CustomerPlan.ACTIVE).select_related('customer__realm'):
|
status=CustomerPlan.ACTIVE).select_related('customer__realm'):
|
||||||
# TODO: figure out what to do for plans that don't automatically
|
# TODO: figure out what to do for plans that don't automatically
|
||||||
# renew, but which probably will renew
|
# renew, but which probably will renew
|
||||||
renewal_cents = renewal_amount(plan, timezone_now()) or 0
|
renewal_cents = renewal_amount(plan, timezone_now())
|
||||||
if plan.billing_schedule == CustomerPlan.MONTHLY:
|
if plan.billing_schedule == CustomerPlan.MONTHLY:
|
||||||
renewal_cents *= 12
|
renewal_cents *= 12
|
||||||
# TODO: Decimal stuff
|
# TODO: Decimal stuff
|
||||||
|
|
|
@ -174,9 +174,6 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
||||||
# Should do this in javascript, using the user's timezone
|
# Should do this in javascript, using the user's timezone
|
||||||
renewal_date = '{dt:%B} {dt.day}, {dt.year}'.format(dt=start_of_next_billing_cycle(plan, now))
|
renewal_date = '{dt:%B} {dt.day}, {dt.year}'.format(dt=start_of_next_billing_cycle(plan, now))
|
||||||
renewal_cents = renewal_amount(plan, now)
|
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
|
|
||||||
charge_automatically = plan.charge_automatically
|
charge_automatically = plan.charge_automatically
|
||||||
if charge_automatically:
|
if charge_automatically:
|
||||||
payment_method = payment_method_string(stripe_customer)
|
payment_method = payment_method_string(stripe_customer)
|
||||||
|
|
Loading…
Reference in New Issue