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: Note applied discount on upgrade and billing pages.

Aman Agrawal95f5d8bdb8e4
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 81f6a5b778a..f0592e606bf 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -99,6 +99,19 @@ def format_money(cents: float) -> str:
return f"{dollars:.{precision}f}"
+def format_discount_percentage(discount: Optional[Decimal]) -> Optional[str]:
+ if type(discount) is not Decimal:
+ return None
+
+ # Even though it looks like /activity/support only finds integers valid,
+ # this will look good for any custom discounts that we apply.
+ if discount * 100 % 100 == 0:
+ precision = 0
+ else:
+ precision = 2 # nocoverage
+ return f"{discount:.{precision}f}"
+
+
def get_latest_seat_count(realm: Realm) -> int:
return get_seat_count(realm, extra_non_guests_count=0, extra_guests_count=0)
@@ -1215,6 +1228,7 @@ class BillingSession(ABC):
"fixed_price": fixed_price,
"price_per_license": price_per_license,
"is_sponsorship_pending": customer.sponsorship_pending,
+ "discount_percent": format_discount_percentage(customer.default_discount),
}
return context
@@ -1256,6 +1270,7 @@ class BillingSession(ABC):
"monthly_price": get_price_per_license(tier, CustomerPlan.MONTHLY, percent_off),
},
"manual_license_management": initial_upgrade_request.manual_license_management,
+ "discount_percent": format_discount_percentage(percent_off),
}
# Check if user was successful in adding a card and we are rendering the page again.
diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html
index ff0978022f7..50fae5c3a85 100644
--- a/templates/corporate/billing.html
+++ b/templates/corporate/billing.html
@@ -169,6 +169,11 @@
{% else %}
{{ "1 month" if billing_frequency == "Monthly" else "12 months" }}
{% endif %})
+ {% if discount_percent %}
+ <br />
+ <i class="billing-page-discount">(includes {{ discount_percent }}% discount)</i>
+ {% endif %}
+
{% endif %}
{% endif %}
{% else %}
diff --git a/templates/corporate/upgrade.html b/templates/corporate/upgrade.html
index 9594db5b100..48399250bde 100644
--- a/templates/corporate/upgrade.html
+++ b/templates/corporate/upgrade.html
@@ -87,6 +87,9 @@
{{ 'user' if seat_count == 1 else 'users' }}
</span> x
<span class="due-today-duration"></span>
+ {% if discount_percent %}
+ <i class="billing-page-discount">(includes {{ discount_percent }}% discount)</i>
+ {% endif %}
<h1>$<span class="due-today-price"></span></h1>
</div>
</div>
diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.css
index 459534fb59c..172d55ba97c 100644
--- a/web/styles/portico/billing.css
+++ b/web/styles/portico/billing.css
@@ -647,3 +647,8 @@ input[name="licenses"] {
#sponsorship-form #sponsorship-button {
width: 100%;
}
+
+.billing-page-discount {
+ opacity: 0.8;
+ font-weight: 400;
+}