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 DetermineBillingPeriods to use type #864

Merged
merged 6 commits into from
Apr 2, 2024

Conversation

Cruikshanks
Copy link
Member

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

We want our Billing & Data team to be able to generate supplementary bill runs all year round. However, at the moment they have to enforce a manual 'stop' on them until annual bill runs are completed. This is because of the 2 ways the engine operates.

Annual just bills for the current charge versions. It doesn't look at replaced charge versions or what was previously billed. supplementary does do these things. So, if the order is 'Annual -> Supplementary' then the bill will be correct. For example, supplementary calculates a debit of £100 for a charge version (the licence was flagged for 'reasons'!) but sees the £100 debit from the annual bill. They cancel each other out so the customer sees nothing.

If the order was Supplementary -> Annual though, annual doesn't look back at previous transactions. It would generate another debit to the customer for £100 leading to them being billed twice.

We could guarantee annual bills were raised on April 1 we wouldn't have a problem. However, the additional work that goes into preparing them and validating what the engine generates, means it can take some time. That leaves a window where a supplementary could be raised and the charges for a customer get messed up.

This has always been the case and billing & data have just had to deal with it by not generating supplementary. But that causes problems because bills start backing up that could be sent out.

So, this year we intend to solve the problem. We will amend our supplementary billing engine to check if an annual bill run for the same region has been raised in the current billing period. If it has we'll carry on as usual. If it hasn't, we'll move the financial year end back to the first year where one was raised. This will allow B&D to crack on with supplementary bills, at least for previous years and prevent charging data from being messed up.

The first step to achieving this is to refactor DetermineBillingPeriods to expect a year and a billRunType. It can then use this information to generate the billing periods accordingly, rather than always from the current billing period.

How we determine the financial end year for a supplementary bill run will come in later changes.

@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Mar 27, 2024
@Cruikshanks Cruikshanks self-assigned this Mar 27, 2024
https://eaflood.atlassian.net/browse/WATER-4403

We want our Billing & Data team to be able to generate supplementary bill runs all year round. However, at the moment they have to enforce a manual 'stop' on them until annual bill runs are completed. This is because of the 2 ways the engine operate.

Annual just bills for the current charge versions. It doesn't look at replaced charge versions or what was previously billed. supplementary does do these things. So, if the order is 'Annual -> Supplementary' then the bill will be correct. For example, supplementary calculates a debit of a £100 for a charge version (the licence was flagged for 'reasons'!) but sees the £100 debit from the annual bill. They cancel each other out so the customer sees nothing.

If the order was `Supplementary -> Annual` though, annual doesn't look back at previous transactions. It would just generate another debit to the customer for £100 leading to them being billed twice.

We could guarantee annual bills were raised on April 1 we wouldn't have a problem. However, because of the additional work that goes into preparing them and then validating the what the engine generates it can take some time. That leaves a window where a supplementary could be raised and the charges for a customer get messed up.

This has always been the case and billing & data have just had to deal with it by not generating supplementary. But that in itself causes problems because then bills start backing up that could be sent out.

So, this year we intend to solve the problem. We are going to amend our supplementary billing engine so that it will check if an annual bill run for the same region has been raised in the current billing period. If it has we'll carry on as usual. If it hasn't, we'll move the financial year end back to the first year where one was raised. This will allow B&D to crack on with supplementary bills, at least for previous years and prevent charging data being messed up.

The first step to achieving this is to refactor `DetermineBillingPeriods` to always expect a `year` and a `billRunType`. It can then use this information to generate the billing periods accordingly, rather than always from the current billing period.

> How we determine the financial end year for a supplementary bill run will come in later changes.
@Cruikshanks Cruikshanks force-pushed the update-determine-billing-periods branch from bb55777 to 23c39db Compare March 28, 2024 08:28
It now expects the bill run type and uses this information to decide how many billing periods to return and not the financial year.

This sets us up to be able to tell the service we need the billing periods for a supplementary bill run, but start in year X instead of the current financial year.
It now needs to pass in `batchType`.
Now we've refactored `DetermineBillingPeriodsService` to not just return a single billing period when financial year is set we can remove the temporary fix we did in [Fix determine billing periods](#859).
@Cruikshanks Cruikshanks marked this pull request as ready for review March 28, 2024 13:51
Cruikshanks added a commit that referenced this pull request Apr 1, 2024
https://eaflood.atlassian.net/browse/WATER-4403

We want our Billing & Data team to be able to generate supplementary bill runs all year round. However, at the moment they have to enforce a manual 'stop' on them until annual bill runs are completed. This is because of the 2 ways the engine operates.

Annual just bills for the current charge versions. It doesn't look at replaced charge versions or what was previously billed. supplementary does do these things. So, if the order is 'Annual -> Supplementary' then the bill will be correct. For example, supplementary calculates a debit of £100 for a charge version (the licence was flagged for 'reasons'!) but sees the £100 debit from the annual bill. They cancel each other out so the customer sees nothing.

If the order was `Supplementary -> Annual` though, annual doesn't look back at previous transactions. It would generate another debit to the customer for £100 leading to them being billed twice.

We could guarantee annual bills were raised on April 1 we wouldn't have a problem. However, the additional work that goes into preparing them and validating what the engine generates, means it can take some time. That leaves a window where a supplementary could be raised and the charges for a customer get messed up.

This has always been the case and billing & data have just had to deal with it by not generating supplementary. But that causes problems because bills start backing up that could be sent out.

So, this year we intend to solve the problem. We will amend our supplementary billing engine to check if an annual bill run for the same region has been raised in the current billing period. If it has we'll carry on as usual. If it hasn't, we'll move the financial year end back to the first year where one was raised. This will allow B&D to crack on with supplementary bills, at least for previous years and prevent charging data from being messed up.

The first step was to refactor [Refactor DetermineBillingPeriods to use type](#864). It can then use this information to generate the billing periods accordingly, rather than always from the current billing period.

Now that service will work appropriately if given a type and year we can implement determining _what_ that year is.
Cruikshanks added a commit that referenced this pull request Apr 2, 2024
https://eaflood.atlassian.net/browse/WATER-4403

We want our Billing & Data team to be able to generate supplementary bill runs all year round. However, at the moment they have to enforce a manual 'stop' on them until annual bill runs are completed. This is because of the 2 ways the engine operates.

Annual just bills for the current charge versions. It doesn't look at replaced charge versions or what was previously billed. supplementary does do these things. So, if the order is 'Annual -> Supplementary' then the bill will be correct. For example, supplementary calculates a debit of £100 for a charge version (the licence was flagged for 'reasons'!) but sees the £100 debit from the annual bill. They cancel each other out so the customer sees nothing.

If the order was `Supplementary -> Annual` though, annual doesn't look back at previous transactions. It would generate another debit to the customer for £100 leading to them being billed twice.

We could guarantee annual bills were raised on April 1 we wouldn't have a problem. However, the additional work that goes into preparing them and validating what the engine generates, means it can take some time. That leaves a window where a supplementary could be raised and the charges for a customer get messed up.

This has always been the case and billing & data have just had to deal with it by not generating supplementary. But that causes problems because bills start backing up that could be sent out.

So, this year we intend to solve the problem. We will amend our supplementary billing engine to check if an annual bill run for the same region has been raised in the current billing period. If it has we'll carry on as usual. If it hasn't, we'll move the financial year end back to the first year where one was raised. This will allow B&D to crack on with supplementary bills, at least for previous years and prevent charging data from being messed up.

The first step was to refactor [Refactor DetermineBillingPeriods to use type](#864). It can then use this information to generate the billing periods accordingly, rather than always from the current billing period.

Now that service will work appropriately if given a type and year we can implement determining _what_ that year is.
Cruikshanks added a commit that referenced this pull request Apr 2, 2024
https://eaflood.atlassian.net/browse/WATER-4403

In [Bump supplementary end year if no annual bill run](#875) we added logic that would mean when creating a new supplementary bill run the engine could tell if an annual bill run existed for the same year and region.

If one doesn't it will make a mess of the billing for customers if the supplementary happened before the annual. But we don't want to block users from working. So, instead we bump the financial end year to use back to the same as the last 'sent' annual bill run for that region.

We even [Refactor DetermineBillingPeriods to use type](#864) so it would know to use the calculated year when determining the billing periods for the supplementary bill run.

What we forgot to do was remove a [temporary fix](#859) we'd added until this work can be completed.

This means the year we've calculated is being dropped and not passed to `DetermineBillingPeriods`. This change fixes that!
@Cruikshanks Cruikshanks merged commit 01e2102 into main Apr 2, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the update-determine-billing-periods branch April 2, 2024 18:18
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