Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
support: Add plan's estimated annual revenue to remote support view.
Lauryn Menard9e9fec68a1fd
diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.pyindex c0cf035fd04..40b18b2f7d0 100644--- a/analytics/tests/test_support_views.py+++ b/analytics/tests/test_support_views.py@@ -303,7 +303,8 @@ class TestSupportEndpoint(ZulipTestCase):"<b>Status</b>: Active","<b>Billing schedule</b>: Annual","<b>Licenses</b>: 2/10 (Manual)",- "<b>Price per license</b>: $80.0",+ "<b>Price per license</b>: $80.00",+ "<b>Annual recurring revenue</b>: $800.00","<b>Next invoice date</b>: 02 January 2017",'<option value="send_invoice" selected>','<option value="charge_automatically" >',@@ -648,7 +649,8 @@ class TestSupportEndpoint(ZulipTestCase):"<b>Discount</b>: 25%","<b>Billing schedule</b>: Monthly","<b>Licenses</b>: 2/10 (Manual)",- "<b>Price per license</b>: $6.0",+ "<b>Price per license</b>: $6.00",+ "<b>Annual recurring revenue</b>: $720.00","<b>Next invoice date</b>: 02 February 2016",],result,diff --git a/analytics/views/support.py b/analytics/views/support.pyindex 93eae91fec2..88a98e5882d 100644--- a/analytics/views/support.py+++ b/analytics/views/support.py@@ -56,6 +56,7 @@ if settings.BILLING_ENABLED:RemoteServerBillingSession,SupportType,SupportViewRequest,+ cents_to_dollar_string,format_discount_percentage,)from corporate.lib.support import (@@ -366,6 +367,7 @@ def support(context["get_discount"] = get_customer_discount_for_support_viewcontext["get_org_type_display_name"] = get_org_type_display_namecontext["format_discount"] = format_discount_percentage+ context["dollar_amount"] = cents_to_dollar_stringcontext["realm_icon_url"] = realm_icon_urlcontext["Confirmation"] = Confirmationcontext["sorted_realm_types"] = sorted(@@ -516,6 +518,7 @@ def remote_servers_support(context["get_plan_type_name"] = get_plan_type_stringcontext["get_org_type_display_name"] = get_org_type_display_namecontext["format_discount"] = format_discount_percentage+ context["dollar_amount"] = cents_to_dollar_stringcontext["SPONSORED_PLAN_TYPE"] = RemoteZulipServer.PLAN_TYPE_COMMUNITYreturn render(diff --git a/corporate/lib/support.py b/corporate/lib/support.pyindex 12b2ddac441..cadd9866091 100644--- a/corporate/lib/support.py+++ b/corporate/lib/support.py@@ -54,6 +54,7 @@ class PlanData:is_legacy_plan: bool = Falsehas_fixed_price: bool = Falsewarning: Optional[str] = None+ annual_recurring_revenue: Optional[int] = None@dataclass@@ -140,6 +141,13 @@ def get_current_plan_data_for_support_view(billing_session: BillingSession) -> Pplan_data.current_plan.tier == CustomerPlan.TIER_SELF_HOSTED_LEGACY)plan_data.has_fixed_price = plan_data.current_plan.fixed_price is not None+ plan_revenue = billing_session.get_customer_plan_renewal_amount(+ plan_data.current_plan, timezone_now(), last_ledger_entry+ )+ if plan_data.current_plan.billing_schedule == CustomerPlan.BILLING_SCHEDULE_MONTHLY:+ plan_data.annual_recurring_revenue = plan_revenue * 12+ else:+ plan_data.annual_recurring_revenue = plan_revenuereturn plan_datadiff --git a/templates/analytics/current_plan_details.html b/templates/analytics/current_plan_details.htmlindex 897ba0c5a82..c760c565f68 100644--- a/templates/analytics/current_plan_details.html+++ b/templates/analytics/current_plan_details.html@@ -16,13 +16,14 @@{% if plan_data.is_legacy_plan %}<b>End date</b>: {{ plan_data.current_plan.end_date.strftime('%d %B %Y') }}<br />{% else %}- <b>Billing schedule</b>: {% if plan_data.current_plan.billing_schedule == plan_data.current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %}<br /><b>Licenses</b>: {{ plan_data.licenses_used }}/{{ plan_data.licenses }} ({% if plan_data.current_plan.automanage_licenses %}Automatic{% else %}Manual{% endif %})<br />+ <b>Billing schedule</b>: {% if plan_data.current_plan.billing_schedule == plan_data.current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %}<br />{% if plan_data.current_plan.price_per_license %}- <b>Price per license</b>: ${{ plan_data.current_plan.price_per_license/100 }}<br />+ <b>Price per license</b>: ${{ dollar_amount(plan_data.current_plan.price_per_license) }}<br />{% elif plan_data.current_plan.fixed_price %}- <b>Fixed price</b>: ${{ plan_data.current_plan.fixed_price/100 }}<br />+ <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 />{% endif %}{% endif %}diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.htmlindex caeca9f7d1d..636bc6c516c 100644--- a/templates/analytics/realm_details.html+++ b/templates/analytics/realm_details.html@@ -114,6 +114,7 @@{% with %}{% set plan_data = plan_data[realm.id] %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include 'analytics/current_plan_details.html' %}{% endwith %}</div>diff --git a/templates/analytics/remote_realm_details.html b/templates/analytics/remote_realm_details.htmlindex 853bf80ebfe..6bb5de18d67 100644--- a/templates/analytics/remote_realm_details.html+++ b/templates/analytics/remote_realm_details.html@@ -30,6 +30,7 @@{% with %}{% set plan_data = support_data[remote_realm.id].plan_data %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include 'analytics/current_plan_details.html' %}{% endwith %}</div>diff --git a/templates/analytics/remote_server_support.html b/templates/analytics/remote_server_support.htmlindex eaedbb01e16..7d83e3c71d2 100644--- a/templates/analytics/remote_server_support.html+++ b/templates/analytics/remote_server_support.html@@ -72,6 +72,7 @@{% with %}{% set plan_data = remote_servers_support_data[remote_server.id].plan_data %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include 'analytics/current_plan_details.html' %}{% endwith %}</div>@@ -91,6 +92,7 @@{% set support_data = remote_realms_support_data %}{% set get_plan_type_name = get_plan_type_name %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include "analytics/remote_realm_details.html" %}{% endwith %}</div>diff --git a/templates/analytics/support.html b/templates/analytics/support.htmlindex ab02df03a7e..aca6df8fcac 100644--- a/templates/analytics/support.html+++ b/templates/analytics/support.html@@ -51,6 +51,7 @@<div>{% with %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include "analytics/realm_details.html" %}{% endwith %}</div>@@ -62,6 +63,7 @@<div class="support-query-result">{% with %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include "analytics/realm_details.html" %}{% endwith %}</div>@@ -114,6 +116,7 @@<div>{% with %}{% set format_discount = format_discount %}+ {% set dollar_amount = dollar_amount %}{% include "analytics/realm_details.html" %}{% endwith %}</div>