[PR #6273] [CLOSED] [WIP] Fix for issue #1253: Budget can't be balanced when "Hide decimal places" in the setting is on #32347

Closed
opened 2026-04-18 08:24:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/6273
Author: @rcgomezap
Created: 11/30/2025
Status: Closed

Base: masterHead: fix-issue-1253


📝 Commits (4)

  • 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

📊 Changes

4 files changed (+37 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)

📄 Description

Fixes #1253

Currency Value Normalization and Styling Enhancements:

  • Refactored makeBalanceAmountStyle in budget/util.ts to normalize integer currency values using integerToCurrency and currencyToAmount, ensuring amounts are correctly formatted before comparison and display. This prevents errors in styling logic when user preferences affect currency format.
  • Added imports for currencyToAmount and integerToCurrency in budget/util.ts to support the new normalization logic.

Number Formatting Improvements:

  • Updated getNumberFormat in shared/util.ts to wrap Intl.NumberFormat with a custom formatter that converts -0 to 0, addressing the negative zero display issue. The exported formatter now uses this wrapper.
  • Changed the formatter parameter type in useFormat.ts from Intl.NumberFormat to an object with a format method, aligning with the new custom formatter implementation.

Testing Edge Cases:

  • Added unit tests in shared/util.test.ts to verify correct formatting of small negative numbers with zero decimal places, confirming that values like -0.1 and -0.9 are formatted as 0 or -1 as expected.

🔄 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/6273 **Author:** [@rcgomezap](https://github.com/rcgomezap) **Created:** 11/30/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix-issue-1253` --- ### 📝 Commits (4) - [`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 ### 📊 Changes **4 files changed** (+37 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) </details> ### 📄 Description Fixes #1253 **Currency Value Normalization and Styling Enhancements:** * Refactored `makeBalanceAmountStyle` in `budget/util.ts` to normalize integer currency values using `integerToCurrency` and `currencyToAmount`, ensuring amounts are correctly formatted before comparison and display. This prevents errors in styling logic when user preferences affect currency format. * Added imports for `currencyToAmount` and `integerToCurrency` in `budget/util.ts` to support the new normalization logic. **Number Formatting Improvements:** * Updated `getNumberFormat` in `shared/util.ts` to wrap `Intl.NumberFormat` with a custom formatter that converts `-0` to `0`, addressing the negative zero display issue. The exported `formatter` now uses this wrapper. * Changed the `formatter` parameter type in `useFormat.ts` from `Intl.NumberFormat` to an object with a `format` method, aligning with the new custom formatter implementation. **Testing Edge Cases:** * Added unit tests in `shared/util.test.ts` to verify correct formatting of small negative numbers with zero decimal places, confirming that values like `-0.1` and `-0.9` are formatted as `0` or `-1` as expected. --- <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-18 08:24:28 -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#32347