Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Render page for legacy server scheduled for upgrade.
Aman Agrawal1a063986e363
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 96c7b7be3ff..a6b34d696ea 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -794,6 +794,23 @@ class BillingSession(ABC):assert plan.end_date is not Nonereturn plan.end_date.strftime("%B %d, %Y")+ def get_legacy_remote_server_new_plan_name(+ self, customer: Customer+ ) -> Optional[str]: # nocoverage+ legacy_plan = self.get_remote_server_legacy_plan(+ customer, CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END+ )+ if legacy_plan is None:+ return None++ # This also asserts that such a plan should exist.+ assert legacy_plan.end_date is not None+ return CustomerPlan.objects.get(+ customer=customer,+ billing_cycle_anchor=legacy_plan.end_date,+ status=CustomerPlan.NEVER_STARTED,+ ).name+@catch_stripe_errorsdef create_stripe_customer(self) -> Customer:stripe_customer_data = self.get_data_for_stripe_customer()@@ -1621,6 +1638,14 @@ class BillingSession(ABC):if plan.fixed_price is not Noneelse None)+ remote_server_legacy_plan_end_date = (+ self.get_formatted_remote_server_legacy_plan_end_date(+ customer, status=CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END+ )+ )+ legacy_remote_server_new_plan_name = self.get_legacy_remote_server_new_plan_name(+ customer+ )context = {"plan_name": plan.name,"has_active_plan": True,@@ -1645,6 +1670,9 @@ class BillingSession(ABC):"is_sponsorship_pending": customer.sponsorship_pending,"discount_percent": format_discount_percentage(customer.default_discount),"is_self_hosted_billing": not isinstance(self, RealmBillingSession),+ "is_server_on_legacy_plan": remote_server_legacy_plan_end_date is not None,+ "remote_server_legacy_plan_end_date": remote_server_legacy_plan_end_date,+ "legacy_remote_server_new_plan_name": legacy_remote_server_new_plan_name,}return contextdiff --git a/corporate/models.py b/corporate/models.pyindex f55221a3ce4..49ac8c512b4 100644--- a/corporate/models.py+++ b/corporate/models.py@@ -297,6 +297,7 @@ class CustomerPlan(models.Model):CustomerPlan.TIER_CLOUD_STANDARD: "Zulip Cloud Standard",CustomerPlan.TIER_CLOUD_PLUS: "Zulip Cloud Plus",CustomerPlan.TIER_CLOUD_ENTERPRISE: "Zulip Enterprise",+ CustomerPlan.TIER_SELF_HOSTED_LEGACY: "Self-managed",CustomerPlan.TIER_SELF_HOSTED_BUSINESS: "Zulip Business",}[tier]diff --git a/templates/corporate/billing.html b/templates/corporate/billing.htmlindex ff478b66cf3..d758e05e4d2 100644--- a/templates/corporate/billing.html+++ b/templates/corporate/billing.html@@ -38,11 +38,20 @@<div id="org-current-plan" class="not-editable-realm-field">{% if free_trial or downgrade_at_end_of_free_trial %}{{ plan_name }} <i>(free trial)</i>+ {% elif is_server_on_legacy_plan %}+ {{ plan_name }} <i>(legacy plan)</i>{% else %}{{ plan_name }}{% endif %}</div></div>+ {% if is_server_on_legacy_plan %}+ <div class="input-box billing-page-field no-validation">+ <div id="legacy-server-push-notification-notice" class="not-editable-realm-field">+ <i>This is a legacy plan that ends on {{ remote_server_legacy_plan_end_date }}</i>+ </div>+ </div>+ {% endif %}<div class="input-box billing-page-field no-validation org-billing-frequency-wrapper"data-current-billing-frequency="{{ billing_frequency }}"{%if free_trial %}data-free-trial="true"{% endif %}@@ -50,7 +59,7 @@{%if switch_to_monthly_at_end_of_cycle %}data-switch-to-monthly-eoc="true"{% endif %}{%if switch_to_annual_at_end_of_cycle %}data-switch-to-annual-eoc="true"{% endif %}><label for="org-billing-frequency">Billing frequency</label>- {% if downgrade_at_end_of_free_trial or downgrade_at_end_of_cycle %}+ {% if downgrade_at_end_of_free_trial or downgrade_at_end_of_cycle or is_server_on_legacy_plan %}<div class="not-editable-realm-field">{{ billing_frequency }}</div>@@ -164,7 +173,11 @@<a href="{{ billing_base_url }}/plans/">other features</a> of your current plan.{% else %}{% if charge_automatically %}+ {% if is_server_on_legacy_plan %}+ Your plan will automatically upgrade to {{ legacy_remote_server_new_plan_name }} on {{ remote_server_legacy_plan_end_date }}.+ {% else %}Your plan will automatically renew on <strong>{{ renewal_date }}</strong>.+ {% endif %}{% else %}Your next invoice is due on <strong>{{ renewal_date }}</strong>.{% endif %}@@ -183,7 +196,6 @@<br /><i class="billing-page-discount">(includes {{ discount_percent }}% discount)</i>{% endif %}-{% endif %}{% endif %}{% else %}@@ -219,6 +231,13 @@<object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object></button></div>+ {% elif is_server_on_legacy_plan %}+ <div class="plan-toggle-action input-box billing-page-field no-validation" id="cancel-legacy-server-upgrade">+ <button class="cancel-legacy-server-upgrade-button plan-toggle-action-button">+ <span class="billing-button-text">Cancel upgrade</span>+ <object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object>+ </button>+ </div>{% else %}<div class="cancel-current-plan plan-toggle-action input-box billing-page-field no-validation" id="cancel-subscription"><button class="cancel-current-plan-button plan-toggle-action-button">diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.cssindex ddde1459144..411a876fd5b 100644--- a/web/styles/portico/billing.css+++ b/web/styles/portico/billing.css@@ -538,6 +538,7 @@ input[name="licenses"] {width: 150px;}+#billing-page-details #legacy-server-push-notification-notice,#billing-page-details .next-payment-info {width: 450px;padding-top: 0;@@ -669,3 +670,7 @@ input[name="licenses"] {#server-login-error {text-align: center;}++#upgrade-page-details #due-today-for-future-update-wrapper {+ display: none;+}