Overview
TheAccountingFacade is the primary interface for all accounting operations in the system. It provides methods for creating accounts, executing transactions, querying balances, and managing financial data using double-entry bookkeeping principles.
Package: com.softwarearchetypes.accounting
Constructor
AccountingConfiguration to obtain an instance.
Account Management
createAccount
Creates a single account.Account creation request containing:
accountId: Unique identifier for the accountname: Human-readable account nametype: Account type (ASSET, LIABILITY, EXPENSE, REVENUE, OFF_BALANCE)
- Success: Returns the created
AccountId - Failure: Returns error message if account already exists
createAccounts
Creates multiple accounts in a single operation.Set of account creation requests
- Success: Returns set of created account IDs
- Failure: Returns error if any account already exists
createAccountsWithInitialBalances
Creates accounts and initializes them with opening balances.Account creation requests
Initial balances for the accounts (positive for credits, negative for debits)
- Success: Returns set of created account IDs
- Failure: Returns error message if creation or initialization fails
Balance Queries
balance
Retrieves the current balance of an account.The account identifier
The current account balance, or empty if account doesn’t exist
balanceAsOf
Retrieves the account balance as of a specific point in time.The account identifier
The point in time for balance calculation
The account balance at the specified time, or empty if account doesn’t exist
balances
Retrieves current balances for multiple accounts.Set of account identifiers
Map of account IDs to their current balances
balancesAsOf
Retrieves balances for multiple accounts at a specific point in time.Set of account identifiers
The point in time for balance calculation
Map of account IDs to their balances at the specified time
Transaction Operations
transaction
Creates a new transaction builder for constructing complex transactions.A builder for constructing and executing transactions
execute
Executes one or more transactions.The transaction to execute
- Success: Returns the transaction ID
- Failure: Returns error message if execution fails
transfer
Performs a simple transfer between two accounts.Source account to debit
Target account to credit
Amount to transfer
When the transfer occurred in real time
When the transfer applies for accounting purposes
Optional metadata to attach to the transaction
- Success: Returns the transaction ID
- Failure: Returns error message if transfer fails
handle (ExecuteTransactionCommand)
Executes a transaction from a command object.Command containing:
transactionType: Type of transactionoccurredAt: When transaction occurredappliesAt: When transaction appliesentries: List of credit/debit entriesmetadata: Optional transaction metadata
- Success: Returns the transaction ID
- Failure: Returns error message if execution fails
handle (ReverseTransactionCommand)
Reverses a previously executed transaction.Command containing:
refTransactionId: ID of transaction to reverseoccurredAt: When reversal occurredappliesAt: When reversal applies
- Success: Returns the reversal transaction ID
- Failure: Returns error message if reversal fails
Query Operations
findAccount
Retrieves detailed account information including entries.The account identifier
Complete account view with balance and entry history, or empty if not found
findAccounts
Retrieves multiple accounts by their IDs.Set of account identifiers
List of account views for existing accounts
findAll
Retrieves all accounts in the system.List of all account views
findTransactionBy
Retrieves complete transaction details including all entries.The transaction identifier
Complete transaction view with all entries and accounts, or empty if not found
findTransactionIdsFor
Finds all transaction IDs associated with an account.The account identifier
List of transaction IDs that affected the account
Projection Accounts
createProjectingAccount
Creates a virtual account that projects (aggregates) entries from other accounts based on filters.ID for the projection account
Filter defining which entries to include
Human-readable description of the projection
- Success: Returns the projection account ID
- Failure: Returns error message if creation fails
Related Types
- Account - Core account entity
- Transaction - Transaction entity
- Entry - Individual accounting entries
Result<F, S>- Result monad for error handlingMoney- Monetary value with currencyInstant- Point in time
