Add payments with TDS, invoice detail view and filterable History (Phase E2)
- Migration M8 adds payments (cash, TDS, mode, reference). Payment status is derived, never stored: unpaid, partially paid, paid, or overdue. Overpayment is rejected, TDS counts toward settling, and only issued invoices accept payments. list_invoices and get_invoice carry the paid, TDS and balance summary. - New invoice detail view: archived-PDF preview, payments list, Record payment modal, Export, Duplicate (as a draft), Re-render and Cancel. An invoice with payments cannot be cancelled until they are deleted. - History gets search, status, financial-year, month and client filters, sortable columns, pagination, footer totals and an FY summary. Cancelled invoices are excluded from totals. The per-row archive-status calls are gone; archiving is on the detail page. - Rust tests for payments and the list summary; vitest for fiscal-year, money, filter and duplicate helpers. PDF output and fingerprint goldens are unchanged. The new UI has not been run in a webview yet.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { currentFyStartYear, fyLabel, fyRange, fyStartYear, monthOf, todayIst, FY_MONTHS } from "./fiscal";
|
||||
|
||||
describe("financial year", () => {
|
||||
it("starts on 1 April", () => {
|
||||
expect(fyStartYear("2026-03-31")).toBe(2025);
|
||||
expect(fyStartYear("2026-04-01")).toBe(2026);
|
||||
expect(fyStartYear("2026-12-31")).toBe(2026);
|
||||
expect(fyStartYear("2027-01-01")).toBe(2026);
|
||||
});
|
||||
|
||||
it("rejects things that are not ISO dates", () => {
|
||||
expect(fyStartYear("")).toBeNull();
|
||||
expect(fyStartYear("01/04/2026")).toBeNull();
|
||||
expect(fyStartYear("2026-13-01")).toBeNull();
|
||||
expect(monthOf("2026-00-10")).toBeNull();
|
||||
expect(monthOf("2026-07-10")).toBe(7);
|
||||
});
|
||||
|
||||
it("labels and ranges", () => {
|
||||
expect(fyLabel(2025)).toBe("FY 2025-26");
|
||||
expect(fyLabel(2099)).toBe("FY 2099-00");
|
||||
expect(fyRange(2025)).toEqual({ from: "2025-04-01", to: "2026-03-31" });
|
||||
});
|
||||
|
||||
it("lists months April to March", () => {
|
||||
expect(FY_MONTHS.map((m) => m.month)).toEqual([4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3]);
|
||||
expect(FY_MONTHS[0].label).toBe("April");
|
||||
});
|
||||
|
||||
it("uses IST for now, not the machine time zone", () => {
|
||||
// 20:00 UTC on 31 March is already 01:30 on 1 April in India: a new financial year.
|
||||
const now = new Date("2026-03-31T20:00:00Z");
|
||||
expect(todayIst(now)).toBe("2026-04-01");
|
||||
expect(currentFyStartYear(now)).toBe(2026);
|
||||
// 18:29 UTC is still 23:59 on 31 March in India.
|
||||
expect(currentFyStartYear(new Date("2026-03-31T18:29:00Z"))).toBe(2025);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user