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 FetchLiveBillRunsService #845

Merged
merged 4 commits into from
Mar 21, 2024
Merged

Fix FetchLiveBillRunsService #845

merged 4 commits into from
Mar 21, 2024

Conversation

Cruikshanks
Copy link
Member

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

We migrated the create bill run process from the legacy service as part of applying updates to support changes for two-part tariff.

One of the things we had to mirror was how it checks for matching or live bill runs at the end of the journey. In testing, we've found there is a scenario our unit tests and therefore the code didn't cover.

There is only a PRESROC bill run that is READY with a financial end year of 2022. You are trying to create an annual bill run for the current financial year (2024).

With that scenario the first test is this and the result would be false.

  if (!supplementary && liveBillRun.toFinancialYearEnding === financialYearEnding) {
    matches.push(liveBillRun)
    break
  }

Our mistake is to assume only supplementary bill runs would get past this point. So, the next test is passing causing a match to be returned when it shouldn't.

  // Because of the check above this will only be applied to supplementary bill runs. This is where we check the
  // live bill run against both the specified financial year ending and the last year of PRESROC 2022
  if (liveBillRun.toFinancialYearEnding === financialYearEnding || liveBillRun.toFinancialYearEnding === LAST_PRESROC_YEAR) {
    matches.push(liveBillRun)
  }

This change updates the unit tests to include this scenario and then fixes the flaw in our logic.

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

We migrated the create bill run process from the legacy service as part applying updates to support changes for two-part tariff.

One of the things we had to mirror was how it checks for matching or live bill runs at the end of the journey. In testing we've found there is a scenario our unit tests and therefore the code didn't cover.

> There is _only_ a PRESROC bill run that is `READY` with a financial end year of 2022. You are trying to create an annual bill run for the current financial year (2024).

With that scenario the first test is this and the result would be false.

```javascript
  if (!supplementary && liveBillRun.toFinancialYearEnding === financialYearEnding) {
    matches.push(liveBillRun)
    break
  }
```

Our mistake is to assume only supplementary bill runs would get past this point. So, the next test is passing causing a match to be returned when it shouldn't.

```javascript
  // Because of the check above this will only be applied to supplementary bill runs. This is where we check the
  // live bill run against both the specified financial year ending and the last year of PRESROC 2022
  if (liveBillRun.toFinancialYearEnding === financialYearEnding || liveBillRun.toFinancialYearEnding === LAST_PRESROC_YEAR) {
    matches.push(liveBillRun)
  }
```

This change updates the unit tests to include this scenario and then fixes the flaw in our logic.
@Cruikshanks Cruikshanks added the bug Something isn't working label Mar 21, 2024
@Cruikshanks Cruikshanks self-assigned this Mar 21, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review March 21, 2024 11:21
@Cruikshanks Cruikshanks merged commit 7eb1bc4 into main Mar 21, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the fix-fetch-live-bill-run branch March 21, 2024 12:01
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.

3 participants