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

Supplementary billing housekeeping #857

Merged
merged 7 commits into from
Mar 24, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Mar 24, 2024

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

Part of changes to exclude the current financial year from supplementary billing if the annual bill run has not been completed

We have recently migrated the SROC annual billing engine into our project ( WATER-4345 ). The primary drive to do this was to enable our users to run annual bill runs in April at the same time as licensees are submitting their return data. This is when the service is under its greatest load so we wanted to ensure annual billing could take advantage of the improvements our supplementary billing engine has over the legacy one.

But having built the annual billing engine, we found there were improvements we could make to our supplementary billing engine!

So, we're doing this in two parts. This first part covers some housekeeping changes we've spotted that could be made.


  • ProcessBillRunService should have used currentTimeInNanoseconds to get the start time
  • Test for HandleErroredBillRunService was in the wrong place
  • Stop passing objects around when all we need are ID's
  • Update FetchPreviousTransactionsService to use Objection rather than Knex raw
  • Drop properties we're not using from FetchPreviousTransactionsService query (which means we can simplify the conversion in ReverseTransactionsService)

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

> Part of changes to exclude the current financial year from supplementary billing if the annual bill run has not been completed

We have recently migrated the SROC annual billing engine into our project ( WATER-4345 ). The primary drive to do this was to enable them run annual bill runs in April at the same time as licensees are submitting their return data. This is when the service is under its greatest load so we wanted to ensure annual billing could take advantage of the improvements we made as part of the supplementary billing we implemented.

Re-visiting supplementary billing as part of that migration meant we spotted further improvements we could make. For example, thanks to our models now being [view](https://www.postgresql.org/docs/current/sql-createview.html) based means tables being in different schemas is no longer a blocker to us creating relationships in the models. In our annual billing engine we are able to fetch everything at the billing account level removing the need for additional queries and the need to pre-generate billing objects.

We were also able to implement a batch process, whereby multiple bills can be processed at the same time. We want to bring these improvements to our supplementary billing engine before we start making changes to support excluding the current financial year.
We never needed the whole BillLicence, just its ID.
We seemed to have been passing whole objects around we think 'just in case'. We can see now we only ever needed their ID's or specific properties so we can stop doing that!
The original query was built when we thought we needed to get billing account details as part of the query. This was because we thought we'd be matching as we iterated the charge versions we fetch and their charge elements.

The version of the supplementary billing engine that finally switched had opted to pre-generate billing data and then iterate it. The need to access billing account information on the transaction had become redundant.

We should have noticed at the time but it's never too late!

Because we can drop those elements we can switch to using Objection which tidies up the query some, for example, the `purposes` field now comes through as proper JSON.

These changes to the what `FetchPreviousTransactionsService` returns also means we can remove some of the logic in `ReverseTransactionsService`.
@Cruikshanks Cruikshanks self-assigned this Mar 24, 2024
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Mar 24, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review March 24, 2024 23:41
@Cruikshanks Cruikshanks merged commit 30f6f6a into main Mar 24, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the supplementary-billing-housekeeping branch March 24, 2024 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant