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

Tidy up two-part tariff review code and routes #1443

Merged
merged 152 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
0ebc51e
Tidy up Two-part tariff review code and routes
Cruikshanks Oct 22, 2024
0af33e2
Move main review page to new `/bill-runs/route`
Cruikshanks Oct 22, 2024
ccade8e
Update link to main review page from `/bill-runs`
Cruikshanks Oct 22, 2024
306ba61
Move the main review bill run modules into folder
Cruikshanks Oct 22, 2024
b9e9075
Move the main review page into review folder
Cruikshanks Oct 22, 2024
7a6aff8
Update cancel links to use new route
Cruikshanks Oct 22, 2024
961979a
Fix main review filter buttons POST action
Cruikshanks Oct 22, 2024
99f9dfb
Merge branch 'main' into tidy-up-two-part-tariff-review
Cruikshanks Oct 24, 2024
d646c7e
Move review licence page to `'/bill-runs/review`
Cruikshanks Oct 24, 2024
9f89759
Add review_licences.id to query
Cruikshanks Oct 24, 2024
5a84c59
Use the review licence ID for the link
Cruikshanks Oct 24, 2024
a22a808
Oops! Remove a .only()
Cruikshanks Oct 24, 2024
7fcb1d2
Move and replace review licence presenter
Cruikshanks Oct 28, 2024
7cd5607
Move and replace fetch review licence service
Cruikshanks Oct 28, 2024
a9ff4f9
Move and update review licence view
Cruikshanks Oct 28, 2024
c57ea03
Update Review licence service to use new modules
Cruikshanks Oct 28, 2024
459df42
Move Review chg ref page to '/bill-runs/review'
Cruikshanks Oct 28, 2024
03a7533
Merge branch 'main' into tidy-up-two-part-tariff-review
Cruikshanks Oct 28, 2024
67d9efd
Move Review licence service into review folder
Cruikshanks Oct 28, 2024
5ab585e
Move, rename and refactor review chg ref presenter
Cruikshanks Oct 29, 2024
0938c8d
Move and refactor Fetch review chg ref service
Cruikshanks Oct 29, 2024
e7e77a3
Move and refactor review chg ref view
Cruikshanks Oct 29, 2024
d0ad279
Move, rename and refactor Review chg ref service
Cruikshanks Oct 29, 2024
eb699e9
Update Bill Runs Review controller with changes
Cruikshanks Oct 29, 2024
9753eb7
Housekeeping - add missing JSDoc comments
Cruikshanks Oct 29, 2024
7c97b15
Housekeeping - update reference to module
Cruikshanks Oct 29, 2024
bf81f8e
Housekeeping - refactor to use existing lib method
Cruikshanks Oct 29, 2024
b1f4b71
Move chg ref factors page to /bill-runs/review
Cruikshanks Oct 29, 2024
614f176
Move, rename and refactor chg ref factors presenter
Cruikshanks Oct 29, 2024
b465d56
Move, rename & refactor chg ref factors service
Cruikshanks Oct 29, 2024
3113019
Move, rename, and refactor chg ref factors view
Cruikshanks Oct 29, 2024
af9c23b
Move, rename and refactor chg ref factors validator
Cruikshanks Oct 29, 2024
257497d
Move, rename & refactor chg ref factors submit
Cruikshanks Oct 29, 2024
c90ba10
Update chg ref factors controllers
Cruikshanks Oct 29, 2024
c8cf931
Housekeeping - fix indenting in view
Cruikshanks Oct 29, 2024
b666d8e
Housekeeping - remove redundant view code
Cruikshanks Oct 30, 2024
28907ed
Housekeeping - remove redundant views
Cruikshanks Oct 30, 2024
d338f73
Housekeeping - Missed rename in comments
Cruikshanks Oct 30, 2024
0e27aec
Housekeeping - property ordering
Cruikshanks Oct 30, 2024
5d2bc28
Housekeeping - Rename function to match property
Cruikshanks Oct 30, 2024
2e15ff5
Housekeeping - Missed rename in comments
Cruikshanks Oct 30, 2024
251c062
Housekeeping - correct typo in comments
Cruikshanks Oct 30, 2024
0668781
Move, rename & refactor chg ref authorised presenter
Cruikshanks Oct 30, 2024
6efdb1c
Move, rename & refactor chg ref authorised service
Cruikshanks Oct 30, 2024
eeb832b
Move, rename & refactor chg ref authorised view
Cruikshanks Oct 30, 2024
46f0811
Move, rename & refactor chg ref authorised validator
Cruikshanks Oct 30, 2024
97c64ca
Move, rename & refactor chg ref authorised submit
Cruikshanks Oct 30, 2024
c8656c8
Move chg ref authorised routes and controllers
Cruikshanks Oct 30, 2024
ff7021f
Remove redundant chg ref authorised fetch service
Cruikshanks Oct 30, 2024
09d9e3d
Merge branch 'main' into tidy-up-two-part-tariff-review
Cruikshanks Oct 30, 2024
1ff2ec6
Move, rename & refactor preview service
Cruikshanks Oct 30, 2024
7b9cf03
Update FetchReviewChargeReference to support preview
Cruikshanks Oct 30, 2024
d69f47e
Move chg ref preview routes and controllers
Cruikshanks Oct 30, 2024
05606cb
Housekeeping - Update path to module
Cruikshanks Oct 30, 2024
0e2b121
Housekeeping - Make back links consistent
Cruikshanks Oct 31, 2024
96040a1
Housekeeping - fix indentation
Cruikshanks Oct 31, 2024
c3599f6
Housekeeping - tidy up the view
Cruikshanks Oct 31, 2024
db601f7
Housekeeping - make Fetch service's reuse clearer
Cruikshanks Oct 31, 2024
2b21f81
Move, rename & refactor chg element presenter
Cruikshanks Oct 31, 2024
a544f6b
Move, rename & refactor fetch chg element service
Cruikshanks Oct 31, 2024
3d0fc35
Move, rename & refactor chg element service
Cruikshanks Oct 31, 2024
a5578de
Update review licence to pass thru element index
Cruikshanks Oct 31, 2024
4b33a99
Move, rename & refactor chg element view
Cruikshanks Oct 31, 2024
28d3c78
Move chg element routes & controllers to /review
Cruikshanks Oct 31, 2024
3bfa65d
Housekeeping - Make chg ref page title consistent
Cruikshanks Oct 31, 2024
28cb7a6
Move, rename & refactor chg element edit presenter
Cruikshanks Nov 3, 2024
d32171c
Move, rename & refactor chg element service
Cruikshanks Nov 3, 2024
303b842
Move, rename & refactor chg element edit view
Cruikshanks Nov 3, 2024
fdd44a4
Move, rename & refactor chg element edit validator
Cruikshanks Nov 3, 2024
349b12f
Move, rename & refactor chg element edit service
Cruikshanks Nov 3, 2024
a102bee
Move chg element routes & controllers to /review
Cruikshanks Nov 3, 2024
eb20738
Housekeeping - fix error in preview for £0 charge
Cruikshanks Nov 3, 2024
02429f8
Housekeeping - Tidy view element
Cruikshanks Nov 3, 2024
a5f4970
Housekeeping - tidy view
Cruikshanks Nov 3, 2024
c55ac74
Enable element index to with edit billable returns
Cruikshanks Nov 3, 2024
ceaa8e8
Move & refactor submit review licence service
Cruikshanks Nov 3, 2024
786e98d
Move, rename & refactor remove licence presenter
Cruikshanks Nov 3, 2024
2038cc3
Move, rename & refactor remove licence service
Cruikshanks Nov 3, 2024
7fe0cb0
Add new fetch service to get data for remove page
Cruikshanks Nov 3, 2024
25c8588
Move, rename & refactor remove licence view
Cruikshanks Nov 3, 2024
088c461
Move, rename & refactor remove licence data service
Cruikshanks Nov 3, 2024
5fd7b6f
Add new process bill run post remove licence service
Cruikshanks Nov 3, 2024
5bbe563
Move, rename & refactor remove licence submit
Cruikshanks Nov 3, 2024
9dce0ba
Move remove licence routes & controllers to /review
Cruikshanks Nov 3, 2024
6060621
Refactor review licence to link to remove licence
Cruikshanks Nov 3, 2024
285cf10
Add $formatChargePeriod instance method to model
Cruikshanks Nov 3, 2024
28e0b1e
Refactor presenters to use new instance method
Cruikshanks Nov 3, 2024
43c5c13
Create new base review presenter & add first helpler
Cruikshanks Nov 3, 2024
aaf317b
Merge branch 'main' into tidy-up-two-part-tariff-review
Cruikshanks Nov 3, 2024
ec4af06
Revert model change and move formatter to presenter
Cruikshanks Nov 4, 2024
2a693b7
Move total billable returns into base presenter
Cruikshanks Nov 4, 2024
e71efaa
Move additional charges and return link into base
Cruikshanks Nov 4, 2024
cbcf175
Move return status to base presenter
Cruikshanks Nov 4, 2024
e69585e
Move return total to base presenter
Cruikshanks Nov 4, 2024
15f9c36
Housekeeping - Update param in review link
Cruikshanks Nov 4, 2024
d5ba94b
Make controller names consistent with others
Cruikshanks Nov 4, 2024
2965760
Fix active nav bar
Cruikshanks Nov 4, 2024
e2569a3
Housekeeping - remove hard coded return reference
Cruikshanks Nov 6, 2024
b94b4b7
Fix issue handling
Cruikshanks Nov 6, 2024
e3c4368
Housekeeping - missed IDs in fetch queries
Cruikshanks Nov 6, 2024
818b6da
Fix FetchReviewLicenceService
Cruikshanks Nov 6, 2024
a8c2b12
Housekeeping - Delete unused field in fetch
Cruikshanks Nov 6, 2024
a3dcee4
Housekeeping - Correct typo in docs
Cruikshanks Nov 6, 2024
c2b65f2
Housekeeping - Correct mismatch in docs
Cruikshanks Nov 6, 2024
c3f8565
Housekeeping - Correct issues being null in helper
Cruikshanks Nov 6, 2024
5ab5cee
Housekeeping - Correct wrong name in JSDocs
Cruikshanks Nov 6, 2024
dfe75f1
Add fixture
Cruikshanks Nov 6, 2024
cd99b63
Move controller tests and update/tidy
Cruikshanks Nov 6, 2024
1e3eeaa
Add tests for our new base-review presenter
Cruikshanks Nov 6, 2024
8f06ff4
Move, rename & refactor authorised presenter test
Cruikshanks Nov 6, 2024
afaaca2
Move, rename & refactor edit presenter test
Cruikshanks Nov 6, 2024
c7b2899
Move, rename & refactor factors presenter test
Cruikshanks Nov 6, 2024
fabfe1c
Move, rename & refactor review chg ref presenter test
Cruikshanks Nov 6, 2024
fa8ee96
Move, rename & refactor review chg elmnt presenter test
Cruikshanks Nov 6, 2024
5be548e
Move, rename & refactor remove presenter test
Cruikshanks Nov 6, 2024
a276e6e
Move & refactor review licence presenter test
Cruikshanks Nov 6, 2024
d6967d7
Update review bill run presenter test
Cruikshanks Nov 6, 2024
6e8796b
Move, rename & refactor factors validator test
Cruikshanks Nov 6, 2024
e872f5b
Move & refactor authorised validator test
Cruikshanks Nov 6, 2024
4ffb429
Move, rename & refactor edit validator test
Cruikshanks Nov 6, 2024
c355e92
Move, rename & refactor authorised service test
Cruikshanks Nov 6, 2024
15bb0e9
Move, rename & refactor edit service test
Cruikshanks Nov 6, 2024
09fb5c4
Move, rename & refactor factors service test
Cruikshanks Nov 6, 2024
2291c94
Move, rename & refactor preview service test
Cruikshanks Nov 6, 2024
61bf653
Move, rename & refactor remove review licence service test
Cruikshanks Nov 6, 2024
8293a5f
Move, rename & refactor review chg ref service test
Cruikshanks Nov 6, 2024
bd5cbb2
Move, rename & refactor review chg elmnt service test
Cruikshanks Nov 6, 2024
965633b
Move, rename & refactor remove service test
Cruikshanks Nov 6, 2024
3b18151
Move, rename & refactor review licence service test
Cruikshanks Nov 6, 2024
90e8d2e
Move, rename & refactor fetch review licence service test
Cruikshanks Nov 6, 2024
5faa056
Move, rename & refactor fetch chg elmnt service test
Cruikshanks Nov 6, 2024
dc586ac
Move, rename & refactor review chg ref service test
Cruikshanks Nov 6, 2024
60ad24d
Add new fetch remove review licence service test
Cruikshanks Nov 6, 2024
cc8878b
Update fetch bill run licences service test
Cruikshanks Nov 6, 2024
868fb43
Update review bill run service test
Cruikshanks Nov 6, 2024
53512a9
Remove redundant fetch authorised volume service test
Cruikshanks Nov 6, 2024
57ebd41
Move, rename & refactor submit authorised test
Cruikshanks Nov 7, 2024
f936ce1
Move, rename & refactor submit edit test
Cruikshanks Nov 7, 2024
7e5cbb8
Move, rename & refactor submit factors test
Cruikshanks Nov 7, 2024
ab3d280
Move, rename & refactor submit remove test
Cruikshanks Nov 7, 2024
df06fcc
Update describe on submit review bill run test
Cruikshanks Nov 7, 2024
7c035e9
Add tests for new ProcessBillRunPostRemove service
Cruikshanks Nov 7, 2024
928a071
Move, rename & refactor submit review licence test
Cruikshanks Nov 7, 2024
95c8908
Housekeeping - fix missing service from filename
Cruikshanks Nov 7, 2024
03896ff
Housekeeping - second pass of the JSDocs
Cruikshanks Nov 7, 2024
b719624
Merge branch 'main' into tidy-up-two-part-tariff-review
Cruikshanks Nov 7, 2024
fbfe9ae
Add new base review formatter for adjustments
Cruikshanks Nov 7, 2024
88ba275
Update Factors presenter to use new formatter
Cruikshanks Nov 7, 2024
b971662
Update chg ref presenter to use new formatter
Cruikshanks Nov 7, 2024
d832c9e
Fixes and updates to support acceptance tests
Cruikshanks Nov 7, 2024
5140a55
Resolve sonarcloud issues with variable shadowing
Cruikshanks Nov 7, 2024
e581c0a
Fix broken tests
Cruikshanks Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 210 additions & 0 deletions app/controllers/bill-runs-review.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
'use strict'

/**
* Controller for /bill-runs/review endpoints
* @module BillRunsReviewController
*/

const AuthorisedService = require('../services/bill-runs/review/authorised.service.js')
const FactorsService = require('../services/bill-runs/review/factors.service.js')
const EditService = require('../services/bill-runs/review/edit.service.js')
const PreviewService = require('../services/bill-runs/review/preview.service.js')
const RemoveService = require('../services/bill-runs/review/remove.service.js')
const ReviewChargeElementService = require('../services/bill-runs/review/review-charge-element.service.js')
const ReviewChargeReferenceService = require('../services/bill-runs/review/review-charge-reference.service.js')
const ReviewBillRunService = require('../services/bill-runs/review/review-bill-run.service.js')
const ReviewLicenceService = require('../services/bill-runs/review/review-licence.service.js')
const SubmitAuthorisedService = require('../services/bill-runs/review/submit-authorised.service.js')
const SubmitEditService = require('..//services/bill-runs/review/submit-edit.service.js')
const SubmitFactorsService = require('../services/bill-runs/review/submit-factors.service.js')
const SubmitRemoveService = require('../services/bill-runs/review/submit-remove.service.js')
const SubmitReviewBillRunService = require('../services/bill-runs/review/submit-review-bill-run.service.js')
const SubmitReviewLicenceService = require('../services/bill-runs/review/submit-review-licence.service.js')

async function authorised (request, h) {
const { reviewChargeReferenceId } = request.params

const pageData = await AuthorisedService.go(reviewChargeReferenceId)

return h.view('bill-runs/review/authorised.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function edit (request, h) {
const { elementIndex, reviewChargeElementId } = request.params

const pageData = await EditService.go(reviewChargeElementId, elementIndex)

return h.view('bill-runs/review/edit.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function factors (request, h) {
const { reviewChargeReferenceId } = request.params

const pageData = await FactorsService.go(reviewChargeReferenceId)

return h.view('bill-runs/review/factors.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function preview (request, h) {
const { reviewChargeReferenceId } = request.params

await PreviewService.go(reviewChargeReferenceId, request.yar)

return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`)
}

async function remove (request, h) {
const { reviewLicenceId } = request.params

const pageData = await RemoveService.go(reviewLicenceId)

return h.view('bill-runs/review/remove.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function reviewBillRun (request, h) {
const { billRunId } = request.params
const { page } = request.query

const pageData = await ReviewBillRunService.go(billRunId, page, request.yar)

return h.view('bill-runs/review/review.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function reviewChargeElement (request, h) {
const { elementIndex, reviewChargeElementId } = request.params

const pageData = await ReviewChargeElementService.go(reviewChargeElementId, elementIndex, request.yar)

return h.view('bill-runs/review/review-charge-element.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function reviewChargeReference (request, h) {
const { reviewChargeReferenceId } = request.params

const pageData = await ReviewChargeReferenceService.go(reviewChargeReferenceId, request.yar)

return h.view('bill-runs/review/review-charge-reference.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function reviewLicence (request, h) {
const { reviewLicenceId } = request.params

const pageData = await ReviewLicenceService.go(reviewLicenceId, request.yar)

return h.view('bill-runs/review/review-licence.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

async function submitAuthorised (request, h) {
const { reviewChargeReferenceId } = request.params
const pageData = await SubmitAuthorisedService.go(reviewChargeReferenceId, request.yar, request.payload)

if (pageData.error) {
return h.view('bill-runs/review/authorised.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`)
}

async function submitEdit (request, h) {
const { elementIndex, reviewChargeElementId } = request.params

const pageData = await SubmitEditService.go(
reviewChargeElementId, elementIndex, request.yar, request.payload
)

if (pageData.error) {
return h.view('bill-runs/review/edit.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

return h.redirect(`/system/bill-runs/review/charge-element/${reviewChargeElementId}/${elementIndex}`)
}

async function submitFactors (request, h) {
const { reviewChargeReferenceId } = request.params
const pageData = await SubmitFactorsService.go(reviewChargeReferenceId, request.yar, request.payload)

if (pageData.error) {
return h.view('bill-runs/review/factors.njk', {
activeNavBar: 'bill-runs',
...pageData
})
}

return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`)
}

async function submitRemove (request, h) {
const { reviewLicenceId } = request.params

const result = await SubmitRemoveService.go(reviewLicenceId, request.yar)

if (result.empty) {
return h.redirect('/system/bill-runs')
}

return h.redirect(`/system/bill-runs/review/${result.billRunId}`)
}

async function submitReviewBillRun (request, h) {
const { billRunId } = request.params

await SubmitReviewBillRunService.go(billRunId, request.payload, request.yar)

return h.redirect(`/system/bill-runs/review/${billRunId}`)
}

async function submitReviewLicence (request, h) {
const { reviewLicenceId } = request.params

await SubmitReviewLicenceService.go(reviewLicenceId, request.yar, request.payload)

return h.redirect(`/system/bill-runs/review/licence/${reviewLicenceId}`)
}

module.exports = {
authorised,
edit,
factors,
preview,
remove,
reviewBillRun,
reviewChargeElement,
reviewChargeReference,
reviewLicence,
submitAuthorised,
submitEdit,
submitFactors,
submitRemove,
submitReviewBillRun,
submitReviewLicence
}
Loading
Loading