Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
support: Show date for start of next billing cycle for current plan.
Lauryn Menardfca9ff1ae7b2
diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.pyindex c5a724d1171..4225ea964d9 100644--- a/analytics/tests/test_support_views.py+++ b/analytics/tests/test_support_views.py@@ -8,7 +8,12 @@ import time_machinefrom django.utils.timezone import now as timezone_nowfrom typing_extensions import override-from corporate.lib.stripe import RealmBillingSession, RemoteRealmBillingSession, add_months+from corporate.lib.stripe import (+ RealmBillingSession,+ RemoteRealmBillingSession,+ add_months,+ start_of_next_billing_cycle,+)from corporate.models import (Customer,CustomerPlan,@@ -599,7 +604,7 @@ class TestSupportEndpoint(ZulipTestCase):"<b>Licenses</b>: 2/10 (Manual)","<b>Price per license</b>: $80.00","<b>Annual recurring revenue</b>: $800.00",- "<b>Next invoice date</b>: 02 January 2017",+ "<b>Start of next billing cycle</b>:",'<option value="send_invoice" selected>','<option value="charge_automatically" >',],@@ -934,6 +939,8 @@ class TestSupportEndpoint(ZulipTestCase):assert plan is not Noneself.assertEqual(customer.default_discount, Decimal(25))self.assertEqual(plan.discount, Decimal(25))+ start_next_billing_cycle = start_of_next_billing_cycle(plan, timezone_now())+ biling_cycle_string = start_next_billing_cycle.strftime("%d %B %Y")result = self.client_get("/activity/support", {"q": "lear"})self.assert_in_success_response(@@ -945,7 +952,7 @@ class TestSupportEndpoint(ZulipTestCase):"<b>Licenses</b>: 2/10 (Manual)","<b>Price per license</b>: $6.00","<b>Annual recurring revenue</b>: $720.00",- "<b>Next invoice date</b>: 02 February 2016",+ f"<b>Start of next billing cycle</b>: {biling_cycle_string}",],result,)diff --git a/corporate/lib/support.py b/corporate/lib/support.pyindex a579678bedb..a9b5eb47e49 100644--- a/corporate/lib/support.py+++ b/corporate/lib/support.py@@ -13,6 +13,7 @@ from corporate.lib.stripe import (BillingSession,RemoteRealmBillingSession,RemoteServerBillingSession,+ start_of_next_billing_cycle,)from corporate.models import (Customer,@@ -60,6 +61,7 @@ class PlanData:next_plan: Optional["CustomerPlan"] = Nonelicenses: Optional[int] = Nonelicenses_used: Optional[int] = None+ next_billing_cycle_start: Optional[datetime] = Noneis_legacy_plan: bool = Falsehas_fixed_price: bool = Falsewarning: Optional[str] = None@@ -167,7 +169,6 @@ def get_current_plan_data_for_support_view(billing_session: BillingSession) -> Pplan_data.warning = ("Recent audit log data missing: No information for used licenses")-assert plan_data.current_plan is not None # for mypyplan_data.next_plan = billing_session.get_next_plan(plan_data.current_plan)@@ -186,6 +187,17 @@ def get_current_plan_data_for_support_view(billing_session: BillingSession) -> Pelse:plan_data.estimated_next_plan_revenue = 0 # nocoverage+ if plan_data.current_plan.status in (+ CustomerPlan.FREE_TRIAL,+ CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL,+ ): # nocoverage+ assert plan_data.current_plan.next_invoice_date is not None+ plan_data.next_billing_cycle_start = plan_data.current_plan.next_invoice_date+ else:+ plan_data.next_billing_cycle_start = start_of_next_billing_cycle(+ plan_data.current_plan, timezone_now()+ )+plan_data.is_legacy_plan = (plan_data.current_plan.tier == CustomerPlan.TIER_SELF_HOSTED_LEGACY)diff --git a/templates/analytics/current_plan_details.html b/templates/analytics/current_plan_details.htmlindex c760c565f68..7e07c0c1460 100644--- a/templates/analytics/current_plan_details.html+++ b/templates/analytics/current_plan_details.html@@ -24,6 +24,6 @@<b>Plan has a fixed price.</b>{% endif %}<b>Annual recurring revenue</b>: ${{ dollar_amount(plan_data.annual_recurring_revenue) }}<br />- <b>Next invoice date</b>: {{ plan_data.current_plan.next_invoice_date.strftime('%d %B %Y') }}<br />+ <b>Start of next billing cycle</b>: {{ plan_data.next_billing_cycle_start.strftime('%d %B %Y') }}<br />{% endif %}{% endif %}