billing: Allow to exclude realms from license limit check.

This commit is contained in:
Vishnu KS 2021-06-08 16:13:44 +05:30 committed by Tim Abbott
parent 1938076f67
commit 42119c136b
3 changed files with 24 additions and 4 deletions

View File

@ -71,12 +71,10 @@ def send_user_unable_to_signup_message_to_signup_notification_stream(
def check_spare_licenses_available_for_adding_new_users(
realm: Realm, number_of_users_to_add: int
) -> None:
if realm.string_id in settings.LICENSE_CHECK_EXEMPTED_REALMS_ON_MANUAL_PLAN:
return # nocoverage
plan = get_current_plan_by_realm(realm)
if plan is None or plan.automanage_licenses:
if plan is None or plan.automanage_licenses or plan.exempt_from_from_license_number_check:
return
if plan.licenses() < get_latest_seat_count(realm) + number_of_users_to_add:
raise LicenseLimitError()

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.2 on 2021-06-08 08:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0009_customer_sponsorship_pending"),
]
operations = [
migrations.AddField(
model_name="customerplan",
name="exempt_from_from_license_number_check",
field=models.BooleanField(default=False),
),
]

View File

@ -45,6 +45,10 @@ class CustomerPlan(models.Model):
automanage_licenses: bool = models.BooleanField(default=False)
charge_automatically: bool = models.BooleanField(default=False)
# Some non-profit organizations on manual license management pay only for their paid employees.
# We don't prevent these organizations from adding more users than the number of licenses they purchased.
exempt_from_from_license_number_check: bool = models.BooleanField(default=False)
# Both of these are in cents. Exactly one of price_per_license or
# fixed_price should be set. fixed_price is only for manual deals, and
# can't be set via the self-serve billing system.