From ba655eb54120709bde50dead7526dab1921b27c9 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 21 Oct 2024 12:12:26 +0100 Subject: [PATCH 1/6] Licence Import Supplementary billing test endpoint https://eaflood.atlassian.net/browse/WATER-4591 Due to the fact the above ticket is happening during the licence import (which is automated), we need to add a test endpoint to allow the QA team to test the new supplementary flagging functionality. The process of flagging a licence for supplementary billing only happens if there is a new end date added to the licence (lapsed, expired or revoked). The imported licence is looking at NALD data, so built into our testing endpoint is functionality that means you can pass a new licence end date and it will act as though that is the imported NALD data. From cb1fb173b07dab2695e0dc1169a3eb04e4dad7a7 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 21 Oct 2024 14:25:25 +0100 Subject: [PATCH 2/6] Add testing endpoint --- app/controllers/data.controller.js | 16 ++++++++++++++++ app/routes/data.routes.js | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/controllers/data.controller.js b/app/controllers/data.controller.js index c26fe2d5bf..ee840bb199 100644 --- a/app/controllers/data.controller.js +++ b/app/controllers/data.controller.js @@ -5,6 +5,7 @@ * @module DataController */ +const DetermineSupplementaryBillingFlagsService = require('../services/import/determine-supplementary-billing-flags.service.js') const LoadService = require('../services/data/load/load.service.js') const SeedService = require('../services/data/seed/seed.service.js') const SubmitDeduplicateService = require('../services/data/deduplicate/submit-deduplicate.service.js') @@ -17,6 +18,20 @@ async function deduplicate (_request, h) { }) } +async function flagForBilling (request, h) { + const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload + + const transformedLicence = { + expiredDate, + lapsedDate, + revokedDate + } + + DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) + + return h.response().code(204) +} + async function load (request, h) { const result = await LoadService.go(request.payload) @@ -51,6 +66,7 @@ async function tearDown (_request, h) { module.exports = { deduplicate, + flagForBilling, load, seed, submitDeduplicate, diff --git a/app/routes/data.routes.js b/app/routes/data.routes.js index e07d0a1625..0d1b1b5bff 100644 --- a/app/routes/data.routes.js +++ b/app/routes/data.routes.js @@ -27,6 +27,21 @@ const routes = [ } } }, + { + method: 'POST', + path: '/data/flag-for-billing', + options: { + handler: DataController.flagForBilling, + app: { + excludeFromProd: true, + plainOutput: true + }, + auth: false, + plugins: { + crumb: false + } + } + }, { method: 'POST', path: '/data/load', From 1a22aa19e1fbd5e4c504ea9b57114b41439866ba Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 21 Oct 2024 16:41:17 +0100 Subject: [PATCH 3/6] Update to check route and controller --- app/controllers/check.controller.js | 28 ++++++++++++++++++++++++++++ app/controllers/data.controller.js | 16 ---------------- app/routes/check.routes.js | 15 +++++++++++++++ app/routes/data.routes.js | 15 --------------- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/app/controllers/check.controller.js b/app/controllers/check.controller.js index 1420fb0ad8..5f3bb51d08 100644 --- a/app/controllers/check.controller.js +++ b/app/controllers/check.controller.js @@ -5,10 +5,37 @@ * @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 +/** + * A test end point for the licence supplementary billing flags process + * + * This endpoint takes a licenceId and licence 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} - 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 + } + + DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) + + return h.response().code(204) +} + /** * A test end point to create return logs for a given licence reference * @@ -32,5 +59,6 @@ async function returnLogsForLicence (_request, h) { } module.exports = { + flagForBilling, returnLogsForLicence } diff --git a/app/controllers/data.controller.js b/app/controllers/data.controller.js index ee840bb199..c26fe2d5bf 100644 --- a/app/controllers/data.controller.js +++ b/app/controllers/data.controller.js @@ -5,7 +5,6 @@ * @module DataController */ -const DetermineSupplementaryBillingFlagsService = require('../services/import/determine-supplementary-billing-flags.service.js') const LoadService = require('../services/data/load/load.service.js') const SeedService = require('../services/data/seed/seed.service.js') const SubmitDeduplicateService = require('../services/data/deduplicate/submit-deduplicate.service.js') @@ -18,20 +17,6 @@ async function deduplicate (_request, h) { }) } -async function flagForBilling (request, h) { - const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload - - const transformedLicence = { - expiredDate, - lapsedDate, - revokedDate - } - - DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) - - return h.response().code(204) -} - async function load (request, h) { const result = await LoadService.go(request.payload) @@ -66,7 +51,6 @@ async function tearDown (_request, h) { module.exports = { deduplicate, - flagForBilling, load, seed, submitDeduplicate, diff --git a/app/routes/check.routes.js b/app/routes/check.routes.js index 6aa6161519..599b123825 100644 --- a/app/routes/check.routes.js +++ b/app/routes/check.routes.js @@ -3,6 +3,21 @@ const CheckController = require('../controllers/check.controller.js') const routes = [ + { + method: 'POST', + path: '/check/flag-for-billing', + options: { + handler: CheckController.flagForBilling, + app: { + excludeFromProd: true, + plainOutput: true + }, + auth: false, + plugins: { + crumb: false + } + } + }, { method: 'POST', path: '/check/licence-return-logs', diff --git a/app/routes/data.routes.js b/app/routes/data.routes.js index 0d1b1b5bff..e07d0a1625 100644 --- a/app/routes/data.routes.js +++ b/app/routes/data.routes.js @@ -27,21 +27,6 @@ const routes = [ } } }, - { - method: 'POST', - path: '/data/flag-for-billing', - options: { - handler: DataController.flagForBilling, - app: { - excludeFromProd: true, - plainOutput: true - }, - auth: false, - plugins: { - crumb: false - } - } - }, { method: 'POST', path: '/data/load', From c28b291a6af89e8ce5d897661fd81110310d2f5b Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 21 Oct 2024 16:41:58 +0100 Subject: [PATCH 4/6] Update comment --- app/controllers/check.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/check.controller.js b/app/controllers/check.controller.js index 5f3bb51d08..f7d4a31a91 100644 --- a/app/controllers/check.controller.js +++ b/app/controllers/check.controller.js @@ -13,7 +13,7 @@ const redirectStatusCode = 204 /** * A test end point for the licence supplementary billing flags process * - * This endpoint takes a licenceId and licence expired, lapsed and revoked date. It passes this onto the + * 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. * From 195983ebe8fd947ed0cc36dc8f865a6c6e36f408 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Tue, 22 Oct 2024 09:53:36 +0100 Subject: [PATCH 5/6] Use redirect status code variable --- app/controllers/check.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/check.controller.js b/app/controllers/check.controller.js index f7d4a31a91..32c2ce778a 100644 --- a/app/controllers/check.controller.js +++ b/app/controllers/check.controller.js @@ -33,7 +33,7 @@ async function flagForBilling (request, h) { DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) - return h.response().code(204) + return h.response().code(redirectStatusCode) } /** From 2e045d5a570ad7dc7c264ca5670d948b511ca72f Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Tue, 22 Oct 2024 10:19:09 +0100 Subject: [PATCH 6/6] Update: Check controller --- app/controllers/check.controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/check.controller.js b/app/controllers/check.controller.js index 32c2ce778a..f168a7914e 100644 --- a/app/controllers/check.controller.js +++ b/app/controllers/check.controller.js @@ -8,7 +8,7 @@ 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 @@ -31,9 +31,9 @@ async function flagForBilling (request, h) { revokedDate } - DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) + await DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId) - return h.response().code(redirectStatusCode) + return h.response().code(NO_CONTENT_STATUS_CODE) } /** @@ -55,7 +55,7 @@ async function returnLogsForLicence (_request, h) { ProcessLicenceReturnLogsService.go(licenceReference) - return h.response().code(redirectStatusCode) + return h.response().code(NO_CONTENT_STATUS_CODE) } module.exports = {