tktax-expense
This crate provides specialized abstractions for handling business expense logic in the tktax ecosystem. By leveraging several foundational crates (e.g., tktax_3p, tktax_account, tktax_line_item, etc.), tktax-expense defines robust data structures and traits for expense categorization, financial transactions, and minimal overhead integrations with existing ledger systems.
Features
-
BusinessExpenseStruct- Carries a
TransactionCategoryand an immutable reference to the correspondingTransaction. - Implements
fmt::Displayfor straightforward logging and reporting. - Conforms to the
LineItemtrait, ensuring consistent treatment as a billable or deductible line item.
- Carries a
-
GetBusinessExpendituresTrait- Exposes the
business_expendituresmethod on anyAccountinstance. - Produces a vector of
BusinessExpenseentities after verifying if a transaction belongs to recognized business-related categories.
- Exposes the
-
Predictive Categorization
- The internal workflow utilizes
predict_category(...)to map textual transaction descriptions to the most probable category. - Only transactions deemed strictly business-oriented are wrapped as
BusinessExpenseinstances.
- The internal workflow utilizes
Example Usage
Below is a minimal illustration of how to gather business expenses from an Account. For brevity, we assume you have already defined or included the necessary structures (Account, CategoryMap, etc.) in your codebase.
Crate Design Rationale
-
Generics for Category Extensibility:
TheTransactionCategorytrait is kept generic, facilitating custom category taxonomies in multifaceted scenarios (e.g., domestic vs. international expenditure, professional fees, office supplies, etc.). -
Integration with Existing Ledger Systems:
GetBusinessExpendituresis implemented forAccount, enabling direct synergy with ledger data. This design sidesteps the need to replicate logic for transaction iteration or specialized extraction in user-facing code. -
Optimized Data Orchestration:
Internally, expenses are collated, sorted, and prepared for further analytics or reporting with minimal overhead.
Contributing
Contributions, bug reports, and feature requests are welcomed at the GitHub repository.
Please adhere to best practices and ensure robust error handling throughout your submission.
License
This project is licensed under the MIT License.