Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new format money with commas to presenters #485

Merged
merged 6 commits into from
Nov 1, 2023

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-4155

To support our work on building a new bill page we need to display money values to the user in the UI for the first time. We've done stuff in our API endpoints before hence we have formatNumberAsMoney() in app/presenters/base.presenter.js.

But this will only take numbers like 1599.4 and 15350 and ensure they have 2 decimal places; 1599.40 and 15350.00. For the UI we need to be even fancier!

In the UI we need to delineate the hundreds and thousands i.e. stick in commas. So, using our examples we need to display them as 1,599.40 and 15,350.00.

The legacy water-abstraction-ui of course does this with a package because you can never have too many! 😜 comma-number if you are interested.

But as with most things we can do this with just the tools Node.js and JavaScript provides. So, this change adds a new formatNumberAsMoneyWithCommas() function to our base presenter to do the same thing.

https://eaflood.atlassian.net/browse/WATER-4155

To support our work on building a new bill page we need to display money values to the user in the UI for the first time. We've done stuff in our API endpoints before hence we have `formatNumberAsMoney()` in `app/presenters/base.presenter.js`.

But this will only take numbers like `1599.4` and `15350` and ensure they have 2 decimal places; `1599.40` and `15350.00`. For the UI we need to be _even fancier_!

In the UI we need to delineate the hundreds and thousands i.e. stick in commas. So, using our examples we need to display them as `1,599.40` and `15,350.00`.

The legacy [water-abstraction-ui](https://github.com/DEFRA/water-abstraction-ui) of course does this with a package because you can never have too many! 😜 [comma-number](https://github.com/elidoran/comma-number) if you are interested.

But as with most things we can do this with just the tools Node.js and JavaScript provides. So, this change adds a new `formatNumberAsMoneyWithCommas()` function to our base presenter to do the same thing.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Oct 26, 2023
@Cruikshanks Cruikshanks self-assigned this Oct 26, 2023
@Cruikshanks Cruikshanks marked this pull request as ready for review October 26, 2023 22:28
Jozzey
Jozzey previously approved these changes Oct 27, 2023
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

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

Also, fix the where I copied the test from!
@Cruikshanks Cruikshanks merged commit 62e7604 into main Nov 1, 2023
6 checks passed
@Cruikshanks Cruikshanks deleted the add-new-money-formatter branch November 1, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants