From b2d6fae400efbfaf2dd5a837fc0c99071b2118ff Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Sat, 16 May 2026 11:29:12 -0400 Subject: [PATCH] Fix failing test: revert quote-based discount to use sourceQuote.DiscountAmount The quote discount must come from the agreed quote price, not the job's pricing snapshot (which may have DiscountAmount=0 for legacy or unset reasons). The job snapshot fix only applies to direct jobs where no source quote exists. Co-Authored-By: Claude Sonnet 4.6 --- src/PowderCoating.Web/Controllers/InvoicesController.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PowderCoating.Web/Controllers/InvoicesController.cs b/src/PowderCoating.Web/Controllers/InvoicesController.cs index fdaf48b..c44f985 100644 --- a/src/PowderCoating.Web/Controllers/InvoicesController.cs +++ b/src/PowderCoating.Web/Controllers/InvoicesController.cs @@ -469,11 +469,10 @@ public class InvoicesController : Controller }); } - // Use the quote's agreed tax rate. For discount, prefer the job's current pricing - // snapshot — it is recalculated on every save and captures any post-conversion edits. - // Fall back to the original quote discount only if no snapshot exists. + // Use the quote's agreed tax rate and discount — these represent the customer-approved + // price and must not be recomputed from the job's current state. dto.TaxPercent = sourceQuote.TaxPercent; - dto.DiscountAmount = jobBreakdown?.DiscountAmount ?? sourceQuote.DiscountAmount; + dto.DiscountAmount = sourceQuote.DiscountAmount; } else if (hadJobItems) {