LedgerStorage

Trait LedgerStorage 

Source
pub trait LedgerStorage: Send + Sync {
Show 14 methods // Required methods fn save_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account: &'life1 Account, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_account<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<Option<Account>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_accounts<'life0, 'async_trait>( &'life0 self, account_type: Option<AccountType>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Account>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account: &'life1 Account, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn save_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_transaction<'life0, 'life1, 'async_trait>( &'life0 self, transaction_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<Option<Transaction>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_account_transactions<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, start_date: Option<NaiveDate>, end_date: Option<NaiveDate>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Transaction>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_transactions<'life0, 'async_trait>( &'life0 self, start_date: Option<NaiveDate>, end_date: Option<NaiveDate>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Transaction>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_account_balance<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, as_of_date: Option<NaiveDate>, ) -> Pin<Box<dyn Future<Output = LedgerResult<BigDecimal>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_trial_balance<'life0, 'async_trait>( &'life0 self, as_of_date: NaiveDate, ) -> Pin<Box<dyn Future<Output = LedgerResult<TrialBalance>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_account_balances_by_type<'life0, 'async_trait>( &'life0 self, as_of_date: NaiveDate, ) -> Pin<Box<dyn Future<Output = LedgerResult<HashMap<AccountType, Vec<AccountBalance>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Storage abstraction for the ledger system

This trait allows the accounting core to work with any storage backend (PostgreSQL, MySQL, SQLite, in-memory, etc.) by implementing these methods.

Required Methods§

Source

fn save_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account: &'life1 Account, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save an account to storage

Source

fn get_account<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<Option<Account>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an account by ID

Source

fn list_accounts<'life0, 'async_trait>( &'life0 self, account_type: Option<AccountType>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Account>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List accounts with optional pagination and filtering

Source

fn update_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account: &'life1 Account, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update an account

Source

fn delete_account<'life0, 'life1, 'async_trait>( &'life0 mut self, account_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an account (if no transactions reference it)

Source

fn save_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save a transaction to storage

Source

fn get_transaction<'life0, 'life1, 'async_trait>( &'life0 self, transaction_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<Option<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a transaction by ID

Source

fn get_account_transactions<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, start_date: Option<NaiveDate>, end_date: Option<NaiveDate>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List transactions for a specific account with optional pagination

Source

fn get_transactions<'life0, 'async_trait>( &'life0 self, start_date: Option<NaiveDate>, end_date: Option<NaiveDate>, pagination: PaginationOption, ) -> Pin<Box<dyn Future<Output = LedgerResult<ListResponse<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all transactions within a date range with optional pagination

Source

fn update_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update a transaction

Source

fn delete_transaction<'life0, 'life1, 'async_trait>( &'life0 mut self, transaction_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = LedgerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a transaction and reverse its effects on account balances

Source

fn get_account_balance<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 str, as_of_date: Option<NaiveDate>, ) -> Pin<Box<dyn Future<Output = LedgerResult<BigDecimal>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get account balance as of a specific date

Source

fn get_trial_balance<'life0, 'async_trait>( &'life0 self, as_of_date: NaiveDate, ) -> Pin<Box<dyn Future<Output = LedgerResult<TrialBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get trial balance as of a specific date

Source

fn get_account_balances_by_type<'life0, 'async_trait>( &'life0 self, as_of_date: NaiveDate, ) -> Pin<Box<dyn Future<Output = LedgerResult<HashMap<AccountType, Vec<AccountBalance>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all account balances grouped by account type

Implementors§