-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace live bill run checking in engine (#843)
https://eaflood.atlassian.net/browse/WATER-4416 https://eaflood.atlassian.net/browse/WATER-4379 We spotted an issue with removing a bill from a bill run and it not setting the supplementary flags on the licences involved correctly. We've fixed that, but it's led to our QA team rigorously re-creating bill runs over and over. Doing this they spotted we did have an issue with the `CheckLiveBillRunService` that we fixed in [Fix broken CheckLiveBillRunService](#841). Now they've spotted something else. `CheckLiveBillRunService` includes batch type as a filter. This means it _will_ allow you to create a supplementary bill run, for example, even if another type of bill run is 'in progress' (queued, processing, or ready). At the time we thought that was ok but now we know better. We spotted this in our work to migrate the setup bill run journey (see [Handle bill run setup matches an existing bill run](#810)). We hoped we'd be using our version of the journey by now and we could quietly retire `CheckLiveBillRunService` as part of ongoing maintenance and no one would be any the wiser (it has been live for 7 months now!) However, our QA team would rather clear the issues currently found before bringing in the new setup journey for testing. So, rather than fix the service, we'll replace it with `DetermineBlockingBillRunService` which matches what the legacy service does and deals with this scenario.
- Loading branch information
1 parent
259be13
commit 81abc4c
Showing
12 changed files
with
54 additions
and
201 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
114 changes: 0 additions & 114 deletions
114
test/services/bill-runs/check-live-bill-run.service.test.js
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,17 @@ const RegionHelper = require('../../support/helpers/region.helper.js') | |
|
||
// Things we need to stub | ||
const ChargingModuleCreateBillRunRequest = require('../../../app/requests/charging-module/create-bill-run.request.js') | ||
const CheckLiveBillRunService = require('../../../app/services/bill-runs/check-live-bill-run.service.js') | ||
const DetermineBlockingBillRunService = require('../../../app/services/bill-runs/determine-blocking-bill-run.service.js') | ||
const SupplementaryProcessBillRunService = require('../../../app/services/bill-runs/supplementary/process-bill-run.service.js') | ||
|
||
// Thing under test | ||
const InitiateBillRunService = require('../../../app/services/bill-runs/initiate-bill-run.service.js') | ||
|
||
describe('Initiate Bill Run service', () => { | ||
const batchType = 'supplementary' | ||
const financialYearEndings = { fromFinancialYearEnding: 2023, toFinancialYearEnding: 2024 } | ||
const user = '[email protected]' | ||
|
||
let batchType | ||
let regionId | ||
|
||
beforeEach(async () => { | ||
|
@@ -34,8 +35,6 @@ describe('Initiate Bill Run service', () => { | |
const region = await RegionHelper.add() | ||
regionId = region.id | ||
|
||
Sinon.stub(CheckLiveBillRunService, 'go').resolves(false) | ||
|
||
// The InitiateBillRun service does not await the call to the ProcessBillRunService. It is intended to | ||
// kick of the process and then move on. This is why we simply stub it in the tests. | ||
Sinon.stub(SupplementaryProcessBillRunService, 'go') | ||
|
@@ -54,6 +53,10 @@ describe('Initiate Bill Run service', () => { | |
} | ||
|
||
beforeEach(() => { | ||
batchType = 'supplementary' | ||
|
||
Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([]) | ||
|
||
Sinon.stub(ChargingModuleCreateBillRunRequest, 'send').resolves({ | ||
succeeded: true, | ||
response: { | ||
|
@@ -101,6 +104,8 @@ describe('Initiate Bill Run service', () => { | |
describe('when initiating a bill run fails', () => { | ||
describe('because a bill run could not be created in the Charging Module', () => { | ||
beforeEach(() => { | ||
Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([]) | ||
|
||
Sinon.stub(ChargingModuleCreateBillRunRequest, 'send').resolves({ | ||
succeeded: false, | ||
response: { | ||
|
@@ -132,17 +137,19 @@ describe('Initiate Bill Run service', () => { | |
}) | ||
}) | ||
|
||
describe('because a bill run already exists for this region, financial year and type', () => { | ||
describe('because a live bill run already exists for this region, financial year and type', () => { | ||
beforeEach(() => { | ||
CheckLiveBillRunService.go.resolves(true) | ||
batchType = 'annual' | ||
|
||
Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([{ id: 'becf430d-f6dd-45a3-b943-42683f7bb889' }]) | ||
}) | ||
|
||
it('rejects with an appropriate error', async () => { | ||
const err = await expect(InitiateBillRunService.go(financialYearEndings, regionId, batchType, user)).to.reject() | ||
|
||
expect(err).to.be.an.error() | ||
expect(err.message).to.equal('Batch already live for region') | ||
expect(err.regionId).to.equal(regionId) | ||
expect(err.billRunId).to.equal('becf430d-f6dd-45a3-b943-42683f7bb889') | ||
}) | ||
}) | ||
}) | ||
|
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