Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stripe: Reset current plan status if deleting fixed-price plan renewal.
Lauryn Menard1742047790d7
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex bacfcb1a48e..d23aa6bf925 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -1718,6 +1718,9 @@ class BillingSession(ABC):).first()assert fixed_price_next_plan is not Nonefixed_price_next_plan.delete()++ assert current_plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END+ do_change_plan_status(current_plan, CustomerPlan.ACTIVE)return "Fixed-price scheduled plan deleted"fixed_price_offer = CustomerPlanOffer.objects.filter(customer=customer, status=CustomerPlanOffer.CONFIGUREDdiff --git a/corporate/tests/test_support_views.py b/corporate/tests/test_support_views.pyindex ae629445752..2c4be9cc3e5 100644--- a/corporate/tests/test_support_views.py+++ b/corporate/tests/test_support_views.py@@ -1817,13 +1817,18 @@ class TestSupportEndpoint(ZulipTestCase):self.assertTrue(next_plan.automanage_licenses)# Test deleting the fixed-price next plan via support.- result = self.client_post(- "/activity/support",- {- "realm_id": f"{lear_realm.id}",- "delete_fixed_price_next_plan": "true",- },- )+ with (+ self.assertLogs("corporate.stripe", "INFO") as m,+ ):+ result = self.client_post(+ "/activity/support",+ {+ "realm_id": f"{lear_realm.id}",+ "delete_fixed_price_next_plan": "true",+ },+ )+ expected_log = f"INFO:corporate.stripe:Change plan status: Customer.id: {customer.id}, CustomerPlan.id: {plan.id}, status: {CustomerPlan.ACTIVE}"+ self.assertEqual(m.output[0], expected_log)self.assert_in_success_response(["Fixed-price scheduled plan deleted"],result,@@ -1831,6 +1836,10 @@ class TestSupportEndpoint(ZulipTestCase):next_plan = billing_session.get_next_plan(plan)self.assertIsNone(next_plan)+ # Confirm that the existing plan's status has been reset to active.+ plan.refresh_from_db()+ self.assertEqual(plan.status, CustomerPlan.ACTIVE)+def test_deactivated_realm_support_view_and_actions(self) -> None:support_admin = self.example_user("iago")with self.settings(BILLING_ENABLED=True):