pub struct AccountService<'a> { /* private fields */ }Expand description
Service for account management
Implementations§
Source§impl<'a> AccountService<'a>
impl<'a> AccountService<'a>
Sourcepub fn create(
&self,
name: &str,
account_type: AccountType,
starting_balance: Money,
on_budget: bool,
) -> EnvelopeResult<Account>
pub fn create( &self, name: &str, account_type: AccountType, starting_balance: Money, on_budget: bool, ) -> EnvelopeResult<Account>
Create a new account
Sourcepub fn get_by_name(&self, name: &str) -> EnvelopeResult<Option<Account>>
pub fn get_by_name(&self, name: &str) -> EnvelopeResult<Option<Account>>
Get an account by name (case-insensitive)
Sourcepub fn find(&self, identifier: &str) -> EnvelopeResult<Option<Account>>
pub fn find(&self, identifier: &str) -> EnvelopeResult<Option<Account>>
Find an account by name or ID string
Sourcepub fn list_with_balances(
&self,
include_archived: bool,
) -> EnvelopeResult<Vec<AccountSummary>>
pub fn list_with_balances( &self, include_archived: bool, ) -> EnvelopeResult<Vec<AccountSummary>>
Get all accounts with their computed balances
Sourcepub fn get_summary(&self, account: &Account) -> EnvelopeResult<AccountSummary>
pub fn get_summary(&self, account: &Account) -> EnvelopeResult<AccountSummary>
Get account summary with computed balances
Sourcepub fn calculate_balance(&self, account_id: AccountId) -> EnvelopeResult<Money>
pub fn calculate_balance(&self, account_id: AccountId) -> EnvelopeResult<Money>
Calculate the current balance for an account
Sourcepub fn calculate_cleared_balance(
&self,
account_id: AccountId,
) -> EnvelopeResult<Money>
pub fn calculate_cleared_balance( &self, account_id: AccountId, ) -> EnvelopeResult<Money>
Calculate the cleared balance for an account
Sourcepub fn update(
&self,
id: AccountId,
name: Option<&str>,
) -> EnvelopeResult<Account>
pub fn update( &self, id: AccountId, name: Option<&str>, ) -> EnvelopeResult<Account>
Update an account
Sourcepub fn archive(&self, id: AccountId) -> EnvelopeResult<Account>
pub fn archive(&self, id: AccountId) -> EnvelopeResult<Account>
Archive an account (soft delete)
Sourcepub fn unarchive(&self, id: AccountId) -> EnvelopeResult<Account>
pub fn unarchive(&self, id: AccountId) -> EnvelopeResult<Account>
Unarchive an account
Sourcepub fn total_on_budget_balance(&self) -> EnvelopeResult<Money>
pub fn total_on_budget_balance(&self) -> EnvelopeResult<Money>
Get total balance across all on-budget accounts
Sourcepub fn total_balance_by_type(
&self,
account_type: AccountType,
) -> EnvelopeResult<Money>
pub fn total_balance_by_type( &self, account_type: AccountType, ) -> EnvelopeResult<Money>
Get total balance for all accounts of a specific type
Sourcepub fn count_by_type(&self, account_type: AccountType) -> EnvelopeResult<usize>
pub fn count_by_type(&self, account_type: AccountType) -> EnvelopeResult<usize>
Get count of accounts of a specific type
Auto Trait Implementations§
impl<'a> Freeze for AccountService<'a>
impl<'a> RefUnwindSafe for AccountService<'a>
impl<'a> Send for AccountService<'a>
impl<'a> Sync for AccountService<'a>
impl<'a> Unpin for AccountService<'a>
impl<'a> UnwindSafe for AccountService<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more