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

Use abstraction data to create return requirements #1107

Merged
merged 14 commits into from
Jun 16, 2024

Conversation

Cruikshanks
Copy link
Member

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

Part of the work to replace NALD for handling return requirements

We want to be able to offer users the option to generate return requirements from the licence's abstraction data. On the /setup page, they can select this option and the service is expected to generate return requirements using the source abstraction data against the licence. The other options are to copy existing return requirements or set them up manually.

This change is about implementing the logic behind the scenes when 'Start by using abstraction data' is selected. We fetch the licence's abstraction data, generate return requirements from it, and save them to the session before redirecting the user to the /check page.

@Cruikshanks Cruikshanks added the enhancement New feature or request label Jun 14, 2024
@Cruikshanks Cruikshanks self-assigned this Jun 14, 2024
@Cruikshanks Cruikshanks force-pushed the ret-req-use-abstraction-data branch 5 times, most recently from edcc181 to 1df7ab7 Compare June 15, 2024 10:09
https://eaflood.atlassian.net/browse/WATER-4442

> Part of the work to replace NALD for handling return requirements

We want to be able to offer users the option to generate return requirements from the licence's abstraction data. On the `/setup` page they can select this option and the service is expected to generate return requirements using the source abstraction data against the licence. The other options are copy existing return requirements or set them up manually.

This change is about implementing the logic behind the scenes for when 'Start by using abstraction data' is selected. To look at the licence's abstraction data, generate return requirements and add them to the session before redirecting the user to the `/check` page.
We are going to need these in what we are building so move them to static lookups where they can be reused.
We don't need a separate service to return this information. We can do it at the same time we fetch the rest of the licence's abstraction data.
Tests coming on a bit! (Got it working and don't want to lose the work!)
Keeps things consistent and avoids any confusion that this returns the data 'as-is' from the DB.
Looking at the tests we going to find it easier if we split the fetch from the transform. But that means adding another service which is specific only to setup so now seems a good time to move things into a /setup folder.
This should make writing the tests much easier.
@Cruikshanks Cruikshanks force-pushed the ret-req-use-abstraction-data branch from 701a6e7 to 15d2a3d Compare June 16, 2024 11:26
We need _so much_ data in _so many_ places to test this service we've opted to add a seeder.
@Cruikshanks Cruikshanks force-pushed the ret-req-use-abstraction-data branch from 15d2a3d to 98d2a4b Compare June 16, 2024 20:29
This was what caused us to do all the model fixes! Need to work out the collection and reporting frequencies correctly.
@Cruikshanks Cruikshanks marked this pull request as ready for review June 16, 2024 21:58
@Cruikshanks Cruikshanks merged commit b783112 into main Jun 16, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the ret-req-use-abstraction-data branch June 16, 2024 21:58
Cruikshanks added a commit that referenced this pull request Jun 19, 2024
https://eaflood.atlassian.net/browse/WATER-4512

> Part of the work to replace NALD for handling return requirements

We want to be able to offer users the option to generate return requirements from the licence's abstraction data. On the `/setup` page, they can select this option and the service is expected to generate return requirements using the source abstraction data against the licence.

We added support for this in [Use abstraction data to create return requirements](#1107). But after double checking the test scenarios we've made a mistake in the logic.

We've determined a return requirement will be linked to a purpose that is two-part tariff purely based on the purpose's two-part tariff flag. This effects what collection and reporting cycle we pick for the return requirement.

But the purpose can only be interpreted as two-part tariff if the licence also has a two-part tariff agreement. So, the purpose might be spray irrigation, for example, which is flagged as two-part tariff. But if the licence doesn't also have a two-part tariff agreement we need to ignore that when determining the cycles for the return requirement.

This change fixes our logic in `GenerateFromAbstractionDataService`.
Cruikshanks added a commit that referenced this pull request Jun 20, 2024
https://eaflood.atlassian.net/browse/WATER-4512

> Part of the work to replace NALD for handling return requirements

We want to be able to offer users the option to generate return requirements from the licence's abstraction data. On the `/setup` page, they can select this option, and the service is expected to generate return requirements using the source abstraction data against the licence.

We added support for this in [Use abstraction data to create return requirements](#1107). But after double-checking the test scenarios we've made a mistake in the logic.

We've determined a return requirement will be linked to a purpose that is two-part tariff purely based on the purpose's two-part tariff flag. This effects the collection and reporting cycle we pick for the return requirement.

But the purpose can only be interpreted as two-part tariff if the licence also has a two-part tariff agreement. So, the purpose might be spray irrigation, for example, which is flagged as two-part tariff. But if the licence doesn't also have a two-part tariff agreement we need to ignore that when determining the cycles for the return requirement.

This change fixes our logic in `GenerateFromAbstractionDataService`.
Cruikshanks added a commit that referenced this pull request Jul 10, 2024
https://eaflood.atlassian.net/browse/WATER-4442

> Part of the work to replace NALD for handling return requirements

In [Use abstraction data to create return requirements](#1107) we added the logic to the return requirements set up journey that allows a user to generate return requirements from a licence's existing abstraction data.

One of the scenarios we had to tackle was how to populate the site description for a return requirement that has multiple points. At the time, we went with concatenating them all using ' - '.

After some additional testing, it has been decided it is clearer if we just use the first available site description. What ever we opt for we can see users will change it anyway. Just picking one at least improves how the return requirement is displayed on the page.
Cruikshanks added a commit that referenced this pull request Jul 10, 2024
https://eaflood.atlassian.net/browse/WATER-4442

> Part of the work to replace NALD for handling return requirements

In [Use abstraction data to create return requirements](#1107) we added the logic to the return requirements set up journey that allows a user to generate return requirements from a licence's existing abstraction data.

One of the scenarios we had to tackle was how to populate the site description for a return requirement that has multiple points. At the time, we went with concatenating them all using ' - '.

After some additional testing, it has been decided that it is clearer if we just use the first available site description. Whatever we opt for we can see users will change it anyway. Just picking one at least improves how the return requirement is displayed on the page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant