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

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

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

State: closed
Merged: Yes


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.

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