stripe: Change realm.plan_type when upgrading a realm to Plus plan.

This commit is contained in:
Mateusz Mandera 2023-02-08 12:30:28 +01:00 committed by Tim Abbott
parent 4dfe3d36e0
commit 89a72c92ea
2 changed files with 7 additions and 0 deletions

View File

@ -1187,6 +1187,10 @@ def switch_realm_from_standard_to_plus_plan(realm: Realm) -> None:
standard_plan.next_invoice_date = plan_switch_time standard_plan.next_invoice_date = plan_switch_time
standard_plan.save(update_fields=["status", "next_invoice_date"]) standard_plan.save(update_fields=["status", "next_invoice_date"])
from zerver.actions.realm_settings import do_change_realm_plan_type
do_change_realm_plan_type(realm, Realm.PLAN_TYPE_PLUS, acting_user=None)
standard_plan_next_renewal_date = start_of_next_billing_cycle(standard_plan, plan_switch_time) standard_plan_next_renewal_date = start_of_next_billing_cycle(standard_plan, plan_switch_time)
standard_plan_last_renewal_ledger = ( standard_plan_last_renewal_ledger = (

View File

@ -3804,6 +3804,9 @@ class StripeTest(StripeTestCase):
self.assertEqual(plus_plan.tier, CustomerPlan.PLUS) self.assertEqual(plus_plan.tier, CustomerPlan.PLUS)
self.assertEqual(LicenseLedger.objects.filter(plan=plus_plan).count(), 1) self.assertEqual(LicenseLedger.objects.filter(plan=plus_plan).count(), 1)
realm.refresh_from_db()
self.assertEqual(realm.plan_type, Realm.PLAN_TYPE_PLUS)
# There are 9 licenses and the realm is on the Standard monthly plan. # There are 9 licenses and the realm is on the Standard monthly plan.
# Therefore, the customer has already paid 800 * 9 = 7200 = $72 for # Therefore, the customer has already paid 800 * 9 = 7200 = $72 for
# the month. Once they upgrade to Plus, the new price for their 9 # the month. Once they upgrade to Plus, the new price for their 9