#date #data #year #transaction #ecosystem #tktax #year-to-date

tktax-year-to-date

A Rust crate for computing year-to-date transaction data in the tktax ecosystem

1 unstable release

0.2.2 Feb 1, 2025

#10 in #tktax

Download history 114/week @ 2025-01-29 15/week @ 2025-02-05

129 downloads per month
Used in tktax

MIT license

120KB
1.5K SLoC

tktax-year-to-date

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_3p
  • tktax_account
  • tktax_monthly
  • tktax_transaction

Overview

  • YearToDate 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.

Example

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.


License

This project is licensed under the MIT License. See LICENSE for details.

Contributing

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!

Dependencies

~29–39MB
~675K SLoC