Refactor money formatters in base presenter #491
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
credit
after the formatted number)£
and commas for large numbersWe'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()
becomesformatPounds()
it will just take a value in pence and return it as pounds which deals with the mock-data endpoint's needsformatNumberAsMoneyWithCommas()
becomesformatMoney()
which will cover the 3 steps listed above