From e9e618fda8bfa994d38324eceb580abb1d12bcd1 Mon Sep 17 00:00:00 2001 From: "Claude (auto-fix)" Date: Sun, 21 Jun 2026 00:32:39 +0530 Subject: [PATCH] feat(po): add week, month, year to line-item unit options The PO line-items Unit of Measure dropdown only offered hr/day among time-based units. Add week, month and year so durations beyond days can be selected, as requested. UOM_OPTIONS is the single source of truth and `unit` is validated as a free-form string, so no schema/validation change is needed. Fixes #44 Co-Authored-By: Claude Opus 4.8 (1M context) --- App/components/po/po-line-items-editor.tsx | 7 +++++-- App/tests/unit/po-line-items-editor.test.tsx | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/App/components/po/po-line-items-editor.tsx b/App/components/po/po-line-items-editor.tsx index 65f3c93..403ad7a 100644 --- a/App/components/po/po-line-items-editor.tsx +++ b/App/components/po/po-line-items-editor.tsx @@ -20,8 +20,11 @@ const UOM_OPTIONS = [ { value: "mL", label: "mL — Millilitre" }, { value: "m", label: "m — Metre" }, { value: "m2", label: "m² — Sq. Metre" }, - { value: "hr", label: "hr — Hour" }, - { value: "day", label: "day — Day" }, + { value: "hr", label: "hr — Hour" }, + { value: "day", label: "day — Day" }, + { value: "week", label: "week — Week" }, + { value: "month", label: "month — Month" }, + { value: "year", label: "year — Year" }, { value: "lump", label: "lump — Lump Sum" }, { value: "Ltr", label: "Ltr — Litre (alt)" }, ]; diff --git a/App/tests/unit/po-line-items-editor.test.tsx b/App/tests/unit/po-line-items-editor.test.tsx index 1d24a93..53eeb19 100644 --- a/App/tests/unit/po-line-items-editor.test.tsx +++ b/App/tests/unit/po-line-items-editor.test.tsx @@ -93,6 +93,25 @@ describe("LineItemsEditor — edit mode", () => { const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0] as LineItemInput[]; expect(lastCall[0].gstRate).toBeCloseTo(0.05); }); + + it("offers month and year as unit-of-measure options", () => { + render(); + const selects = screen.getAllByRole("combobox") as HTMLSelectElement[]; + const unitSelect = selects.find((s) => s.value === "pc")!; + const values = Array.from(unitSelect.options).map((o) => o.value); + expect(values).toContain("month"); + expect(values).toContain("year"); + }); + + it("calls onChange with the selected duration unit", async () => { + const onChange = vi.fn(); + render(); + const selects = screen.getAllByRole("combobox") as HTMLSelectElement[]; + const unitSelect = selects.find((s) => s.value === "pc")!; + fireEvent.change(unitSelect, { target: { value: "year" } }); + const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0] as LineItemInput[]; + expect(lastCall[0].unit).toBe("year"); + }); }); // ── Totals calculation (edit mode) ────────────────────────────────────────────