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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<IQueryable<Quote>, IOrderedQueryable<Quote>> 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
|
||||
|
||||
Reference in New Issue
Block a user