billing: Hide license management fields for free trial states.

* For free trial, don't show number of licenses for current billing period.
* For free trial scheduled to downgrade, don't show number of
  licenses for next billing period.
This commit is contained in:
Aman Agrawal 2023-12-08 01:45:11 +00:00 committed by Tim Abbott
parent 9594e635cd
commit 134a05ff5e
3 changed files with 17 additions and 2 deletions

View File

@ -1919,6 +1919,10 @@ class BillingSession(ABC):
licenses = update_plan_request.licenses licenses = update_plan_request.licenses
if licenses is not None: 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: if plan.automanage_licenses:
raise JsonableError( raise JsonableError(
_( _(
@ -1952,6 +1956,15 @@ class BillingSession(ABC):
"Unable to update licenses manually. Your plan is on automatic license management." "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: if last_ledger_entry.licenses_at_next_renewal == licenses_at_next_renewal:
raise JsonableError( raise JsonableError(
_( _(

View File

@ -1331,7 +1331,7 @@ class StripeTest(StripeTestCase):
for substring in [ for substring in [
"Zulip Cloud Standard <i>(free trial)</i>", "Zulip Cloud Standard <i>(free trial)</i>",
str(self.seat_count), str(self.seat_count),
"Number of licenses for current billing period", "Number of licenses for next billing period",
f"{self.seat_count} in use", f"{self.seat_count} in use",
"Your next invoice is due on", "Your next invoice is due on",
"March 2, 2012", "March 2, 2012",

View File

@ -104,6 +104,7 @@
</div> </div>
</div> </div>
{% else %} {% else %}
{% if not (free_trial or downgrade_at_end_of_free_trial) %}
<div class="input-box billing-page-field no-validation input-box-number"> <div class="input-box billing-page-field no-validation input-box-number">
<label for="current-manual-license-count" class="inline-block label-title"> <label for="current-manual-license-count" class="inline-block label-title">
Number of licenses for current billing period Number of licenses for current billing period
@ -123,7 +124,8 @@
</div> </div>
<div id="current-license-change-error" class="alert alert-danger billing-page-error"></div> <div id="current-license-change-error" class="alert alert-danger billing-page-error"></div>
</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"> <div class="input-box billing-page-field no-validation input-box-number">
<label for="next-manual-license-count" class="inline-block label-title"> <label for="next-manual-license-count" class="inline-block label-title">
Number of licenses for next billing period Number of licenses for next billing period