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.

stripe: Fix licenses not updated to latest seat count after trial ends.

Aman Agrawal203da5008a0e
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index ab0945e9244..5217eb188ad 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -2319,6 +2319,16 @@ class BillingSession(ABC):
microsecond=0
)
last_renewal_ledger_entry.save(update_fields=["event_time"])
+ # Since we are skipping over processing license ledger
+ # entries / RealmAuditLogs that are after `last_renewal_ledger_entry`,
+ # we need to update `licenses_at_next_renewal` to reflect the current value.
+ # It is okay to skip over them here since they were in free trial.
+ licenses_at_next_renewal = max(
+ self.get_billable_licenses_for_customer(
+ plan.customer, plan.tier, licenses_at_next_renewal
+ ),
+ licenses_at_next_renewal,
+ )
else:
# We end the free trial since customer hasn't paid.
plan.status = CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL