diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py index c0cf035fd0..40b18b2f7d 100644 --- a/analytics/tests/test_support_views.py +++ b/analytics/tests/test_support_views.py @@ -303,7 +303,8 @@ class TestSupportEndpoint(ZulipTestCase): "Status: Active", "Billing schedule: Annual", "Licenses: 2/10 (Manual)", - "Price per license: $80.0", + "Price per license: $80.00", + "Annual recurring revenue: $800.00", "Next invoice date: 02 January 2017", '', '', @@ -648,7 +649,8 @@ class TestSupportEndpoint(ZulipTestCase): "Discount: 25%", "Billing schedule: Monthly", "Licenses: 2/10 (Manual)", - "Price per license: $6.0", + "Price per license: $6.00", + "Annual recurring revenue: $720.00", "Next invoice date: 02 February 2016", ], result, diff --git a/analytics/views/support.py b/analytics/views/support.py index 93eae91fec..88a98e5882 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_view context["get_org_type_display_name"] = get_org_type_display_name context["format_discount"] = format_discount_percentage + context["dollar_amount"] = cents_to_dollar_string context["realm_icon_url"] = realm_icon_url context["Confirmation"] = Confirmation context["sorted_realm_types"] = sorted( @@ -516,6 +518,7 @@ def remote_servers_support( context["get_plan_type_name"] = get_plan_type_string context["get_org_type_display_name"] = get_org_type_display_name context["format_discount"] = format_discount_percentage + context["dollar_amount"] = cents_to_dollar_string context["SPONSORED_PLAN_TYPE"] = RemoteZulipServer.PLAN_TYPE_COMMUNITY return render( diff --git a/corporate/lib/support.py b/corporate/lib/support.py index 12b2ddac44..cadd986609 100644 --- a/corporate/lib/support.py +++ b/corporate/lib/support.py @@ -54,6 +54,7 @@ class PlanData: is_legacy_plan: bool = False has_fixed_price: bool = False warning: 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) -> P plan_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_revenue return plan_data diff --git a/templates/analytics/current_plan_details.html b/templates/analytics/current_plan_details.html index 897ba0c5a8..c760c565f6 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 %} End date: {{ plan_data.current_plan.end_date.strftime('%d %B %Y') }} {% else %} - Billing schedule: {% if plan_data.current_plan.billing_schedule == plan_data.current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %} Licenses: {{ plan_data.licenses_used }}/{{ plan_data.licenses }} ({% if plan_data.current_plan.automanage_licenses %}Automatic{% else %}Manual{% endif %}) + Billing schedule: {% if plan_data.current_plan.billing_schedule == plan_data.current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %} {% if plan_data.current_plan.price_per_license %} - Price per license: ${{ plan_data.current_plan.price_per_license/100 }} + Price per license: ${{ dollar_amount(plan_data.current_plan.price_per_license) }} {% elif plan_data.current_plan.fixed_price %} - Fixed price: ${{ plan_data.current_plan.fixed_price/100 }} + Plan has a fixed price. {% endif %} + Annual recurring revenue: ${{ dollar_amount(plan_data.annual_recurring_revenue) }} Next invoice date: {{ plan_data.current_plan.next_invoice_date.strftime('%d %B %Y') }} {% endif %} {% endif %} diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.html index caeca9f7d1..636bc6c516 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 %} diff --git a/templates/analytics/remote_realm_details.html b/templates/analytics/remote_realm_details.html index 853bf80ebf..6bb5de18d6 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 %} diff --git a/templates/analytics/remote_server_support.html b/templates/analytics/remote_server_support.html index eaedbb01e1..7d83e3c71d 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 %} @@ -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 %} diff --git a/templates/analytics/support.html b/templates/analytics/support.html index ab02df03a7..aca6df8fca 100644 --- a/templates/analytics/support.html +++ b/templates/analytics/support.html @@ -51,6 +51,7 @@ {% with %} {% set format_discount = format_discount %} + {% set dollar_amount = dollar_amount %} {% include "analytics/realm_details.html" %} {% endwith %} @@ -62,6 +63,7 @@ {% with %} {% set format_discount = format_discount %} + {% set dollar_amount = dollar_amount %} {% include "analytics/realm_details.html" %} {% endwith %} @@ -114,6 +116,7 @@ {% with %} {% set format_discount = format_discount %} + {% set dollar_amount = dollar_amount %} {% include "analytics/realm_details.html" %} {% endwith %}