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 use of new points in setup ret. req. journey #1314

Merged
merged 5 commits into from
Sep 8, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Sep 7, 2024

https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

Part of the work to migrate return versions from NALD to WRLS

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them.

In Update Return req set up journey to use new points we updated the return requirement setup journey to use the new water.licence_version_purpose_points table we've created and now populate thanks to a change to the import.

We then began updating our acceptance tests to update the return requirement fixtures to use new points but found the 'Copy from existing journey' was failing.

We tracked the issue down to the use of IDs. The changes we had made to the journey to support reading points from water.licence_version_purpose_points were the cause.

Starting with the manual journey, we updated the fetch points service to retrieve points information from water.licence_version_purpose_points. The ID we provided in the presenter to the view was the LicenceVersionPurposePoint.id. This is then what gets stored in the session when a user makes a selection.

Then, we did something similar in the 'Use abstraction data' journey. Again, we retrieve the licence version purpose points and store their IDs in the session.

In both journeys, when you get to the /check screen, it will use the FetchPointsService to fetch the licence version purpose points again. The presenter for the check page can match the selected points in the session to the results of the fetch points service.

The journey we broke was 'Copy from existing'. In that scenario, the points are sourced from water.return_requirement_points, which means they have a different ID than what is in water.licence_version_purpose_points that we are storing in the session. This means that when you then get passed to the /check page, it is unable to find a match in the results from FetchPointsService, so an error is thrown.

Fortunately, the one value both tables share is the NALD point ID. Like with our journey, when you create the return requirement in NALD, you select from the same licence points as ours, which also have a NALD point ID. This means there will always be a match between licence points and return points. You just have to match on NALD Point ID instead of their IDs.

https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

> Part of the work to migrate return versions from NALD to WRLS

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them.

In [Update Return req set up journey to use new points](#1301) we updated the return requirement setup journey to use the new `water.licence_version_purpose_points` table we've created and now populate thanks to [a change to the import](#1301).

This change updates the logic behind the 'Approve' step in the journey to use the new points rather than those pulled from the `permit.licence` record.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Sep 7, 2024
@Cruikshanks Cruikshanks self-assigned this Sep 7, 2024
Working on [Update rtn requirement fixtures to use new points](DEFRA/water-abstraction-acceptance-tests#134) exposed that copy from an existing return requirement was not actually working.

We tracked the issue down to the use of IDs. The changes we had made to the journey to support reading points from `water.licence_version_purpose_points` were the cause.

We were storing the licence point ID in the session and using it as the value when displaying the points on the manual journey. But when you copy from existing, the source point comes from `water.return_requirement_points`. When it got to the `/check` page its presenter was trying to match the ID we'd stored in the session (from return points) with the ID of a licence point. No matching was being found causing the error.

Fortunately, the one value both tables share is the NALD point ID. Like with our journey, when you create the return requirement in NALD you select from the same licence points as we do. This means there will _always_ be a match between licence points and return points. You just have to match on NALD Point ID instead.
Also tweak where we need to use toString().
@Cruikshanks Cruikshanks changed the title Update approve new return req. to use new points Fix use of new points in setup ret. req. journey Sep 8, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review September 8, 2024 15:06
@Cruikshanks Cruikshanks merged commit 53c9b35 into main Sep 8, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the updateapprove-ret-requirements-for-new-points branch September 8, 2024 15:06
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