[PR #6274] [MERGED] Fix for issue #1253 (Budget can't be balanced when "Hide decimal places" in the setting is on) #40854

Closed
opened 2026-04-23 13:39:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/6274
Author: @rcgomezap
Created: 11/30/2025
Status: Merged
Merged: 12/21/2025
Merged by: @MatissJanis

Base: masterHead: fix-issue-1253


📝 Commits (8)

  • 031c17b Fix number formatting of intlFormatter with a wrapper to handle -0 edge case (#1253)
  • f23c9b9 Fix Normalize integer currency values in makeBalanceAmountStyle function based on formatting user prefs (#1253)
  • 875b960 Merge branch 'master' into fix-issue-1253
  • 4b064a0 [autofix.ci] apply automated fixes
  • e52fa93 Add release notes for budget balancing issue when "Hide decimal places" is enabled
  • ff92ce3 Merge branch 'fix-issue-1253' of https://github.com/rcgomezap/actual into fix-issue-1253
  • adc78ad Merge branch 'master' into fix-issue-1253
  • 1f39259 [autofix.ci] apply automated fixes

📊 Changes

5 files changed (+43 additions, -5 deletions)

View changed files

📝 packages/desktop-client/src/components/budget/util.ts (+16 -3)
📝 packages/desktop-client/src/hooks/useFormat.ts (+1 -1)
📝 packages/loot-core/src/shared/util.test.ts (+9 -0)
📝 packages/loot-core/src/shared/util.ts (+11 -1)
upcoming-release-notes/6274.md (+6 -0)

📄 Description

Fix for #1253
Performed actions:

  • Updated the number formatter in getNumberFormat to wrap Intl.NumberFormat and handle the "-0" edge case, ensuring it displays "0" instead of "-0" when decimal places are hidden.
  • Changed the format function in useFormat.ts to use the new formatter interface, supporting the improved handling of number formatting.
  • Enhanced makeBalanceAmountStyle in budget/util.ts to normalize currency values using user preferences.
  • Added tests for number formatting with small negative numbers and zero decimal places.

Note

Wraps number formatting to avoid "-0", updates formatting API and budget balance logic to use normalized amounts, and adds tests and release notes.

  • Core (shared util):
    • getNumberFormat now returns a formatter wrapper that converts -0 to 0 and supports configurable fraction digits.
    • Exposes the wrapper via formatter.format(...) API used across formatting helpers.
    • Tests: Add cases for small negative numbers with hidden decimals.
  • Desktop Client:
    • hooks/useFormat.ts: Update format to accept a { format(value) } formatter; use new getNumberFormat(...).formatter and preserve currency styling behavior.
    • components/budget/util.ts: Normalize integer currency values via integerToCurrencycurrencyToAmount before comparisons in makeBalanceAmountStyle to ensure correct styling when decimals are hidden.
  • Release Notes: Add bugfix entry for budget balance with "Hide decimal places" setting.

Written by Cursor Bugbot for commit adc78ad527. This will update automatically on new commits. Configure here.


🔄 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/6274 **Author:** [@rcgomezap](https://github.com/rcgomezap) **Created:** 11/30/2025 **Status:** ✅ Merged **Merged:** 12/21/2025 **Merged by:** [@MatissJanis](https://github.com/MatissJanis) **Base:** `master` ← **Head:** `fix-issue-1253` --- ### 📝 Commits (8) - [`031c17b`](https://github.com/actualbudget/actual/commit/031c17b9d1f55c6a6e7311a697408e2187ed8a6d) Fix number formatting of intlFormatter with a wrapper to handle -0 edge case (#1253) - [`f23c9b9`](https://github.com/actualbudget/actual/commit/f23c9b96c66f4618d5d29d9bdaf5f8b0f3968d42) Fix Normalize integer currency values in makeBalanceAmountStyle function based on formatting user prefs (#1253) - [`875b960`](https://github.com/actualbudget/actual/commit/875b9607fa9f5a15a0b517c4558a05d4159d454a) Merge branch 'master' into fix-issue-1253 - [`4b064a0`](https://github.com/actualbudget/actual/commit/4b064a019d04894c259cd9b869dd21be4598a2de) [autofix.ci] apply automated fixes - [`e52fa93`](https://github.com/actualbudget/actual/commit/e52fa93422cbab62d8680e3becae97bee835b762) Add release notes for budget balancing issue when "Hide decimal places" is enabled - [`ff92ce3`](https://github.com/actualbudget/actual/commit/ff92ce3da668dcc4efc2371fd4410340c5598b30) Merge branch 'fix-issue-1253' of https://github.com/rcgomezap/actual into fix-issue-1253 - [`adc78ad`](https://github.com/actualbudget/actual/commit/adc78ad527da60bddb425bdf6bd65e6d6446c5b2) Merge branch 'master' into fix-issue-1253 - [`1f39259`](https://github.com/actualbudget/actual/commit/1f3925921ef2ffa3122b4e80c903e325c7cd7a74) [autofix.ci] apply automated fixes ### 📊 Changes **5 files changed** (+43 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/budget/util.ts` (+16 -3) 📝 `packages/desktop-client/src/hooks/useFormat.ts` (+1 -1) 📝 `packages/loot-core/src/shared/util.test.ts` (+9 -0) 📝 `packages/loot-core/src/shared/util.ts` (+11 -1) ➕ `upcoming-release-notes/6274.md` (+6 -0) </details> ### 📄 Description Fix for #1253 **Performed actions:** * Updated the number formatter in `getNumberFormat` to wrap `Intl.NumberFormat` and handle the "-0" edge case, ensuring it displays "0" instead of "-0" when decimal places are hidden. * Changed the `format` function in `useFormat.ts` to use the new formatter interface, supporting the improved handling of number formatting. * Enhanced `makeBalanceAmountStyle` in `budget/util.ts` to normalize currency values using user preferences. * Added tests for number formatting with small negative numbers and zero decimal places. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Wraps number formatting to avoid "-0", updates formatting API and budget balance logic to use normalized amounts, and adds tests and release notes. > > - **Core (shared util)**: > - `getNumberFormat` now returns a formatter wrapper that converts `-0` to `0` and supports configurable fraction digits. > - Exposes the wrapper via `formatter.format(...)` API used across formatting helpers. > - **Tests**: Add cases for small negative numbers with hidden decimals. > - **Desktop Client**: > - `hooks/useFormat.ts`: Update `format` to accept a `{ format(value) }` formatter; use new `getNumberFormat(...).formatter` and preserve currency styling behavior. > - `components/budget/util.ts`: Normalize integer currency values via `integerToCurrency` → `currencyToAmount` before comparisons in `makeBalanceAmountStyle` to ensure correct styling when decimals are hidden. > - **Release Notes**: Add bugfix entry for budget balance with "Hide decimal places" setting. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit adc78ad527da60bddb425bdf6bd65e6d6446c5b2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --- <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-23 13:39:45 -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#40854