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);