Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

billing: Hide license management fields for free trial states.

Aman Agrawal134a05ff5e43
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 6f3fa931833..2e69523ea8b 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -1919,6 +1919,10 @@ class BillingSession(ABC):
licenses = update_plan_request.licenses
if licenses is not None:
+ if plan.is_free_trial(): # nocoverage
+ raise JsonableError(
+ _("Cannot update licenses in the current billing period for free trial plan.")
+ )
if plan.automanage_licenses:
raise JsonableError(
_(
@@ -1952,6 +1956,15 @@ class BillingSession(ABC):
"Unable to update licenses manually. Your plan is on automatic license management."
)
)
+ if plan.status in (
+ CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE,
+ CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL,
+ ): # nocoverage
+ raise JsonableError(
+ _(
+ "Cannot change the licenses for next billing cycle for a plan that is being downgraded."
+ )
+ )
if last_ledger_entry.licenses_at_next_renewal == licenses_at_next_renewal:
raise JsonableError(
_(
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 01e8a576310..9935410cfba 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -1331,7 +1331,7 @@ class StripeTest(StripeTestCase):
for substring in [
"Zulip Cloud Standard <i>(free trial)</i>",
str(self.seat_count),
- "Number of licenses for current billing period",
+ "Number of licenses for next billing period",
f"{self.seat_count} in use",
"Your next invoice is due on",
"March 2, 2012",
diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html
index 8fa89b36410..ea2447f6e61 100644
--- a/templates/corporate/billing.html
+++ b/templates/corporate/billing.html
@@ -104,6 +104,7 @@
</div>
</div>
{% else %}
+ {% if not (free_trial or downgrade_at_end_of_free_trial) %}
<div class="input-box billing-page-field no-validation input-box-number">
<label for="current-manual-license-count" class="inline-block label-title">
Number of licenses for current billing period
@@ -123,7 +124,8 @@
</div>
<div id="current-license-change-error" class="alert alert-danger billing-page-error"></div>
</div>
- {% if not downgrade_at_end_of_cycle %}
+ {% endif %}
+ {% if not (downgrade_at_end_of_cycle or downgrade_at_end_of_free_trial) %}
<div class="input-box billing-page-field no-validation input-box-number">
<label for="next-manual-license-count" class="inline-block label-title">
Number of licenses for next billing period