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 reissuing to ProcessBillingBatchService #290

Merged
merged 18 commits into from
Jul 7, 2023

Conversation

StuAA78
Copy link
Contributor

@StuAA78 StuAA78 commented Jun 29, 2023

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

We update ProcessBillingBatchService to call our new ReissueInvoicesService. This has involved a small refactor to ProcessBillingBatchService so that each stage is called in its own function, leaving the main go function clean.

We also hide the reissuing behind a feature flag, which is set by ENABLE_REISSUING_BILLING_BATCHES in .env. This enables us to selectively enable reissuing in environments so that it isn't prematurely deployed.

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

We update `ProcessBillingBatchService` to call our new `ReissueInvoicesService`.
@StuAA78 StuAA78 added the enhancement New feature or request label Jun 29, 2023
@StuAA78 StuAA78 self-assigned this Jun 29, 2023
StuAA78 added 16 commits June 29, 2023 12:13
We don't yet have `ReissueInvoicesService` approved and merged. We therefore create a dummy service in the meantime to stand in for it.
We noticed that we don't have any docs in `ProcessBillingBatchService`. We add some brief placeholder docs to be fleshed out later.
We originally had a `isBatchPopulated` flag which we set `false` at the start of processing, then updated to `true` if the call to `ProcessBillingPeriodService` came back as `true` at any point. To avoid duplicating logic when we introduce reissuing, we refactor this to add the result to an array and then set `isBatchPopulated` based on whether at least one result in the array is truthy.
We add in a call to `ReissueInvoicesService` and add its return value to our results array
We refactor our logging function to accept different messages, and add logging for our reissue invoices process
We update our unit tests to stub `ReissueInvoicesService` and test that its return value is used to determine whether or not the billing batch is empty
We refactor `ProcessBillingBatch` to shorten the number of lines in `go`
In the interests of getting this PR merged asap we're going to leave the docs to be fleshed out at a later date. However we will at least get the right `@param` details in there
We noticed that `UnflagUnbilledLicencesService` is documented as returning a value, but it actually returns an Objection query object. We therefore refactor it so that it executes the query and then returns its result.
As we don't want to enable reissuing in all environments, we hide it behind a feature flag, set in `.env` as `ENABLE_REISSUING_BILLING_BATCHES`.
Some early feedback was that we don't care so much about the time taken to reissue invoices -- we're more concerned with how long the overall process takes. So we revert the time logging to how things were prior to this PR -- that is, we log the overall process time, and we do this within the `go` function to ensure it covers the entire process (ie. reissuing as well as processing the billing periods)
@StuAA78 StuAA78 requested review from Cruikshanks, Jozzey and Beckyrose200 and removed request for Cruikshanks and Jozzey July 7, 2023 14:11
@StuAA78 StuAA78 marked this pull request as ready for review July 7, 2023 14:11
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.

@StuAA78 StuAA78 merged commit 58d4a68 into main Jul 7, 2023
@StuAA78 StuAA78 deleted the add-reissuing-to-process-billing-batch-service branch July 7, 2023 14:42
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