1 unstable release
new 0.2.2 | Feb 1, 2025 |
---|
#6 in #tktax
210KB
3K
SLoC
tktax-medical
Overview
tktax-medical
is a specialized sub-crate of the broader tktax ecosystem. It facilitates analysis and generation of medical- or insurance-related line items in the context of tax accounting. The library builds upon shared types from multiple tktax
sub-crates to streamline the process of identifying, categorizing, and reporting health expenditures.
Key features include:
- Automated Categorization: Leverages
predict_category
(fromtktax_3p
) to inspect and categorize transaction descriptions. - Robust Line-Item Framework: Implements
LineItem<TxCat>
for generating consistent, domain-specific records. - Flexible Trait Boundaries: The
GetMedicalAndInsuranceExpenditures
trait can be implemented for anyAccount
, providing a clear, extensible API.
Usage
-
Add as a Dependency
[dependencies] tktax-medical = { git = "https://github.com/klebs6/tktax", path = "tktax-medical" } # Also ensure dependencies on other tktax crates as needed
-
Import and Use Within Your Code
use tktax_medical::GetMedicalAndInsuranceExpenditures; use tktax_account::Account; // Provided by tktax_account use tktax_transaction_category::CategoryMap; // Provided by tktax_transaction_category fn main() { // Assume you have a valid Account instance and a category_map let my_account = Account::new(/* ... */); let my_category_map = CategoryMap::new(/* ... */); let medical_items = my_account.medical_and_insurance_expenditures(&my_category_map); for item in medical_items { println!("Detected medical expense: {}", item); } }
-
Integrate With Other tktax Tools
This crate synergizes seamlessly with other
tktax
sub-crates to produce comprehensive tax reporting. For instance, you can feed the generated medical line-items into further processing pipelines, aggregated reports, or specialized data export functions.
Technical Details
-
MedicalExpense<'a, TxCat>
Struct- category: A transaction category implementing the
TransactionCategory
trait. - tx: A reference to a
Transaction
, representing the underlying financial record.
- category: A transaction category implementing the
-
LineItem<TxCat>
Implementation- The struct implements the core
LineItem<TxCat>
trait, providing standardized methods for quantity retrieval, pricing, and referencing the transaction.
- The struct implements the core
-
GetMedicalAndInsuranceExpenditures
Trait- Extends any
Account
to discover and capture medical or insurance transactions automatically. - Excludes reliance on panic-driven error handling in production settings. All internal predictions are handled gracefully.
- Extends any
-
Sorting and Formatting
- After potential matches are collected, the library sorts items by category for consistent organization.
fmt::Display
is implemented for user-facing display.
-
No
unwrap
orexpect
- This crate adheres to best practices in error handling, returning robust typed results without forcibly unwrapping.
Contributing
Contributions are welcome! Please open issues or submit pull requests on GitHub. Make sure to follow the general tktax
repository coding guidelines and style conventions.
License
Licensed under the MIT License.
Enjoy efficient and streamlined handling of health-related financial transactions with tktax-medical
.
Dependencies
~26–38MB
~644K SLoC