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

AP-3563/AP-5496: Standardise currency handling across the app #7424

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

jsugarman
Copy link
Contributor

@jsugarman jsugarman commented Nov 12, 2024

What

Standardise currency handling across the app and fix existing bugs

Cash income/outgoings handling
Currency field storing invalid values

Standardise currency field handling

Certain currency/amount fields accept humanized monetary
values while others did not. Some would accept but clean
£ and , values such that £1,000 would become 1000
while others would error. Yet others would ignore £ and , values
for validation purposes but when persisting this data they would not, resulting
in, for example, £2,000 becoming a stored value of 2.0.

This PR standardise the approach, removing £ and , values prior to saving
across regular incomes, regular outgoings, cash incomes, cash outgoings,
state benefits, housing benefit, student finance and mandatory and discretionary
capital disregards monetary amount fields.

In should be noted that some forms validate currency, which ignores
£ and , chars, while others do not validate this way. This has not been
changed.

Checklist

Before you ask people to review this PR:

  • Tests and rubocop should be passing: bundle exec rake
  • Github should not be reporting conflicts; you should have recently run git rebase main.
  • The standards in the Git Workflow document on Confluence should be followed
  • There should be no unnecessary whitespace changes. These make diffs harder to read and conflicts more likely.
  • The PR description should say what you changed and why, with a link to the JIRA story.
  • You should have looked at the diff against main and ensured that nothing unexpected is included in your changes.
  • You should have checked that the commit messages say why the change was made.

@jsugarman jsugarman changed the title AP-3565/AP-5496: Standardise currency handling across the app AP-3563/AP-5496: Standardise currency handling across the app Nov 12, 2024
@jsugarman jsugarman force-pushed the ap-3563/standardise-currency-handling-across-app branch 4 times, most recently from 93eb131 to 89aeb61 Compare November 13, 2024 08:22
@jsugarman jsugarman marked this pull request as ready for review November 13, 2024 08:34
@jsugarman jsugarman requested a review from a team as a code owner November 13, 2024 08:34
@jsugarman jsugarman added the ready for review Please review label Nov 13, 2024
Copy link
Contributor

@colinbruce colinbruce left a comment

Choose a reason for hiding this comment

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

Looks okay to me, but maybe it would be better to get input from design to ensure consistent errors and handling?

@jsugarman jsugarman force-pushed the ap-3563/standardise-currency-handling-across-app branch from 89aeb61 to d33f55f Compare November 13, 2024 12:27
@jsugarman jsugarman force-pushed the ap-3563/standardise-currency-handling-across-app branch 4 times, most recently from d6ac7e3 to 0862967 Compare November 13, 2024 17:23
This fixes an underlying bug that causes the behaviour described
in the bug ticket AP-3563. Namely, that while the amount for any
cash income or outgoing type is validated it is not done in the way
common to other pages or forms. This has resulted in a difference
whereby comma separated monetayr values, `1,000`, are invalid but
where being rendered as a value when the form errors and rerenders.

This has been corrected to emulate the functionality seen in
form objects with monetary amount fields.

1. It now "cleans" the monetary amount params to remove `£` and `,`.

2. When rendering the form the field value is no longer rendered as a
"number to currency" value with no unit - which was rendering commas
for numeric values over 3 digits long.
Certain currency/amount fields accepted humanized monetary
values while others did not. Some would accept but clean
`£` and `,` values such that `£1,000` would become `1000`
while others would error. Yet others would ignore `£` and `,` values
for validation purposes but when peristing this data would not, resulting
in, for example, `£2,000` become a stored value of `2.0`.

This PR standardise the approach, removing `£` and `,` values prior to saving
across regular incomes, regular outgoings, cash incomes, cash outgoings,
state benefits, housing benefit, student finance and mandatory and discretionary
capital disregards monetary amount fields.

In shouldbe noted that some forms validate currency, which cleans/ignores
`£` and `,` chars, while others do not validate this way. This has not been
changed.
@jsugarman jsugarman force-pushed the ap-3563/standardise-currency-handling-across-app branch from 0862967 to 22989fd Compare November 14, 2024 11:36
@jsugarman jsugarman merged commit 5bc98b1 into main Nov 14, 2024
14 checks passed
@jsugarman jsugarman deleted the ap-3563/standardise-currency-handling-across-app branch November 14, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review Please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants