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

Select SROC supplementary charge versions for real #27

Merged
merged 13 commits into from
Nov 15, 2022

Conversation

Cruikshanks
Copy link
Member

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

In Fetching the charge versions data we added a new service to start selecting charge versions to be included in the Supplementary Bill run.

But at the moment, its only filter is all charge versions with the scheme SROC. We have test data and scenarios to work with so we can now start implementing the filter 'for real'.

This is the start of the process. We expect it's likely we'll be finessing the filter in subsequent PRs. But this gets the ball rolling.

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

In [Fetching the charge versions data](#15) we added a new service to start selecting scharge versions to be included in the Supplementary Bill run.

But at the moment, it's only filter is all charge versions with the `scheme` SROC. We have test data and scenarios to work with so we can now start implementing the filter 'for real'.

This is the start of the process. We expect it's likely we'll be finessing the filter in subsequent PR's. But this gets the ball rolling.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Nov 11, 2022
@Cruikshanks Cruikshanks self-assigned this Nov 11, 2022
It turns out the oft-mentioned `include_in_supplementary_billing` flag is in the `licences` table and not the `charge_versions` table. This means we can't just rely on checking the charge versions table and will need to build a licences table for our testing.

We also add a migration to add `licence_id` and `end_date` fields to the charge versions table. `licence_id` is how the 2 tables are linked and `end_date` is what we are having to rely on to determine the 'current' charge version.
Two changes here. First me re-ordered the method calls and swapped some out for other aliases in order for the query to read more like traditional SQL.

The second is that we have updated it to take into account the `include_in_supplementary_billing` flag on the licences table. This is the main driver of whether to include something in supplementary billing.

“Simple”, was our next thought. Charge versions have a `scheme` and a `status` column; we'll just grab the one where `scheme=sroc && status=current` for each licence flagged for supplementary billing. That was until our initial tests showed that `status` is not getting set correctly. This means we have multiple SROC charge versions both with a status of `current`.

Fortunately, it looks like `end_date` is getting set as expected, which means we have a way of selecting them (for now!)
We add a new `LicenceHelper` as our query now needs these linked to charge versions. Rather than have our test have to repeatedly set up this up we expand our data helpers.

First part of this is having the charge version helper automatically call the licence helper and manage linking the 2 records. Adding the licence also means we need to start passing a bunch of data around now. So, instead we go with some defaults. We'll add some documentation to make this more visible in subsequent commits.
With the updated query in the service we needed to update our tests to setup the appropriate environments. We've expanded the functionality of our data helpers. So, we take advantage of them to update and expand the tests we have for this service.
@Cruikshanks Cruikshanks force-pushed the select-sroc-sup-charge-versions branch from 8ff4104 to d749826 Compare November 13, 2022 22:38
@Cruikshanks Cruikshanks marked this pull request as ready for review November 15, 2022 10:02
Jozzey
Jozzey previously approved these changes Nov 15, 2022
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.

test/controllers/test/supplementary.controller.test.js Outdated Show resolved Hide resolved
app/controllers/test/supplementary.controller.js Outdated Show resolved Hide resolved
app/services/test/supplementary.service.js Outdated Show resolved Hide resolved
test/services/test/supplementary.service.test.js Outdated Show resolved Hide resolved
test/services/test/supplementary.service.test.js Outdated Show resolved Hide resolved
test/services/test/supplementary.service.test.js Outdated Show resolved Hide resolved
test/services/test/supplementary.service.test.js Outdated Show resolved Hide resolved
@Cruikshanks Cruikshanks requested a review from StuAA78 November 15, 2022 11:35
@Cruikshanks Cruikshanks merged commit 9d226d5 into main Nov 15, 2022
@Cruikshanks Cruikshanks deleted the select-sroc-sup-charge-versions branch November 15, 2022 11:45
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.

3 participants