diff --git a/backend/app/services/pl_quota_business.py b/backend/app/services/pl_quota_business.py index 4a6832b29..1673b7839 100644 --- a/backend/app/services/pl_quota_business.py +++ b/backend/app/services/pl_quota_business.py @@ -121,17 +121,19 @@ def apply_plan_quota(db, user, plan, action, payload=None): sourceNote=getattr(payload, 'quota_source_note', None)) from app.services.pl_quota_waiver import assert_waived_sources, quota_cert_waived from app.services.pl_cert_quota_rule_config_service import ( + plan_applies_customer_category_rule, plan_skips_archive_cert_quota, - plan_uses_customer_category, ) + tenant_no = getattr(user, 'tenant_no', None) or '' + customer_rule = plan_applies_customer_category_rule(db, tenant_no, plan) # 新规则:齐备仅放行安排/改派预占;归档与实际调整必须真证结转。 # 切点前首次安排:归档/实调不校证件(无需齐备);齐备仍可跳过安排预占。 skip_actions = ('reserve', 'resize') - if not plan_uses_customer_category(plan): + if not customer_rule: skip_actions = ('reserve', 'resize', 'settle', 'actual_adjust') grandfather_archive_skip = ( action in ('settle', 'actual_adjust') - and plan_skips_archive_cert_quota(plan, db, getattr(user, 'tenant_no', None)) + and plan_skips_archive_cert_quota(plan, db, tenant_no) ) if grandfather_archive_skip: return {'operationId': ledger_id, 'usageIds': [], 'waived': True, 'skippedCertQuota': True} @@ -140,7 +142,7 @@ def apply_plan_quota(db, user, plan, action, payload=None): assert_waived_sources(db, user, plan, lock=True) return {'operationId': ledger_id, 'usageIds': [], 'waived': True} if ( - plan_uses_customer_category(plan) + customer_rule and action in ('settle', 'actual_adjust') and int(getattr(plan, 'quota_cert_pending_fulfill', 0) or 0) == 1 ):