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

Do not create SROC bill run if one already exists #98

Merged
merged 10 commits into from
Jan 25, 2023

Conversation

StuAA78
Copy link
Contributor

@StuAA78 StuAA78 commented Jan 25, 2023

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

The legacy system will not create a presroc bill run if one exists that is "live" (ie. has a status of processing, ready or review) with the same region, financial year and type. The same logic needs to be implemented for sroc supplementary bill runs (adding our new queued status to the list of statuses we consider to be "live").

We do this by creating CheckLiveBillRunService, which takes a region id and financial year and returns a boolean to indicate whether there are any "live" bill runs. We then call this from InitiateBillingBatchService and throw an error if it returns true. Note that we give the error the same message that the water-abstraction-service has but we don't format it as a 409 error.

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

The legacy system will not create a PRESROC bill run if one exists with the same region, financial year and type. There are some exceptions, for example, if the previous bill run has a status of EMPTY or ERROR.

The same logic needs to be implemented for SROC supplementary bill runs.
@StuAA78 StuAA78 added the enhancement New feature or request label Jan 25, 2023
@StuAA78 StuAA78 self-assigned this Jan 25, 2023
We started this work on an incorrect, outdated branch. When we realised our mistake, we created a new branch and cherry-picked the commits across to it. However we'd overlooked the fact that we recently added the additional status `queued`, which we should also consider to be "live". We therefore update our `LIVE_STATUSES` list to include it
@StuAA78 StuAA78 marked this pull request as ready for review January 25, 2023 15:57
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.

It's not critical. More in the 'every penny helps' category. What do you think?

Although `.resultSize()` only gives us the number of rows that a query would return and not the actual data itself, the query still has to be run and the data returned from the db. We therefore select just the `billing_batch_id` to ensure only the minimum required data is returned from the db
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.

👍🏼

@StuAA78 StuAA78 merged commit 6dd774c into main Jan 25, 2023
@StuAA78 StuAA78 deleted the check-whether-sroc-bill-run-exists-before-creation branch January 25, 2023 17:16
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