| Crates.io | tktax-account |
| lib.rs | tktax-account |
| version | 0.2.2 |
| created_at | 2025-02-01 03:59:52.348878+00 |
| updated_at | 2025-02-01 03:59:52.348878+00 |
| description | Robust account analysis and transaction categorization for the tktax financial suite. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538085 |
| size | 105,751 |
tktax-account is a Rust crate offering robust account transaction analytics within the broader tktax financial suite. It provides traits and data structures for:
Grounded in oikonomikós (οἰκονομικός, Ancient Greek for household management), this crate helps manage account-related data with strong type safety and production-grade error handling.
This library implements an Account struct encapsulating:
AccountKind (e.g., Checking, Credit, or Savings)TrackedYear for annual groupingTransaction entries parsed from CSVMultiple traits define how accounts produce analytics:
GetTransactionsByKeyword, GetTransactionsWithinDates, etc.GetAccountSummary, CreateMonthlySummary.GetTotalDebits, GetTotalCredits, GetTotalChecks, and more.Integrated error handling uses error_tree! variants (e.g., TransactionFileReadError) to ensure robust runtime resilience without resorting to .unwrap() or .expect().
Highly Typed
Avoids string-based error returns. All business logic uses specialized types (e.g., MonetaryAmount, TransactionType).
Production-Grade Error Handling
Custom errors (AccountCreationError, TransactionFileReadError, etc.) unify the codebase for consistent error paths.
Efficient Data Processing
Aggregates monthly data, sums credits/debits, and categorizes transactions with minimal overhead.
Expandability
New categories and account behaviors can be integrated by implementing the core traits (like TransactionCategory).
Extensive Trait Implementations
Simplifies advanced queries (e.g., transactions_over(price)) for in-depth financial analyses.
use tktax_account::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Suppose we have a ProgramConfig from tktax_config
let config: ProgramConfig = ...;
let year = TrackedYear::from(2024);
let account = Account::new(&year, AccountKind::Checking, &config)?;
// Print a monthly summary
let monthly_data = account.monthly_summary();
for summary in monthly_data {
println!("{:?}", summary);
}
// Categorize and display transactions in short format
let category_map: CategoryMap<MyTxCat> = ...; // from tktax_line_item
account.print_categorized_transactions_short(&category_map);
Ok(())
}
Transaction::try_from_csv_contents reads transaction logs, ensuring minimal data loss and robust type-conversion.AccountSummary type offers a concise overview of an account's yearly activity (credits, debits, etc.).