| Crates.io | tktax-quarterly |
| lib.rs | tktax-quarterly |
| version | 0.2.2 |
| created_at | 2025-02-01 06:30:18.241719+00 |
| updated_at | 2025-02-01 06:30:18.241719+00 |
| description | Quarterly summarization tools for financial transactions in the TKTAX ecosystem. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538234 |
| size | 94,883 |
tktax-quarterly provides functionality for aggregating transaction data into quarterly summaries, ideal for financial or accounting applications that require time-based grouping and analysis of credits, debits, checks, deposits, and point-of-sale (POS) totals.
QuarterlySummary struct collates and stores transaction totals (credits, debits, checks, deposits, and POS amounts) for three-month intervals.start_of_quarter function computes the first date of a quarter for any NaiveDate.CreateQuarterlySummary trait enables any struct (for example, an Account) to provide quarterly aggregation without bespoke logic scattered throughout the codebase.Add the following to your Cargo.toml:
[dependencies]
tktax-quarterly = "0.1.0"
Ensure you also include or have access to the companion crates (tktax_3p, tktax_account, tktax_money, and tktax_transaction) as needed.
Below is a minimal example demonstrating how to produce quarterly summaries from an Account:
use tktax_quarterly::{CreateQuarterlySummary, QuarterlySummary};
use tktax_account::Account;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Assume `my_account` is already populated with transactions
let my_account = Account::new(/* details omitted for brevity */);
// Generate all quarterly summaries
let summaries: Vec<QuarterlySummary> = my_account.quarterly_summary();
for s in summaries {
println!(
"Quarter starting {} -> credits: {}, debits: {}, checks: {}, deposits: {}, pos: {}",
s.start_of_quarter(),
s.credits().value(), // Hypothetical .value() method on MonetaryAmount
s.debits().value(),
s.checks().value(),
s.deposits().value(),
s.point_of_sale().value(),
);
}
Ok(())
}
In the above code:
Account integrates the CreateQuarterlySummary trait, allowing an immediate quarterly_summary() call.QuarterlySummary instance contains total monetary amounts for the specified quarter.NaiveDate type for precise date operations, ensuring correct quarter boundaries even when crossing calendar-year boundaries.Contributions are welcome. Please submit issues and pull requests on GitHub. For major changes, open an issue first to discuss the intended modifications.
Licensed under either MIT or Apache-2.0, at your option.