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

Add SROC include in supplementary billing flag #2077

Merged
merged 11 commits into from
Mar 28, 2023

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Mar 27, 2023

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

We have an issue that the current include_in_supplementary_billing was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for all licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

Our solution is to add a new include_in_sroc_supplementary_billing flag to the licences table. This change covers

  • a migration to add it to the table
  • updating the logic which sets the include in supp. billing flags when a charge version is approved to update only the relevant flag
  • ensuring the db to model mappings recognise the new field

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

We have an issue that the current `include_in_supplementary_billing` was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example the PRESROC bill run, and send the SROC one we loose which licences still need to be processed on the PRESROC one.

Our solution, is to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table. This change covers

- a migration to add it to the table
- updating the logic which sets the include in supp. billing flags when a charge version is approved to update only the relevant flag
@Cruikshanks Cruikshanks added the enhancement New feature or request label Mar 27, 2023
@Cruikshanks Cruikshanks self-assigned this Mar 27, 2023
The test setup was duplicating setting the charge version and calling `fromHash()` unnecessarily.

It  also had a test that was just confirming the scheme matched what we set in the test value. Pointless!
Update the charge versions workflow approve to get ready for testing whether we are just setting the respective include in supplementary billing flag.
We update the `flagForSupplementaryBilling()` to now take an optional scheme arg. Then in the `approve()` function we pass through the scheme of the newly approved and persisted charge version.

It's still setting the same field, but we'll sort the migration and update that logic next.
It _is_ a pointless await because `flagForSupplementaryBilling()` was never marked as async.

Now, we didn't put the await in. But because we touched SonarCloud is shouting at us.
@Cruikshanks Cruikshanks marked this pull request as ready for review March 27, 2023 17:29
We want to ensure our new field is available for use in the UI. But when we looked at the existing DB to Model mapper test even the existing include in supplementary billing flag was not being checked.

So, first step is to ensure that is covered.
@Cruikshanks Cruikshanks marked this pull request as draft March 27, 2023 17:38
Cruikshanks added a commit to DEFRA/water-abstraction-ui that referenced this pull request Mar 27, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](DEFRA/water-abstraction-service#2077) was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. But this means a licence might be flagged only for SROC supplementary billing and the existing functionality to highlight this only looks at the `include_in_supplementary_billing` field.

This change updates the 'marked for next supplementary bill run' notice to handle

- marked for next PRESROC supplementary bill run only
- marked for next SROC supplementary bill run only
- marked for both schemes next supplementary bill run only
@Cruikshanks Cruikshanks marked this pull request as ready for review March 27, 2023 20:16
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Mar 27, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](DEFRA/water-abstraction-service#2077) is to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. With this in place our `FetchChargeVersionsService` needs to be altered to look at that field instead of the old one to identify charge versions to consider for billing.
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Mar 27, 2023
https://eaflood.atlassian.net/browse/WATER-3948

To resolve the issue of dealing with PRESROC and SROC licences flagged for supplementary billing, and how we remove those flags when bill runs get 'sent' we've [made a change to the `FetchChargeVersionsService`](#177) to look at a [new field we've added](DEFRA/water-abstraction-service#2077) to the `water.licences` table.

This broke some tests, a number of which were in the `FetchLicencesService`. We were about to embark on fixing them when we remembered that with the direction our work on supplementary billing took `FetchLicencesService` had become redundant.

So, rather than spend time fixing them we're just getting on and removing the service.
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Cruikshanks merged commit 7ce9863 into main Mar 28, 2023
@Cruikshanks Cruikshanks deleted the add-separate-inc-sup-billing-flag-for-sroc branch March 28, 2023 09:20
Cruikshanks added a commit to DEFRA/water-abstraction-ui that referenced this pull request Mar 28, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](DEFRA/water-abstraction-service#2077) was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. But this means a licence might be flagged only for SROC supplementary billing and the existing functionality to highlight this only looks at the `include_in_supplementary_billing` field.

This change updates the 'marked for next supplementary bill run' notice to handle

- marked for next PRESROC supplementary bill run only
- marked for next SROC supplementary bill run only
- marked for both schemes next supplementary bill run only
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Mar 28, 2023
https://eaflood.atlassian.net/browse/WATER-3948

To resolve the issue of dealing with PRESROC and SROC licences flagged for supplementary billing, and how we remove those flags when bill runs get 'sent' we've [made a change to the `FetchChargeVersionsService`](#177) to look at a [new field we've added](DEFRA/water-abstraction-service#2077) to the `water.licences` table.

This broke some tests, a number of which were in the `FetchLicencesService`. We were about to embark on fixing them when we remembered that with the direction our work on supplementary billing took `FetchLicencesService` had become redundant.

So, rather than spend time fixing them we're just getting on and removing the service.
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Mar 28, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](DEFRA/water-abstraction-service#2077) is to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. With this in place our `FetchChargeVersionsService` needs to be altered to look at that field instead of the old one to identify charge versions to consider for billing.
Cruikshanks added a commit that referenced this pull request Mar 28, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

Our solution was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table in [Add SROC include in supplementary billing flag](#2077). That also covered setting the new flag when a new charge version is approved. We now need to handle clearing the flag when the SROC bill run is 'sent'.
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Mar 29, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](DEFRA/water-abstraction-service#2077) is to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. With this in place our `FetchChargeVersionsService` needs to be altered to look at that field instead of the old one to identify charge versions to consider for billing.
Cruikshanks added a commit that referenced this pull request Mar 30, 2023
https://eaflood.atlassian.net/browse/WATER-3948

We have an issue that the current `include_in_supplementary_billing` was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

Our solution was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table in [Add SROC include in supplementary billing flag](#2077). That also covered setting the new flag when a new charge version is approved. We now need to handle clearing the flag when the SROC bill run is 'sent'.
Cruikshanks added a commit that referenced this pull request Mar 31, 2023
https://eaflood.atlassian.net/browse/WATER-3951

We had an issue that the current `include_in_supplementary_billing` flag was added at a time there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](#2077) was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. That is all now working for new charge versions created and approved.

The remaining issue is existing charge versions that have been processed. When this change goes live there will be a number of SROC charge versions that have been approved and should be considered. But when they were approved only the `include_in_supplementary_billing` flag existed.

We could try and do something clever, and look at all the SROC charge versions that have been approved this year and then only set the flag against their connect licences. But we've decided instead to just set `include_in_sroc_supplementary_billing` to true for those licences where `include_in_supplementary_billing` is true.

It might result in some empty SROC bill runs. But it's far simpler, so there is less chance we'll get something wrong and miss licences.

So, this change adds a migration that will set the flags when first deployed.
Cruikshanks added a commit that referenced this pull request Mar 31, 2023
https://eaflood.atlassian.net/browse/WATER-3951

We had an issue that the current `include_in_supplementary_billing` flag was added when there was only 1 charge scheme. A licence gets flagged irrespective of whether the change relates to PRESROC or SROC.

Where that has impacted us is when sending a billing batch. When it gets sent it clears the flag for _all_ licences included. But if we cancel one, for example, the PRESROC bill run, and send the SROC one we lose which licences still need to be processed on the PRESROC one.

[Our solution](#2077) was to add a new `include_in_sroc_supplementary_billing` flag to the `licences` table and only set it to 'true' when an SROC charge version is approved. That is all now working for new charge versions created and approved.

The remaining issue is existing charge versions that have been processed. When this change goes live there will be some SROC charge versions that have been approved and should be considered. But when they were approved only the `include_in_supplementary_billing` flag existed.

We could try and do something clever, and look at all the SROC charge versions that have been approved this year and then only set the flag against their connect licences. But we've decided instead to set `include_in_sroc_supplementary_billing` to true for those licences where `include_in_supplementary_billing` is true.

It might result in some empty SROC bill runs. But it's far simpler, so there is less chance we'll get something wrong and miss licences.

So, this change adds a migration that will set the flags when first deployed.
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.

2 participants