mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
billing: Create update_license_ledger_for_manual_plan.
This commit is contained in:
@@ -629,6 +629,30 @@ def process_initial_upgrade(
|
||||
do_change_plan_type(realm, Realm.STANDARD, acting_user=user)
|
||||
|
||||
|
||||
def update_license_ledger_for_manual_plan(
|
||||
plan: CustomerPlan,
|
||||
event_time: datetime,
|
||||
licenses: Optional[int] = None,
|
||||
licenses_at_next_renewal: Optional[int] = None,
|
||||
) -> None:
|
||||
if licenses is not None:
|
||||
assert get_latest_seat_count(plan.customer.realm) <= licenses
|
||||
assert licenses > plan.licenses()
|
||||
LicenseLedger.objects.create(
|
||||
plan=plan, event_time=event_time, licenses=licenses, licenses_at_next_renewal=licenses
|
||||
)
|
||||
elif licenses_at_next_renewal is not None:
|
||||
assert get_latest_seat_count(plan.customer.realm) <= licenses_at_next_renewal
|
||||
LicenseLedger.objects.create(
|
||||
plan=plan,
|
||||
event_time=event_time,
|
||||
licenses=plan.licenses(),
|
||||
licenses_at_next_renewal=licenses_at_next_renewal,
|
||||
)
|
||||
else:
|
||||
raise AssertionError("Pass licenses or licenses_at_next_renewal")
|
||||
|
||||
|
||||
def update_license_ledger_for_automanaged_plan(
|
||||
realm: Realm, plan: CustomerPlan, event_time: datetime
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user