Make AiCatalogPriceCheckEnabled a plan-override toggle

Company-level toggle now grants access regardless of plan tier, checked
before the plan gate. Useful for enabling the feature on individual
Pro/Basic companies without upgrading their plan.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 08:41:27 -04:00
parent cb7bbc37bd
commit f03a198e79
3 changed files with 12 additions and 12 deletions
@@ -316,12 +316,12 @@ public class SubscriptionService : ISubscriptionService
}
/// <summary>
/// Returns <c>true</c> if the company can submit another AI Photo Quote analysis this month.
/// Three gates are evaluated in sequence, stopping at the first failure:
/// (1) plan-level <c>AllowAiPhotoQuotes</c> flag in <see cref="SubscriptionPlanConfig"/>,
/// (2) company-level <c>AiPhotoQuotesEnabled</c> toggle (SuperAdmin override),
/// (3) monthly usage quota from <see cref="GetAiPhotoQuoteUsageAsync"/>.
/// Comped companies bypass all three gates.
/// Returns <c>true</c> if the company can run an AI Catalog Price Check.
/// The company-level <c>AiCatalogPriceCheckEnabled</c> flag is checked first as an
/// explicit SuperAdmin override — enabling it grants access regardless of plan tier,
/// useful for granting individual companies on lower plans. If the override is not set,
/// access falls back to the plan-level <c>AllowAiCatalogPriceCheck</c> flag.
/// Comped companies bypass all gates.
/// </summary>
public async Task<bool> CanUseAiCatalogPriceCheckAsync(int companyId)
{
@@ -329,11 +329,11 @@ public class SubscriptionService : ISubscriptionService
if (company == null) return false;
if (company.IsComped) return true;
// Plan-level gate: Enterprise plan must have this feature enabled
if (config != null && !config.AllowAiCatalogPriceCheck) return false;
// Company toggle is an explicit override — grants access regardless of plan
if (company.AiCatalogPriceCheckEnabled) return true;
// Company-level toggle: SuperAdmin can disable per company
return company.AiCatalogPriceCheckEnabled;
// Fall back to plan-level gate
return config != null && config.AllowAiCatalogPriceCheck;
}
public async Task<bool> CanUseAiPhotoQuoteAsync(int companyId)