fin-hub/workplans/FIN-WP-0006-internal-transfer-settlement.md
tegwick 91d62f6430
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 6s
Implement FIN-WP-0006-T01 settlement statement join; mark FIN-WP-0004/0005 blocked
Add SettlementStatement schema and a dedicated settlement_statements store
(ingest_settlement_statement, current_settlement_statements) so
resource-control internal transfer settlements join as a referenced
projection without ever entering the booked-cost ledger. exchange_health
now surfaces a current statement with payment_recognition=unknown as a
settlement_awaiting_payment_join residual instead of booked cost. Adds
CLI commands finhub ledger ingest-settlement / settlements.

FIN-WP-0006-T01 is done; the workplan is finished.

Reviewed all other open workplans for closeable work: FIN-WP-0004's only
remaining task (T05) waits on an external provider fact from
resource-control, and every FIN-WP-0005 task waits on operator/Steuerbüro
confirmation or a non-production DATEV tenant. Neither has actionable
in-repo work right now, so both move to status: blocked.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: sonnet
Assistant-Process: 242919@bnt-lap001
Assistant-Session: 286d235a-1654-40ff-b8fd-eee4e2ff9ea6
2026-09-27 21:51:09 +02:00

2.9 KiB

id type title domain repo status flavor owner topic_slug created updated related origin origin_ref state_hub_workstream_id
FIN-WP-0006 workplan Consume resource-control internal transfer settlement financials fin-hub finished residual codex financials 2026-08-14 2026-09-27
FIN-WP-0004
RESOURCE-WP-0005
residual RESOURCE-WP-0005 e9413a20-5b11-50ff-ba21-15215841cf11

FIN-WP-0006 — consume internal transfer settlement

Goal

Accept proposed internal transfer charges and credit-state records from resource-control without taking resource authority or creating a second ledger. Recognize internal payments as booked facts joined by financial_fact_id, financial_entity_id, and period.

Origin: RESOURCE-WP-0005-T07. Terms live in resource-control/docs/TermsOfResourceProcurement.md. Outbound shape: resource-control/schemas/settlement-statement.schema.json.

Boundaries

  • resource-control owns transfer-price arithmetic, statements, and consumption mode.
  • fin-hub owns booked provider cost, tax, recognized payments, and any later DATEV-facing internal settlement posting.
  • A settlement statement is not booked spend.

T01 — Join proposed transfer charges

id: FIN-WP-0006-T01
status: done
flavor: residual
priority: high
state_hub_task_id: "9ef3fab5-51a6-57ef-8121-b9714298c502"

Document and implement the inbound join for resource-control settlement statements. Preserve financial_entity_id, period, terms_version, and statement identity. Reject any path that would post the statement as a provider invoice.

Done when an inbound fixture can be stored as a referenced projection and exchange_health shows statements lacking a payment join as a visible residual, not as booked cost.

Completed 2026-09-27: added SettlementStatement (src/fin_hub/schemas/exchange.py) matching resource-control's v0.1 settlement-statement.schema.json, with a dedicated settlement_statements table (services/exchange.py) that never touches ledger_entries. ingest_settlement_statement validates and stores each statement keyed by financial_entity_id + procuring_entity_id + period

  • statement_date, idempotent on identical resubmission, and superseding the prior current statement for the same entity/period pair on a later statement_date. exchange_health now emits settlement_awaiting_payment_join (severity warning) for any current statement with payment_recognition: "unknown", listing its outstanding amount as a residual rather than booked cost. current_settlement_statements exposes the stored projection for reporting. CLI: finhub ledger ingest-settlement and finhub ledger settlements. Fixture: tests/fixtures/settlement-statement-2026-08.json. Tests: tests/test_exchange.py::test_settlement_statement_* and ::test_exchange_health_surfaces_settlement_without_payment_join_as_residual. Full suite: 102 passed.