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

Amend charge versions fetched for SROC supplementary #158

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

Cruikshanks
Copy link
Member

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

Initial tests of the SROC supplementary bill run process immediately identified charge versions were being included in the bill run that shouldn't be.

The current query is based on WATER-3826, the story that originally defined which charge versions to base the bill run on. It just said

  • charge versions linked to a licence flagged for supplementary billing
  • that are applicable to the financial year being billed
  • where the charge version is linked to a licence that matches the selected region

And by inference, the charge version is for the SROC scheme.

The change we have been asked to make is to further filter the charge versions to only those that show as APPROVED in the water-abstraction-ui.

After some digging we found the water.charge_versions table uses a custom data type for the status column. The only permitted values are

  • current
  • draft
  • superseded

We also checked the UI code and found repos/water-abstraction-ui/src/shared/view/nunjucks/filters/charge-version-badge.js that handles determining which badge to display based on the charge version status.

//  Map the backend statuses to the desired front-end labels from acceptance criteria.
//  Statuses are: 'Draft', 'Review', 'Change Request', 'Approved', 'Replaced' - We will also keep invalid to accomodate errors and edge cases. TT 2020-08-28
const displayedTextTransformer = {
  current: 'approved',
  draft: 'draft',
  approved: 'approved',
  replaced: 'replaced',
  superseded: 'replaced',
  invalid: 'invalid',
  review: 'review',
  changes_requested: 'change request',
  to_setup: 'to set up'
}

It looks like there were a lot more statuses at one point. But the TL;DR; is APPROVED equates to current.

So, this change updates FetchChargeVersionsService to only return charge versions where the status is current.

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

Initial tests of the SROC supplementary bill run process immediately identified charge versions were being included in the bill run that shouldn't be.

The current query is based on WATER-3826, the story that originally defined which charge versions to base the bill run on. It just said

- charge versions linked to a licence flagged for supplementary billing
- that are applicable to the financial year being billed
- where the charge version is linked to a licence that matches the selected region

And by inference, the charge version is for the SROC scheme.

The change we have been asked to make is to further filter the charge versions to only those that show as `APPROVED` in the [water-abstraction-ui](https://github.com/DEFRA/water-abstraction-ui).

After some digging we found the `water.charge_versions` table uses a custom data type for the `status` column. The only permitted values are

- **current**
- **draft**
- **superseded**

We also checked the UI code and found `repos/water-abstraction-ui/src/shared/view/nunjucks/filters/charge-version-badge.js` that handles what determining which badge to display based on the charge version status.

```javascript
//  Map the backend statuses to the desired front-end labels from acceptance criteria.
//  Statuses are: 'Draft', 'Review', 'Change Request', 'Approved', 'Replaced' - We will also keep invalid to accomodate errors and edge cases. TT 2020-08-28
const displayedTextTransformer = {
  current: 'approved',
  draft: 'draft',
  approved: 'approved',
  replaced: 'replaced',
  superseded: 'replaced',
  invalid: 'invalid',
  review: 'review',
  changes_requested: 'change request',
  to_setup: 'to set up'
}
```

It looks like there were a lot more statuses at one point. But the TL;DR; is `APPROVED` equates to `current`.

So, this change updates `FetchChargeVersionsService` to only return charge versions where the status is `current`.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Mar 10, 2023
@Cruikshanks Cruikshanks self-assigned this Mar 10, 2023
@Cruikshanks Cruikshanks marked this pull request as ready for review March 10, 2023 18:31
@Cruikshanks Cruikshanks merged commit 579e570 into main Mar 10, 2023
@Cruikshanks Cruikshanks deleted the fix-charge-versions-fetched branch March 10, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant