mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
stripe: Fix licenses not updated to latest seat count after trial ends.
Since we are forward dating the LicenseLedger entry user initially paid for, we need to create the new LicenseLedger entry with current license count so that user can be billed for the difference in licenses.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user