@property
    def response_mobile_worker_creation(self):
        from corehq.apps.accounting.models import FeatureType, FeatureRate, UNLIMITED_FEATURE_USAGE
        num_users = CommCareUser.total_by_domain(self.domain.name, is_active=True)
        try:
            user_rate = self.new_plan_version.feature_rates.filter(
                feature__feature_type=FeatureType.USER).latest('date_created')
            if user_rate.monthly_limit == UNLIMITED_FEATURE_USAGE:
                return
            num_allowed = user_rate.monthly_limit
            num_extra = num_users - num_allowed
            if num_extra > 0:
                return _fmt_alert(
                    ungettext(
                        "You have %(num_users)d Mobile Worker over the monthly "
                        "limit of %(monthly_limit)d for this new plan. There "
                        "will be an additional monthly charge of USD "
                        "%(excess_fee)s per Mobile Worker, totalling USD "
                        "%(monthly_total)s per month, if you select this plan.",
                        "You have %(num_users)d Mobile Workers over the "
                        "monthly limit of %(monthly_limit)d for this new plan. "
                        "There will be an additional monthly charge "
                        "of USD %(excess_fee)s per Mobile Worker, totalling "
                        "USD %(monthly_total)s per month, if you "
                        "select this plan.",
                        num_extra
                    ) % {
                        'num_users': num_extra,
                        'monthly_limit': user_rate.monthly_limit,
                        'excess_fee': user_rate.per_excess_fee,
                        'monthly_total': user_rate.per_excess_fee * num_extra,
                    }
                )
        except FeatureRate.DoesNotExist:
            log_accounting_error(
                "It seems that the plan %s did not have rate for Mobile "
                "Workers. This is problematic."
                % self.new_plan_version.plan.name
            )
Get the allowed number of mobile workers based on plan version.
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/accounting/subscription_changes.py/DomainDowngradeStatusHandler.response_mobile_worker_creation