Skip to content

Commit

Permalink
Remove POST create bill run route (#1418)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4201

When we first added SROC supplementary billing to this project, creation of the bill run was triggered from [water-abstraction-ui](https://github.com/DEFRA/water-abstraction-ui).

Later, we added SROC two-part tariff annual billing. That required a change to the create bill run journey, so we took the opportunity to migrate it to this project.

This means we no longer expect the legacy UI to trigger bill runs. The endpoint it was using is now defunct. But also, it means we can simplify our bill run creation/initialisation logic because we no longer have to consider two trigger points.

We have been working on SROC two-part tariff supplementary recently. We're ready to stitch all the pieces we've built together, the first step being triggering the bill run. Our journey now includes the option, but it hasn't been updated to check whether a user can create a two-part tariff supplementary bill run (based on the state of existing bill runs).

That will complicate the create/initiate process even more. So, as a preparatory step, we're simplifying things first by dropping the old POST create bill run route.
  • Loading branch information
Cruikshanks authored Oct 17, 2024
1 parent 29eea30 commit 6135ba0
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 347 deletions.
20 changes: 0 additions & 20 deletions app/controllers/bill-runs.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ const AmendBillableReturnsService = require('../services/bill-runs/two-part-tari
const CalculateChargeService = require('../services/bill-runs/two-part-tariff/calculate-charge.service.js')
const CancelBillRunService = require('../services/bill-runs/cancel-bill-run.service.js')
const ChargeReferenceDetailsService = require('../services/bill-runs/two-part-tariff/charge-reference-details.service.js')
const CreateBillRunValidator = require('../validators/create-bill-run.validator.js')
const GenerateBillRunService = require('../services/bill-runs/two-part-tariff/generate-bill-run.service.js')
const IndexBillRunsService = require('../services/bill-runs/index-bill-runs.service.js')
const MatchDetailsService = require('../services/bill-runs/two-part-tariff/match-details.service.js')
const RemoveBillRunLicenceService = require('../services/bill-runs/two-part-tariff/remove-bill-run-licence.service.js')
const ReviewBillRunService = require('../services/bill-runs/two-part-tariff/review-bill-run.service.js')
const ReviewLicenceService = require('../services/bill-runs/two-part-tariff/review-licence.service.js')
const SendBillRunService = require('../services/bill-runs/send-bill-run.service.js')
const StartBillRunProcessService = require('../services/bill-runs/start-bill-run-process.service.js')
const SubmitAmendedAdjustmentFactorService = require('../services/bill-runs/two-part-tariff/submit-amended-adjustment-factor.service.js')
const SubmitAmendedAuthorisedVolumeService = require('../services/bill-runs/two-part-tariff/submit-amended-authorised-volume.service.js')
const SubmitAmendedBillableReturnsService = require('..//services/bill-runs/two-part-tariff/submit-amended-billable-returns.service.js')
Expand Down Expand Up @@ -92,23 +90,6 @@ async function chargeReferenceDetails (request, h) {
})
}

async function create (request, h) {
const validatedData = CreateBillRunValidator.go(request.payload)

if (validatedData.error) {
return Boom.badRequest(validatedData.error.details[0].message)
}

try {
const { region, type, user, financialYearEnding } = validatedData.value
const result = await StartBillRunProcessService.go(region, type, user, financialYearEnding)

return h.response(result).code(200)
} catch (error) {
return Boom.badImplementation(error.message)
}
}

async function index (request, h) {
const { page } = request.query

Expand Down Expand Up @@ -328,7 +309,6 @@ module.exports = {
amendBillableReturns,
cancel,
chargeReferenceDetails,
create,
index,
matchDetails,
previewCharge,
Expand Down
15 changes: 0 additions & 15 deletions app/routes/bill-runs.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ const routes = [
}
}
},
{
method: 'POST',
path: '/bill-runs',
options: {
handler: BillRunsController.create,
app: {
plainOutput: true
},
auth: {
access: {
scope: ['billing']
}
}
}
},
{
method: 'GET',
path: '/bill-runs/{id}',
Expand Down
29 changes: 0 additions & 29 deletions app/validators/create-bill-run.validator.js

This file was deleted.

68 changes: 0 additions & 68 deletions test/controllers/bill-runs.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const RemoveBillRunLicenceService = require('../../app/services/bill-runs/two-pa
const ReviewBillRunService = require('../../app/services/bill-runs/two-part-tariff/review-bill-run.service.js')
const ReviewLicenceService = require('../../app/services/bill-runs/two-part-tariff/review-licence.service.js')
const SendBillRunService = require('../../app/services/bill-runs/send-bill-run.service.js')
const StartBillRunProcessService = require('../../app/services/bill-runs/start-bill-run-process.service.js')
const SubmitAmendedAdjustmentFactorService = require('../../app/services/bill-runs/two-part-tariff/submit-amended-adjustment-factor.service.js')
const SubmitAmendedAuthorisedVolumeService = require('../../app/services/bill-runs/two-part-tariff/submit-amended-authorised-volume.service.js')
const SubmitAmendedBillableReturnsService = require('../../app/services/bill-runs/two-part-tariff/submit-amended-billable-returns.service.js')
Expand Down Expand Up @@ -115,73 +114,6 @@ describe('Bill Runs controller', () => {
})
})
})

describe('POST', () => {
beforeEach(() => {
options = postRequestOptions(
'/bill-runs',
{
type: 'supplementary',
scheme: 'sroc',
region: '07ae7f3a-2677-4102-b352-cc006828948c',
user: '[email protected]'
}
)
})

describe('when a request is valid', () => {
const validResponse = {
id: 'f561990b-b29a-42f4-b71a-398c52339f78',
region: '07ae7f3a-2677-4102-b352-cc006828948c',
scheme: 'sroc',
batchType: 'supplementary',
status: 'processing'
}

beforeEach(async () => {
Sinon.stub(StartBillRunProcessService, 'go').resolves(validResponse)
})

it('returns a 200 response including details of the new bill run', async () => {
const response = await server.inject(options)
const payload = JSON.parse(response.payload)

expect(response.statusCode).to.equal(200)
expect(payload).to.equal(validResponse)
})
})

describe('when the request fails', () => {
describe('because the request is invalid', () => {
beforeEach(() => {
options.payload.scheme = 'INVALID'
})

it('returns an error response', async () => {
const response = await server.inject(options)
const payload = JSON.parse(response.payload)

expect(response.statusCode).to.equal(400)
expect(payload.message).to.startWith('"scheme" must be')
})
})

describe('because the bill run could not be initiated', () => {
beforeEach(async () => {
Sinon.stub(Boom, 'badImplementation').returns(new Boom.Boom('Bang', { statusCode: 500 }))
Sinon.stub(StartBillRunProcessService, 'go').rejects()
})

it('returns an error response', async () => {
const response = await server.inject(options)
const payload = JSON.parse(response.payload)

expect(response.statusCode).to.equal(500)
expect(payload.message).to.equal('An internal server error occurred')
})
})
})
})
})

describe('/bill-runs/{id}', () => {
Expand Down
215 changes: 0 additions & 215 deletions test/validators/create-bill-run.validator.test.js

This file was deleted.

0 comments on commit 6135ba0

Please sign in to comment.