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

Refactor Supplementary output to test presenter #32

Merged
merged 11 commits into from
Nov 23, 2022

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Nov 22, 2022

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

We're trying to make it easy to test that we are selecting the right values from the DB when generating the SROC supplementary bill run. Our test endpoint currently lists the charge versions, which includes the licence reference. In Add new SROC Billing Period service we add the financial years.

But it would be easier to validate the licences that have been selected if the response included a unique list of them rather than having to search through the charge version results. This gives us a prime opportunity to split out the presentation logic from what the service is doing, especially as it is likely to be discarded when we are happy the process is working.

So, in this change, we move formatting the response to a new 'presenter'. As part of the change, we'll add a unique list of the Licences being used.

Example response following this change

{
    "billingPeriods": [
        {
            "startDate": "2022-04-01T00:00:00.000Z",
            "endDate": "2023-03-31T00:00:00.000Z"
        }
    ],
    "licences": [
        {
            "licenceId": "2627a306-23a3-432f-9c71-a71663888285",
            "licenceRef": "AT/SROC/SUPB/01"
        }
    ],
    "chargeVersions": [
        {
            "chargeVersionId": "4b5cbe04-a0e2-468c-909e-1e2d93810ba8",
            "licenceRef": "AT/SROC/SUPB/01",
            "licenceId": "2627a306-23a3-432f-9c71-a71663888285",
            "scheme": "sroc",
            "endDate": null
        },
        {
            "chargeVersionId": "732fde85-fd3b-44e8-811f-8e6f4eb8cf6f",
            "licenceRef": "AT/SROC/SUPB/01",
            "licenceId": "2627a306-23a3-432f-9c71-a71663888285",
            "scheme": "sroc",
            "endDate": null
        }
    ]
}

@Cruikshanks Cruikshanks added the enhancement New feature or request label Nov 22, 2022
@Cruikshanks Cruikshanks self-assigned this Nov 22, 2022
@Cruikshanks Cruikshanks marked this pull request as ready for review November 22, 2022 14:24
Jozzey
Jozzey previously approved these changes Nov 22, 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.

👍🏼

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

We're trying to make it easy to test that we are selecting the right values from the DB when generating the SROC supplementary bill run. Our test endpoint currently list the charge versions, which includes the licence reference. In [Add new SROC Billing Period service](#30) we add the financial years.

But it would be easier to validate the licences that have been selected if the response included a unique list of them rather than having to searching through the charge version results. This gives us a prime opportunity to split out the presentation logic from what the service is doing, especially as it is likely to be discarded when we are happy the process is working.

So, in this change we move formatting the response to a new 'presenter'. As part of the change we'll add a unique list of the Licences being used.
This is copying what the `SupplementaryService` is doing with the result.
We are going to amend the query to return more fields. But those fields will clash if we don't specify which table they come from. This is likely to explode the query as we have to prefix every field name.

If you were writing raw SQL, you'd alias the table names to avoid this. Knex allows us to do the same so we take advantage of this feature.
Again, we're updating the functionality to mirror what we are currently expecting. But we're almost ready to start expanding what the service appears to return.
Now we include the scheme and end date in the results
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 895b071 into main Nov 23, 2022
@Cruikshanks Cruikshanks deleted the refactor-to-test-presenter branch November 23, 2022 15:22
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