Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
support: Show annual revenue for active fixed price plans.
Lauryn Menard4fcf7945b0f9
diff --git a/corporate/lib/activity.py b/corporate/lib/activity.pyindex 0a1da331a98..90a6bf1aa4b 100644--- a/corporate/lib/activity.py+++ b/corporate/lib/activity.py@@ -191,18 +191,15 @@ def get_remote_activity_plan_data(elif remote_realm is not None:renewal_cents = RemoteRealmBillingSession(remote_realm=remote_realm- ).get_customer_plan_renewal_amount(plan, license_ledger)+ ).get_annual_recurring_revenue_for_support_data(plan, license_ledger)current_rate = get_plan_rate_percentage(plan.discount)else:assert remote_server is not Nonerenewal_cents = RemoteServerBillingSession(remote_server=remote_server- ).get_customer_plan_renewal_amount(plan, license_ledger)+ ).get_annual_recurring_revenue_for_support_data(plan, license_ledger)current_rate = get_plan_rate_percentage(plan.discount)- if plan.billing_schedule == CustomerPlan.BILLING_SCHEDULE_MONTHLY:- renewal_cents *= 12-return RemoteActivityPlanData(current_status=plan.get_plan_status_as_text(),current_plan_name=plan.name,@@ -238,9 +235,7 @@ def get_estimated_arr_and_rate_by_realm() -> Tuple[Dict[str, int], Dict[str, strassert latest_ledger_entry is not Nonerenewal_cents = RealmBillingSession(realm=plan.customer.realm- ).get_customer_plan_renewal_amount(plan, latest_ledger_entry)- if plan.billing_schedule == CustomerPlan.BILLING_SCHEDULE_MONTHLY:- renewal_cents *= 12+ ).get_annual_recurring_revenue_for_support_data(plan, latest_ledger_entry)annual_revenue[plan.customer.realm.string_id] = renewal_centsplan_rate[plan.customer.realm.string_id] = get_plan_rate_percentage(plan.discount)return annual_revenue, plan_ratediff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 57709ebc4d9..67536936d85 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -2305,6 +2305,19 @@ class BillingSession(ABC):).first()return None+ def get_annual_recurring_revenue_for_support_data(+ self, plan: CustomerPlan, last_ledger_entry: LicenseLedger+ ) -> int:+ if plan.fixed_price is not None:+ # For support and activity views, we want to show the annual+ # revenue for the currently configured fixed price, which+ # is the annual amount charged in cents.+ return plan.fixed_price+ revenue = self.get_customer_plan_renewal_amount(plan, last_ledger_entry)+ if plan.billing_schedule == CustomerPlan.BILLING_SCHEDULE_MONTHLY:+ revenue *= 12+ return revenue+def get_customer_plan_renewal_amount(self,plan: CustomerPlan,diff --git a/corporate/lib/support.py b/corporate/lib/support.pyindex ac04c30ab7f..1acfd0c5669 100644--- a/corporate/lib/support.py+++ b/corporate/lib/support.py@@ -186,7 +186,7 @@ def get_customer_sponsorship_data(customer: Customer) -> SponsorshipData:def get_annual_invoice_count(billing_schedule: int) -> int:if billing_schedule == CustomerPlan.BILLING_SCHEDULE_MONTHLY:return 12- else:+ else: # nocoveragereturn 1@@ -283,13 +283,11 @@ def get_plan_data_for_support_view(plan_data.is_current_plan_billable = billing_session.check_plan_tier_is_billable(plan_tier=plan_data.current_plan.tier)- annual_invoice_count = get_annual_invoice_count(plan_data.current_plan.billing_schedule)if last_ledger_entry is not None:plan_data.annual_recurring_revenue = (- billing_session.get_customer_plan_renewal_amount(+ billing_session.get_annual_recurring_revenue_for_support_data(plan_data.current_plan, last_ledger_entry)- * annual_invoice_count)else:plan_data.annual_recurring_revenue = 0 # nocoveragediff --git a/corporate/tests/test_activity_views.py b/corporate/tests/test_activity_views.pyindex 0bd21d05ebf..058f0974df3 100644--- a/corporate/tests/test_activity_views.py+++ b/corporate/tests/test_activity_views.py@@ -367,6 +367,6 @@ class ActivityTest(ZulipTestCase):add_audit_log_data(realm.server, remote_realm=realm, realm_id=None)self.login("iago")- with self.assert_database_query_count(12):+ with self.assert_database_query_count(11):result = self.client_get("/activity/remote")self.assertEqual(result.status_code, 200)