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)
@@ -167,7 +167,7 @@
<input asp-for="AiCatalogPriceCheckEnabled" class="form-check-input" type="checkbox" />
<label asp-for="AiCatalogPriceCheckEnabled" class="form-check-label fw-medium">AI Catalog Price Check</label>
</div>
<div class="form-text">Allow this company to run AI-powered catalog price analysis.</div>
<div class="form-text">Override: grants access regardless of plan tier.</div>
</div>
<div class="col-md-4">
<label asp-for="MaxAiPhotoQuotesPerMonthOverride" class="form-label">Monthly AI Quote Limit Override</label>
@@ -300,7 +300,7 @@
@(Model.AiCatalogPriceCheckEnabled ? "checked" : "") />
<label class="form-check-label" for="aiCatalogPriceCheck">AI Catalog Price Check</label>
</div>
<div class="form-text">Allow AI-powered catalog price analysis.</div>
<div class="form-text">Override: grants access regardless of plan tier.</div>
</div>
<div class="col-md-4">
<label class="form-label small fw-medium">AI Photo Quotes / Month Override</label>