From f03a198e79146de0cc06c753c85f73c36e0dbe89 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Sun, 26 Apr 2026 08:41:27 -0400 Subject: [PATCH] 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 --- .../Services/SubscriptionService.cs | 20 +++++++++---------- .../Views/Companies/Edit.cshtml | 2 +- .../SubscriptionManagement/Manage.cshtml | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/PowderCoating.Infrastructure/Services/SubscriptionService.cs b/src/PowderCoating.Infrastructure/Services/SubscriptionService.cs index 21cfa9f..612986d 100644 --- a/src/PowderCoating.Infrastructure/Services/SubscriptionService.cs +++ b/src/PowderCoating.Infrastructure/Services/SubscriptionService.cs @@ -316,12 +316,12 @@ public class SubscriptionService : ISubscriptionService } /// - /// Returns true 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 AllowAiPhotoQuotes flag in , - /// (2) company-level AiPhotoQuotesEnabled toggle (SuperAdmin override), - /// (3) monthly usage quota from . - /// Comped companies bypass all three gates. + /// Returns true if the company can run an AI Catalog Price Check. + /// The company-level AiCatalogPriceCheckEnabled 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 AllowAiCatalogPriceCheck flag. + /// Comped companies bypass all gates. /// public async Task 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 CanUseAiPhotoQuoteAsync(int companyId) diff --git a/src/PowderCoating.Web/Views/Companies/Edit.cshtml b/src/PowderCoating.Web/Views/Companies/Edit.cshtml index 3b4a341..62cdd59 100644 --- a/src/PowderCoating.Web/Views/Companies/Edit.cshtml +++ b/src/PowderCoating.Web/Views/Companies/Edit.cshtml @@ -167,7 +167,7 @@ -
Allow this company to run AI-powered catalog price analysis.
+
Override: grants access regardless of plan tier.
diff --git a/src/PowderCoating.Web/Views/SubscriptionManagement/Manage.cshtml b/src/PowderCoating.Web/Views/SubscriptionManagement/Manage.cshtml index be3599d..e9e3ef1 100644 --- a/src/PowderCoating.Web/Views/SubscriptionManagement/Manage.cshtml +++ b/src/PowderCoating.Web/Views/SubscriptionManagement/Manage.cshtml @@ -300,7 +300,7 @@ @(Model.AiCatalogPriceCheckEnabled ? "checked" : "") />
-
Allow AI-powered catalog price analysis.
+
Override: grants access regardless of plan tier.