tktax-year-to-date

Crates.iotktax-year-to-date
lib.rstktax-year-to-date
version0.2.2
created_at2025-02-01 16:29:20.639915+00
updated_at2025-02-01 16:29:20.639915+00
descriptionA Rust crate for computing year-to-date transaction data in the tktax ecosystem.
homepage
repositoryhttps://github.com/klebs6/tktax
max_upload_size
id1538562
size82,664
(klebs6)

documentation

README

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!

Commit count: 0

cargo fmt