Repository navigation
Fix payee/category is nothing rules not applying correctly - #7531
sk10727-a11y wants to merge 5 commits into
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hello contributor! We would love to review your PR! Before we can do that, please make sure:
We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges. For more information, please see our Contributing Guide. |
✅ Deploy Preview for actualbudget-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughNormalize Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 Auto-generated Release Notes Hey @sk10727-a11y! I've automatically created a release notes file based on CodeRabbit's analysis: Category: Bugfixes If you're happy with this release note, you can add it to your pull request. If not, you'll need to add your own before a maintainer can review your change. |
✅ Deploy Preview for actualbudget-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/loot-core/src/server/transactions/transaction-rules.ts (1)
1043-1065: Add_normalizedRuleFieldstoTransactionForRulesinstead of using type assertions.Per the repo guideline to avoid
asassertions, extend the existingTransactionForRulestype (line 961) with_normalizedRuleFields?: string[]so the threeas TransactionForRules & { _normalizedRuleFields?: string[] }casts in prepare/finalize become plain property access. This also letsfinalizeTransactionForRules' subtransaction-cleanup loop (Lines 1129-1143) handle it uniformly alongsidebalance/_balanceOfPrefetched/parent_amountif ever needed.♻️ Proposed diff
export type TransactionForRules = TransactionEntity & { payee_name?: string; _account?: db.DbAccount; balance?: number; _category_name?: string; _account_name?: string; parent_amount?: number; /** Prefetched cent balances for BALANCE_OF("…") in rule formulas; cleared in finalize */ _balanceOfPrefetched?: Map<string, number>; + /** Fields normalized from undefined→null for rule matching; cleared in finalize */ + _normalizedRuleFields?: string[]; }; @@ - if (normalizedRuleFields.length > 0) { - ( - r as TransactionForRules & { _normalizedRuleFields?: string[] } - )._normalizedRuleFields = normalizedRuleFields; - } + if (normalizedRuleFields.length > 0) { + r._normalizedRuleFields = normalizedRuleFields; + }As per coding guidelines: "Avoid type assertions (
as,!) - prefersatisfiesfor type narrowing".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/loot-core/src/server/transactions/transaction-rules.ts` around lines 1043 - 1065, Extend the TransactionForRules type to include an optional _normalizedRuleFields?: string[] property and remove the ad-hoc type assertions in prepareTransactionForRules (and the corresponding casts in finalizeTransactionForRules), so you can assign r._normalizedRuleFields directly; update the type definition near TransactionForRules and replace the three occurrences of "as TransactionForRules & { _normalizedRuleFields?: string[] }" in prepareTransactionForRules/finalizeTransactionForRules with direct property access to _normalizedRuleFields to keep handling uniform with other optional fields like balance/_balanceOfPrefetched/parent_amount.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/loot-core/src/server/transactions/transaction-rules.ts`:
- Around line 1043-1065: Extend the TransactionForRules type to include an
optional _normalizedRuleFields?: string[] property and remove the ad-hoc type
assertions in prepareTransactionForRules (and the corresponding casts in
finalizeTransactionForRules), so you can assign r._normalizedRuleFields
directly; update the type definition near TransactionForRules and replace the
three occurrences of "as TransactionForRules & { _normalizedRuleFields?:
string[] }" in prepareTransactionForRules/finalizeTransactionForRules with
direct property access to _normalizedRuleFields to keep handling uniform with
other optional fields like balance/_balanceOfPrefetched/parent_amount.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cd14d883-d4d2-4153-addc-f1366a1ec24f
📒 Files selected for processing (1)
packages/loot-core/src/server/transactions/transaction-rules.ts
09f0a6c to
6ea8f92
Compare
✅ Deploy Preview for actualbudget-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| }); | ||
| } | ||
|
|
||
| // remove temporary normalization used for "is nothing" rules |
There was a problem hiding this comment.
Instead of using type assertion. can you do:
if ('__normalizedRuleFields' in trans) {
// Loop through trans._normalizedRuleFields
}|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
This PR was closed because it has been stalled for 5 days with no activity. |
Description
Fixes an issue where "payee is blank, set payee" or "category is blank, set category" were not being enforced correctly. Transactions missing those fields were not matching the rule condition as expected, causing the action to be skipped.
This change normalizes missing ID fields during rule matching, so blank payee and blank category conditions are handled consistently.
Related issue(s)
Fixes #5724
Testing
Tested rule behavior for "is nothing" conditions across different flows by creating two rules: payee is nothing → set payee and category is nothing → set category. Tested both rules in both the All Accounts view and individual account views.
Verified that the rules applied automatically for new transactions in both views. No regressions observed for other rule conditions.
Notes
As a result of this fix, rules targeting blank fields (e.g. "payee is blank") will now correctly apply during manual transaction entry, since missing values are normalized during rule evaluation.
For testing:
Checklist
Bundle Stats
View detailed bundle stats
desktop-client
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
loot-core
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.tsView detailed bundle breakdown
Added
Removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
No assets were unchanged
api
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.tsView detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
Smaller
No assets were smaller
Unchanged
cli
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
crdt
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged