From c02a5584b4e70a114f398c7f16a188e456050b38 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Mon, 11 May 2026 16:45:09 -0400 Subject: [PATCH] Hide Converted quotes from default listing to reduce clutter The Quotes index now excludes Converted status by default so the list stays focused on active work. Converted quotes remain accessible via the status filter dropdown. Selecting any explicit status filter (including Converted) bypasses the exclusion as expected. Also consolidated the two GetQuoteStatusLookupsAsync calls into one at the top of the action since the cache makes it free. Co-Authored-By: Claude Sonnet 4.6 --- .../Controllers/QuotesController.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/PowderCoating.Web/Controllers/QuotesController.cs b/src/PowderCoating.Web/Controllers/QuotesController.cs index 9997f03..81384cc 100644 --- a/src/PowderCoating.Web/Controllers/QuotesController.cs +++ b/src/PowderCoating.Web/Controllers/QuotesController.cs @@ -112,12 +112,14 @@ public class QuotesController : Controller { try { + // Load statuses once up front — needed for statusCode resolution and default filter + var companyId = _tenantContext.GetCurrentCompanyId() ?? 0; + var quoteStatuses = await _lookupCache.GetQuoteStatusLookupsAsync(companyId); + // Resolve statusCode → statusFilter ID if provided (e.g. from dashboard links) if (!string.IsNullOrWhiteSpace(statusCode) && !statusFilter.HasValue) { - var companyIdForLookup = _tenantContext.GetCurrentCompanyId() ?? 0; - var allStatuses = await _lookupCache.GetQuoteStatusLookupsAsync(companyIdForLookup); - var match = allStatuses.FirstOrDefault(s => + var match = quoteStatuses.FirstOrDefault(s => s.StatusCode.Equals(statusCode.Trim().ToUpper(), StringComparison.OrdinalIgnoreCase)); if (match != null) statusFilter = match.Id; @@ -169,6 +171,18 @@ public class QuotesController : Controller var statusId = statusFilter.Value; filter = q => q.QuoteStatusId == statusId; } + else + { + // Default (no filter): hide Converted to keep the list clean. + // Users can view converted quotes by selecting Converted from the status filter. + var convertedId = quoteStatuses + .FirstOrDefault(s => s.StatusCode == AppConstants.StatusCodes.Quote.Converted)?.Id; + if (convertedId.HasValue) + { + var cId = convertedId.Value; + filter = q => q.QuoteStatusId != cId; + } + } // Build orderBy function Func, IOrderedQueryable> orderBy = gridRequest.SortColumn switch @@ -216,9 +230,6 @@ public class QuotesController : Controller ViewBag.SortColumn = gridRequest.SortColumn; ViewBag.SortDirection = gridRequest.SortDirection; - // Use cached quote statuses - var companyId = _tenantContext.GetCurrentCompanyId() ?? 0; - var quoteStatuses = await _lookupCache.GetQuoteStatusLookupsAsync(companyId); ViewBag.QuoteStatuses = quoteStatuses .OrderBy(s => s.DisplayOrder) .Select(s => new SelectListItem