From a2e10652a4a24e5c952d8563e84f6cb9bb01a6a9 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 26 Aug 2026 23:39:15 +0200 Subject: [PATCH] fix(quotes): no-quote letters always flip to approval_pending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The downstream status-flip logic uses ready.length === allItems.length to choose between approval_pending and partial_approval_pending. For an is_no_quote quote with all-unpriced items, the unfiltered bypass in Task 7 made ready.length === 0 while allItems.length > 0, flipping to partial_approval_pending instead of approval_pending — contradicting the spec ('new → approval_pending → sending → emailed' for no-quote letters). Add a guard so is_no_quote quotes always flip to approval_pending. The partial-flip path remains unchanged for priced quotes. --- src/app/api/v1/quotes/[id]/pdf/route.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/api/v1/quotes/[id]/pdf/route.ts b/src/app/api/v1/quotes/[id]/pdf/route.ts index 497d701..4e6d962 100644 --- a/src/app/api/v1/quotes/[id]/pdf/route.ts +++ b/src/app/api/v1/quotes/[id]/pdf/route.ts @@ -345,10 +345,9 @@ export async function POST( // Pick partial vs full based on whether every priced item is // ready to send. `ready` is the array of priced, has-supplier // items (defined earlier in the validation block). - const targetStatus = - ready.length === allItems.length - ? "approval_pending" - : "partial_approval_pending"; + const targetStatus = !isNoQuote && ready.length !== allItems.length + ? "partial_approval_pending" + : "approval_pending"; await pb.collection("quotes").update(quoteId, { status: targetStatus, pdf_generated_at: pdfGeneratedAt,