1 unstable release
0.2.2 | Feb 1, 2025 |
---|
#26 in #tax
127 downloads per month
Used in tktax
420KB
4.5K
SLoC
Overview
tktax-analysis
is a Rust crate dedicated to robust, production-grade tax and financial data analysis (ἀνάλυσις). It integrates multiple transaction sources (e.g., Amazon purchases, charity donatio (Latin), medical records, etc.) and provides an extensible framework for categorization, histogram generation, and summarization. By capitalizing on a composable set of traits and robust error handling, this crate streamlines year-end reporting, business expense analysis, philanthropic contributions, and beyond.
Core capabilities:
- Account Analysis: Parameterized via
AccountAnalysis<TxCat>
for any user-definedTransactionCategory
. - Hooks:
AccountAnalysisHooks
enable flexible instantiation of business and medical transaction sets, donation builders, and category maps. - Donations: Structured philanthropic data ingestion, including optional Amazon item mappings.
- Monthly and Histogram Summaries: Summaries by month and visual histograms to highlight bursts or spikes in financial flow.
- Extensive Reporting: Configurable for short or full reports (via
AccountAnalysisFlags
) to highlight medical/insurance expenses, treasury transactions, checks, and more.
Example Usage
use tktax_analysis::*;
use tktax_transaction_category::MyCustomCategory; // a user-defined TxCat
fn main() -> Result<(), AccountError> {
// Acquire program config from your environment or configuration file
let program_config = ProgramConfig::new(/* ... */);
// Construct hooks for specialized analysis
let hooks = AccountAnalysisHooksBuilder::default()
.program_config(program_config)
// Provide user-defined function pointers for custom data initialization
.create_amazon_biz_expenses_fn(Some(my_create_amazon_biz_expenses))
// ...
.build()
.map_err(|e| AccountError::new(/* handle error without unwrap */))?;
// Prepare account list, donation config, etc.
let year = TrackedYear::new(2025);
let accounts = vec![AccountKind::Checking, AccountKind::Credit];
let donation_config = Some(DonationConfig::new(/* ... */));
// Perform the full analysis
hooks.run_analysis::<MyCustomCategory>(year, accounts, donation_config.as_ref())?;
Ok(())
}
- Implement your custom
TransactionCategory
for domain-specific categorization. - Construct the required hooks and category map with your data.
- Execute
run_analysis
to produce short or comprehensive financial reports. - Leverage the modular trait-based architecture for specialized reporting tasks, from medical disbursements to philanthropic itemization.
Features
run_analysis
fosters end-to-end data ingestion and processing.- Bitflags in
AccountAnalysisFlags
deliver flexible configuration (e.g., partial or complete reports). - Rigorously typed error-handling ensures resilience in production environments.
- Straightforward extension points (
ShowAccountSummary
,ShowMonthlySummary
, etc.) let you adapt analysis logic to custom data structures.
License
tktax-analysis
is distributed under terms compatible with typical open-source licenses (e.g., MIT). Refer to LICENSE
for details.
Dependencies
~26–37MB
~639K SLoC