| Crates.io | tktax-donations |
| lib.rs | tktax-donations |
| version | 0.2.2 |
| created_at | 2025-02-01 02:34:36.822074+00 |
| updated_at | 2025-02-01 02:34:36.822074+00 |
| description | A robust library for donation transaction handling, including inflationary adjustments, depreciation, and fair-market valuations. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538024 |
| size | 101,549 |
A focused crate for modeling charitable transactions (donationes in Latin) with comprehensive valuation features (inflatio, depreciatio) for tax or record-keeping systems. This crate is part of the broader TKTAX ecosystem, providing calculations for fair-market values, generating donation summaries, and handling advanced date-based amortization.
DonationValueEstimate items, supporting multiple display formats and advanced grouped reporting.Add the dependency to your Cargo.toml:
[dependencies]
tktax-donations = "0.1.0"
Then construct and estimate donations:
use tktax_donations::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Assume we have an existing `Option<AmazonItemMap>` for previous purchases
let builder = DonationBuilder::new(
None, // no Amazon map for this example
&chrono::NaiveDate::from_ymd_opt(2025, 3, 15).unwrap(),
&DonationLocation::Goodwill { name: "uptown" },
&chrono::NaiveDate::from_ymd_opt(2005, 1, 1).unwrap(),
);
let example_donation = builder.create_unknown_origin_but_item_has_amazon_listing(
DonationType::Book,
2,
"Textbook donation",
AmazonItemListing::new("Example Book", monetary_amount!(14.99), ...), // details elided
);
// Compute estimate
let estimate = example_donation.estimate();
println!("Donation estimate: {}", estimate);
Ok(())
}
Decimal for monetary and factor operations, preventing floating-point inaccuracies.chrono::NaiveDate for date arithmetic, ensuring day-level precision without time-zone complexity.DonationBuilderError and related error structures avoid stringly-typed error messages.Within an application, you can group and display donation data:
use tktax_donations::*;
fn analyze() {
let donations = // vector of `Donation`s from your domain logic
analyze_donations(&donations);
// prints grouped donation info with computed totals
}
Dual-licensed under MIT or Apache-2.0. See LICENSE for details.
Contributions and suggestions are welcome. Please open an issue or pull request in the GitHub repository.