-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor money formatters in base presenter (#491)
https://eaflood.atlassian.net/browse/WATER-4070 https://eaflood.atlassian.net/browse/WATER-4155 https://eaflood.atlassian.net/browse/WATER-4132 https://eaflood.atlassian.net/browse/WATER-4156 We are working on replacing the legacy bill view page because it crashes for large bills. As we are doing this work we are creating some new presenters and have found all rely on taking a value stored in the DB as pence, for example `12776805` and formatting it as money `£127,768.05`. This means each presenter is going through the same steps - make the value positive (we don't show a sign but instead will add ` credit` after the formatted number) - convert it to pounds - format it with `£` and commas for large numbers We're doing this enough it is time to move the logic to our base presenter. But another money formatter? We already have 2! When we checked `formatNumberAsMoney()` is only used by one mock-data endpoint which never asks for the currency symbol. `formatNumberAsMoneyWithCommas()` was added to deal with the final step we listed above in the new presenters we wish to add. So, rather than add _another_ formatter we are refactoring the 2 we have - `formatNumberAsMoney()` becomes `formatPounds()` it will just take a value in pence and return it as pounds which deals with the mock-data endpoint's needs - `formatNumberAsMoneyWithCommas()` becomes `formatMoney()` which will cover the 3 steps listed above
- Loading branch information
1 parent
62e7604
commit ed2f3d7
Showing
3 changed files
with
50 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters