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

Fix FetchMatchingBillRunService for PRESROC 2PT #870

Merged
merged 7 commits into from
Mar 28, 2024

Conversation

Cruikshanks
Copy link
Member

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

In testing, it was found that when you complete the journey to set up a PRESROC two-part tariff bill run and select 'winter and all year' as the season you get a match for the summer 2PT bill run in that year returned.

After investigating the issue it's not that we are matching the wrong season but that we are not filtering by season at all. If in the environment where the tests were being run the winter 2PT had been created last then it would always be the result returned first.

The flaw is a result of initially passing in the values selected in the UI raw, and then switching to transformed values. We always get values back from the UI as strings and this is what we are matching financial year against to determine if we need to apply the season clause to our query. But at some point in our development, we changed that to a number, which means it now never matches.

  // financialYearEnding is 2022 not '2022'!
  if (['2022', '2021'].includes(financialYearEnding)) {
    query.where('summer', summer)
  }

This change fixes the issue.

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

In testing it was found that when you complete the journey to setup a PRESROC two-part tariff bill run and selected 'winter and all year' as the season you get a match for the summer 2PT bill run in that year returned.

After investigating the issue its not that we are matching the wrong season but that we are not filtering by season at all. If in the environment where the tests were being run the winter 2PT had been created last then it would always be the result returned first.

The flaw is a result of initially passing in the values selected in the UI raw, and then switching to transformed values. We always get values back from the UI as strings and this is what we are matching financial year against to determine if we need to apply the season clause to our query. But at some point in our development we changed that to a number, which means it now never matches.

```javascript
  // financialYearEnding is 2022 not '2022'!
  if (['2022', '2021'].includes(financialYearEnding)) {
    query.where('summer', summer)
  }
```

This change fixes the issue.
@Cruikshanks Cruikshanks added the bug Something isn't working label Mar 27, 2024
@Cruikshanks Cruikshanks self-assigned this Mar 27, 2024
The tests were passing before because we were only creating one bill run for each test. The flaw wasn't that no result was found, just that it returned the first 2PT for that region and year regardless of season.
@Cruikshanks Cruikshanks marked this pull request as ready for review March 28, 2024 08:22
@Cruikshanks Cruikshanks merged commit 07c9426 into main Mar 28, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the fix-fetch-matching-for-alcs-2pt branch March 28, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants