Skip to main content

TrialBalance

Struct TrialBalance 

Source
pub struct TrialBalance {
Show 21 fields pub trial_balance_id: String, pub company_code: String, pub company_name: Option<String>, pub as_of_date: NaiveDate, pub fiscal_year: i32, pub fiscal_period: u32, pub currency: String, pub balance_type: TrialBalanceType, pub lines: Vec<TrialBalanceLine>, pub total_debits: Decimal, pub total_credits: Decimal, pub is_balanced: bool, pub out_of_balance: Decimal, pub is_equation_valid: bool, pub equation_difference: Decimal, pub category_summary: HashMap<AccountCategory, CategorySummary>, pub created_at: NaiveDateTime, pub created_by: String, pub approved_by: Option<String>, pub approved_at: Option<NaiveDateTime>, pub status: TrialBalanceStatus,
}
Expand description

A trial balance report for a company and period.

Fields§

§trial_balance_id: String

Trial balance identifier.

§company_code: String

Company code.

§company_name: Option<String>

Company name.

§as_of_date: NaiveDate

As-of date.

§fiscal_year: i32

Fiscal year.

§fiscal_period: u32

Fiscal period.

§currency: String

Currency.

§balance_type: TrialBalanceType

Trial balance type.

§lines: Vec<TrialBalanceLine>

Individual account lines.

§total_debits: Decimal

Total debits.

§total_credits: Decimal

Total credits.

§is_balanced: bool

Is the trial balance balanced (debits = credits)?

§out_of_balance: Decimal

Out of balance amount.

§is_equation_valid: bool

Is the accounting equation valid (Assets = Liabilities + Equity)?

§equation_difference: Decimal

Difference in accounting equation (Assets - (Liabilities + Equity)).

§category_summary: HashMap<AccountCategory, CategorySummary>

Summary by account category.

§created_at: NaiveDateTime

Created timestamp.

§created_by: String

Created by.

§approved_by: Option<String>

Approved by (if applicable).

§approved_at: Option<NaiveDateTime>

Approval date.

§status: TrialBalanceStatus

Status.

Implementations§

Source§

impl TrialBalance

Source

pub fn new( trial_balance_id: String, company_code: String, as_of_date: NaiveDate, fiscal_year: i32, fiscal_period: u32, currency: String, balance_type: TrialBalanceType, ) -> Self

Create a new trial balance.

Source

pub fn add_line(&mut self, line: TrialBalanceLine)

Add a line to the trial balance.

Source

pub fn add_from_account_balance(&mut self, balance: &AccountBalance)

Add a line from an AccountBalance.

Source

pub fn validate_accounting_equation( &self, ) -> (bool, Decimal, Decimal, Decimal, Decimal)

Validate the accounting equation (Assets = Liabilities + Equity).

Returns true if the equation holds within tolerance, along with the calculated totals for each component.

Source

pub fn get_lines_by_category( &self, category: AccountCategory, ) -> Vec<&TrialBalanceLine>

Get lines for a specific category.

Source

pub fn get_category_total( &self, category: AccountCategory, ) -> Option<&CategorySummary>

Get total for a category.

Source

pub fn total_assets(&self) -> Decimal

Get total assets.

Source

pub fn total_liabilities(&self) -> Decimal

Get total liabilities.

Source

pub fn total_equity(&self) -> Decimal

Get total equity.

Source

pub fn total_revenue(&self) -> Decimal

Get total revenue.

Source

pub fn total_expenses(&self) -> Decimal

Get total expenses.

Source

pub fn net_income(&self) -> Decimal

Get net income.

Source

pub fn finalize(&mut self)

Finalize the trial balance.

Source

pub fn approve(&mut self, approved_by: String)

Approve the trial balance.

Source

pub fn sort_by_account(&mut self)

Sort lines by account code.

Source

pub fn sort_by_category(&mut self)

Sort lines by category then account code.

Trait Implementations§

Source§

impl Clone for TrialBalance

Source§

fn clone(&self) -> TrialBalance

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TrialBalance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TrialBalance

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TrialBalance

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,