| Crates.io | tktax-year-to-date |
| lib.rs | tktax-year-to-date |
| version | 0.2.2 |
| created_at | 2025-02-01 16:29:20.639915+00 |
| updated_at | 2025-02-01 16:29:20.639915+00 |
| description | A Rust crate for computing year-to-date transaction data in the tktax ecosystem. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538562 |
| size | 82,664 |
This crate provides facilities for calculating year-to-date transaction summaries within the tktax ecosystem. It integrates with the following companion crates for comprehensive financial data handling:
tktax_3ptktax_accounttktax_monthlytktax_transactionYearToDate Trait
The central feature is the YearToDate trait, enabling aggregated financial data from the beginning of a year up to a given date.
Transaction Types
Summation covers multiple transaction variants—Credit, Debit, Check, Deposit, and PointOfSale.
Error Handling
Where necessary, robust error-handling mechanisms (rather than stringly-typed errors) are employed for reliability in production deployments.
use chrono::NaiveDate;
use tktax_year_to_date::YearToDate; // Exposes the trait
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Assume 'account' is a valid Account instance with data populated.
let account = get_some_account()?; // Some hypothetical function
// Compute year-to-date up to today's date
let today = NaiveDate::from_ymd_opt(2025, 1, 19)
.ok_or_else(|| MyCustomError::InvalidDate)?;
let summary = account.year_to_date_summary(today);
println!("Credits so far: {}", summary.credits());
println!("Debits so far: {}", summary.debits());
// ...and so on
Ok(())
}
In this example, an Account object is queried for all valid transactions up to the specified date. The resulting MonthlySummary accumulates the total amounts for each transaction category, giving you a straightforward, aggregated view of your financial activity.
This project is licensed under the MIT License. See LICENSE for details.
Contributions are welcome through the GitHub repository. For bug reports, suggestions, or feature requests, please open an issue or submit a pull request.
Happy coding with tktax-year-to-date!