Repository navigation
bookkeeping: per-child mixed allocation classification (successor to #314) - #533
alexeygrigorev wants to merge 6 commits into
Conversation
… evidence from reportable children (successor to #314)
The snapshot counts and selects evidence per reportable child, but the archive still reloaded each snapshotted payment and wrote the parent row, so a mixed Software/Taxes payment shipped its full total with only the Software child's documents. The archive now renders its snapshotted payments through the same accountant rows the snapshot and the reconcile package use: an allocated payment as its reportable children (child label, amount, category, EUR and VAT; the payment's dates, entry type and bank reference), any other payment as itself. The stored snapshot stays a v2 ID list: nothing is migrated and no ledger row or evidence document is written. An already archived report is served as stored. A snapshot whose payment has no reportable child any more, or whose child has no EUR value, is refused before any write instead of shipping evidence without a row. The snapshot's missing-evidence warning follows the same evidence rule: an allocated child is evidenced by its own allocation document, not by a parent-level link. Tests read the CSV back out of the generated ZIP.
|
Archive parity for the gap from the #314 review, on top of 7e860c7: 201e25f (this PR stays draft; nothing merged). Reproduced on 7e860c7 with
Fixed in 201e25f
Verification (targeted only, no bulk reruns)
Trade-offs and residuals
|
…ldren The package preview classified and counted on the parent payment, so a mixed Software/Taxes payment showed one row with the parent total and the payment's own links as evidence, while the package the snapshot builds lists its reportable children and their allocation documents. The preview now selects rows the way the snapshot does: a payment with saved invoice allocations as its reportable children, each kept in or out on its own category and text, never on the payment's markers; any other entry as itself under the surface's rule. An ordinary entry is evidenced by its links and a child by its own allocation document, so links of an allocated payment no longer count as evidence. The EUR preflight runs on the reportable children: a converted payment with an unconverted child blocks the package, as the snapshot's 409 does. An entry without complete allocations previews exactly as before. Nothing is written: snapshots, the archive and ledger rows are untouched.
|
Backlog triage 2026-11-27, status check (no merge by the triage session — this stays the owner's draft):
Still a separate decision: what to do with #314's unported parts (chunked v4 snapshots with CAS migration, the VAT category exemption, frontend VAT/format changes). Whichever of this PR and #524 lands second re-validates against the other's real head (shared files: bookkeepingAllocations.ts, api-bookkeeping.test.ts). |
Successor to #314 (kept open and draft), on current main.
Fixes the mixed-allocation classification bug that survives on main: a payment with invoice allocations was classified on its parent (Taxes/mandatory/owner-draw markers), and children inherited the parent's markers. Now each child is classified on its own, parent-only markers are dropped from child projections, snapshot evidence is selected from the reportable children only, and the monthly archive lists the same rows.
Archive parity (
backend/src/routes/bookkeepingReports.ts). The archive reloaded each snapshotted payment and wrote the parent row, so a mixed Software/Taxes payment shipped its full total next to only the Software child's documents. It now renders the snapshotted payments through the shared accountant rows (accountantReportRowsplus the reportable filter, the selection the snapshot counts and the reconcile package exports): an allocated payment as its reportable children, with the child's label, amount, category, EUR value and VAT and the payment's dates, entry type and bank reference; any other payment as itself. The twelve-column format is unchanged (unsigned amount withentryType, quoted cells).Snapshot storage is unchanged. The v2 ID lists (
transactionIds,documentIds) stay on the report, nothing is migrated, and archive generation writes no ledger row or evidence document. An already archived report is served as stored.Safety gates (409, before any write or S3 call). A snapshot whose payment has no reportable child any more (
staleTransactionIds), or whose child has no EUR value, is refused instead of shipping evidence without a row.The snapshot's
missingEvidencewarning follows the same evidence rule: an allocated child is evidenced by its own allocation document, not by a parent-level link.Not ported (see the comment on #314): chunked v4 snapshots, CAS migration, and the VAT category exemption.
Tests (synthetic fixtures).
backend/tests/bookkeeping-report-archive.test.tsreads the CSV back out of the generated ZIP: child totals, labels and order, the evidence list, payment direction, dates and cell format, an older ID-list report, and both refusals. Plusbackend/tests/bookkeeping-reporting.test.tsand a case inbackend/tests/api-bookkeeping.test.ts. The archive cases fail on 7e860c7 and pass on 201e25f.tscis clean for the source, test and script configs.