Skip to content

fix: investment form leading zeros, nav prop mismatch, decimal rounding + add return projection - #491

Merged
sshdopey merged 1 commit into
Heliobond:mainfrom
SarahDoma:fix/investment-form-and-nav
Aug 30, 2026
Merged

fix: investment form leading zeros, nav prop mismatch, decimal rounding + add return projection#491
sshdopey merged 1 commit into
Heliobond:mainfrom
SarahDoma:fix/investment-form-and-nav

Conversation

@SarahDoma

Copy link
Copy Markdown
Contributor

Summary

Four small, focused fixes/enhancements to the investment (deposit) flow:

  • Leading zeros in the amount inputsanitizeAmount now strips leading zeros from the whole-number part as the user types, so 007 becomes 7 instead of displaying an unprofessional zero-padded amount. 0 and 0.5 still work correctly while typing.
  • onNav ignoring its argumentLanding's onNav: (screen: Screen) => void prop was only ever called with 'explore'. Renamed to onExplore: () => void in Landing.tsx, src/app/page.tsx, and src/app/verify/page.tsx so the prop's type now matches its actual, single behaviour.
  • Inconsistent decimal rounding — added roundToDecimals / roundToCents / formatDecimal to src/lib/format.ts (decimal-precision rounding, avoiding binary floating-point artifacts like (1.005).toFixed(2) === '1.00'). Deposit.tsx and Withdraw.tsx now round the entered amount once to cents and reuse that single rounded value everywhere it's displayed (pay amount, fee, net proceeds, review row), instead of each .toFixed() call re-rounding the raw float independently.
  • Investment projection — added projectedReturn(amount, annualYieldPct, years) to src/lib/bondUtils.ts and a real-time "Projected return in 1 year" line next to the deposit amount input, computed from the pool's bond yield (HB_DATA.pool.projectedRate). New Deposit.projection key added to both messages/en.json and messages/fr.json.

Linked issues

Closes #370
Closes #373
Closes #369
Closes #367

Type of change

  • Bug fix
  • Feature

Testing

  • Added unit tests for the leading-zero stripping behaviour in AmountInput.test.tsx.
  • bun run build compiles successfully (Turbopack); the TypeScript check step surfaces pre-existing type errors unrelated to this change (present on main prior to this branch, verified by diffing typecheck output against main).
  • bun run lint — no new lint errors introduced (verified by diffing against main).
  • bun run format:check — all files touched by this PR are formatted; remaining warnings are in files not touched by this PR.
  • bun run test — all new/existing tests around the changed code pass; the 3 pre-existing failing test files (useSessionTimeout.test.ts, AdminConsole.test.tsx) fail identically on main and are unrelated to this change.

Checklist

  • Tied to an accepted issue (Closes #…)
  • Follows the design system — token CSS vars, no hardcoded colours
  • User-facing strings added to both messages/en.json and messages/fr.json
  • No secrets committed

…eturn projection

- Strip leading zeros in AmountInput so "007" becomes "7" instead of
  displaying an unprofessional zero-padded number (Heliobond#370).
- Simplify Landing's onNav(screen) to onExplore(), since it was only ever
  called with 'explore' — the prop signature now matches its actual,
  single behaviour (Heliobond#373).
- Add roundToDecimals/roundToCents/formatDecimal helpers and round investment
  amounts once to cents, reusing that value everywhere it's displayed, so
  Deposit and Withdraw no longer show inconsistent rounded figures like
  2.00 next to an underlying 1.995 (Heliobond#369).
- Show a real-time projected 1-year return next to the deposit amount input,
  computed from the pool's bond yield via a new projectedReturn helper (Heliobond#367).

Closes Heliobond#370
Closes Heliobond#373
Closes Heliobond#369
Closes Heliobond#367
@SarahDoma
SarahDoma requested a review from dadadave80 as a code owner August 30, 2026 12:02
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@SarahDoma is attempting to deploy a commit to the David Dada's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@SarahDoma Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey sshdopey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lovely, well-scoped PR that tackles four distinct issues with care. The leading-zero fix, the prop rename, the consistent rounding helpers, and the new projection feature all directly address the linked issues and include tests. The code is clean and the changes are focused. Great work, Sarah! 🎉 Keep it up!

@sshdopey
sshdopey merged commit 8af3409 into Heliobond:main Aug 30, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants