[PR #2790] [MERGED] Fix CSV import not matching category is (nothing) rules #4513

Closed
opened 2026-02-28 20:56:53 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/2790
Author: @matt-fidd
Created: 5/22/2024
Status: Merged
Merged: 6/3/2024
Merged by: @twk3

Base: masterHead: csv-category


📝 Commits (4)

  • 5359f80 Fix CSV import not matching category is (nothing) rules
  • 5e13414 release note
  • d839650 Merge branch 'master' into csv-category
  • f08b58f Merge branch 'master' into csv-category

📊 Changes

2 files changed (+7 additions, -3 deletions)

View changed files

📝 packages/desktop-client/src/components/modals/ImportTransactions.jsx (+1 -3)
upcoming-release-notes/2790.md (+6 -0)

📄 Description

Fixes #2052

@Maxiimeeb was correct in the issue that the root cause of this is the fact that the csv import passes new transactions down the stack with { category: undefined } if the category is not set in the CSV.

The eval function in the Condition class has a guard that fails the rule if the value it's checking is strictly equal to undefined.

b803731bc5/packages/loot-core/src/server/accounts/rules.ts (L264-L266)

This change takes one of the two possible approaches, which is to pass null as the category if unset instead of undefined. parseCategoryFields already does this so it makes sense just to use its return value.

b803731bc5/packages/desktop-client/src/components/modals/ImportTransactions.jsx (L313-L324)

The other way this could be fixed is to amend the guard condition to pick up any nullish values and return accordingly straight away but I'm not sure if this approach would be in line with existing conventions throughout the project for usage of null and undefined.

-    if (fieldValue === undefined) {
-      return false;
-    }
+ if (fieldValue == null) {
+   return this.value == null && this.op === 'is';
+ }

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/2790 **Author:** [@matt-fidd](https://github.com/matt-fidd) **Created:** 5/22/2024 **Status:** ✅ Merged **Merged:** 6/3/2024 **Merged by:** [@twk3](https://github.com/twk3) **Base:** `master` ← **Head:** `csv-category` --- ### 📝 Commits (4) - [`5359f80`](https://github.com/actualbudget/actual/commit/5359f803cd76713921475ed5ff49fc8d24884d31) Fix CSV import not matching category is (nothing) rules - [`5e13414`](https://github.com/actualbudget/actual/commit/5e134147138f35d130d93cb6902cfc22d62fe8af) release note - [`d839650`](https://github.com/actualbudget/actual/commit/d8396507afa48a3d6d0869bf8aa57f6d74d99921) Merge branch 'master' into csv-category - [`f08b58f`](https://github.com/actualbudget/actual/commit/f08b58f2558e772442b5eda0c356ca686af86277) Merge branch 'master' into csv-category ### 📊 Changes **2 files changed** (+7 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/modals/ImportTransactions.jsx` (+1 -3) ➕ `upcoming-release-notes/2790.md` (+6 -0) </details> ### 📄 Description Fixes #2052 @Maxiimeeb was correct in the issue that the root cause of this is the fact that the csv import passes new transactions down the stack with `{ category: undefined }` if the category is not set in the CSV. The `eval` function in the `Condition` class has a guard that fails the rule if the value it's checking is strictly equal to `undefined`. https://github.com/actualbudget/actual/blob/b803731bc52dbf3628b2129c7881cebabd24488e/packages/loot-core/src/server/accounts/rules.ts#L264-L266 This change takes one of the two possible approaches, which is to pass `null` as the category if unset instead of `undefined`. parseCategoryFields already does this so it makes sense just to use its return value. https://github.com/actualbudget/actual/blob/b803731bc52dbf3628b2129c7881cebabd24488e/packages/desktop-client/src/components/modals/ImportTransactions.jsx#L313-L324 The other way this could be fixed is to amend the guard condition to pick up any nullish values and return accordingly straight away but I'm not sure if this approach would be in line with existing conventions throughout the project for usage of `null` and `undefined`. ```diff - if (fieldValue === undefined) { - return false; - } + if (fieldValue == null) { + return this.value == null && this.op === 'is'; + } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-02-28 20:56:53 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#4513