mirror of https://github.com/zulip/zulip.git
billing: Create downgrade_at_the_end_of_billing_cycle.
This commit is contained in:
parent
b8b2e443bc
commit
dbaea757ae
|
@ -637,6 +637,11 @@ def downgrade_now_without_creating_additional_invoices(realm: Realm) -> None:
|
|||
plan.next_invoice_date = next_invoice_date(plan)
|
||||
plan.save(update_fields=["invoiced_through", "next_invoice_date"])
|
||||
|
||||
def downgrade_at_the_end_of_billing_cycle(realm: Realm) -> None:
|
||||
plan = get_current_plan_by_realm(realm)
|
||||
assert(plan is not None)
|
||||
do_change_plan_status(plan, CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE)
|
||||
|
||||
def void_all_open_invoices(realm: Realm) -> int:
|
||||
customer = get_customer_by_realm(realm)
|
||||
if customer is None:
|
||||
|
|
|
@ -20,6 +20,7 @@ from corporate.lib.stripe import (
|
|||
BillingError,
|
||||
do_change_plan_status,
|
||||
do_replace_payment_source,
|
||||
downgrade_at_the_end_of_billing_cycle,
|
||||
downgrade_now_without_creating_additional_invoices,
|
||||
get_latest_seat_count,
|
||||
make_end_of_cycle_updates_if_needed,
|
||||
|
@ -317,7 +318,7 @@ def change_plan_status(request: HttpRequest, user: UserProfile,
|
|||
do_change_plan_status(plan, status)
|
||||
elif status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE:
|
||||
assert(plan.status == CustomerPlan.ACTIVE)
|
||||
do_change_plan_status(plan, status)
|
||||
downgrade_at_the_end_of_billing_cycle(user.realm)
|
||||
elif status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE:
|
||||
assert(plan.billing_schedule == CustomerPlan.MONTHLY)
|
||||
assert(plan.status == CustomerPlan.ACTIVE)
|
||||
|
|
Loading…
Reference in New Issue