Fix Quotes Index stat cards counting Converted quotes hidden from the list
The Quotes Index stat strip (OPEN / APPROVED / TOTAL VALUE) summed every non-deleted quote, while the default list hides Converted quotes. A quote converted to a job (whose deletion is blocked by the linked job) therefore stayed invisible in the list but kept inflating the cards -- e.g. a blank list showing "1" and a non-zero total value. GetIndexStatsAsync now excludes the Converted status so the cards reflect the same population as the default list. Converted value is intentionally dropped from the quote pipeline because it carries forward on the job (counting it in both would double-count the same dollars). Also adds an explicit CompanyId predicate to GetIndexStatsAsync (defense in depth) -- it was the only Quote query in the typed repo relying solely on the global tenant filter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -248,7 +248,10 @@ public class QuotesController : Controller
|
||||
var approvedConvertedIds = quoteStatuses
|
||||
.Where(s => s.StatusCode == AppConstants.StatusCodes.Quote.Approved || s.StatusCode == AppConstants.StatusCodes.Quote.Converted)
|
||||
.Select(s => s.Id).ToList();
|
||||
var indexStats = await _unitOfWork.Quotes.GetIndexStatsAsync(draftSentIds, approvedConvertedIds);
|
||||
// Exclude Converted from the stat cards so they match the default list (which hides Converted).
|
||||
var convertedStatusId = quoteStatuses
|
||||
.FirstOrDefault(s => s.StatusCode == AppConstants.StatusCodes.Quote.Converted)?.Id;
|
||||
var indexStats = await _unitOfWork.Quotes.GetIndexStatsAsync(companyId, draftSentIds, approvedConvertedIds, convertedStatusId);
|
||||
ViewBag.StatOpenCount = indexStats.OpenCount;
|
||||
ViewBag.StatApprovedCount = indexStats.ApprovedConvertedCount;
|
||||
ViewBag.StatTotalValue = indexStats.TotalValue;
|
||||
|
||||
Reference in New Issue
Block a user