TransactionService

Struct TransactionService 

Source
pub struct TransactionService<'a> { /* private fields */ }
Expand description

Service for transaction management

Implementations§

Source§

impl<'a> TransactionService<'a>

Source

pub fn new(storage: &'a Storage) -> Self

Create a new transaction service

Source

pub fn create( &self, input: CreateTransactionInput, ) -> EnvelopeResult<Transaction>

Create a new transaction

Source

pub fn get(&self, id: TransactionId) -> EnvelopeResult<Option<Transaction>>

Get a transaction by ID

Source

pub fn find(&self, identifier: &str) -> EnvelopeResult<Option<Transaction>>

Find a transaction by ID string

Source

pub fn list( &self, filter: TransactionFilter, ) -> EnvelopeResult<Vec<Transaction>>

List all transactions with optional filtering

Source

pub fn list_for_account( &self, account_id: AccountId, ) -> EnvelopeResult<Vec<Transaction>>

Get transactions for an account

Source

pub fn list_for_category( &self, category_id: CategoryId, ) -> EnvelopeResult<Vec<Transaction>>

Get transactions for a category

Source

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

Source

pub fn delete(&self, id: TransactionId) -> EnvelopeResult<Transaction>

Delete a transaction

Source

pub fn set_status( &self, id: TransactionId, status: TransactionStatus, ) -> EnvelopeResult<Transaction>

Set the status of a transaction

Source

pub fn clear(&self, id: TransactionId) -> EnvelopeResult<Transaction>

Clear a transaction (mark as cleared)

Source

pub fn unclear(&self, id: TransactionId) -> EnvelopeResult<Transaction>

Unclear a transaction (mark as pending)

Source

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.

Source

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.

Source

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.

Source

pub fn clear_splits(&self, id: TransactionId) -> EnvelopeResult<Transaction>

Clear all splits from a transaction

Source

pub fn learn_from_transaction(&self, txn: &Transaction) -> EnvelopeResult<()>

Learn from a transaction - update payee’s category frequency

Source

pub fn suggest_category( &self, payee_name: &str, ) -> EnvelopeResult<Option<CategoryId>>

Get suggested category for a payee name

Source

pub fn count(&self) -> EnvelopeResult<usize>

Count transactions

Source

pub fn get_uncleared( &self, account_id: AccountId, ) -> EnvelopeResult<Vec<Transaction>>

Get uncleared transactions for an account

Source

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.