Repository navigation
feat(categories): support dual-use income and expense categories - #544
Open
marianialessandro wants to merge 2 commits into
Open
marianialessandro wants to merge 2 commits into
marianialessandro wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses issue #510 by introducing categories that can be used for both income and expense transactions. Users can now create an "Income & Expense" category and select it in either transaction flow, so they no longer need to maintain two separate categories for the same purpose.
These dual-use categories are stored using the new
BOTHvalue. They appear in the appropriate category selectors, are included in frequent-category results, and can also be selected when creating a budget. The category itself does not determine whether a transaction is treated as income or an expense. That still depends on the transaction type, so income and expense totals continue to be calculated correctly.Budget calculations now consider only expense transactions. This means that income assigned to a dual-use category does not increase that category's budget spending or progress. When the type of a parent category is changed, the new type is also applied to all of its subcategories, along with the parent's color.
The change is backward-compatible and does not require a database migration, because the existing category type column already stores unrestricted text values rather than limiting them to
INorOUT. Existing categories therefore continue to work as before, and their identifiers, notes, and transaction associations remain unchanged.Automated tests cover the full behavior introduced by this change. They verify that the new category type can be correctly serialized and used in the category form and budget flow. They also check that dual-use categories can be selected and appear among frequent categories for both income and expense transactions. Finally, the tests confirm compatibility with an existing populated SQLite database and ensure that income assigned to a dual-use category is excluded from budget spending calculations.