tktax-year-comparison
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.
Features
-
Differential Analysis
- Compare totals between two distinct
Accountinstances. - Obtain a
YearComparisonstruct containing each year’s identifier and the total difference in amounts.
- Compare totals between two distinct
-
Multi-Year Aggregation
- Consolidate data across any number of
Accounts. - Produce a
MultiYearSummarythat maps eachTrackedYearto a summedMonetaryAmount. - Facilitates high-level audits of various yearly totals.
- Consolidate data across any number of
-
Extensibility
- Straightforward to integrate additional fields or metrics (e.g., totals of certain transaction types).
- Built to interoperate with other TKTAX libraries, such as
tktax_moneyandtktax_transaction.
Usage Example
Below is a minimal code sample illustrating how to compare two years and then aggregate a set of Accounts:
use ;
// Suppose we have two `Account` instances from different years: `acct_2021` and `acct_2022`.
// Both satisfy `DifferentialAnalysis` from this crate.
if let Some = acct_2021.compare_years else
// To aggregate a slice of `Account`s spanning different years:
let accounts = vec!;
let summary = aggregate_multi_year;
for in &summary.yearly_totals
Data Structures
-
YearComparison
- Tracks the two compared years (year_aandyear_b).
- Stores thetotal_difference(year_b - year_a). -
MultiYearSummary
- Maintains aHashMap<TrackedYear, MonetaryAmount>, mapping eachTrackedYearto its aggregated total.
Crate Integration
To incorporate tktax-year-comparison into your project, add it to your Cargo.toml:
[]
= "0.1"
Then import it in your Rust code:
use *;
License
Licensed under either of
- Apache License, Version 2.0,
- MIT license
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.