billing: downgrade_now -> downgrade_now_without_creating_additional_invoice.

This commit is contained in:
Vishnu KS
2020-08-13 13:52:58 +05:30
committed by Tim Abbott
parent 0c2d1f068d
commit 0d30f59c97
3 changed files with 8 additions and 5 deletions

View File

@@ -627,7 +627,7 @@ def estimate_annual_recurring_revenue_by_realm() -> Dict[str, int]: # nocoverag
# During realm deactivation we instantly downgrade the plan to Limited. # During realm deactivation we instantly downgrade the plan to Limited.
# Extra users added in the final month are not charged. Also used # Extra users added in the final month are not charged. Also used
# for the cancellation of Free Trial. # for the cancellation of Free Trial.
def downgrade_now(realm: Realm) -> None: def downgrade_now_without_creating_additional_invoices(realm: Realm) -> None:
plan = get_current_plan_by_realm(realm) plan = get_current_plan_by_realm(realm)
if plan is None: if plan is None:
return return

View File

@@ -20,7 +20,7 @@ from corporate.lib.stripe import (
BillingError, BillingError,
do_change_plan_status, do_change_plan_status,
do_replace_payment_source, do_replace_payment_source,
downgrade_now, downgrade_now_without_creating_additional_invoices,
get_latest_seat_count, get_latest_seat_count,
make_end_of_cycle_updates_if_needed, make_end_of_cycle_updates_if_needed,
process_initial_upgrade, process_initial_upgrade,
@@ -325,7 +325,7 @@ def change_plan_status(request: HttpRequest, user: UserProfile,
do_change_plan_status(plan, status) do_change_plan_status(plan, status)
elif status == CustomerPlan.ENDED: elif status == CustomerPlan.ENDED:
assert(plan.status == CustomerPlan.FREE_TRIAL) assert(plan.status == CustomerPlan.FREE_TRIAL)
downgrade_now(user.realm) downgrade_now_without_creating_additional_invoices(user.realm)
return json_success() return json_success()
@require_billing_access @require_billing_access

View File

@@ -232,7 +232,10 @@ from zerver.models import (
from zerver.tornado.django_api import send_event from zerver.tornado.django_api import send_event
if settings.BILLING_ENABLED: if settings.BILLING_ENABLED:
from corporate.lib.stripe import downgrade_now, update_license_ledger_if_needed from corporate.lib.stripe import (
downgrade_now_without_creating_additional_invoices,
update_license_ledger_if_needed,
)
# This will be used to type annotate parameters in a function if the function # This will be used to type annotate parameters in a function if the function
# works on both str and unicode in python 2 but in python 3 it only works on str. # works on both str and unicode in python 2 but in python 3 it only works on str.
@@ -813,7 +816,7 @@ def do_deactivate_realm(realm: Realm, acting_user: Optional[UserProfile]=None) -
realm.save(update_fields=["deactivated"]) realm.save(update_fields=["deactivated"])
if settings.BILLING_ENABLED: if settings.BILLING_ENABLED:
downgrade_now(realm) downgrade_now_without_creating_additional_invoices(realm)
event_time = timezone_now() event_time = timezone_now()
RealmAuditLog.objects.create( RealmAuditLog.objects.create(