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: Create cents_to_dollar_string helper function.

Vishnu KS203ddfc5466b
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index b11ade681e0..723f69b174f 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -190,6 +190,10 @@ def get_idempotency_key(ledger_entry: LicenseLedger) -> Optional[str]:
return f"ledger_entry:{ledger_entry.id}" # nocoverage
+def cents_to_dollar_string(cents: int) -> str:
+ return f"{cents / 100.:,.2f}"
+
+
class BillingError(Exception):
# error messages
CONTACT_SUPPORT = gettext_lazy("Something went wrong. Please contact {email}.")
diff --git a/corporate/views.py b/corporate/views.py
index 05b11048a7a..4e9e864db30 100644
--- a/corporate/views.py
+++ b/corporate/views.py
@@ -17,6 +17,7 @@ from corporate.lib.stripe import (
MIN_INVOICED_LICENSES,
STRIPE_PUBLISHABLE_KEY,
BillingError,
+ cents_to_dollar_string,
do_change_plan_status,
do_replace_payment_source,
downgrade_at_the_end_of_billing_cycle,
@@ -332,7 +333,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
licenses_at_next_renewal=licenses_at_next_renewal,
seat_count=seat_count,
renewal_date=renewal_date,
- renewal_amount=f"{renewal_cents / 100.:,.2f}",
+ renewal_amount=cents_to_dollar_string(renewal_cents),
payment_method=payment_method,
charge_automatically=charge_automatically,
publishable_key=STRIPE_PUBLISHABLE_KEY,