tktax-account
tktax-account is a Rust crate offering robust account transaction analytics within the broader tktax financial suite. It provides traits and data structures for:
- Processing CSV-based transaction logs
- Categorizing and summarizing transaction data
- Generating monthly aggregates and annual summaries
- Deriving arithmetic totals (credits, debits, checks, deposits)
- Assembling advanced financial insights based on transaction patterns
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.
Overview
This library implements an Account struct encapsulating:
- An
AccountKind(e.g., Checking, Credit, or Savings) - A
TrackedYearfor annual grouping - A collection of
Transactionentries parsed from CSV
Multiple traits define how accounts produce analytics:
- Filtering & Searching:
GetTransactionsByKeyword,GetTransactionsWithinDates, etc. - Summaries & Aggregates:
GetAccountSummary,CreateMonthlySummary. - Total Computations:
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().
Key Features
-
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 (likeTransactionCategory). -
Extensive Trait Implementations
Simplifies advanced queries (e.g.,transactions_over(price)) for in-depth financial analyses.
Example Usage
use *;
Additional Notes
- CSV Parsing:
Transaction::try_from_csv_contentsreads transaction logs, ensuring minimal data loss and robust type-conversion. - Summaries: The
AccountSummarytype offers a concise overview of an account's yearly activity (credits, debits, etc.). - Expand or Integrate: Extend this crate by adding custom filtering logic or new transaction types via the trait system.