-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update tests due to supplementary year bump #86
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://eaflood.atlassian.net/browse/WATER-4403 In [Bump supplementary end year if no annual bill run](DEFRA/water-abstraction-system#875) we amended our billing engine for supplementary. We made it possible for users to generate supplementary bill runs in years where no annual has yet been created and sent. Previously, the Billing & Data team would have to put a block on creating bill runs until the annuals were generated. This is because supplementary takes into account previous transactions whereas annual doesn't. Without the change creating a supplementary followed by an annual bill run would result in the customer getting charged twice. We now determine when the last annual bill run was sent and use its financial end year as the end year for the supplementary bill run. Annual created in this billing period? Then the supplementary will start there and work back 5 years. If the last sent annual was for the previous billing period the supplementary will start _there_ and work back 5 years. The problem is this means our billing engine is working on the assumption there is _always_ at least one 'sent' annual bill run for a region. This is definitely the case in our live service but not in our test setup. We've made changes to our [acceptance test fixture setup](DEFRA/water-abstraction-service#2484) to ensure we always create an annual as part of our SROC test fixture. These changes cover any other tweaks needed to get the existing tests working.
It was 'cheating' before by using a test data fixture that would result in empty bill runs. Because we have only added the annual bill run entry to our SROC data fixture we need to switch it to use that and update the tests accordingly.
Cruikshanks
added
the
housekeeping
Refactoring, tidying up or other work which supports the project
label
Apr 5, 2024
The issue is that having moved into 2024-25 we've hit a point where part of the PRESROC charge version is no longer included in the bill run. It starts on Jan 1 2019. When the billing period was 2023-24 five years prior to that year would include the billing period 2018-19. This means there would be 4 supplementary bills with the first just being for the period 2019-01-01 to 2019-03-31. Now the billing period is 2024-25 the period 2018-2019 has dropped off. This means 1 less bill which also effects the bill run total.
Moving into a new billing period means the number of billable days being calculated is different which has a knock on effect to all the values.
This corrects a faulty assumption in the test, put there no doubt because of a copy and paste. Once we add the new charge version for the current year and then create the second SRO supplementary, with no other changes we should only ever see 2 bills; the credit for the previous and the debit for the new account. But we were using the number returned from our logic which works out how many bills we expect to see based on the number of billing periods since 2022. It worked when running the tests in 2023-24 because the result was also 2. Now we are in 2024-25 its exposed the faulty logic.
We had overlooked that the annual billing tests were using the `sroc-billing-data` fixture as well. Adding an annual bill run to that fixture causes the annual test to fail due to there be an existing bill run. It was a simple fix in [water-abstraction-service](https://github.com/DEFRA/water-abstraction-service). We just needed to add in a copy of the fixture set without the annual bill run. But to make things clearer we've renamed the 3 sets hence the need to go back through all our tests and update the references.
This new test gives us a means to check that the supplementary end year bump feature is working. It uses a new SROC fixture that is the same as our normal one only the annual bill run created is for the previous billing period. This means we can confirm when we create an SROC supplementary that its financial year end is also for the previous billing period.
We realised that we could use the 'previous' fixture both for our new supplementary test and the annual tests. This saves a bunch of duplication in the integration sets. It still creates a bill run but it is for the previous year. If anything it's a more robust way of checking that bill runs in previous billing periods shouldn't prevent a new one from being created.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4403
In Bump supplementary end year if no annual bill run we amended our billing engine for supplementary. We made it possible for users to generate supplementary bill runs in years where no annual has yet been created and sent.
Previously, the Billing & Data team would have to put a block on creating bill runs until the annuals were generated. This is because supplementary takes into account previous transactions whereas annual doesn't. Without the change creating a supplementary followed by an annual bill run would result in the customer getting charged twice.
We now determine when the last annual bill run was sent and use its financial end year as the end year for the supplementary bill run. Annual created in this billing period? Then the supplementary will start there and work back 5 years. If the last sent annual was for the previous billing period the supplementary will start there and work back 5 years.
The problem is this means our billing engine is working on the assumption there is always at least one 'sent' annual bill run for a region. This is the case in our live service but not in our test setup.
We've made changes to our acceptance test fixture setup to ensure we always create an annual as part of our SROC test fixture. These changes cover any other tweaks needed to get the existing tests working.
Notes on the changes
cypress/e2e/internal/billing/supplementary/cancel-existing.cy.js
It was 'cheating' before by using a two-part tariff test fixture that would result in empty bill runs. We have only added the annual bill run entry to our SROC data fixture so we needed to switch it to use that and update the assertions accordingly.
Having moved into 2024-25 we've hit a point where part of the PRESROC charge version is no longer included in the bill run.
It starts on Jan 1 2019. When the billing period was 2023-24 five years before that year it would include the billing period 2018-19. This means there would be 4 supplementary bills with the first just being for 2019-01-01 to 2019-03-31.
Now the billing period is 2024-25 the period 2018-2019 has dropped off. This means 1 less bill which affects the bill run total.
internal/billing/supplementary/replace-cv-current-year-with-changes.cy.js
Moving into a new billing period means the number of billable days being calculated is different which affects the values being asserted.
internal/billing/supplementary/change-billing-account-current-year.cy.js
This corrects a faulty assumption in the test, put there no doubt because of a copy and paste. Once we add the new charge version for the current year and then create the second SRO supplementary, with no other changes we should only see 2 bills; the credit for the previous one and the debit for the new account.
But we were using the number returned from our logic which works out how many bills we expect to see based on the number of billing periods since 2022. It worked when running the tests in 2023-24 because the result was also 2. Now we are in 2024-25 it's exposed the faulty logic.
We had overlooked that the annual billing tests were using the
sroc-billing-data
fixture as well. Adding an annual bill run to that fixture caused the annual tests to fail because of the existing bill run.We realised that we could use the 'previous' fixture we created as part of these changes both for our new supplementary test and the annual tests. This saves a bunch of duplication in the integration sets. It still creates a bill run but it is for the previous year. If anything it's a more robust way of checking that bill runs in previous billing periods shouldn't prevent a new one from being created.
This new test gives us a means to check that the supplementary end-year bump feature is working. It uses a new SROC fixture that is the same as our normal one only the annual bill run created is for the previous billing period.
This means we can confirm when we create an SROC supplementary that its financial year end is also for the previous billing period.