#monthly #transaction #accounting #tax #finance

tktax-monthly

Library for monthly transaction summaries and average calculations in tax/accounting contexts

1 unstable release

0.2.2 Feb 1, 2025

#10 in #monthly

Download history 115/week @ 2025-01-29 25/week @ 2025-02-05

140 downloads per month
Used in 12 crates (4 directly)

MIT license

160KB
2.5K SLoC

README.md

tktax-monthly

A Rust library for monthly financial transaction aggregation, designed to integrate seamlessly with the tktax ecosystem. This crate provides abstractions for enumerating, aggregating, and displaying monthly transactions, allowing concise transformations of raw data into validated summaries. By leveraging AvgMonthly and MonthlySummary structures, users gain production-ready tools suitable for rigorous accounting and tax-reporting applications.

Overview

  • AvgMonthly<TxCat>:
    A structure for representing the average monetary outlay or inflow within a given TransactionCategory. It encapsulates:

    • ty - The TransactionType (e.g., credit, debit).
    • category - The domain-specific transaction category.
    • value - The calculated average MonetaryAmount.
  • MonthlySummary:
    A chronological consolidation of transactions starting at start_date. Each field accumulates tallies (akin to aggregare in Latin) of different transaction types:

    • credits
    • debits
    • checks
    • deposits
    • point_of_sale

These monoidal accumulations resemble the ἐμπορική συναλλαγή (commercial transaction) grouping, keeping numeric precision intact via MonetaryAmount.

  • CreateMonthlySummary:
    A trait that can be implemented by a higher-level data repository to produce a collection of MonthlySummary instances.

Usage Example

use tktax_monthly::{CreateMonthlySummary, MonthlySummary};

fn compute_monthly_summaries(repo: &impl CreateMonthlySummary) {
    let summaries: Vec<MonthlySummary> = repo.monthly_summary();
    for summary in summaries {
        println!("{:#?}", summary);
        // Implement domain logic here:
        // e.g., sending this summary for further auditing or analytics
    }
}
  1. Add the dependency to your Cargo.toml:
    [dependencies]
    tktax-monthly = "0.1.0"
    
  2. Implement CreateMonthlySummary in your repository type, ensuring it returns a vector of MonthlySummary objects.
  3. Generate monthly summaries, optionally using AvgMonthly for category-based average calculations.

Features

  • Robust Aggregation: Safely accumulates monetary transactions across multiple categories.
  • Human-Readable Debugging: The custom fmt::Debug allows single-line or pretty-printed views.
  • Typed Categories: Avoids stringly-typed design through domain-centric enumerations.
  • Production-Ready: Zero usage of .unwrap() or .expect(), ensuring stable error handling paths.

For additional documentation and usage details, consult the repository or open an issue for feature requests.

Dependencies

~26–37MB
~640K SLoC