Skip to content

Commit

Permalink
Merge branch 'main' into view-licence-contact-details-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks authored May 13, 2024
2 parents ab3c5bd + c2e165d commit fc84d51
Show file tree
Hide file tree
Showing 10 changed files with 635 additions and 168 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = {
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreUrls: true
}]
}],
'import/extensions': ['error', 'always']
}
}

Expand Down
38 changes: 24 additions & 14 deletions app/controllers/bill-runs.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const StartBillRunProcessService = require('../services/bill-runs/start-bill-run
const SubmitAmendedBillableReturnsService = require('..//services/bill-runs/two-part-tariff/submit-amended-billable-returns.service.js')
const SubmitCancelBillRunService = require('../services/bill-runs/submit-cancel-bill-run.service.js')
const SubmitRemoveBillRunLicenceService = require('../services/bill-runs/two-part-tariff/submit-remove-bill-run-licence.service.js')
const SubmitReviewBillRunService = require('../services/bill-runs/two-part-tariff/submit-review-bill-run.service.js')
const SubmitReviewLicenceService = require('../services/bill-runs/two-part-tariff/submit-review-licence.service.js')
const SubmitSendBillRunService = require('../services/bill-runs/submit-send-bill-run.service.js')
const ViewBillRunService = require('../services/bill-runs/view-bill-run.service.js')
Expand Down Expand Up @@ -49,6 +50,18 @@ async function cancel (request, h) {
})
}

async function chargeReferenceDetails (request, h) {
const { id: billRunId, licenceId, reviewChargeReferenceId } = request.params

const pageData = await ChargeReferenceDetailsService.go(billRunId, licenceId, reviewChargeReferenceId)

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

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

Expand Down Expand Up @@ -102,7 +115,7 @@ async function removeLicence (request, h) {

async function review (request, h) {
const { id } = request.params
const pageData = await ReviewBillRunService.go(id, request.payload, request.yar)
const pageData = await ReviewBillRunService.go(id, request.yar)

return h.view('bill-runs/review.njk', {
pageTitle: 'Review licences',
Expand All @@ -111,18 +124,6 @@ async function review (request, h) {
})
}

async function chargeReferenceDetails (request, h) {
const { id: billRunId, licenceId, reviewChargeReferenceId } = request.params

const pageData = await ChargeReferenceDetailsService.go(billRunId, licenceId, reviewChargeReferenceId)

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

async function reviewLicence (request, h) {
const { id: billRunId, licenceId } = request.params

Expand Down Expand Up @@ -191,6 +192,14 @@ async function submitRemoveLicence (request, h) {
return h.redirect(`/system/bill-runs/${billRunId}/review`)
}

async function submitReview (request, h) {
const { id } = request.params

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

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

async function submitReviewLicence (request, h) {
const { id: billRunId, licenceId } = request.params

Expand Down Expand Up @@ -228,16 +237,17 @@ async function view (request, h) {
module.exports = {
amendBillableReturns,
cancel,
chargeReferenceDetails,
create,
index,
matchDetails,
removeLicence,
review,
chargeReferenceDetails,
reviewLicence,
send,
submitAmendedBillableReturns,
submitCancel,
submitReview,
submitRemoveLicence,
submitReviewLicence,
submitSend,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/bill-runs.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const routes = [
{
method: 'POST',
path: '/bill-runs/{id}/review',
handler: BillRunsController.review,
handler: BillRunsController.submitReview,
options: {
auth: {
access: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const ReviewBillRunPresenter = require('../../../presenters/bill-runs/two-part-t
* Orchestrates fetching and presenting the data needed for the review bill run page
*
* @param {String} id The UUID for the bill run to review
* @param {Object} payload The `request.payload` containing the filter data. This is only passed to the service when
* there is a POST request, which only occurs when a filter is applied to the results.
* @param {Object} yar - The Hapi `request.yar` session manager passed on by the controller
*
* @returns {Promise<Object>} An object representing the `pageData` needed by the review bill run template. It contains
* details of the bill run and the licences linked to it as well as any data that has been used to filter the results.
*/
async function go (id, payload, yar) {
const filterIssues = payload?.filterIssues
const filterLicenceHolder = payload?.filterLicenceHolder
const filterLicenceStatus = payload?.filterLicenceStatus
async function go (id, yar) {
const filters = yar.get('reviewFilters')

const filterIssues = filters?.filterIssues
const filterLicenceHolder = filters?.filterLicenceHolder
const filterLicenceStatus = filters?.filterLicenceStatus

const { billRun, licences } = await FetchBillRunLicencesService.go(
id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict'

/**
* Updates the session cookie with the filter data needed for the two-part tariff review bill run page
* @module SubmitReviewBillRunService
*/

/**
* Updates the session cookie with the filter data needed for the two-part tariff review bill run page
*
* @param {Object} payload The `request.payload` containing the filter data.
* @param {Object} yar - The Hapi `request.yar` session manager passed on by the controller
*/
async function go (payload, yar) {
const clearFilters = payload?.clearFilters
const filterIssues = payload?.filterIssues
const filterLicenceHolder = payload?.filterLicenceHolder
const filterLicenceStatus = payload?.filterLicenceStatus

if (clearFilters) {
yar.clear('reviewFilters')
} else {
yar.set('reviewFilters', {
filterIssues,
filterLicenceHolder,
filterLicenceStatus
})
}
}

module.exports = {
go
}
3 changes: 1 addition & 2 deletions app/views/bill-runs/review.njk
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@
text: "Clear filters",
classes: "govuk-button--secondary ",
name: "clearFilters",
type: "reset",
href: "review",
value: 'reset',
preventDoubleClick: true
}) }}
</div>
Expand Down
Loading

0 comments on commit fc84d51

Please sign in to comment.