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 logic to trigger SROC supplementary from PRESROC #2247

Merged
merged 12 commits into from
Dec 8, 2022

Conversation

StuAA78
Copy link
Contributor

@StuAA78 StuAA78 commented Dec 5, 2022

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

When presroc supplementary billing has completed, we want to trigger sroc supplementary billing. To do this we update the existing billing routing so that when the current batch has reached ready status, we check to see if it's a presroc supplementary batch so we can trigger the creation of an sroc supplementary batch if needed, and continue the billing flow using this new batch so the user once again sees the spinner page until it has completed.

At present we don't have the ability to create sroc supplementary batches so we simply create a dummy batch with its status already set to ready.

This is all hidden behind a feature flag TRIGGER_SROC_SUPPLEMENTARY.

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

When PRESROC supplementary billing has completed, we want to trigger SROC supplementary billing.
@StuAA78 StuAA78 added the enhancement New feature or request label Dec 5, 2022
@StuAA78 StuAA78 self-assigned this Dec 5, 2022
The unit tests for `routing` didn't easily lend themselves to how we wanted to write our tests, so we refactor them to make our lives a little easier.
We add `TRIGGER_SROC_SUPPLEMENTARY` to our `.env` file which we can use to enable the new behaviour
The method of redirection used to determine routing can only handle `GET` requests. We therefore change the `POST` endpoint developed to be a `GET` endpoint instead. We also pass in the region as a parameter since this is what we'll need this to kick off the sroc supplementary billing
@StuAA78 StuAA78 changed the title Trigger SROC supplementary from PRESROC Add logic to trigger SROC supplementary from PRESROC Dec 7, 2022
@StuAA78 StuAA78 marked this pull request as ready for review December 7, 2022 13:42
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

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

The minor-ist of minor changes!

src/internal/modules/billing/routes/create-bill-run.js Outdated Show resolved Hide resolved
Co-authored-by: Alan Cruikshanks <alan.cruikshanks@gmail.com>
@StuAA78 StuAA78 requested a review from Cruikshanks December 8, 2022 09:58
@StuAA78 StuAA78 merged commit dbd4ed4 into main Dec 8, 2022
@StuAA78 StuAA78 deleted the trigger-sroc-supplementary branch December 8, 2022 11:08
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Jan 2, 2023
We need something that handles formatting the response for the POST `/bill-runs` endpoint. We use what we did in DEFRA/water-abstraction-ui#2247 as a spec.
Cruikshanks added a commit to DEFRA/water-abstraction-system that referenced this pull request Jan 2, 2023
We need something that handles formatting the response for the POST `/bill-runs` endpoint. We use what we did in DEFRA/water-abstraction-ui#2247 as a spec.
StuAA78 added a commit to DEFRA/water-abstraction-system that referenced this pull request Jan 3, 2023
* Update "create bill run" endpoint to create a bill run

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

When we set up our "create bill run" endpoint, we had it simply respond to requests with a dummy response. We now update it to actually create a bill run and an event, and return the required details in the same format as the dummy response.

* Add `idColumn` static method to `BillingBatchModel`

As we start to look at creating entries in the db, we run into an issue when Objection errors because it can't find an `id` column. On investigation it turns out that if the primary id column isn't called `id`, it needs to be specified in the model. We therefore add an `idColumn` static method to our billing batch model

* Initial pass at inserting bill run in db

We update our `createBillRun` controller to create a record for the bill run in the db. We initially hardcode the financial year fields just to get it working, with the intention of pulling these through properly from the request in a later commit

* Move bill runs controller into folder

We try and follow that the path you see in the url matches where the controller sits in the repo.

* Add presenter for formatting response

We need something that handles formatting the response for the POST `/bill-runs` endpoint. We use what we did in DEFRA/water-abstraction-ui#2247 as a spec.

* Add new initialise Billing Batch service

At the start of a new bill run we need to

- create the initial billing batch record
- create the associated event record
- send a request to the SROC Charging Module API and link it to our billing batch

With those 3 things done we can return control back to the requester (which will be the UI) whilst we get on with the rest of the bill run process.

This adds the service that will handle those 3 steps. We're waiting on additional functionality before we can do the last one. But for now steps 1 & 2 are done and we'll have a home for step 3 when it's ready!

* Refactor bill-runs controller to use new service

Now we've created the InitiateBillingBatchService we refactor the bill runs controller to use it.

Co-authored-by: Alan Cruikshanks <alan.cruikshanks@gmail.com>
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