From 84816fa466bea99c6dc591fb20d6fca6d1074708 Mon Sep 17 00:00:00 2001 From: DEls Date: Sat, 10 Oct 2026 00:24:12 +0200 Subject: [PATCH] fix(financial): say "supplier" when one supplier is owed The "Received this month" sub-line always said "suppliers", so a single supplier read as "Owed to 1 suppliers". Use the singular when the count is 1. Co-Authored-By: Claude Opus 5.5 --- src/app/dashboard/financial/page.test.tsx | 11 +++++++++++ src/app/dashboard/financial/page.tsx | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/dashboard/financial/page.test.tsx b/src/app/dashboard/financial/page.test.tsx index 723c1ab..091f554 100644 --- a/src/app/dashboard/financial/page.test.tsx +++ b/src/app/dashboard/financial/page.test.tsx @@ -191,6 +191,17 @@ it("counts only deliveries received this month, and names the suppliers owed", a expect(html).toContain('/dashboard/financial/suppliers?site=site1'); }); +it("says 'supplier' when only one supplier is owed", async () => { + setup({ + pos: [{ id: "po1", site: "site1", supplier_ref: "s1", processing_status: "processed", total_value: 1000, date_uploaded: "2026-10-01 00:00:00.000Z" }], + items: [{ id: "i1", purchase_order: "po1", qty: 10, rate: 100 }], + dnItems: [{ id: "d1", purchase_order_item: "i1", qty_received: 4, delivery_note: "dn1" }], + notes: [{ id: "dn1", document_type: "delivery_note", date_received: "2026-10-02 00:00:00.000Z" }], + }); + const html = await renderPage(); + expect(tileSub(html, "Received this month")).toBe("Owed to 1 supplier for this month"); +}); + it("says so plainly when nothing has been received yet this month", async () => { setup({ pos: [], items: [], dnItems: [], notes: [] }); const html = await renderPage(); diff --git a/src/app/dashboard/financial/page.tsx b/src/app/dashboard/financial/page.tsx index 6508d22..b75ef47 100644 --- a/src/app/dashboard/financial/page.tsx +++ b/src/app/dashboard/financial/page.tsx @@ -210,7 +210,7 @@ export default async function FinancialLanding({ label="Received this month" value={formatCurrency(summary.receivedValue)} sub={summary.owedSupplierCount > 0 - ? `Owed to ${formatNumber(summary.owedSupplierCount)} suppliers for this month` + ? `Owed to ${formatNumber(summary.owedSupplierCount)} ${summary.owedSupplierCount === 1 ? "supplier" : "suppliers"} for this month` : "Nothing received yet this month"} icon={Package} />