pub struct BalanceSnapshot {Show 16 fields
pub snapshot_id: String,
pub company_code: String,
pub as_of_date: NaiveDate,
pub fiscal_year: i32,
pub fiscal_period: u32,
pub currency: String,
pub balances: HashMap<String, AccountBalance>,
pub total_assets: Decimal,
pub total_liabilities: Decimal,
pub total_equity: Decimal,
pub total_revenue: Decimal,
pub total_expenses: Decimal,
pub net_income: Decimal,
pub is_balanced: bool,
pub balance_difference: Decimal,
pub created_at: NaiveDateTime,
}Expand description
A snapshot of all account balances at a point in time.
Fields§
§snapshot_id: StringSnapshot identifier.
company_code: StringCompany code.
as_of_date: NaiveDateSnapshot date.
fiscal_year: i32Fiscal year.
fiscal_period: u32Fiscal period.
currency: StringCurrency.
balances: HashMap<String, AccountBalance>All account balances.
total_assets: DecimalTotal assets.
total_liabilities: DecimalTotal liabilities.
total_equity: DecimalTotal equity.
total_revenue: DecimalTotal revenue.
total_expenses: DecimalTotal expenses.
net_income: DecimalNet income.
is_balanced: boolIs the balance sheet balanced (A = L + E)?
balance_difference: DecimalBalance sheet difference (should be zero).
created_at: NaiveDateTimeCreated timestamp.
Implementations§
Source§impl BalanceSnapshot
impl BalanceSnapshot
Sourcepub fn new(
snapshot_id: String,
company_code: String,
as_of_date: NaiveDate,
fiscal_year: i32,
fiscal_period: u32,
currency: String,
) -> Self
pub fn new( snapshot_id: String, company_code: String, as_of_date: NaiveDate, fiscal_year: i32, fiscal_period: u32, currency: String, ) -> Self
Create a new balance snapshot.
Sourcepub fn add_balance(&mut self, balance: AccountBalance)
pub fn add_balance(&mut self, balance: AccountBalance)
Add an account balance to the snapshot.
Sourcepub fn recalculate_totals(&mut self)
pub fn recalculate_totals(&mut self)
Recalculate totals and validate balance sheet equation.
Sourcepub fn get_balance(&self, account_code: &str) -> Option<&AccountBalance>
pub fn get_balance(&self, account_code: &str) -> Option<&AccountBalance>
Get balance for a specific account.
Sourcepub fn get_asset_balances(&self) -> Vec<&AccountBalance>
pub fn get_asset_balances(&self) -> Vec<&AccountBalance>
Get all asset balances.
Sourcepub fn get_liability_balances(&self) -> Vec<&AccountBalance>
pub fn get_liability_balances(&self) -> Vec<&AccountBalance>
Get all liability balances.
Sourcepub fn get_equity_balances(&self) -> Vec<&AccountBalance>
pub fn get_equity_balances(&self) -> Vec<&AccountBalance>
Get all equity balances.
Sourcepub fn get_income_statement_balances(&self) -> Vec<&AccountBalance>
pub fn get_income_statement_balances(&self) -> Vec<&AccountBalance>
Get all income statement balances.
Sourcepub fn current_ratio(
&self,
current_asset_accounts: &[&str],
current_liability_accounts: &[&str],
) -> Option<Decimal>
pub fn current_ratio( &self, current_asset_accounts: &[&str], current_liability_accounts: &[&str], ) -> Option<Decimal>
Get current ratio (Current Assets / Current Liabilities).
Sourcepub fn debt_to_equity_ratio(&self) -> Option<Decimal>
pub fn debt_to_equity_ratio(&self) -> Option<Decimal>
Get debt-to-equity ratio.
Sourcepub fn gross_margin(&self, cogs_accounts: &[&str]) -> Option<Decimal>
pub fn gross_margin(&self, cogs_accounts: &[&str]) -> Option<Decimal>
Get gross margin (Revenue - COGS) / Revenue.
Trait Implementations§
Source§impl Clone for BalanceSnapshot
impl Clone for BalanceSnapshot
Source§fn clone(&self) -> BalanceSnapshot
fn clone(&self) -> BalanceSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BalanceSnapshot
impl Debug for BalanceSnapshot
Source§impl<'de> Deserialize<'de> for BalanceSnapshot
impl<'de> Deserialize<'de> for BalanceSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BalanceSnapshot
impl RefUnwindSafe for BalanceSnapshot
impl Send for BalanceSnapshot
impl Sync for BalanceSnapshot
impl Unpin for BalanceSnapshot
impl UnwindSafe for BalanceSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more