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
+12 -1
View File
@@ -84,6 +84,9 @@ interface NewInvoiceProps {
active: boolean;
/** Ask the shell to show this view (used by Ctrl+N from another tab). */
onActivate: () => void;
/** A draft to open as soon as the form is shown (set by "Duplicate" on the invoice page). */
openDraftId?: number | null;
onDraftOpened?: () => void;
}
const AUTOSAVE_MS = 1000;
@@ -94,7 +97,7 @@ const formatStamp = (iso: string) => {
return Number.isNaN(d.getTime()) ? iso : `${d.toLocaleDateString("en-GB")} ${formatTime(d)}`;
};
export default function NewInvoice({ settings, onSettingsChange, active, onActivate }: NewInvoiceProps) {
export default function NewInvoice({ settings, onSettingsChange, active, onActivate, openDraftId = null, onDraftOpened }: NewInvoiceProps) {
const toast = useToast();
const newItem = (): InvoiceItem => ({ ...EMPTY_ITEM, hsnSac: settings.defaultHsnSac });
const blankState = (): InvoiceFormState => {
@@ -562,6 +565,14 @@ export default function NewInvoice({ settings, onSettingsChange, active, onActiv
}
};
useEffect(() => {
if (openDraftId === null || !active) return;
onDraftOpened?.();
void resumeDraft(openDraftId);
// resumeDraft closes over fresh state each render; only a new request should trigger it.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [openDraftId, active]);
const removeDraft = async (id: number) => {
try {
await api.deleteDraft(id);