[PR #7149] [MERGED] fix(csv-import): trim whitespace from amount strings before parsing #14023

Closed
opened 2026-04-10 22:10:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/7149
Author: @mibragimov
Created: 3/7/2026
Status: Merged
Merged: 3/7/2026
Merged by: @MatissJanis

Base: masterHead: fix/issue-7121


📝 Commits (2)

  • 8f2e88d fix(csv-import): trim whitespace from amount strings before parsing
  • e97815b chore: add release notes for #7149

📊 Changes

3 files changed (+17 additions, -0 deletions)

View changed files

📝 packages/loot-core/src/shared/util.test.ts (+9 -0)
📝 packages/loot-core/src/shared/util.ts (+2 -0)
upcoming-release-notes/7149.md (+6 -0)

📄 Description

Summary

Fix CSV import incorrectly parsing transaction amounts that contain trailing whitespace (e.g. from Excel-saved files).

Root Cause

looselyParseAmount uses a regex anchored at $ to detect decimal markers. Trailing whitespace shifts the pattern so a thousands separator (,) is misidentified as a decimal point, producing wildly wrong values.

Examples before this fix:

Input Imported as
"$1,055" $1,055.00
"$1,055 " $1.06
"$1,055.00 " $105,500.00

Fix

Added amount = amount.trim() at the top of looselyParseAmount, before any regex logic runs. This eliminates leading/trailing whitespace introduced by Excel and other CSV editors.

Testing

Added 6 test cases covering trailing whitespace, leading whitespace, and combined cases. All 23 tests in util.test.ts pass.

Closes #7121


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 27 14.89 MB → 14.89 MB (+26 B) +0.00%
loot-core 1 5.82 MB → 5.82 MB (+30 B) +0.00%
api 1 4.43 MB → 4.43 MB (+26 B) +0.00%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
27 14.89 MB → 14.89 MB (+26 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +26 B (+0.27%) 9.29 kB → 9.31 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 9.54 MB → 9.54 MB (+26 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/ca.js 187.93 kB 0%
static/js/da.js 106.2 kB 0%
static/js/de.js 179.89 kB 0%
static/js/en-GB.js 7.18 kB 0%
static/js/en.js 170.42 kB 0%
static/js/es.js 174.37 kB 0%
static/js/fr.js 179.41 kB 0%
static/js/it.js 170.98 kB 0%
static/js/nb-NO.js 156.8 kB 0%
static/js/nl.js 113.06 kB 0%
static/js/pl.js 89.33 kB 0%
static/js/pt-BR.js 182.89 kB 0%
static/js/th.js 181.58 kB 0%
static/js/uk.js 214.65 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 120.54 kB 0%
static/js/ReportRouter.js 1.16 MB 0%
static/js/narrow.js 638.11 kB 0%
static/js/TransactionList.js 106.22 kB 0%
static/js/wide.js 164.15 kB 0%
static/js/AppliedFilters.js 9.71 kB 0%
static/js/usePayeeRuleCounts.js 10.04 kB 0%
static/js/useTransactionBatchActions.js 13.23 kB 0%
static/js/FormulaEditor.js 1.04 MB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.82 MB → 5.82 MB (+30 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +30 B (+0.38%) 7.67 kB → 7.7 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
kcab.worker.CVw5oNPx.js 0 B → 5.82 MB (+5.82 MB) -

Removed

Asset File Size % Changed
kcab.worker.MNtpiHkH.js 5.82 MB → 0 B (-5.82 MB) -100%

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged
No assets were unchanged


api

Total

Files count Total bundle size % Changed
1 4.43 MB → 4.43 MB (+26 B) +0.00%
Changeset
File Δ Size
src/shared/util.ts 📈 +26 B (+0.38%) 6.66 kB → 6.69 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
bundle.api.js 4.43 MB → 4.43 MB (+26 B) +0.00%

Smaller
No assets were smaller

Unchanged
No assets were unchanged


🔄 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/7149 **Author:** [@mibragimov](https://github.com/mibragimov) **Created:** 3/7/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@MatissJanis](https://github.com/MatissJanis) **Base:** `master` ← **Head:** `fix/issue-7121` --- ### 📝 Commits (2) - [`8f2e88d`](https://github.com/actualbudget/actual/commit/8f2e88d45e6e8320e064e570691265e551de8bd9) fix(csv-import): trim whitespace from amount strings before parsing - [`e97815b`](https://github.com/actualbudget/actual/commit/e97815b3da84b9a1d75a8b4d53b5b94e829043c0) chore: add release notes for #7149 ### 📊 Changes **3 files changed** (+17 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/shared/util.test.ts` (+9 -0) 📝 `packages/loot-core/src/shared/util.ts` (+2 -0) ➕ `upcoming-release-notes/7149.md` (+6 -0) </details> ### 📄 Description ## Summary Fix CSV import incorrectly parsing transaction amounts that contain trailing whitespace (e.g. from Excel-saved files). ## Root Cause `looselyParseAmount` uses a regex anchored at `$` to detect decimal markers. Trailing whitespace shifts the pattern so a thousands separator (`,`) is misidentified as a decimal point, producing wildly wrong values. Examples before this fix: | Input | Imported as | |---|---| | `"$1,055"` | `$1,055.00` ✅ | | `"$1,055 "` | `$1.06` ❌ | | `"$1,055.00 "` | `$105,500.00` ❌ | ## Fix Added `amount = amount.trim()` at the top of `looselyParseAmount`, before any regex logic runs. This eliminates leading/trailing whitespace introduced by Excel and other CSV editors. ## Testing Added 6 test cases covering trailing whitespace, leading whitespace, and combined cases. All 23 tests in `util.test.ts` pass. Closes #7121 <!--- actual-bot-sections ---> <hr /> <!--- bundlestats-action-comment key:combined start ---> ### Bundle Stats Bundle | Files count | Total bundle size | % Changed ------ | ----------- | ----------------- | --------- desktop-client | 27 | 14.89 MB → 14.89 MB (+26 B) | +0.00% loot-core | 1 | 5.82 MB → 5.82 MB (+30 B) | +0.00% api | 1 | 4.43 MB → 4.43 MB (+26 B) | +0.00% <details> <summary>View detailed bundle stats</summary> #### desktop-client **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 27 | 14.89 MB → 14.89 MB (+26 B) | +0.00% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts` | 📈 +26 B (+0.27%) | 9.29 kB → 9.31 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** Asset | File Size | % Changed ----- | --------- | --------- static/js/index.js | 9.54 MB → 9.54 MB (+26 B) | +0.00% **Smaller** No assets were smaller **Unchanged** Asset | File Size | % Changed ----- | --------- | --------- static/js/indexeddb-main-thread-worker-e59fee74.js | 12.94 kB | 0% static/js/workbox-window.prod.es5.js | 5.64 kB | 0% static/js/ca.js | 187.93 kB | 0% static/js/da.js | 106.2 kB | 0% static/js/de.js | 179.89 kB | 0% static/js/en-GB.js | 7.18 kB | 0% static/js/en.js | 170.42 kB | 0% static/js/es.js | 174.37 kB | 0% static/js/fr.js | 179.41 kB | 0% static/js/it.js | 170.98 kB | 0% static/js/nb-NO.js | 156.8 kB | 0% static/js/nl.js | 113.06 kB | 0% static/js/pl.js | 89.33 kB | 0% static/js/pt-BR.js | 182.89 kB | 0% static/js/th.js | 181.58 kB | 0% static/js/uk.js | 214.65 kB | 0% static/js/resize-observer.js | 18.37 kB | 0% static/js/BackgroundImage.js | 120.54 kB | 0% static/js/ReportRouter.js | 1.16 MB | 0% static/js/narrow.js | 638.11 kB | 0% static/js/TransactionList.js | 106.22 kB | 0% static/js/wide.js | 164.15 kB | 0% static/js/AppliedFilters.js | 9.71 kB | 0% static/js/usePayeeRuleCounts.js | 10.04 kB | 0% static/js/useTransactionBatchActions.js | 13.23 kB | 0% static/js/FormulaEditor.js | 1.04 MB | 0% </div> </details> --- #### loot-core **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 5.82 MB → 5.82 MB (+30 B) | +0.00% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts` | 📈 +30 B (+0.38%) | 7.67 kB → 7.7 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** Asset | File Size | % Changed ----- | --------- | --------- kcab.worker.CVw5oNPx.js | 0 B → 5.82 MB (+5.82 MB) | - **Removed** Asset | File Size | % Changed ----- | --------- | --------- kcab.worker.MNtpiHkH.js | 5.82 MB → 0 B (-5.82 MB) | -100% **Bigger** No assets were bigger **Smaller** No assets were smaller **Unchanged** No assets were unchanged </div> </details> --- #### api **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 4.43 MB → 4.43 MB (+26 B) | +0.00% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `src/shared/util.ts` | 📈 +26 B (+0.38%) | 6.66 kB → 6.69 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** Asset | File Size | % Changed ----- | --------- | --------- bundle.api.js | 4.43 MB → 4.43 MB (+26 B) | +0.00% **Smaller** No assets were smaller **Unchanged** No assets were unchanged </div> </details> </details> <!--- bundlestats-action-comment key:combined end ---> --- <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-04-10 22:10:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#14023