Files
SGF/packages/general-ledger/README.md
T
2026-11-04 09:37:20 +02:00

34 lines
7.5 KiB
Markdown

# General ledger — synthetic supplier and customer cycles
Correcção industrial QA: `industry.cost.reversal/replacement`, capturadas/revistas/aplicadas apenas como grupo pelo writer existente. `IndustrialCorrectionSchema` exige livro SGF novo vazio e delega só o domínio industrial, preservando guardas fornecedor/directo. Sem activar capacidades em livros antigos ou no destino; ver a entrega industrial de correcção no SGF.
Industrial QA SGF: tipo `industry.cost.validated` em duas linhas pelo mesmo escritor, fonte/guardas explicitamente configuradas no host e identidade por lote/perímetro. Residual separado. `IndustrialSchema` só em livro SGF novo vazio. Sem dependência industrial exigida no SGC ou alteração dos pacotes congelados; ver `docs/GENERAL_LEDGER_INDUSTRIAL_DELIVERY.md` no SGF.
The separately authorised `COMMON-LEDGER-DIRECT-COST-CORRECTION-SIM-v1` composes one explicit original275 → reversal275/replacement295 cost group in NEW SGF QA books. `CostCorrectionSchema` delegates only cost results to its asymmetric, scoped, deferred pair check; supplier pair validation is retained. Public individual review/post routes refuse all correction parts. The host requires a separate default-off flag, current verified cost source, exact review and original period open; period completeness follows the applied replacement source revision. Original journals, costs and outbox remain immutable. No reopen or implicit chain. See `docs/GENERAL_LEDGER_DIRECT_COST_CORRECTION_DELIVERY.md`.
The separately authorised `COMMON-LEDGER-DIRECT-COST-SIM-v1` adds an optional SGF actual validated workshop cost source: D QA-CUSTO-DIRECTO275 / C QA-COMPENSACAO-ENSAIO275. `CostSchema` installs an explicit append-only order/perimeter mapping only in a NEW empty SGF QA book. The host owns cost completeness, current source/rate/decision validation and exact minor-unit eligibility. Stable effect identity is the selected order/perimeter, not a successor calculation ID. Corrections of already-posted costs are refused/out of scope; no automatic stock/payroll/financial effect or outbox processing. Native SGC requires no workshop schema/provider and refuses the uncomposed source. Single Sales-provider period packets retain their prior hash contract. See `docs/GENERAL_LEDGER_DIRECT_COST_DELIVERY.md`.
`LedgerReports` adds read-only trial balance and account ledger APIs over posted facts. Explicit inclusive dates, scoped account validation, 25/100 server pagination, SQL totals and running balances computed before pagination. The host supplies the same current read authorizer and a repeatable-read/read-only transaction. Three report queries serve each trial balance page; account ledger additionally validates the account and counts its entries. `ReportsWorkspace` renders the shared view without commands. No financial authority, schema installer or rights were added; unavailable capability/schema is refused by the host. See `docs/GENERAL_LEDGER_REPORTS_DELIVERY.md`.
The separately authorised `COMMON-LEDGER-SALES-RECEIVABLE-SIM-v1` now composes actual test sales invoices and confirmed receivable allocations/reversals in SGF through optional host callbacks. `SalesSchema` installs only in a NEW empty owned SGF QA ledger: documentary recognition has three reviewed lines; allocation/reversal and supplier journals retain two. The deferred journal AND line-insert constraints enforce the exact reviewed line count, accounts and balance, including an attempted late third line on an existing two-line journal. Existing demonstrations are not upgraded. See `docs/GENERAL_LEDGER_SALES_RECEIVABLE_DELIVERY.md`.
Sales capability defaults off. Standalone SGC needs neither Sales nor its schema; its adapter explicitly refuses those source kinds. Source identifiers are typed: the legacy supplier `obligation_id` filter must never mix a customer obligation with the same integer ID. Customer reads use `sales_invoice_id`. One scoped period completeness check includes both composed sources, without creating financial effects.
Single canonical writer for `COMMON-LEDGER-PAYABLE-SIM-v1` and the separately authorised `COMMON-LEDGER-COMPLETE-CYCLE-SIM-v1`. SGF and standalone SGC adapters opt into NEW owned QA databases. No operational installer, bank execution, real chart/tax policy or production use is delivered. See `docs/GENERAL_LEDGER_COMPLETE_CYCLE_DELIVERY.md` in the canonical repository.
`PayableJournal` consumes a current recognised payable effect through a host callback. It never creates/settles a payable. `prepare` captures source/rule/period/lines; `validate` records an independent approval/refusal; `post` revalidates the exact capture and writes one journal, two lines, history and a request receipt atomically. Source effect identity is independent of request key and source revision. Different versions cannot silently book the same principal again.
The host authorizer must lock the company before source/configuration reads and recheck context, person and explicit action rights before idempotent recovery. All normal source/configuration writers must use that same serialization boundary. Account/rule editing is not exposed; reviewed period close appends a new closed version. The source provider must return scoped, compatible, current recognition identity/revision and integral principal. Do not pass report totals, an invoice status alone or a cached browser snapshot as source authority.
`effect-prepare` accepts only confirmed financial allocation/reversal IDs. The original recognition must already be posted; reversing an allocation also requires its original accounting effect. `amount_minor` is the factual allocation amount, separate from the original principal. Normal review/post commands retain exact current-state checks and the same journal writer.
`correct-prepare/validate/post` capture and apply a linked full reversal/replacement of an original recognition. The public individual routes refuse corrective parts. Both postings and their group result are atomic; deferred SQL checks refuse an orphan part. Original journals remain immutable. `period-prepare/validate/close` capture reconciled facts/configuration, require distinct review and recheck after serialization; pending effects or changed evidence refuse. No reopen command exists.
`CycleSchema::install` refuses any existing ledger proposals/journals and is never called by host boot or migrations. Old demonstration schemas are not upgraded. Cycle permissions are separately granted only in new fixtures. Both host defaults remain off.
Rules, periods, accounts, proposals, decisions, journals, lines, command receipts and events are append-only. Composite foreign keys prevent cross-scope account/line/review references. Immediate application validation plus deferred database constraints enforce the reviewed balanced journal (two lines in supplier composition; two or three in new Sales composition), exact source snapshot, preparer and accounts. Database ownership/role separation for real deployment remains unvalidated; the QA application role owns its new test database.
`listing` returns 25-row journal/proposal/event windows and filtered account/period totals over all matching journal lines, not only the visible page. The SGF host wraps reads in repeatable-read/read-only transactions. Unknown period/account is refused, not displayed as a missing-source zero.
The optional checkpoint closure is test instrumentation only, absent from HTTP/configuration. No dependencies were added. Current artificial rule: D `QA-CONTRAPARTIDA` / C `QA-FORNECEDOR`, MZN, explicit October 2026 period; it is not a client chart, expense/inventory determination or fiscal approval.