pub struct TransactionService<'a> { /* private fields */ }Expand description
Service for transaction management
Implementations§
Source§impl<'a> TransactionService<'a>
impl<'a> TransactionService<'a>
Sourcepub fn create(
&self,
input: CreateTransactionInput,
) -> EnvelopeResult<Transaction>
pub fn create( &self, input: CreateTransactionInput, ) -> EnvelopeResult<Transaction>
Create a new transaction
Sourcepub fn get(&self, id: TransactionId) -> EnvelopeResult<Option<Transaction>>
pub fn get(&self, id: TransactionId) -> EnvelopeResult<Option<Transaction>>
Get a transaction by ID
Sourcepub fn find(&self, identifier: &str) -> EnvelopeResult<Option<Transaction>>
pub fn find(&self, identifier: &str) -> EnvelopeResult<Option<Transaction>>
Find a transaction by ID string
Sourcepub fn list(
&self,
filter: TransactionFilter,
) -> EnvelopeResult<Vec<Transaction>>
pub fn list( &self, filter: TransactionFilter, ) -> EnvelopeResult<Vec<Transaction>>
List all transactions with optional filtering
Sourcepub fn list_for_account(
&self,
account_id: AccountId,
) -> EnvelopeResult<Vec<Transaction>>
pub fn list_for_account( &self, account_id: AccountId, ) -> EnvelopeResult<Vec<Transaction>>
Get transactions for an account
Sourcepub fn list_for_category(
&self,
category_id: CategoryId,
) -> EnvelopeResult<Vec<Transaction>>
pub fn list_for_category( &self, category_id: CategoryId, ) -> EnvelopeResult<Vec<Transaction>>
Get transactions for a category
Sourcepub fn update(
&self,
id: TransactionId,
date: Option<NaiveDate>,
amount: Option<Money>,
payee_name: Option<String>,
category_id: Option<Option<CategoryId>>,
memo: Option<String>,
) -> EnvelopeResult<Transaction>
pub fn update( &self, id: TransactionId, date: Option<NaiveDate>, amount: Option<Money>, payee_name: Option<String>, category_id: Option<Option<CategoryId>>, memo: Option<String>, ) -> EnvelopeResult<Transaction>
Update a transaction
Sourcepub fn delete(&self, id: TransactionId) -> EnvelopeResult<Transaction>
pub fn delete(&self, id: TransactionId) -> EnvelopeResult<Transaction>
Delete a transaction
Sourcepub fn set_status(
&self,
id: TransactionId,
status: TransactionStatus,
) -> EnvelopeResult<Transaction>
pub fn set_status( &self, id: TransactionId, status: TransactionStatus, ) -> EnvelopeResult<Transaction>
Set the status of a transaction
Sourcepub fn clear(&self, id: TransactionId) -> EnvelopeResult<Transaction>
pub fn clear(&self, id: TransactionId) -> EnvelopeResult<Transaction>
Clear a transaction (mark as cleared)
Sourcepub fn unclear(&self, id: TransactionId) -> EnvelopeResult<Transaction>
pub fn unclear(&self, id: TransactionId) -> EnvelopeResult<Transaction>
Unclear a transaction (mark as pending)
Sourcepub fn unlock(&self, id: TransactionId) -> EnvelopeResult<Transaction>
pub fn unlock(&self, id: TransactionId) -> EnvelopeResult<Transaction>
Unlock a reconciled transaction for editing
This is a potentially dangerous operation - it allows editing a transaction that has already been reconciled with a bank statement. Use with caution.
Sourcepub fn add_split(
&self,
id: TransactionId,
category_id: CategoryId,
amount: Money,
memo: Option<String>,
) -> EnvelopeResult<Transaction>
pub fn add_split( &self, id: TransactionId, category_id: CategoryId, amount: Money, memo: Option<String>, ) -> EnvelopeResult<Transaction>
Add a split to a transaction
Note: This validates that splits total equals the transaction amount.
If you need to add multiple splits, use set_splits instead to avoid
intermediate validation failures.
Sourcepub fn set_splits(
&self,
id: TransactionId,
splits: Vec<Split>,
) -> EnvelopeResult<Transaction>
pub fn set_splits( &self, id: TransactionId, splits: Vec<Split>, ) -> EnvelopeResult<Transaction>
Set all splits for a transaction at once
This replaces any existing splits with the new ones. The splits must sum to the transaction amount.
Sourcepub fn clear_splits(&self, id: TransactionId) -> EnvelopeResult<Transaction>
pub fn clear_splits(&self, id: TransactionId) -> EnvelopeResult<Transaction>
Clear all splits from a transaction
Sourcepub fn learn_from_transaction(&self, txn: &Transaction) -> EnvelopeResult<()>
pub fn learn_from_transaction(&self, txn: &Transaction) -> EnvelopeResult<()>
Learn from a transaction - update payee’s category frequency
Sourcepub fn suggest_category(
&self,
payee_name: &str,
) -> EnvelopeResult<Option<CategoryId>>
pub fn suggest_category( &self, payee_name: &str, ) -> EnvelopeResult<Option<CategoryId>>
Get suggested category for a payee name
Sourcepub fn count(&self) -> EnvelopeResult<usize>
pub fn count(&self) -> EnvelopeResult<usize>
Count transactions
Sourcepub fn get_uncleared(
&self,
account_id: AccountId,
) -> EnvelopeResult<Vec<Transaction>>
pub fn get_uncleared( &self, account_id: AccountId, ) -> EnvelopeResult<Vec<Transaction>>
Get uncleared transactions for an account
Sourcepub fn get_cleared(
&self,
account_id: AccountId,
) -> EnvelopeResult<Vec<Transaction>>
pub fn get_cleared( &self, account_id: AccountId, ) -> EnvelopeResult<Vec<Transaction>>
Get cleared (but not reconciled) transactions for an account
Auto Trait Implementations§
impl<'a> Freeze for TransactionService<'a>
impl<'a> RefUnwindSafe for TransactionService<'a>
impl<'a> Send for TransactionService<'a>
impl<'a> Sync for TransactionService<'a>
impl<'a> Unpin for TransactionService<'a>
impl<'a> UnwindSafe for TransactionService<'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
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>
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>
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