Skip to main content

RunningBalanceTracker

Struct RunningBalanceTracker 

Source
pub struct RunningBalanceTracker { /* private fields */ }
Expand description

Tracks running balances for all accounts across companies.

Implementations§

Source§

impl RunningBalanceTracker

Source

pub fn new(config: BalanceTrackerConfig) -> Self

Creates a new balance tracker.

Source

pub fn with_defaults() -> Self

Creates a tracker with default configuration.

Source

pub fn register_account_type( &mut self, account_code: &str, account_type: AccountType, )

Registers an account type for balance tracking.

Source

pub fn register_account_types(&mut self, types: &[(String, AccountType)])

Registers multiple account types.

Source

pub fn register_from_chart_prefixes(&mut self, prefixes: &[(&str, AccountType)])

Registers account types from a chart of accounts prefix pattern.

Source

pub fn initialize_from_snapshot(&mut self, snapshot: &BalanceSnapshot)

Initializes balances from opening balance snapshot.

Source

pub fn apply_entry( &mut self, entry: &JournalEntry, ) -> Result<(), ValidationError>

Applies a journal entry to the running balances.

Source

pub fn apply_entries( &mut self, entries: &[JournalEntry], ) -> Vec<ValidationError>

Applies a batch of entries.

Source

pub fn validate_balance_sheet( &mut self, company_code: &str, date: NaiveDate, entry_id: Option<&str>, ) -> Result<(), ValidationError>

Validates the balance sheet equation for a company.

Source

pub fn get_snapshot( &self, company_code: &str, as_of_date: NaiveDate, ) -> Option<BalanceSnapshot>

Gets the current snapshot for a company.

Source

pub fn get_all_snapshots(&self, as_of_date: NaiveDate) -> Vec<BalanceSnapshot>

Gets snapshots for all companies.

Source

pub fn get_balance_changes( &self, company_code: &str, from_date: NaiveDate, to_date: NaiveDate, ) -> Vec<AccountPeriodActivity>

Gets balance changes for a period.

Source

pub fn get_account_balance( &self, company_code: &str, account_code: &str, ) -> Option<&AccountBalance>

Gets balance for a specific account.

Source

pub fn get_validation_errors(&self) -> &[ValidationError]

Gets all validation errors.

Source

pub fn clear_validation_errors(&mut self)

Clears validation errors.

Source

pub fn get_statistics(&self) -> &TrackerStatistics

Gets tracker statistics.

Source

pub fn roll_forward(&mut self, _new_period_start: NaiveDate)

Rolls forward balances to a new period.

Source

pub fn export_balances(&self, company_code: &str) -> Vec<(String, Decimal)>

Exports balances to a simple format.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V