From 4085ff7c7314a9a8c37637f7e199540fec4fae68 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Wed, 6 May 2026 17:04:25 -0400 Subject: [PATCH] Advance quote to Sent status when approval link sent via SMS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SMS path was sending the message but never updating QuoteStatusId or SentDate, leaving the quote in Draft. Now mirrors the email send path: transitions Draft → Sent and stamps SentDate on first send only. Co-Authored-By: Claude Sonnet 4.6 --- .../Controllers/QuotesController.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/PowderCoating.Web/Controllers/QuotesController.cs b/src/PowderCoating.Web/Controllers/QuotesController.cs index 2f71d8b..557a93f 100644 --- a/src/PowderCoating.Web/Controllers/QuotesController.cs +++ b/src/PowderCoating.Web/Controllers/QuotesController.cs @@ -3361,6 +3361,19 @@ public class QuotesController : Controller tokenChanged = true; } + // Advance quote to Sent status when it is still in Draft — mirrors what the email send path does. + var companyId = _tenantContext.GetCurrentCompanyId() ?? 0; + var statuses = await _lookupCache.GetQuoteStatusLookupsAsync(companyId); + var sentStatus = statuses.FirstOrDefault(s => s.StatusCode == "SENT"); + var draftStatus = statuses.FirstOrDefault(s => s.StatusCode == "DRAFT"); + + if (sentStatus != null && quote.QuoteStatusId == (draftStatus?.Id ?? 0)) + { + quote.QuoteStatusId = sentStatus.Id; + quote.SentDate ??= DateTime.UtcNow; + tokenChanged = true; // ensure a save happens + } + if (tokenChanged) { await _unitOfWork.Quotes.UpdateAsync(quote);