From 1d9ba70fc761cb1d97fd90e6c8f96d0d7867be97 Mon Sep 17 00:00:00 2001 From: Darsh Gupta Date: Wed, 15 Apr 2026 11:00:32 +0530 Subject: [PATCH] fix: persist discount fields when clearing quote discount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The updateQuote action used a spread pattern `...(discountType && {...})` which silently dropped null values — clearing a discount had no effect. Changed to always persist discount fields with explicit null. Also merged `data.settings` from the form into the saved settings JSON so deposit/signature preferences are not lost on save. Fixes #55 Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/lib/quotes/actions.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/web/lib/quotes/actions.ts b/apps/web/lib/quotes/actions.ts index 5775b7a..ad6abdb 100644 --- a/apps/web/lib/quotes/actions.ts +++ b/apps/web/lib/quotes/actions.ts @@ -436,16 +436,17 @@ export async function updateQuote( notes: data.notes, terms: data.terms, internalNotes: data.internalNotes, - // Always include discount fields when calculated - ...(discountType && { discountType }), - ...(discountValue !== undefined && { discountValue }), - ...(discountAmount !== undefined && { discountAmount }), + // Always persist discount fields — use null to clear when no discount + discountType: discountType || null, + discountValue: discountValue ?? 0, + discountAmount, ...(data.blocks && { subtotal, taxTotal, total, settings: { ...(existingQuote.settings as object), + ...data.settings, blocks: data.blocks, } as unknown as Prisma.InputJsonValue, lineItems: {