| Crates.io | tktax-year-comparison |
| lib.rs | tktax-year-comparison |
| version | 0.2.2 |
| created_at | 2025-02-01 16:27:58.593809+00 |
| updated_at | 2025-02-01 16:27:58.593809+00 |
| description | Cross-year tax accounting analysis for the TKTAX suite, enabling multi-year aggregation and differential comparisons. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538561 |
| size | 84,872 |
tktax-year-comparison is a Rust crate focused on performing comparative accounting between multiple fiscal years for the TKTAX ecosystem. It provides tools to compute cross-year differentials and construct multi-year summaries. This library is especially helpful for uncovering changes in total monetary amounts and extracting year-by-year data across diverse sets of transactions.
Differential Analysis
Account instances.YearComparison struct containing each year’s identifier and the total difference in amounts.Multi-Year Aggregation
Accounts.MultiYearSummary that maps each TrackedYear to a summed MonetaryAmount.Extensibility
tktax_money and tktax_transaction.Below is a minimal code sample illustrating how to compare two years and then aggregate a set of Accounts:
use tktax_year_comparison::{
DifferentialAnalysis,
aggregate_multi_year,
YearComparison,
MultiYearSummary,
};
// Suppose we have two `Account` instances from different years: `acct_2021` and `acct_2022`.
// Both satisfy `DifferentialAnalysis` from this crate.
if let Some(diff) = acct_2021.compare_years(&acct_2022) {
println!("Year A: {:?}", diff.year_a);
println!("Year B: {:?}", diff.year_b);
println!("Difference: {:?}", diff.total_difference);
} else {
println!("Unable to perform cross-year comparison.");
}
// To aggregate a slice of `Account`s spanning different years:
let accounts = vec![acct_2021, acct_2022, /* possibly more */];
let summary = aggregate_multi_year(&accounts);
for (year, total) in &summary.yearly_totals {
println!("Year: {:?}, Summed Amount: {:?}", year, total);
}
YearComparison
- Tracks the two compared years (year_a and year_b).
- Stores the total_difference (year_b - year_a).
MultiYearSummary
- Maintains a HashMap<TrackedYear, MonetaryAmount>, mapping each TrackedYear to its aggregated total.
To incorporate tktax-year-comparison into your project, add it to your Cargo.toml:
[dependencies]
tktax-year-comparison = "0.1"
Then import it in your Rust code:
use tktax_year_comparison::*;
Licensed under either of
at your option.
For advanced or specialized usage (e.g., computing nuanced debits/credits breakdowns), consider extending YearComparison or MultiYearSummary. Their internal fields remain amenable to expansions to capture more thorough financial data (Latin: data pecuniaria, Greek: δεδομένα λογιστικά).
Contributions and feedback welcome via the project repository.