Skip to content

Commit

Permalink
Merge branch 'main' into return-cycle-dates-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
robertparkinson authored Oct 22, 2024
2 parents 6c3beb2 + 606a8ec commit c6769e6
Show file tree
Hide file tree
Showing 219 changed files with 1,687 additions and 1,247 deletions.
32 changes: 30 additions & 2 deletions app/controllers/check.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,36 @@
* @module CheckController
*/

const DetermineSupplementaryBillingFlagsService = require('../services/import/determine-supplementary-billing-flags.service.js')
const ProcessLicenceReturnLogsService = require('../services/jobs/return-logs/process-licence-return-logs.service.js')

const redirectStatusCode = 204
const NO_CONTENT_STATUS_CODE = 204

/**
* A test end point for the licence supplementary billing flags process
*
* This endpoint takes a licenceId and an expired, lapsed and revoked date. It passes this onto the
* `DetermineSupplementaryBillingFlagsService` to test if it correctly flags the licence for supplementary billing. This
* normally happens during the licence import process.
*
* @param request - the hapi request object
* @param h - the hapi response object
*
* @returns {Promise<object>} - A promise that resolves to an HTTP response object with a 204 status code
*/
async function flagForBilling (request, h) {
const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload

const transformedLicence = {
expiredDate,
lapsedDate,
revokedDate
}

await DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId)

return h.response().code(NO_CONTENT_STATUS_CODE)
}

/**
* A test end point to create return logs for a given licence reference
Expand All @@ -28,9 +55,10 @@ async function returnLogsForLicence (_request, h) {

ProcessLicenceReturnLogsService.go(licenceReference)

return h.response().code(redirectStatusCode)
return h.response().code(NO_CONTENT_STATUS_CODE)
}

module.exports = {
flagForBilling,
returnLogsForLicence
}
6 changes: 3 additions & 3 deletions app/controllers/licences.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module LicencesController
*/

const InitiateSessionService = require('../services/return-requirements/setup/initiate-session.service.js')
const InitiateSessionService = require('../services/return-versions/setup/initiate-session.service.js')
const LicenceSupplementaryProcessBillingFlagService = require('../services/licences/supplementary/process-billing-flag.service.js')
const MarkedForSupplementaryBillingService = require('../services/licences/supplementary/marked-for-supplementary-billing.service.js')
const MarkForSupplementaryBillingService = require('../services/licences/supplementary/mark-for-supplementary-billing.service.js')
Expand Down Expand Up @@ -50,15 +50,15 @@ async function noReturnsRequired (request, h) {

const session = await InitiateSessionService.go(id, 'no-returns-required')

return h.redirect(`/system/return-requirements/setup/${session.id}/start-date`)
return h.redirect(`/system/return-versions/setup/${session.id}/start-date`)
}

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

const session = await InitiateSessionService.go(id, 'returns-required')

return h.redirect(`/system/return-requirements/setup/${session.id}/start-date`)
return h.redirect(`/system/return-versions/setup/${session.id}/start-date`)
}

async function submitMarkForSupplementaryBilling (request, h) {
Expand Down
21 changes: 0 additions & 21 deletions app/controllers/return-requirements.controller.js

This file was deleted.

Loading

0 comments on commit c6769e6

Please sign in to comment.