From 70ee567215312ae9ee83204a7a79e11a9e572c15 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 20 Oct 2026 07:35:25 +0200 Subject: [PATCH] fix(collection-confirm): show the stock line's cost on the card Stock rows on Collection Confirm were built without cost_price, so the Cost column was blank (card total R0) and the AI price tick red ("no cost") on every stock line, even when the line had a cost (e.g. all ten lines of PO26100702STK after the B&R invoice was checked). Co-Authored-By: Claude Opus 5.5 --- src/lib/server/collection-confirm-service.test.ts | 2 ++ src/lib/server/collection-confirm-service.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/lib/server/collection-confirm-service.test.ts b/src/lib/server/collection-confirm-service.test.ts index 5e5aeee..a529b1d 100644 --- a/src/lib/server/collection-confirm-service.test.ts +++ b/src/lib/server/collection-confirm-service.test.ts @@ -173,6 +173,8 @@ describe("listCollectedItems", () => { expect(row.qty_collected).toBe(50); expect(row.order_qty).toBe(50); expect(row.quantity).toBe(50); + // The line's own cost: the Cost column and the AI price tick read it. + expect(row.cost_price).toBe(1.5); expect(row.item_status).toBe("collected"); expect(row.stock_line_status).toBe("collected"); expect(row.assigned_at).toBe("2026-08-01T10:00:00.000Z"); diff --git a/src/lib/server/collection-confirm-service.ts b/src/lib/server/collection-confirm-service.ts index e748118..b72a2d4 100644 --- a/src/lib/server/collection-confirm-service.ts +++ b/src/lib/server/collection-confirm-service.ts @@ -405,6 +405,9 @@ export async function listCollectedItems(): Promise { qty_collected: s.quantity_received ?? 0, order_qty: s.quantity, quantity: s.quantity, + // Was missing: the Cost column was blank and the AI price tick red + // ("no cost") on every stock line, though the line has a cost. + cost_price: typeof s.cost_price === "number" ? s.cost_price : null, item_status: s.status ?? undefined, sku: s.expand?.stock_item?.sku, line_sku: typeof s.sku === "string" ? s.sku.trim() : "",