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:
@@ -316,12 +316,12 @@ public class SubscriptionService : ISubscriptionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns <c>true</c> if the company can submit another AI Photo Quote analysis this month.
|
/// Returns <c>true</c> if the company can run an AI Catalog Price Check.
|
||||||
/// Three gates are evaluated in sequence, stopping at the first failure:
|
/// The company-level <c>AiCatalogPriceCheckEnabled</c> flag is checked first as an
|
||||||
/// (1) plan-level <c>AllowAiPhotoQuotes</c> flag in <see cref="SubscriptionPlanConfig"/>,
|
/// explicit SuperAdmin override — enabling it grants access regardless of plan tier,
|
||||||
/// (2) company-level <c>AiPhotoQuotesEnabled</c> toggle (SuperAdmin override),
|
/// useful for granting individual companies on lower plans. If the override is not set,
|
||||||
/// (3) monthly usage quota from <see cref="GetAiPhotoQuoteUsageAsync"/>.
|
/// access falls back to the plan-level <c>AllowAiCatalogPriceCheck</c> flag.
|
||||||
/// Comped companies bypass all three gates.
|
/// Comped companies bypass all gates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<bool> CanUseAiCatalogPriceCheckAsync(int companyId)
|
public async Task<bool> CanUseAiCatalogPriceCheckAsync(int companyId)
|
||||||
{
|
{
|
||||||
@@ -329,11 +329,11 @@ public class SubscriptionService : ISubscriptionService
|
|||||||
if (company == null) return false;
|
if (company == null) return false;
|
||||||
if (company.IsComped) return true;
|
if (company.IsComped) return true;
|
||||||
|
|
||||||
// Plan-level gate: Enterprise plan must have this feature enabled
|
// Company toggle is an explicit override — grants access regardless of plan
|
||||||
if (config != null && !config.AllowAiCatalogPriceCheck) return false;
|
if (company.AiCatalogPriceCheckEnabled) return true;
|
||||||
|
|
||||||
// Company-level toggle: SuperAdmin can disable per company
|
// Fall back to plan-level gate
|
||||||
return company.AiCatalogPriceCheckEnabled;
|
return config != null && config.AllowAiCatalogPriceCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> CanUseAiPhotoQuoteAsync(int companyId)
|
public async Task<bool> CanUseAiPhotoQuoteAsync(int companyId)
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
<input asp-for="AiCatalogPriceCheckEnabled" class="form-check-input" type="checkbox" />
|
<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>
|
<label asp-for="AiCatalogPriceCheckEnabled" class="form-check-label fw-medium">AI Catalog Price Check</label>
|
||||||
</div>
|
</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>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<label asp-for="MaxAiPhotoQuotesPerMonthOverride" class="form-label">Monthly AI Quote Limit Override</label>
|
<label asp-for="MaxAiPhotoQuotesPerMonthOverride" class="form-label">Monthly AI Quote Limit Override</label>
|
||||||
|
|||||||
@@ -300,7 +300,7 @@
|
|||||||
@(Model.AiCatalogPriceCheckEnabled ? "checked" : "") />
|
@(Model.AiCatalogPriceCheckEnabled ? "checked" : "") />
|
||||||
<label class="form-check-label" for="aiCatalogPriceCheck">AI Catalog Price Check</label>
|
<label class="form-check-label" for="aiCatalogPriceCheck">AI Catalog Price Check</label>
|
||||||
</div>
|
</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>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<label class="form-label small fw-medium">AI Photo Quotes / Month Override</label>
|
<label class="form-label small fw-medium">AI Photo Quotes / Month Override</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user