Skip to content

accounting_service

AccountingService: maps Transaction dataclasses to journal entries and posts to the Ledger.

Supports reversal (counter-entries) for step-back simulation.

Classes:

  • AccountingService

    Maps Transaction records to journal entries and posts them to a Ledger.

AccountingService

AccountingService()

Maps Transaction records to journal entries and posts them to a Ledger.

The service looks up named accounts from the ledger's chart of accounts so that callers do not need to pass account references explicitly.

Methods:

  • post

    Map transaction to journal entries and post each one to ledger.

  • post_all

    Post all transactions to ledger and update positions as needed.

  • reverse

    Post the reversal (counter-entries) of transaction to ledger.

post

post(transaction: Transaction, ledger: Ledger) -> None

Map transaction to journal entries and post each one to ledger.

post_all

post_all(
    transactions: list[Transaction],
    ledger: Ledger,
    position_store: PositionStore,
) -> None

Post all transactions to ledger and update positions as needed.

reverse

reverse(transaction: Transaction, ledger: Ledger) -> None

Post the reversal (counter-entries) of transaction to ledger.

This undoes the effect of a prior :meth:post call for the same transaction, restoring account balances to their pre-post state.