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:
2026-10-04 17:49:25 +05:30
parent 3510cc4260
commit 1623b879e2
25 changed files with 2220 additions and 175 deletions
+21
View File
@@ -0,0 +1,21 @@
import { useEffect, useRef } from "react";
/**
* Gives focus back to whatever had it when a modal opened, once the modal closes. Carbon's Modal only
* does this with a launcher ref, which does not suit modals opened from table rows or menus.
*/
export function useReturnFocus(open: boolean): void {
const origin = useRef<HTMLElement | null>(null);
const wasOpen = useRef(false);
useEffect(() => {
if (open && !wasOpen.current) {
origin.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
} else if (!open && wasOpen.current) {
const el = origin.current;
origin.current = null;
// After the modal has unmounted its focus trap.
if (el && el.isConnected) setTimeout(() => el.focus(), 0);
}
wasOpen.current = open;
}, [open]);
}