Skip to content

feat(m1): ledger domain in pure Java - #2

Merged
saifcores merged 1 commit into
mainfrom
milestone/m1-ledger-domain
Nov 1, 2026
Merged

saifcores merged 1 commit into
mainfrom
milestone/m1-ledger-domain

Conversation

@saifcores

Copy link
Copy Markdown
Owner

Double-entry ledger domain in contexts/ledger/ledger-domain, with no framework dependencies.

  • LedgerTransaction aggregate: at least two entries, single currency, sum of debits = sum of credits; PENDING -> POSTED | ARCHIVED only; domain events pulled via pullEvents(); accountIds() sorted for deterministic lock ordering.
  • Amount (> 0, built on Money, ADR-17), Direction, ExternalId, Entry.
  • LedgerAccount with Balances (four non-negative buckets + lockVersion), posted/pending/available for both normal balances.
  • BalanceCondition (GT/GTE/EQ/LTE/LT on POSTED/PENDING/AVAILABLE), evaluated on the post-transaction balance.
  • PostingService: apply, settle, release. Balances are projected first and written only if every check passes, so a rejection changes nothing.
  • Repository ports plus in-memory implementations in testFixtures.
  • Shared kernel: AccountId is now Comparable.

Tests:

  • LedgerInvariantProperties (jqwik): random transaction streams keep debits = credits, no negative bucket, rejections are side-effect free, and balances match a recomputation from entries.
  • SendCashScenarioTest: deposit, P2P with fees, pending cash-out, rejected overdraft, settlement.
  • Unit tests for Amount, Balances, LedgerTransaction, BalanceCondition, PostingService.
  • ArchUnit domainIsPure no longer allows an empty rule.

Docs: ADR-17, docs/milestones/M1.md, README milestone table.

Double-entry ledger domain in contexts/ledger/ledger-domain, with no
framework dependencies.

- LedgerTransaction aggregate: at least two entries, single currency,
  sum of debits = sum of credits; PENDING -> POSTED | ARCHIVED only;
  domain events pulled via pullEvents(); accountIds() sorted for
  deterministic lock ordering.
- Amount (> 0, built on Money, ADR-17), Direction, ExternalId, Entry.
- LedgerAccount with Balances (four non-negative buckets + lockVersion),
  posted/pending/available for both normal balances.
- BalanceCondition (GT/GTE/EQ/LTE/LT on POSTED/PENDING/AVAILABLE),
  evaluated on the post-transaction balance.
- PostingService: apply, settle, release. Balances are projected first
  and written only if every check passes, so a rejection changes nothing.
- Repository ports plus in-memory implementations in testFixtures.
- Shared kernel: AccountId is now Comparable.

Tests:
- LedgerInvariantProperties (jqwik): random transaction streams keep
  debits = credits, no negative bucket, rejections are side-effect free,
  and balances match a recomputation from entries.
- SendCashScenarioTest: deposit, P2P with fees, pending cash-out,
  rejected overdraft, settlement.
- Unit tests for Amount, Balances, LedgerTransaction, BalanceCondition,
  PostingService.
- ArchUnit domainIsPure no longer allows an empty rule.

Docs: ADR-17, docs/milestones/M1.md, README milestone table.
@saifcores saifcores self-assigned this Nov 1, 2026
@saifcores
saifcores merged commit 7fc6cbd into main Nov 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant