Skip to content

fix: show minus sign for negative amounts in fmt#80

Merged
tomfunk merged 6 commits into
devfrom
fix/fmt-negative-sign
Jun 13, 2026
Merged

fix: show minus sign for negative amounts in fmt#80
tomfunk merged 6 commits into
devfrom
fix/fmt-negative-sign

Conversation

@tomfunk

@tomfunk tomfunk commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • fmt() was calling Math.abs(n) unconditionally, stripping the sign from negative values
  • Negative amounts displayed as e.g. $50.00 instead of -$50.00 on the Trends page (tooltip + summary cards)
  • Added a n < 0 ? '-' : '' prefix before the $ sign

Test plan

  • Open Trends page and check a view with expense/negative totals — amounts should now show -$X.XX
  • Verify fmtSigned still works correctly (e.g. -$X.XX for negative, +$X.XX for positive)
  • Verify fmtCompact Y-axis labels are unaffected (has its own sign handling)

🤖 Generated with Claude Code

tomfunk and others added 6 commits June 12, 2026 20:32
fmt was stripping the sign via Math.abs, causing negative values to
display as e.g. $50.00 instead of -$50.00 on the Trends page.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dashboard, Tags, and Health were manually prepending '+'/'-' before
calling fmt(). Now that fmt() includes the minus sign for negatives,
these would produce '--$X' or '+-$X'. Switched to fmtSigned() or
plain fmt() as appropriate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After fmt gained its own minus-sign prefix, fmtSigned('-' + fmt(n))
would produce '--$50.00' for negatives. Pass Math.abs(n) so the sign
comes only from fmtSigned's own prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- TUI Health net cash: fmt → fmtSigned to match GUI (show + for surplus)
- TUI Health net worth: remove manual '-' prefix; fmtCompact already handles sign
- TUI Trends search view: remove redundant Math.abs (fmt now handles negatives)
- GUI NetWorth tooltip: remove redundant Math.abs for same reason

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fmt(-50) now returns '-$50.00' instead of '$50.00'. The networth
test's getByText regex now matched balance <td>s too; scope it to
<span> so it stays targeted at the bigNumber element.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tomfunk tomfunk merged commit 15f122d into dev Jun 13, 2026
3 checks passed
@tomfunk tomfunk deleted the fix/fmt-negative-sign branch June 13, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant