Skip to content

Correctly format amounts of less than 10 cents - #591

Merged
krokosik merged 1 commit into
oss-apps:mainfrom
FriesischScott:fix-single-digit-cent-display
Mar 23, 2026
Merged

krokosik merged 1 commit into
oss-apps:mainfrom
FriesischScott:fix-single-digit-cent-display

Conversation

@FriesischScott

@FriesischScott FriesischScott commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Amounts of less than 10 cents are currently formatted incorrectly. For example 1 cent (represented as 1n) is rendered as $0.1.

When simplifyDebts results in very small amounts they render incorrectly and do not add up to the correct debts anymore.

The issue is fixed by padding the string with the appropriate number of zeros.

I've also added a corresponding test.

Checklist

  • I have read CONTRIBUTING.md in its entirety
  • I have performed a self-review of my own code
  • I have added unit tests to cover my changes
  • The last commit successfully passed pre-commit checks

Amounts of less than 10 cents where incorrectly formatted such that one
cent would render as 0.1. The issue is fixed by padding the string with
the appropriate number of zeros.

I've also added a corresponding test.
@krokosik

Copy link
Copy Markdown
Collaborator

Nice catch! Thanks

@krokosik
krokosik merged commit d9959ea into oss-apps:main Mar 23, 2026
1 check passed
@FriesischScott
FriesischScott deleted the fix-single-digit-cent-display branch March 24, 2026 14:59
krokosik pushed a commit that referenced this pull request Nov 1, 2026
Negative cent amounts from -1 to -9 were incorrectly formatted to be 0.1 and 0.9. The issue was the negative sign '-' which caused the padding to be off by one.
A test including a negative number was also added.
This completes the fix in #591.
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.

2 participants