-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rules not checking "category is nothing" when reconciling #3572
Fix rules not checking "category is nothing" when reconciling #3572
Conversation
WalkthroughThe changes in this pull request primarily involve modifications to the Assessment against linked issues
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
packages/loot-core/src/server/accounts/sync.ts (2)
299-299
: LGTM: Consistent handling of category for bank sync transactionsThis change ensures that bank sync transactions include the
category
property, maintaining consistency with regular transactions.For consistency with the
normalizeTransactions
function, consider moving this assignment to a separate line:- category: trans.category || null, + category: null, + }, + }); + normalized[normalized.length - 1].trans.category = trans.category || null;This change would make it easier to add any future normalization logic for the
category
property.
Line range hint
380-380
: LGTM: Proper handling of category during reconciliationThis change ensures that the
category
is included when updating existing transactions during reconciliation. The logic correctly prioritizes the existing category, then the new transaction's category, and finally defaults tonull
.For improved clarity, consider using a ternary operator:
- category: existing.category || trans.category || null, + category: existing.category ? existing.category : (trans.category || null),This change makes it more explicit that we're prioritizing the existing category over the new one.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3572.md
is excluded by!**/*.md
📒 Files selected for processing (1)
- packages/loot-core/src/server/accounts/sync.ts (2 hunks)
🔇 Additional comments (3)
packages/loot-core/src/server/accounts/sync.ts (3)
241-242
: LGTM: Ensures category is always setThis change ensures that all transactions have a
category
property, even if it'snull
. This addresses the core issue where rules were not checking 'category is nothing' when reconciling transactions.
Line range hint
724-726
: LGTM: No changes needed for addTransactionsThe
addTransactions
function doesn't require direct changes related to thecategory
property. Thecategory
is already being handled correctly in thenormalizeTransactions
function, which is called at the beginning ofaddTransactions
. The existing logic preserves thecategory
property when creating thefinalTransaction
object.
Line range hint
1-1004
: Overall assessment: Changes effectively address the PR objectiveThe modifications in this file consistently handle the
category
property across different functions involved in transaction synchronization and normalization. These changes effectively address the PR objective of fixing the issue where rules were not checking 'category is nothing' when reconciling transactions.Key improvements:
normalizeTransactions
: Ensures all transactions have acategory
property, even if it'snull
.normalizeBankSyncTransactions
: Maintains consistency in handling thecategory
property for bank sync transactions.reconcileTransactions
: Properly includes thecategory
when updating existing transactions during reconciliation.The implementation is consistent and maintains backwards compatibility. These changes should resolve the issue described in the linked bug report (#2540) where the 'Category is (nothing)' rule was not being respected during account synchronization.
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged No assets were unchanged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I've added a couple of suggestions with the operators, and a minor wording tweak on the release note to make it a little clearer
Co-authored-by: Matt Fiddaman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/loot-core/src/server/accounts/sync.ts (1)
Line range hint
1-793
: Overall, the changes improve category handling, but a few points need attention.The modifications consistently handle the new
category
property across different functions, addressing the PR objectives. However, consider addressing the following points:
- In the
reconcileTransactions
function, consider adding logic to preserve manually set categories that differ from imported ones.- In the
addTransactions
function, either implement the usage of the newcategory
parameter or remove it if it's not intended to be used.These adjustments will further enhance the robustness and clarity of the category handling implementation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3572.md
is excluded by!**/*.md
📒 Files selected for processing (1)
- packages/loot-core/src/server/accounts/sync.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (4)
packages/loot-core/src/server/accounts/sync.ts (4)
241-242
: LGTM! Nullish coalescing implemented as suggested.The change ensures that
trans.category
is always set to either its existing value ornull
, addressing the issue mentioned in the PR objectives. This implementation also follows the previous review suggestion to use nullish coalescing.
299-299
: LGTM! Consistent handling of category property.The addition of the
category
property to bank sync transactions, with nullish coalescing to default tonull
, is consistent with the changes made in thenormalizeTransactions
function. This ensures uniform handling of the category across different transaction sources.
Line range hint
686-686
: LGTM, but the newcategory
parameter is unused.The addition of the
category
parameter to theaddTransactions
function signature is consistent with the other changes for handling categories. However, it appears that this new parameter is not utilized within the function body.Consider one of the following actions:
- Remove the
category
parameter if it's not intended to be used.- Implement the logic to use the
category
parameter within the function.To verify the usage of the
category
parameter, we can search for its occurrences within theaddTransactions
function:
Line range hint
391-391
: LGTM, but consider preserving manually set categories.The addition of the
category
property to theupdates
object ensures proper category handling during reconciliation. The fallback chain (existing category → transaction category → null) is a good approach. However, consider the following:
- This logic might overwrite manually set categories with imported ones.
- It may be beneficial to add a check to preserve manually set categories, especially if they differ from the imported category.
To verify the potential impact on manually set categories, we can check for instances where categories might be overwritten:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fixes #2540
The call to
runRules
passes a transaction that doesn't include a category (aka undefined), so the rule checking "category is nothing" doesn't work.My solution is to provide a category or null in both
normalizeBankSyncTransactions
andnormalizeTransactions
This is my first dig into the source of the project, but hopefully this solution or similar is valid.