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

Closed
opened 2026-02-28 21:28:05 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/6273

State: closed
Merged: No


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.
**Original Pull Request:** https://github.com/actualbudget/actual/pull/6273 **State:** closed **Merged:** No --- 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.
GiteaMirror added the pull-request label 2026-02-28 21:28:05 -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#6422