- 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.
26 lines
974 B
TypeScript
26 lines
974 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatPaise, paiseToInput, parseRupeesToPaise } from "./money";
|
|
|
|
describe("money", () => {
|
|
it("parses typed amounts to exact paise", () => {
|
|
expect(parseRupeesToPaise("1250.5")).toBe(125050);
|
|
expect(parseRupeesToPaise("1,25,000")).toBe(12500000);
|
|
expect(parseRupeesToPaise("₹ 99.99")).toBe(9999);
|
|
expect(parseRupeesToPaise("0.29")).toBe(29);
|
|
expect(parseRupeesToPaise("19.9")).toBe(1990);
|
|
expect(parseRupeesToPaise("5.")).toBe(500);
|
|
expect(parseRupeesToPaise("")).toBe(0);
|
|
});
|
|
|
|
it("rejects non-amounts", () => {
|
|
for (const bad of ["abc", "-5", "1.234", "1e3", "1.2.3", ".5"]) expect(parseRupeesToPaise(bad)).toBeNull();
|
|
expect(parseRupeesToPaise("99999999999999999999")).toBeNull();
|
|
});
|
|
|
|
it("formats", () => {
|
|
expect(paiseToInput(123450)).toBe("1234.50");
|
|
expect(paiseToInput(5)).toBe("0.05");
|
|
expect(formatPaise(12500000)).toBe("₹1,25,000.00");
|
|
});
|
|
});
|