From 0938dcd55ef6462490d0f95a68f384eb1631958e Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Wed, 11 Dec 2024 21:12:05 +0000 Subject: [PATCH 1/9] feat: add change links with entity IDs in url --- src/app.ts | 19 ++++- src/config/index.ts | 21 ++++++ .../check.your.answers.controller.ts | 4 +- src/service/payment.service.ts | 2 +- src/utils/change.link.ts | 14 ++++ src/utils/trust/individual.trustee.mapper.ts | 2 +- ...overseas.entity.payment.controller.spec.ts | 60 ++++++++++----- test/utils/change.link.spec.ts | 33 ++++++++- .../beneficial-owner-gov.html | 6 +- .../beneficial-owner-individual.html | 6 +- .../beneficial-owner-other.html | 6 +- .../beneficial-owner-statements.html | 7 +- .../historical-trustee.html | 7 +- .../individual-trustee.html | 6 +- .../legal-entity-trustee.html | 6 +- .../managing-officer-corporate.html | 6 +- .../managing-officer-individual.html | 6 +- .../check-your-answers/presenter.html | 9 ++- views/includes/check-your-answers/trusts.html | 6 +- .../verification-checks.html | 73 ++++++++++++------- views/includes/entity.html | 12 ++- 21 files changed, 242 insertions(+), 69 deletions(-) diff --git a/src/app.ts b/src/app.ts index 360003967..16e7f26d8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -12,14 +12,19 @@ import { import { v4 as uuidv4 } from 'uuid'; import { prepareCSPConfig } from "./middleware/content.security.policy.middleware"; import nocache from "nocache"; - import * as config from "./config"; import { logger } from "./utils/logger"; import router from "./routes"; import errorHandler from "./controllers/error.controller"; -import { createChangeLinkConfig, createSummaryListLink } from "./utils/change.link"; import { countryFilter } from "./utils/country.filter"; import { ErrorMessages } from "./validation/error.messages"; +import { isActiveFeature } from "./utils/feature.flag"; +import { getTransactionIdAndSubmissionIdFromOriginalUrl } from "./utils/url"; +import { + createChangeLinkConfig, + createSummaryListLink, + createChangeLinkWithIds, +} from "./utils/change.link"; const app = express(); @@ -39,6 +44,7 @@ const nunjucksEnv = nunjucks.configure([ autoescape: true, express: app, }); + nunjucksEnv.addGlobal("CDN_HOST", config.CDN_HOST); nunjucksEnv.addGlobal("SERVICE_NAME", config.SERVICE_NAME); nunjucksEnv.addGlobal("UPDATE_SERVICE_NAME", config.UPDATE_SERVICE_NAME); @@ -47,7 +53,9 @@ nunjucksEnv.addGlobal("OE_CONFIGS", config); nunjucksEnv.addGlobal("ERROR_MESSAGES", ErrorMessages); nunjucksEnv.addGlobal("COUNTRY_FILTER", countryFilter ); nunjucksEnv.addGlobal("CREATE_CHANGE_LINK", createChangeLinkConfig); +nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDs", createChangeLinkWithIds); nunjucksEnv.addGlobal("SUMMARY_LIST_LINK", createSummaryListLink); +nunjucksEnv.addGlobal("IS_REDIS_REMOVAL_ENABLED", isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB)); nunjucksEnv.addGlobal("PIWIK_URL", config.PIWIK_URL); nunjucksEnv.addGlobal("PIWIK_SITE_ID", config.PIWIK_SITE_ID); nunjucksEnv.addGlobal("PIWIK_START_GOAL_ID", config.PIWIK_START_GOAL_ID); @@ -61,6 +69,13 @@ app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); +app.use((req, res, next) => { + const ids = getTransactionIdAndSubmissionIdFromOriginalUrl(req); + nunjucksEnv.addGlobal("OE_TRANSACTION_ID", ids?.transactionId); + nunjucksEnv.addGlobal("OE_SUBMISSION_ID", ids?.submissionId); + next(); +}); + const nonce: string = uuidv4(); app.use(helmet(prepareCSPConfig(nonce))); app.use(nocache()); diff --git a/src/config/index.ts b/src/config/index.ts index d58fcf992..4b5a9e67b 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -497,3 +497,24 @@ export const TRUST_ENTRY_WITH_PARAMS_URL = REGISTER_AN_OVERSEAS_ENTITY_WITH_PARA export const TRUST_INFO_WITH_PARAMS_URL = REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL + TRUST_INFO_PAGE; export const TRANSACTION_ID_URL_KEY = "/transaction/"; export const SUBMISSION_ID_URL_KEY = "/submission/"; + +// Check-your-answers page links +export const ENTITY_CHANGE_NAME_WITH_PARAMS = OVERSEAS_NAME_WITH_PARAMS_URL + ENTITY_NAME; +export const PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + "#full_name"; +export const PRESENTER_CHANGE_EMAIL_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + "#email"; +export const DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + AGENT_CODE; +export const DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_DATE; +export const DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + NAME; +export const DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_ADDRESS; +export const DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + EMAIL; +export const DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + SUPERVISORY_NAME; +export const DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + AML_NUMBER; +export const DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + PARTNER_NAME; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_DATE; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + NAME; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_ADDRESS; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + EMAIL; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + SUPERVISORY_NAME; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + AML_NUMBER; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + PARTNER_NAME; + diff --git a/src/controllers/check.your.answers.controller.ts b/src/controllers/check.your.answers.controller.ts index 18784244d..42a77ab15 100644 --- a/src/controllers/check.your.answers.controller.ts +++ b/src/controllers/check.your.answers.controller.ts @@ -52,9 +52,11 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { changeLinkUrl, overseasEntityHeading, whoIsCompletingChangeLink, + transactionId: req?.params[config.ROUTE_PARAM_TRANSACTION_ID], + submissionId: req?.params[config.ROUTE_PARAM_SUBMISSION_ID], pageParams: { isTrustFeatureEnabled: isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB), - isRegistration: true + isRegistration: true, }, FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC: isActiveFeature(config.FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC) }); diff --git a/src/service/payment.service.ts b/src/service/payment.service.ts index d682aa3a2..e9984844c 100644 --- a/src/service/payment.service.ts +++ b/src/service/payment.service.ts @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'; import { Session } from "@companieshouse/node-session-handler"; import ApiClient from "@companieshouse/api-sdk-node/dist/client"; import { isActiveFeature } from "../utils/feature.flag"; -import { ApplicationData } from "model"; +import { ApplicationData } from "../model"; import { createAndLogErrorRequest, logger } from "../utils/logger"; import { createOAuthApiClient } from "./api.service"; diff --git a/src/utils/change.link.ts b/src/utils/change.link.ts index fa451d75e..f63fcefa1 100644 --- a/src/utils/change.link.ts +++ b/src/utils/change.link.ts @@ -1,3 +1,5 @@ +import { getUrlWithTransactionIdAndSubmissionId } from "./url"; + export const createSummaryListLink = ( text: string, href: string, @@ -17,3 +19,15 @@ export const createSummaryListLink = ( export const createChangeLinkConfig = (href: string, text: string, dataEventId: string) => { return createSummaryListLink('Change', href, text, dataEventId); }; + +/** + * Return a change link with the transactionId and submissionId included + * - In case of an exception, return an HTML-safe hash(#) + */ +export const createChangeLinkWithIds = (link: string, transactionId: string, submissionId: string) => { + try { + return getUrlWithTransactionIdAndSubmissionId(link, transactionId, submissionId); + } catch (e) { + return "#"; + } +}; diff --git a/src/utils/trust/individual.trustee.mapper.ts b/src/utils/trust/individual.trustee.mapper.ts index 1d1b6a2ce..3780faf4d 100644 --- a/src/utils/trust/individual.trustee.mapper.ts +++ b/src/utils/trust/individual.trustee.mapper.ts @@ -145,7 +145,7 @@ export const mapIndividualTrusteeFromSessionToPage = ( relevant_period: trustee.relevant_period, }; - if (trustee.type === RoleWithinTrustType.INTERESTED_PERSON){ + if (trustee.type === RoleWithinTrustType.INTERESTED_PERSON) { return { ...data, dateBecameIPDay: trustee.date_became_interested_person_day, diff --git a/test/controllers/update/overseas.entity.payment.controller.spec.ts b/test/controllers/update/overseas.entity.payment.controller.spec.ts index 77c4907bc..685b279f5 100644 --- a/test/controllers/update/overseas.entity.payment.controller.spec.ts +++ b/test/controllers/update/overseas.entity.payment.controller.spec.ts @@ -2,41 +2,64 @@ jest.mock("ioredis"); jest.mock('../../../src/middleware/authentication.middleware'); jest.mock('../../../src/middleware/company.authentication.middleware'); jest.mock("../../../src/utils/logger"); -jest.mock("../../../src/utils/feature.flag" ); +jest.mock("../../../src/utils/feature.flag"); jest.mock('../../../src/utils/application.data'); jest.mock('../../../src/middleware/service.availability.middleware'); - -// import remove journey middleware mock before app to prevent real function being used instead of mock -import mockJourneyDetectionMiddleware from "../../__mocks__/journey.detection.middleware.mock"; +jest.mock('../../../src/utils/url'); import { NextFunction, Request, Response } from "express"; -import { describe, expect, jest, test, beforeEach } from "@jest/globals"; import request from "supertest"; -import { PAYMENT_PAID, UPDATE_CONFIRMATION_PAGE, UPDATE_CONFIRMATION_URL, PAYMENT_FAILED_PAGE, UPDATE_PAYMENT_FAILED_URL } from "../../../src/config"; +// import remove journey middleware mock before app to prevent real function being used instead of mock +import mockJourneyDetectionMiddleware from "../../__mocks__/journey.detection.middleware.mock"; import app from "../../../src/app"; + import { PaymentKey } from "../../../src/model/data.types.model"; -import { PAYMENT_OBJECT_MOCK, PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING, UPDATE_PAYMENT_DECLINED_WITH_TRANSACTION_URL_AND_QUERY_STRING, UPDATE_PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING } from "../../__mocks__/session.mock"; -import { getApplicationData } from "../../../src/utils/application.data"; import { authentication } from "../../../src/middleware/authentication.middleware"; import { companyAuthentication } from "../../../src/middleware/company.authentication.middleware"; import { createAndLogErrorRequest, logger } from "../../../src/utils/logger"; -import { ANY_MESSAGE_ERROR, FOUND_REDIRECT_TO, MESSAGE_ERROR, SERVICE_UNAVAILABLE } from "../../__mocks__/text.mock"; import { serviceAvailabilityMiddleware } from "../../../src/middleware/service.availability.middleware"; +import { isRegistrationJourney } from "../../../src/utils/url"; +import { getApplicationData } from "../../../src/utils/application.data"; + +import { + ANY_MESSAGE_ERROR, + FOUND_REDIRECT_TO, + MESSAGE_ERROR, + SERVICE_UNAVAILABLE +} from "../../__mocks__/text.mock"; + +import { + PAYMENT_PAID, + UPDATE_CONFIRMATION_PAGE, + UPDATE_CONFIRMATION_URL, + PAYMENT_FAILED_PAGE, + UPDATE_PAYMENT_FAILED_URL +} from "../../../src/config"; + +import { + PAYMENT_OBJECT_MOCK, + PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING, + UPDATE_PAYMENT_DECLINED_WITH_TRANSACTION_URL_AND_QUERY_STRING, + UPDATE_PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING +} from "../../__mocks__/session.mock"; mockJourneyDetectionMiddleware.mockClear(); const mockGetApplicationData = getApplicationData as jest.Mock; const mockAuthenticationMiddleware = authentication as jest.Mock; -mockAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); +mockAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); const mockCompanyAuthenticationMiddleware = companyAuthentication as jest.Mock; -mockCompanyAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); +mockCompanyAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); + +const mockIsRegistrationJourney = isRegistrationJourney as jest.Mock; +mockIsRegistrationJourney.mockReturnValue(false); const mockLoggerDebugRequest = logger.debugRequest as jest.Mock; const mockLoggerInfoRequest = logger.infoRequest as jest.Mock; const mockCreateAndLogErrorRequest = createAndLogErrorRequest as jest.Mock; const mockServiceAvailabilityMiddleware = serviceAvailabilityMiddleware as jest.Mock; -mockServiceAvailabilityMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); +mockServiceAvailabilityMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); describe('OVERSEAS ENTITY PAYMENT controller suit', () => { @@ -45,7 +68,7 @@ describe('OVERSEAS ENTITY PAYMENT controller suit', () => { }); test("should rejecting redirect, state does not match", async () => { - mockGetApplicationData.mockReturnValueOnce( {} ); + mockGetApplicationData.mockReturnValueOnce({}); await request(app).get(UPDATE_PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING); expect(mockLoggerInfoRequest).toHaveBeenCalledTimes(1); expect(mockLoggerDebugRequest).not.toHaveBeenCalled(); @@ -53,7 +76,7 @@ describe('OVERSEAS ENTITY PAYMENT controller suit', () => { }); test(`should redirect to ${UPDATE_CONFIRMATION_PAGE} page, Payment Successful with status ${PAYMENT_PAID}`, async () => { - mockGetApplicationData.mockReturnValueOnce( { [PaymentKey]: PAYMENT_OBJECT_MOCK } ); + mockGetApplicationData.mockReturnValueOnce({ [PaymentKey]: PAYMENT_OBJECT_MOCK }); const resp = await request(app).get(UPDATE_PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING); expect(resp.status).toEqual(302); expect(resp.text).toEqual(`${FOUND_REDIRECT_TO} ${UPDATE_CONFIRMATION_URL}`); @@ -63,9 +86,8 @@ describe('OVERSEAS ENTITY PAYMENT controller suit', () => { }); test(`should redirect to ${UPDATE_PAYMENT_FAILED_URL} page, Payment failed somehow`, async () => { - mockGetApplicationData.mockReturnValueOnce( { [PaymentKey]: PAYMENT_OBJECT_MOCK } ); + mockGetApplicationData.mockReturnValueOnce({ [PaymentKey]: PAYMENT_OBJECT_MOCK }); const resp = await request(app).get(UPDATE_PAYMENT_DECLINED_WITH_TRANSACTION_URL_AND_QUERY_STRING); - expect(resp.status).toEqual(302); expect(resp.text).toEqual(`${FOUND_REDIRECT_TO} ${UPDATE_PAYMENT_FAILED_URL}`); expect(mockLoggerDebugRequest).toHaveBeenCalledTimes(1); @@ -91,9 +113,8 @@ describe('OVERSEAS ENTITY PAYMENT controller suit', () => { }); test(`Should render the error page`, async () => { - mockLoggerDebugRequest.mockImplementationOnce( () => { throw new Error(MESSAGE_ERROR); }); + mockLoggerDebugRequest.mockImplementationOnce(() => { throw new Error(MESSAGE_ERROR); }); const response = await request(app).get(PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING); - expect(response.status).toEqual(500); expect(response.text).toContain(SERVICE_UNAVAILABLE); expect(mockLoggerDebugRequest).not.toHaveBeenCalled(); @@ -101,9 +122,8 @@ describe('OVERSEAS ENTITY PAYMENT controller suit', () => { }); test('catch error on get request', async () => { - mockLoggerDebugRequest.mockImplementationOnce( () => { throw new Error(ANY_MESSAGE_ERROR); }); + mockLoggerDebugRequest.mockImplementationOnce(() => { throw new Error(ANY_MESSAGE_ERROR); }); const resp = await request(app).get(PAYMENT_WITH_TRANSACTION_URL_AND_QUERY_STRING); - expect(resp.status).toEqual(500); expect(resp.text).toContain(SERVICE_UNAVAILABLE); }); diff --git a/test/utils/change.link.spec.ts b/test/utils/change.link.spec.ts index 309e9b87b..2d6dc04ac 100644 --- a/test/utils/change.link.spec.ts +++ b/test/utils/change.link.spec.ts @@ -1,8 +1,22 @@ -import { describe, expect, test } from '@jest/globals'; +import { + createChangeLinkConfig, + createChangeLinkWithIds, +} from '../../src/utils/change.link'; -import { CHANGE_LINK, CHANGE_LINK_NAME_PRESENTER, DATA_EVENT_ID } from '../__mocks__/text.mock'; -import { PRESENTER_CHANGE_FULL_NAME } from '../../src/config'; -import { createChangeLinkConfig } from '../../src/utils/change.link'; +import { + LANDING_URL, + PRESENTER_CHANGE_FULL_NAME, + REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL, +} from '../../src/config'; + +import { + CHANGE_LINK, + CHANGE_LINK_NAME_PRESENTER, + DATA_EVENT_ID +} from '../__mocks__/text.mock'; + +const transcationId = "123abc"; +const submissionId = "abc123"; describe('createChangeLinkConfig test suite', () => { @@ -14,4 +28,15 @@ describe('createChangeLinkConfig test suite', () => { expect(testChangeLinkConfig.attributes['data-event-id']).toEqual(DATA_EVENT_ID); }); + test('should correctly substitute the transactionId and submissionId in a url ', () => { + const substitutedUrl = createChangeLinkWithIds(REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL, transcationId, submissionId); + expect(substitutedUrl).toEqual(`${LANDING_URL}/transaction/${transcationId}/submission/${submissionId}/`); + }); + + test('should return a hash value if the substitution for transactionId and submissionId fails', () => { + // eslint-disable-next-line + const substitutedUrl = createChangeLinkWithIds(undefined, transcationId, submissionId); + expect(substitutedUrl).toEqual('#'); + }); + }); diff --git a/views/includes/check-your-answers/beneficial-owner-gov.html b/views/includes/check-your-answers/beneficial-owner-gov.html index ea82c97da..7da6acfbe 100644 --- a/views/includes/check-your-answers/beneficial-owner-gov.html +++ b/views/includes/check-your-answers/beneficial-owner-gov.html @@ -80,7 +80,11 @@ {% endset %} {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_GOV_URL + "/" + bog.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_GOV_URL + "/" + bog.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_GOV_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + bog.id %} + {% endif %} {% else %} {% if bog.ch_reference %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_REVIEW_BENEFICIAL_OWNER_GOV_URL + OE_CONFIGS.REVIEW_OWNER_INDEX_PARAM + loop.index0 %} diff --git a/views/includes/check-your-answers/beneficial-owner-individual.html b/views/includes/check-your-answers/beneficial-owner-individual.html index 7b8cdd7f9..310739740 100644 --- a/views/includes/check-your-answers/beneficial-owner-individual.html +++ b/views/includes/check-your-answers/beneficial-owner-individual.html @@ -99,7 +99,11 @@ {% endset %} {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_URL + "/" + boi.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_URL + "/" + boi.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boi.id %} + {% endif %} {% else %} {% if boi.ch_reference %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_REVIEW_BENEFICIAL_OWNER_INDIVIDUAL_URL + OE_CONFIGS.REVIEW_OWNER_INDEX_PARAM + loop.index0 %} diff --git a/views/includes/check-your-answers/beneficial-owner-other.html b/views/includes/check-your-answers/beneficial-owner-other.html index d0568fd5c..f80eab332 100644 --- a/views/includes/check-your-answers/beneficial-owner-other.html +++ b/views/includes/check-your-answers/beneficial-owner-other.html @@ -95,7 +95,11 @@ {% endset %} {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_OTHER_URL + "/" + boc.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_OTHER_URL + "/" + boc.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_OTHER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boc.id %} + {% endif %} {% else %} {% if boc.ch_reference %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_REVIEW_BENEFICIAL_OWNER_OTHER_URL + OE_CONFIGS.REVIEW_OWNER_INDEX_PARAM + loop.index0 %} diff --git a/views/includes/check-your-answers/beneficial-owner-statements.html b/views/includes/check-your-answers/beneficial-owner-statements.html index 00483d7ac..18b96e826 100644 --- a/views/includes/check-your-answers/beneficial-owner-statements.html +++ b/views/includes/check-your-answers/beneficial-owner-statements.html @@ -18,6 +18,11 @@ {% if pageParams.isRegistration %}

Has the overseas entity identified any registrable beneficial owners?

+ {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_URL %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% endif %} {{ govukSummaryList({ rows: [ @@ -30,7 +35,7 @@

Has the overseas entity identified any registrable b }, actions: { items: [ CREATE_CHANGE_LINK( - OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_URL, + changeLinkUrl, identifiedStatementText, "change-registrable-beneficial-owner-statement-button" ) ] diff --git a/views/includes/check-your-answers/historical-trustee.html b/views/includes/check-your-answers/historical-trustee.html index a5da41a90..b8b95605c 100644 --- a/views/includes/check-your-answers/historical-trustee.html +++ b/views/includes/check-your-answers/historical-trustee.html @@ -13,9 +13,12 @@ {% set formerTrusteeStartDate = dateMacros.formatDate(formerTrustee.notified_date_day, formerTrustee.notified_date_month, formerTrustee.notified_date_year) %} {% set formerTrusteeEndDate = dateMacros.formatDate(formerTrustee.ceased_date_day, formerTrustee.ceased_date_month, formerTrustee.ceased_date_year) %} - {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} + {% endif %} {% else %} {% if manageTrusts %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_MANAGE_TRUSTS_ORCHESTRATOR_CHANGE_HANDLER_URL + "/" + trust.trust_id + "/historical/" + formerTrustee.id %} diff --git a/views/includes/check-your-answers/individual-trustee.html b/views/includes/check-your-answers/individual-trustee.html index 331260d84..633fc2983 100644 --- a/views/includes/check-your-answers/individual-trustee.html +++ b/views/includes/check-your-answers/individual-trustee.html @@ -42,7 +42,11 @@ {% endset %} {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} + {% endif %} {% else %} {% set stillInvolved = individualTrustee.still_involved %} {% set isNotStillInvolved = stillInvolved === "No" %} diff --git a/views/includes/check-your-answers/legal-entity-trustee.html b/views/includes/check-your-answers/legal-entity-trustee.html index 0d572d71c..5ddc65f47 100644 --- a/views/includes/check-your-answers/legal-entity-trustee.html +++ b/views/includes/check-your-answers/legal-entity-trustee.html @@ -52,7 +52,11 @@ {% endset %} {% if pageParams.isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} + {% endif %} {% else %} {% set stillInvolved = legalEntity.still_involved %} {% set isNotStillInvolved = stillInvolved === "No" %} diff --git a/views/includes/check-your-answers/managing-officer-corporate.html b/views/includes/check-your-answers/managing-officer-corporate.html index f6da9e286..5c5b593de 100644 --- a/views/includes/check-your-answers/managing-officer-corporate.html +++ b/views/includes/check-your-answers/managing-officer-corporate.html @@ -26,7 +26,11 @@ {% endif %} {% endset %} -{% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_CORPORATE_URL + "/" + moc.id %} +{% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_CORPORATE_URL + "/" + moc.id %} +{% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.MANAGING_OFFICER_CORPORATE_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moc.id %} %} +{% endif %}

Corporate managing officer

diff --git a/views/includes/check-your-answers/managing-officer-individual.html b/views/includes/check-your-answers/managing-officer-individual.html index 805c60b71..f44db6d09 100644 --- a/views/includes/check-your-answers/managing-officer-individual.html +++ b/views/includes/check-your-answers/managing-officer-individual.html @@ -26,7 +26,11 @@ {% endif %} {% endset %} -{% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_URL + "/" + moi.id %} +{% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_URL + "/" + moi.id %} +{% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.MANAGING_OFFICER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moi.id %} +{% endif %} {# Build and add each govukSummaryList row separately so that some rows can be optional #} {% set rows=[] %} diff --git a/views/includes/check-your-answers/presenter.html b/views/includes/check-your-answers/presenter.html index 9eb631dcd..6e7fa6eae 100644 --- a/views/includes/check-your-answers/presenter.html +++ b/views/includes/check-your-answers/presenter.html @@ -1,11 +1,16 @@ {% if pageParams.isRegistration %} {% set contactDetailsSubText = "Who can we contact about this application?" %} - {% set presenterNameChangeLink = OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME %} - {% set presenterEmailChangeLink = OE_CONFIGS.PRESENTER_CHANGE_EMAIL %} {% set nameFieldLabel = "Name" %} {% set emailFieldLabel = "Email" %} {% set nameChangeText = "Full name - Who can we contact about this application" %} {% set emailChangeText = "Email address - Who can we contact about this application" %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set presenterNameChangeLink = OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME %} + {% set presenterEmailChangeLink = OE_CONFIGS.PRESENTER_CHANGE_EMAIL %} + {% else %} + {% set presenterNameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set presenterEmailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.PRESENTER_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% endif %} {% else %} {% set contactDetailsSubText %} {% if pageParams.noChangeFlag %} diff --git a/views/includes/check-your-answers/trusts.html b/views/includes/check-your-answers/trusts.html index ca4ab1bda..64a42f2ae 100644 --- a/views/includes/check-your-answers/trusts.html +++ b/views/includes/check-your-answers/trusts.html @@ -16,7 +16,11 @@

{{ trust_heading }}

{% if pageParams.isTrustFeatureEnabled %} {% set isRegistration = pageParams.isRegistration %} {% if isRegistration %} - {% set changeLinkUrl = OE_CONFIGS.TRUST_DETAILS_URL %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = OE_CONFIGS.TRUST_DETAILS_URL %} + {% else %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% endif %} {% else %} {% set trustStillInvolved = trust.trust_still_involved_in_overseas_entity %} {% set isTrustStillInvolved = trustStillInvolved === "Yes" %} diff --git a/views/includes/check-your-answers/verification-checks.html b/views/includes/check-your-answers/verification-checks.html index fa5abff42..a4237b23e 100644 --- a/views/includes/check-your-answers/verification-checks.html +++ b/views/includes/check-your-answers/verification-checks.html @@ -5,25 +5,48 @@ {% if pageParams.isRegistration %} {% set whoIsCompletingText = "Who is completing this registration" %} - {% if who_is_registering == "agent" %} - {% set whoIsCompleting = ukAgent %} - {% set agentChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE %} - {% set dateChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} - {% set nameChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_NAME%} - {% set addressChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS%} - {% set emailChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_EMAIL%} - {% set supervisoryChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME%} - {% set amlChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_AML_NUMBER%} - {% set partnerChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_PARTNER_NAME%} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% if who_is_registering == "agent" %} + {% set whoIsCompleting = ukAgent %} + {% set agentChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE %} + {% set dateChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} + {% set nameChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_NAME %} + {% set addressChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS %} + {% set emailChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_EMAIL %} + {% set supervisoryChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME %} + {% set amlChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_AML_NUMBER %} + {% set partnerChangeLink = OE_CONFIGS.DUE_DILIGENCE_CHANGE_PARTNER_NAME %} + {% else %} + {% set whoIsCompleting = someoneElse %} + {% set dateChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} + {% set nameChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME %} + {% set addressChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS %} + {% set emailChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL %} + {% set supervisoryChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME %} + {% set amlChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER %} + {% set partnerChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME %} + {% endif %} {% else %} - {% set whoIsCompleting = someoneElse %} - {% set dateChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} - {% set nameChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME %} - {% set addressChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS %} - {% set emailChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL %} - {% set supervisoryChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME %} - {% set amlChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER %} - {% set partnerChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME %} + {% if who_is_registering == "agent" %} + {% set whoIsCompleting = ukAgent %} + {% set agentChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% else %} + {% set whoIsCompleting = someoneElse %} + {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% endif %} {% endif %} {% else %} {% set whoIsCompletingText = "Who is completing this update" %} @@ -31,12 +54,12 @@ {% set whoIsCompleting = ukAgent %} {% set agentChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_AGENT_CODE %} {% set dateChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} - {% set nameChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_NAME%} - {% set addressChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS%} - {% set emailChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_EMAIL%} - {% set supervisoryChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME%} - {% set amlChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_AML_NUMBER%} - {% set partnerChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_PARTNER_NAME%} + {% set nameChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_NAME %} + {% set addressChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS %} + {% set emailChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_EMAIL %} + {% set supervisoryChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME %} + {% set amlChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_AML_NUMBER %} + {% set partnerChangeLink = OE_CONFIGS.UPDATE_DUE_DILIGENCE_CHANGE_PARTNER_NAME %} {% else %} {% set whoIsCompleting = someoneElse %} {% set dateChangeLink = OE_CONFIGS.UPDATE_OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE %} @@ -49,7 +72,7 @@ {% endif %} {% endif %} -{% if ( due_diligence and due_diligence | length ) %} +{% if (due_diligence and due_diligence | length) %} {% set dueDiligence = due_diligence %} {% set agentCode = { key: { diff --git a/views/includes/entity.html b/views/includes/entity.html index 86d470e8d..c2da32a85 100644 --- a/views/includes/entity.html +++ b/views/includes/entity.html @@ -1,6 +1,10 @@ {% set inNoChangeJourney = pageParams.noChangeFlag %} {% set inChangeJourney = not inNoChangeJourney %} +{% if pageParams.isRegistration and IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.ENTITY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} +{% endif %} + {% set formattedPrincipalAddressHtml %} {% set address = entity.principal_address %} {% include "includes/display_address.html" %} @@ -29,8 +33,13 @@ {% endset %} {% if pageParams.isRegistration %} + {% if not IS_REDIS_REMOVAL_ENABLED %} + {% set changeLinkEntityName = OE_CONFIGS.ENTITY_CHANGE_NAME %} + {% else %} + {% set changeLinkEntityName = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.ENTITY_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% endif %} {% set entityNameLink = CREATE_CHANGE_LINK( - OE_CONFIGS.ENTITY_CHANGE_NAME, + changeLinkEntityName, "Name of the overseas entity", "change-entity-name-button") %} @@ -103,7 +112,6 @@ %} {% endif %} -

{{ overseasEntityHeading }}

{{ govukSummaryList({ From 4cf7cb22806e3ed570fa37b3c51ac0004ab21474 Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Tue, 17 Dec 2024 09:25:21 +0000 Subject: [PATCH 2/9] fix: add missing address and type fields in trust forms and the check-your-answers page --- ...ll.us.about.the.legal.entity.controller.ts | 5 +- src/model/trust.model.ts | 6 +- src/utils/trust.former.bo.ts | 1 - .../trust.individual.beneficial.owner.ts | 9 +-- .../historical.beneficial.owner.mapper.ts | 3 +- src/utils/trust/individual.trustee.mapper.ts | 28 ++++----- .../legal.entity.beneficial.owner.mapper.ts | 32 +++++----- src/utils/trusts.ts | 1 - ....about.the.legal.entity.controller.spec.ts | 1 + ...gal.entity.beneficial.owner.mapper.spec.ts | 59 +++++++++++++------ .../individual-trustee.html | 38 ++++++------ .../legal-entity-trustee.html | 40 ++++++------- .../page-templates/trust-historical-bo.html | 7 ++- .../trust-individual-beneficial-owner.html | 9 ++- .../page-templates/trust-legal-entity-bo.html | 8 +-- 15 files changed, 138 insertions(+), 109 deletions(-) diff --git a/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts b/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts index d82c9a6b0..7ebbabeb2 100644 --- a/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts +++ b/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts @@ -52,15 +52,16 @@ const getPagePropertiesRelevantPeriod = (isRelevantPeriod, trust, formData, url: }; export const get = async (req: Request, res: Response, next: NextFunction) => { + try { + logger.debugRequest(req, `${req.method} ${req.route.path}`); + const appData = await getApplicationData(req.session); const trusteeId = req.params[ROUTE_PARAM_TRUSTEE_ID]; const isRelevantPeriod = req.query['relevant-period']; - const trust = getTrustInReview(appData) as Trust; const trustee = getTrustee(trust, trusteeId, TrusteeType.LEGAL_ENTITY) as TrustCorporate; - const formData = trustee ? mapLegalEntityTrusteeFromSessionToPage(trustee) : {}; if (isRelevantPeriod || (trustee && trustee.relevant_period)) { diff --git a/src/model/trust.model.ts b/src/model/trust.model.ts index aea14c9cf..9d47871fa 100644 --- a/src/model/trust.model.ts +++ b/src/model/trust.model.ts @@ -1,8 +1,8 @@ import { BeneficialOwnerIndividual } from '../model/beneficial.owner.individual.model'; import { BeneficialOwnerOther } from '../model/beneficial.owner.other.model'; import { BeneficialOwnerTypeChoice } from '../model/beneficial.owner.type.model'; -import { yesNoResponse } from './data.types.model'; import { RoleWithinTrustType } from './role.within.trust.type.model'; +import { Address, yesNoResponse } from './data.types.model'; export const TrustKey = "trusts"; @@ -89,6 +89,8 @@ export interface TrustIndividual { ceased_date_month?: string; ceased_date_year?: string; relevant_period?: boolean; + usual_residential_address?: Address + service_address?: Address } interface TrustHistoricalBeneficialOwnerCommon { @@ -172,6 +174,8 @@ export type TrustCorporate = { start_date_month?: string; start_date_year?: string; relevant_period?: boolean; + registered_office_address?: Address; + service_address?: Address }; export interface BeneficialOwnerItem { diff --git a/src/utils/trust.former.bo.ts b/src/utils/trust.former.bo.ts index bce690f42..ec494c9fe 100644 --- a/src/utils/trust.former.bo.ts +++ b/src/utils/trust.former.bo.ts @@ -86,7 +86,6 @@ export const getTrustFormerBo = async (req: Request, res: Response, next: NextFu trusteeId ); const pageProps = await getPageProperties(req, trustId, isUpdate, formData); - return res.render(pageProps.template, pageProps); } catch (error) { diff --git a/src/utils/trust.individual.beneficial.owner.ts b/src/utils/trust.individual.beneficial.owner.ts index c6c924886..4c6805dcc 100644 --- a/src/utils/trust.individual.beneficial.owner.ts +++ b/src/utils/trust.individual.beneficial.owner.ts @@ -1,4 +1,5 @@ import { NextFunction, Request, Response } from 'express'; +import { Session } from '@companieshouse/node-session-handler'; import { logger } from './logger'; import * as config from '../config'; import * as CommonTrustDataMapper from './trust/common.trust.data.mapper'; @@ -6,18 +7,17 @@ import { RoleWithinTrustType } from '../model/role.within.trust.type.model'; import * as PageModel from '../model/trust.page.model'; import { ApplicationData } from '../model'; import { safeRedirect } from './http.ext'; -import { Session } from '@companieshouse/node-session-handler'; import { saveAndContinue } from './save.and.continue'; +import { updateOverseasEntity } from "../service/overseas.entities.service"; import { isActiveFeature } from './feature.flag'; -import { getUrlWithParamsToPath, isRegistrationJourney } from './url'; import { checkTrustIndividualCeasedDate } from '../validation/async'; import { checkTrustIndividualBeneficialOwnerStillInvolved } from '../validation/stillInvolved.validation'; +import { getUrlWithParamsToPath, isRegistrationJourney } from './url'; import { ValidationError, validationResult } from 'express-validator'; import { fetchApplicationData, setExtraData } from './application.data'; import { getTrustByIdFromApp, saveTrustInApp, saveIndividualTrusteeInTrust } from './trusts'; import { mapIndividualTrusteeToSession, mapIndividualTrusteeByIdFromSessionToPage } from './trust/individual.trustee.mapper'; import { FormattedValidationErrors, formatValidationError } from '../middleware/validation.middleware'; -import { updateOverseasEntity } from "../service/overseas.entities.service"; export const INDIVIDUAL_BO_TEXTS = { title: 'Tell us about the individual', @@ -104,7 +104,8 @@ export const getTrustIndividualBo = async (req: Request, res: Response, next: Ne } else { const pagePropertiesRelevantPeriod = await getPagePropertiesRelevantPeriod( isRelevantPeriod, - req, trustId, + req, + trustId, isUpdate, formData, appData.entity_name diff --git a/src/utils/trust/historical.beneficial.owner.mapper.ts b/src/utils/trust/historical.beneficial.owner.mapper.ts index f8afede8e..d73c28123 100644 --- a/src/utils/trust/historical.beneficial.owner.mapper.ts +++ b/src/utils/trust/historical.beneficial.owner.mapper.ts @@ -59,7 +59,8 @@ const mapFormerTrusteeFromSessionToPage = ( endDateYear: trustee.ceased_date_year, is_newly_added: trustee.ch_references ? false : true }; - if (trustee.corporate_indicator === yesNoResponse.Yes && 'corporate_name' in trustee) { + + if (trustee.corporate_indicator && 'corporate_name' in trustee) { return { ...data, type: TrusteeType.LEGAL_ENTITY, diff --git a/src/utils/trust/individual.trustee.mapper.ts b/src/utils/trust/individual.trustee.mapper.ts index 3780faf4d..d275bfcdc 100644 --- a/src/utils/trust/individual.trustee.mapper.ts +++ b/src/utils/trust/individual.trustee.mapper.ts @@ -120,21 +120,21 @@ export const mapIndividualTrusteeFromSessionToPage = ( dateOfBirthYear: trustee.dob_year, nationality: trustee.nationality, second_nationality: trustee.second_nationality, - usual_residential_address_property_name_number: trustee.ura_address_premises, - usual_residential_address_line_1: trustee.ura_address_line_1, - usual_residential_address_line_2: trustee.ura_address_line_2, - usual_residential_address_town: trustee.ura_address_locality, - usual_residential_address_county: trustee.ura_address_region, - usual_residential_address_country: trustee.ura_address_country, - usual_residential_address_postcode: trustee.ura_address_postal_code, + usual_residential_address_property_name_number: trustee.ura_address_premises ?? trustee?.usual_residential_address?.property_name_number, + usual_residential_address_line_1: trustee.ura_address_line_1 ?? trustee?.usual_residential_address?.line_1, + usual_residential_address_line_2: trustee.ura_address_line_2 ?? trustee?.usual_residential_address?.line_2, + usual_residential_address_town: trustee.ura_address_locality ?? trustee?.usual_residential_address?.town, + usual_residential_address_county: trustee.ura_address_region ?? trustee?.usual_residential_address?.county, + usual_residential_address_country: trustee.ura_address_country ?? trustee?.usual_residential_address?.country, + usual_residential_address_postcode: trustee.ura_address_postal_code ?? trustee?.usual_residential_address?.postcode, is_service_address_same_as_usual_residential_address: trustee.is_service_address_same_as_usual_residential_address, - service_address_property_name_number: trustee.sa_address_premises, - service_address_line_1: trustee.sa_address_line_1, - service_address_line_2: trustee.sa_address_line_2, - service_address_town: trustee.sa_address_locality, - service_address_county: trustee.sa_address_region, - service_address_country: trustee.sa_address_country, - service_address_postcode: trustee.sa_address_postal_code, + service_address_property_name_number: trustee.sa_address_premises ?? trustee?.service_address?.property_name_number, + service_address_line_1: trustee.sa_address_line_1 ?? trustee?.service_address?.line_1, + service_address_line_2: trustee.sa_address_line_2 ?? trustee?.service_address?.line_2, + service_address_town: trustee.sa_address_locality ?? trustee?.service_address?.town, + service_address_county: trustee.sa_address_region ?? trustee?.service_address?.county, + service_address_country: trustee.sa_address_country ?? trustee?.service_address?.country, + service_address_postcode: trustee.sa_address_postal_code ?? trustee?.service_address?.postcode, stillInvolved: stillInvolvedInTrust, ceasedDateDay: trustee.ceased_date_day, ceasedDateMonth: trustee.ceased_date_month, diff --git a/src/utils/trust/legal.entity.beneficial.owner.mapper.ts b/src/utils/trust/legal.entity.beneficial.owner.mapper.ts index 961ec1711..c20943168 100644 --- a/src/utils/trust/legal.entity.beneficial.owner.mapper.ts +++ b/src/utils/trust/legal.entity.beneficial.owner.mapper.ts @@ -125,20 +125,20 @@ const mapLegalEntityTrusteeFromSessionToPage = ( is_newly_added: trustee.ch_references ? false : true, roleWithinTrust: trustee.type, legalEntityName: trustee.name, - principal_address_property_name_number: trustee.ro_address_premises, - principal_address_line_1: trustee.ro_address_line_1, - principal_address_line_2: trustee.ro_address_line_2, - principal_address_town: trustee.ro_address_locality, - principal_address_county: trustee.ro_address_region, - principal_address_country: trustee.ro_address_country, - principal_address_postcode: trustee.ro_address_postal_code, - service_address_property_name_number: trustee.sa_address_premises, - service_address_line_1: trustee.sa_address_line_1, - service_address_line_2: trustee.sa_address_line_2, - service_address_town: trustee.sa_address_locality, - service_address_county: trustee.sa_address_region, - service_address_country: trustee.sa_address_country, - service_address_postcode: trustee.sa_address_postal_code, + principal_address_property_name_number: trustee.ro_address_premises ?? trustee?.registered_office_address?.property_name_number, + principal_address_line_1: trustee.ro_address_line_1 ?? trustee?.registered_office_address?.line_1, + principal_address_line_2: trustee.ro_address_line_2 ?? trustee?.registered_office_address?.line_2, + principal_address_town: trustee.ro_address_locality ?? trustee?.registered_office_address?.town, + principal_address_county: trustee.ro_address_region ?? trustee?.registered_office_address?.county, + principal_address_country: trustee.ro_address_country ?? trustee?.registered_office_address?.country, + principal_address_postcode: trustee.ro_address_postal_code ?? trustee?.registered_office_address?.postcode, + service_address_property_name_number: trustee.sa_address_premises ?? trustee?.service_address?.property_name_number, + service_address_line_1: trustee.sa_address_line_1 ?? trustee?.service_address?.line_1, + service_address_line_2: trustee.sa_address_line_2 ?? trustee?.service_address?.line_2, + service_address_town: trustee.sa_address_locality ?? trustee?.service_address?.town, + service_address_county: trustee.sa_address_region ?? trustee?.service_address?.county, + service_address_country: trustee.sa_address_country ?? trustee?.service_address?.country, + service_address_postcode: trustee.sa_address_postal_code ?? trustee?.service_address?.postcode, governingLaw: trustee.identification_legal_authority, legalForm: trustee.identification_legal_form, public_register_name: trustee.identification_place_registered, @@ -158,13 +158,13 @@ const mapLegalEntityTrusteeFromSessionToPage = ( const stillInvolvedInTrust: string = !trustee.still_involved || !isYesOrNo(trustee.still_involved) ? "" : YesOrNo[trustee.still_involved]; - if (trustee.type === RoleWithinTrustType.INTERESTED_PERSON) { + if (trustee?.type && (trustee.type.toLowerCase() === RoleWithinTrustType.INTERESTED_PERSON.toLowerCase())) { return { ...data, interestedPersonStartDateDay: trustee.date_became_interested_person_day, interestedPersonStartDateMonth: trustee.date_became_interested_person_month, interestedPersonStartDateYear: trustee.date_became_interested_person_year, - principal_address_property_name_number: trustee.ro_address_premises, + principal_address_property_name_number: trustee.ro_address_premises ?? trustee?.registered_office_address?.property_name_number, stillInvolved: stillInvolvedInTrust, } as Page.TrustLegalEntityForm; } diff --git a/src/utils/trusts.ts b/src/utils/trusts.ts index 2bd199587..404805eba 100644 --- a/src/utils/trusts.ts +++ b/src/utils/trusts.ts @@ -229,7 +229,6 @@ const getIndividualTrustee = ( isReview?: boolean, ): IndividualTrustee => { const individualTrustees = getIndividualTrusteesFromTrust(appData, trustId, isReview); - if (individualTrustees.length === 0 || trusteeId === undefined) { return {} as IndividualTrustee; } diff --git a/test/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.spec.ts b/test/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.spec.ts index 8569b0086..2b76a21fb 100644 --- a/test/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.spec.ts +++ b/test/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.spec.ts @@ -338,6 +338,7 @@ describe('Update - Manage Trusts - Review legal entities', () => { mockFetchApplicationData.mockReturnValue(appData); mockGetTrustInReview.mockReturnValue(trustInReview); mockGetTrustee.mockReturnValue(trustee); + const response = await request(app).get(UPDATE_MANAGE_TRUSTS_TELL_US_ABOUT_THE_LEGAL_ENTITY_URL); expect(response.status).toEqual(200); diff --git a/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts b/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts index 749b94744..6ff257bd2 100644 --- a/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts +++ b/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts @@ -1,8 +1,7 @@ jest.mock('uuid'); - -import { beforeEach, describe, expect, jest, test } from "@jest/globals"; -import { ApplicationData } from "../../../src/model"; import * as uuid from 'uuid'; +import { yesNoResponse } from "@companieshouse/api-sdk-node/dist/services/overseas-entities"; +import { ApplicationData } from "../../../src/model"; import { TrustLegalEntityForm } from '../../../src/model/trust.page.model'; import { TrustCorporate, TrustKey } from "../../../src/model/trust.model"; import { TrusteeType } from "../../../src/model/trustee.type.model"; @@ -13,14 +12,15 @@ import { mapLegalEntityToSession, mapLegalEntityTrusteeByIdFromSessionToPage, } from '../../../src/utils/trust/legal.entity.beneficial.owner.mapper'; -import { yesNoResponse } from "@companieshouse/api-sdk-node/dist/services/overseas-entities"; describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { + beforeEach(() => { jest.clearAllMocks(); }); describe('Test session mapper methods', () => { + describe('Test trust legal entity form to session mapping', () => { const mockFormDataBasic = { legalEntityId: "9999", @@ -148,7 +148,9 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { still_involved: "No", }); }); + test('Map start_date to session when relevant_period is true', () => { + const mockFormData = { ...mockFormDataBasic, roleWithinTrust: RoleWithinTrustType.INTERESTED_PERSON, @@ -203,10 +205,10 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { still_involved: "No", }); }); + test('test generateId', () => { const expectNewId = '9999'; jest.spyOn(uuid, 'v4').mockReturnValue(expectNewId); - expect(generateId()).toBe(expectNewId); }); }); @@ -246,6 +248,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceased_date_year: "2020", still_involved: "No" }; + test("Map legal entity trustee session data to page", () => { const trustId = '987'; @@ -352,6 +355,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { stillInvolved: "0" }); }); + test("Map legal entity trustee session data to page trustee item", () => { expect( mapLegalEntityItemToPage(mockSessionDataBasic as TrustCorporate) @@ -367,18 +371,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; - const mockSessionData = { ...mockSessionDataBasic, still_involved: "Yes", + type: RoleWithinTrustType.GRANTOR }; - const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; + expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -409,7 +413,12 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "1" + stillInvolved: "1", + relevant_period: undefined, + roleWithinTrust: RoleWithinTrustType.GRANTOR, + startDateDay: undefined, + startDateMonth: undefined, + startDateYear: undefined, }); }); @@ -417,18 +426,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; - const mockSessionData = { ...mockSessionDataBasic, still_involved: "No", + type: RoleWithinTrustType.BENEFICIARY }; - const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; + expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -459,7 +468,12 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "0" + stillInvolved: "0", + relevant_period: undefined, + roleWithinTrust: "Beneficiary", + startDateDay: undefined, + startDateMonth: undefined, + startDateYear: undefined }); }); @@ -467,18 +481,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; - const mockSessionData = { ...mockSessionDataBasic, still_involved: undefined, + type: RoleWithinTrustType.BENEFICIARY }; - const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; + expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -509,7 +523,12 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "" + stillInvolved: "", + relevant_period: undefined, + roleWithinTrust: RoleWithinTrustType.BENEFICIARY, + startDateDay: undefined, + startDateMonth: undefined, + startDateYear: undefined, }); }); @@ -517,18 +536,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; - const mockSessionData = { ...mockSessionDataBasic, still_involved: "Wrong", + type: RoleWithinTrustType.BENEFICIARY }; - const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; + expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -559,10 +578,14 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "" + stillInvolved: "", + relevant_period: undefined, + roleWithinTrust: RoleWithinTrustType.BENEFICIARY, + startDateDay: undefined, + startDateMonth: undefined, + startDateYear: undefined, }); }); - }); }); }); diff --git a/views/includes/check-your-answers/individual-trustee.html b/views/includes/check-your-answers/individual-trustee.html index 633fc2983..cc55bd2c9 100644 --- a/views/includes/check-your-answers/individual-trustee.html +++ b/views/includes/check-your-answers/individual-trustee.html @@ -10,13 +10,13 @@ {% set individualTrusteeFormattedResidentialAddressHtml %} {% set address = { - property_name_number: individualTrustee.ura_address_premises, - line_1: individualTrustee.ura_address_line_1, - line_2: individualTrustee.ura_address_line_2, - town: individualTrustee.ura_address_locality, - county: individualTrustee.ura_address_region, - country: individualTrustee.ura_address_country, - postcode: individualTrustee.ura_address_postal_code + property_name_number: individualTrustee.ura_address_premises or individualTrustee.usual_residential_address.property_name_number, + line_1: individualTrustee.ura_address_line_1 or individualTrustee.usual_residential_address.line_1, + line_2: individualTrustee.ura_address_line_2 or individualTrustee.usual_residential_address.line_2, + town: individualTrustee.ura_address_locality or individualTrustee.usual_residential_address.town, + county: individualTrustee.ura_address_region or individualTrustee.usual_residential_address.county, + country: individualTrustee.ura_address_country or individualTrustee.usual_residential_address.country, + postcode: individualTrustee.ura_address_postal_code or individualTrustee.usual_residential_address.postcode } %} {% include "includes/display_address.html" %} {% endset %} @@ -30,12 +30,12 @@ {% set individualTrusteeChangeServiceAddressHtml = OE_CONFIGS.CHANGE_SERVICE_ADDRESS %} {% set address = { property_name_number: individualTrustee.sa_address_premises, - line_1: individualTrustee.sa_address_line_1, - line_2: individualTrustee.sa_address_line_2, - town: individualTrustee.sa_address_locality, - county: individualTrustee.sa_address_region, - country: individualTrustee.sa_address_country, - postcode: individualTrustee.sa_address_postal_code + line_1: individualTrustee.sa_address_line_1 or individualTrustee.service_address.line_1, + line_2: individualTrustee.sa_address_line_2 or individualTrustee.service_address.line_2, + town: individualTrustee.sa_address_locality or individualTrustee.service_address.town, + county: individualTrustee.sa_address_region or individualTrustee.service_address.county, + country: individualTrustee.sa_address_country or individualTrustee.service_address.country, + postcode: individualTrustee.sa_address_postal_code or individualTrustee.service_address.postcode } %} {% include "includes/display_address.html" %} {% endif %} @@ -49,7 +49,7 @@ {% endif %} {% else %} {% set stillInvolved = individualTrustee.still_involved %} - {% set isNotStillInvolved = stillInvolved === "No" %} + {% set isNotStillInvolved = stillInvolved === "No" %} {% set trusteeCeasedDate = dateMacros.formatDate(individualTrustee.ceased_date_day, individualTrustee.ceased_date_month, individualTrustee.ceased_date_year) %} {% if manageTrusts %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_MANAGE_TRUSTS_ORCHESTRATOR_CHANGE_HANDLER_URL + "/" + trust.trust_id + "/individual/" + individualTrustee.id %} @@ -213,8 +213,8 @@ }), rows) %} {% endif %} -{% if not pageParams.isRegistration and - not inNoChangeJourney and +{% if not pageParams.isRegistration and + not inNoChangeJourney and (isTrustStillInvolved or isNotStillInvolved) %} {% set rows = (rows.push({ key: { @@ -231,7 +231,7 @@ ) ] } }), rows) %} - + {% set rows = (rows.push({ key: { text: "Date they ceased to be involved in the trust" @@ -245,8 +245,8 @@ "Individual beneficial owner " + individualTrusteeFullName + " - ceased date", "change-individual-beneficial-owner-ceased-date-button" ) ] - } - }) if isNotStillInvolved, rows) %} + } + }) if isNotStillInvolved, rows) %} {% endif %}

Individual for {{trust.trust_name}}

diff --git a/views/includes/check-your-answers/legal-entity-trustee.html b/views/includes/check-your-answers/legal-entity-trustee.html index 5ddc65f47..13f13724a 100644 --- a/views/includes/check-your-answers/legal-entity-trustee.html +++ b/views/includes/check-your-answers/legal-entity-trustee.html @@ -8,13 +8,13 @@ {% set legalEntityFormattedResidentialAddressHtml %} {% set address = { - property_name_number: legalEntity.ro_address_premises, - line_1: legalEntity.ro_address_line_1, - line_2: legalEntity.ro_address_line_2, - town: legalEntity.ro_address_locality, - county: legalEntity.ro_address_region, - country: legalEntity.ro_address_country, - postcode: legalEntity.ro_address_postal_code + property_name_number: legalEntity.registered_office_address.property_name_number, + line_1: legalEntity.ro_address_line_1 or legalEntity.registered_office_address.line_1, + line_2: legalEntity.ro_address_line_2 or legalEntity.registered_office_address.line_2, + town: legalEntity.ro_address_locality or legalEntity.registered_office_address.town, + county: legalEntity.ro_address_region or legalEntity.registered_office_address.county, + country: legalEntity.ro_address_country or legalEntity.registered_office_address.country, + postcode: legalEntity.ro_address_postal_code or legalEntity.registered_office_address.postcode } %} {% include "includes/display_address.html" %} {% endset %} @@ -27,13 +27,13 @@ {% else %} {% set legalEntityChangeServiceAddressHtml = OE_CONFIGS.CHANGE_SERVICE_ADDRESS %} {% set address = { - property_name_number: legalEntity.sa_address_premises, - line_1: legalEntity.sa_address_line_1, - line_2: legalEntity.sa_address_line_2, - town: legalEntity.sa_address_locality, - county: legalEntity.sa_address_region, - country: legalEntity.sa_address_country, - postcode: legalEntity.sa_address_postal_code + property_name_number: legalEntity.sa_address_premises or legalEntity.service_address.property_name_number, + line_1: legalEntity.sa_address_line_1 or legalEntity.service_address.line_1, + line_2: legalEntity.sa_address_line_2 or legalEntity.service_address.line_2, + town: legalEntity.sa_address_locality or legalEntity.service_address.town, + county: legalEntity.sa_address_region or legalEntity.service_address.county, + country: legalEntity.sa_address_country or legalEntity.service_address.country, + postcode: legalEntity.sa_address_postal_code or legalEntity.service_address.postcode } %} {% include "includes/display_address.html" %} {% endif %} @@ -59,7 +59,7 @@ {% endif %} {% else %} {% set stillInvolved = legalEntity.still_involved %} - {% set isNotStillInvolved = stillInvolved === "No" %} + {% set isNotStillInvolved = stillInvolved === "No" %} {% set trusteeCeasedDate = dateMacros.formatDate(legalEntity.ceased_date_day, legalEntity.ceased_date_month, legalEntity.ceased_date_year) %} {% if manageTrusts %} {% set changeLinkUrl = OE_CONFIGS.UPDATE_MANAGE_TRUSTS_ORCHESTRATOR_CHANGE_HANDLER_URL + "/" + trust.trust_id + "/legalEntity/" + legalEntity.id %} @@ -222,7 +222,7 @@ }), rows) %} {% if not pageParams.isRegistration and - not inNoChangeJourney and + not inNoChangeJourney and (isTrustStillInvolved or isNotStillInvolved) %} {% set rows = (rows.push({ key: { @@ -239,7 +239,7 @@ ) ] } }), rows) %} - + {% set rows = (rows.push({ key: { text: "Date it ceased to be involved in the trust" @@ -253,9 +253,9 @@ "Legal entity " + legalEntity.name + " - ceased date", "change-legal-entity-ceased-date-button" ) ] - } - }) if isNotStillInvolved, rows) %} -{% endif %} + } + }) if isNotStillInvolved, rows) %} +{% endif %}

Legal Entity for {{trust.trust_name}}

diff --git a/views/includes/page-templates/trust-historical-bo.html b/views/includes/page-templates/trust-historical-bo.html index e58b25803..7dbdc175a 100644 --- a/views/includes/page-templates/trust-historical-bo.html +++ b/views/includes/page-templates/trust-historical-bo.html @@ -1,12 +1,13 @@
+ {% include "includes/list/errors.html" %} {{ pageData.trustData.trustName }}

{{ pageParams.title }}


You can add more later.


-
+ {% include "includes/csrf_token.html" %} {% set legalEntityHtml %} @@ -51,7 +52,7 @@

{{ pageParams.title }}

{ value: pageData.trusteeType.LEGAL_ENTITY, text: "Legal Entity", - checked: formData.type == pageData.trusteeType.LEGAL_ENTITY, + checked: (formData.type | lower) === (pageData.trusteeType.LEGAL_ENTITY | lower), conditional: { html: legalEntityHtml } @@ -59,7 +60,7 @@

{{ pageParams.title }}

{ value: pageData.trusteeType.INDIVIDUAL, text: "Individual", - checked: formData.type == pageData.trusteeType.INDIVIDUAL, + checked: (formData.type | lower) === (pageData.trusteeType.INDIVIDUAL | lower), conditional: { html: individualBoHtml } diff --git a/views/includes/page-templates/trust-individual-beneficial-owner.html b/views/includes/page-templates/trust-individual-beneficial-owner.html index 22824b766..a07b66c83 100644 --- a/views/includes/page-templates/trust-individual-beneficial-owner.html +++ b/views/includes/page-templates/trust-individual-beneficial-owner.html @@ -1,5 +1,4 @@ {% set pageTitle = pageParams.title %} - {% set trustName = pageData.trustData.trustName %} {% set trusteeId = formData.trusteeId %} @@ -121,28 +120,28 @@

What is their date of birth?

{ value: pageData.roleWithinTrustType.BENEFICIARY, text: "Beneficiary", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.BENEFICIARY, + checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.BENEFICIARY | lower), attributes: { "data-event-id": "beneficiary-type-radio-option" } }, { value: pageData.roleWithinTrustType.SETTLOR, text: "Settlor", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.SETTLOR, + checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.SETTLOR | lower), attributes: { "data-event-id": "settlor-type-radio-option" } }, { value: pageData.roleWithinTrustType.GRANTOR, text: "Grantor", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.GRANTOR, + checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.GRANTOR | lower), attributes: { "data-event-id": "grantor-type-radio-option" } }, { value: pageData.roleWithinTrustType.INTERESTED_PERSON, text: "Interested Person", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.INTERESTED_PERSON, + checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.INTERESTED_PERSON | lower), attributes: { "data-event-id": "interested-person-type-radio-option" }, diff --git a/views/includes/page-templates/trust-legal-entity-bo.html b/views/includes/page-templates/trust-legal-entity-bo.html index 94081c7a3..91d8920f2 100644 --- a/views/includes/page-templates/trust-legal-entity-bo.html +++ b/views/includes/page-templates/trust-legal-entity-bo.html @@ -61,28 +61,28 @@

{{ pageParams.title }}

{ value: pageData.roleWithinTrustType.BENEFICIARY, text: "Beneficiary", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.BENEFICIARY, + checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.BENEFICIARY | lower), attributes: { "data-event-id": "beneficiaries-type-radio-option" } }, { value: pageData.roleWithinTrustType.SETTLOR, text: "Settlor", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.SETTLOR, + checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.SETTLOR | lower), attributes: { "data-event-id": "settlors-type-radio-option" } }, { value: pageData.roleWithinTrustType.GRANTOR, text: "Grantor", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.GRANTOR, + checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.GRANTOR | lower), attributes: { "data-event-id": "grantors-type-radio-option" } }, { value: pageData.roleWithinTrustType.INTERESTED_PERSON, text: "Interested Person", - checked: formData.roleWithinTrust == pageData.roleWithinTrustType.INTERESTED_PERSON, + checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.INTERESTED_PERSON | lower), attributes: { "data-event-id": "interested-persons-type-radio-option" }, From 8d318f266378908443c29677335239ef0cd261cb Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Tue, 17 Dec 2024 09:52:48 +0000 Subject: [PATCH 3/9] chore: remove unused object entries when rendering template --- src/controllers/check.your.answers.controller.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/controllers/check.your.answers.controller.ts b/src/controllers/check.your.answers.controller.ts index 42a77ab15..18784244d 100644 --- a/src/controllers/check.your.answers.controller.ts +++ b/src/controllers/check.your.answers.controller.ts @@ -52,11 +52,9 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { changeLinkUrl, overseasEntityHeading, whoIsCompletingChangeLink, - transactionId: req?.params[config.ROUTE_PARAM_TRANSACTION_ID], - submissionId: req?.params[config.ROUTE_PARAM_SUBMISSION_ID], pageParams: { isTrustFeatureEnabled: isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB), - isRegistration: true, + isRegistration: true }, FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC: isActiveFeature(config.FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC) }); From da6eef1ad0244c5151be239198ace93d960c6ee6 Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Tue, 17 Dec 2024 11:49:11 +0000 Subject: [PATCH 4/9] fix: use correct flag in app.ts --- src/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 16e7f26d8..31ddec193 100644 --- a/src/app.ts +++ b/src/app.ts @@ -55,7 +55,7 @@ nunjucksEnv.addGlobal("COUNTRY_FILTER", countryFilter ); nunjucksEnv.addGlobal("CREATE_CHANGE_LINK", createChangeLinkConfig); nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDs", createChangeLinkWithIds); nunjucksEnv.addGlobal("SUMMARY_LIST_LINK", createSummaryListLink); -nunjucksEnv.addGlobal("IS_REDIS_REMOVAL_ENABLED", isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB)); +nunjucksEnv.addGlobal("IS_REDIS_REMOVAL_ENABLED", isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL)); nunjucksEnv.addGlobal("PIWIK_URL", config.PIWIK_URL); nunjucksEnv.addGlobal("PIWIK_SITE_ID", config.PIWIK_SITE_ID); nunjucksEnv.addGlobal("PIWIK_START_GOAL_ID", config.PIWIK_START_GOAL_ID); From f6a42e0b1151e3fb1e8e5135b5536dd5aa8fb9e1 Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Thu, 19 Dec 2024 19:48:03 +0000 Subject: [PATCH 5/9] refactor: implement changes from code review --- src/app.ts | 4 +- src/config/index.ts | 1 + .../check.your.answers.controller.ts | 5 +- .../common.resume.submission.controller.ts | 63 ++++++++------- ...ll.us.about.the.legal.entity.controller.ts | 5 +- src/model/trust.model.ts | 6 +- src/utils/change.link.ts | 7 +- src/utils/trust.former.bo.ts | 14 +++- .../trust.individual.beneficial.owner.ts | 8 +- src/utils/trust.legal.entity.bo.ts | 3 + src/utils/trust/api.to.web.mapper.ts | 12 +++ src/utils/trust/common.trust.data.mapper.ts | 4 +- src/utils/trust/individual.trustee.mapper.ts | 28 +++---- .../legal.entity.beneficial.owner.mapper.ts | 32 ++++---- src/utils/trusts.ts | 12 +-- .../check.your.answers.controller.spec.ts | 1 - .../resume.submission.controller.spec.ts | 67 ++++++++++----- test/utils/change.link.spec.ts | 11 +-- test/utils/trust.spec.ts | 81 ++++++++++--------- test/utils/trust/api.to.web.mapper.spec.ts | 56 +++++++++++++ .../trust/common.trust.data.mapper.spec.ts | 1 - ...gal.entity.beneficial.owner.mapper.spec.ts | 59 +++++--------- .../beneficial-owner-gov.html | 2 +- .../beneficial-owner-individual.html | 2 +- .../beneficial-owner-other.html | 2 +- .../beneficial-owner-statements.html | 2 +- .../historical-trustee.html | 2 +- .../individual-trustee.html | 30 +++---- .../legal-entity-trustee.html | 30 +++---- .../managing-officer-corporate.html | 2 +- .../managing-officer-individual.html | 2 +- .../check-your-answers/presenter.html | 4 +- views/includes/check-your-answers/trusts.html | 2 +- .../verification-checks.html | 31 +++---- views/includes/entity.html | 4 +- .../page-templates/trust-historical-bo.html | 7 +- .../trust-individual-beneficial-owner.html | 9 ++- .../page-templates/trust-legal-entity-bo.html | 8 +- 38 files changed, 350 insertions(+), 269 deletions(-) create mode 100644 src/utils/trust/api.to.web.mapper.ts create mode 100644 test/utils/trust/api.to.web.mapper.spec.ts diff --git a/src/app.ts b/src/app.ts index 31ddec193..a113da94e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,13 +18,13 @@ import router from "./routes"; import errorHandler from "./controllers/error.controller"; import { countryFilter } from "./utils/country.filter"; import { ErrorMessages } from "./validation/error.messages"; -import { isActiveFeature } from "./utils/feature.flag"; import { getTransactionIdAndSubmissionIdFromOriginalUrl } from "./utils/url"; import { createChangeLinkConfig, createSummaryListLink, createChangeLinkWithIds, } from "./utils/change.link"; +import { isActiveFeature } from "./utils/feature.flag"; const app = express(); @@ -53,7 +53,7 @@ nunjucksEnv.addGlobal("OE_CONFIGS", config); nunjucksEnv.addGlobal("ERROR_MESSAGES", ErrorMessages); nunjucksEnv.addGlobal("COUNTRY_FILTER", countryFilter ); nunjucksEnv.addGlobal("CREATE_CHANGE_LINK", createChangeLinkConfig); -nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDs", createChangeLinkWithIds); +nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDS", createChangeLinkWithIds); nunjucksEnv.addGlobal("SUMMARY_LIST_LINK", createSummaryListLink); nunjucksEnv.addGlobal("IS_REDIS_REMOVAL_ENABLED", isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL)); nunjucksEnv.addGlobal("PIWIK_URL", config.PIWIK_URL); diff --git a/src/config/index.ts b/src/config/index.ts index 4b5a9e67b..cf5ef0327 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -510,6 +510,7 @@ export const DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_ export const DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + SUPERVISORY_NAME; export const DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + AML_NUMBER; export const DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + PARTNER_NAME; +export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + AGENT_CODE; export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_DATE; export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + NAME; export const OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS = OVERSEAS_ENTITY_DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_ADDRESS; diff --git a/src/controllers/check.your.answers.controller.ts b/src/controllers/check.your.answers.controller.ts index 18784244d..ebd8e9376 100644 --- a/src/controllers/check.your.answers.controller.ts +++ b/src/controllers/check.your.answers.controller.ts @@ -9,10 +9,10 @@ import { ApplicationData } from "../model"; import { startPaymentsSession } from "../service/payment.service"; import { RoleWithinTrustType } from "../model/role.within.trust.type.model"; import { fetchApplicationData } from "../utils/application.data"; - +import { OverseasEntityKey, Transactionkey } from "../model/data.types.model"; import { getUrlWithParamsToPath, isRegistrationJourney } from "../utils/url"; import { checkEntityRequiresTrusts, getTrustLandingUrl } from "../utils/trusts"; -import { OverseasEntityKey, Transactionkey } from "../model/data.types.model"; +import { mapTrustApiToWebWhenFlagsAreSet } from "../utils/trust/api.to.web.mapper"; export const get = async (req: Request, res: Response, next: NextFunction) => { @@ -22,6 +22,7 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { const isRegistration = isRegistrationJourney(req); const appData: ApplicationData = await fetchApplicationData(req, isRegistration); + mapTrustApiToWebWhenFlagsAreSet (appData, isRegistration); const requiresTrusts: boolean = checkEntityRequiresTrusts(appData); const changeLinkUrl: string = config.ENTITY_URL; const overseasEntityHeading: string = config.OVERSEAS_ENTITY_SECTION_HEADING; diff --git a/src/controllers/shared/common.resume.submission.controller.ts b/src/controllers/shared/common.resume.submission.controller.ts index fc3546e61..c2fe67c1f 100644 --- a/src/controllers/shared/common.resume.submission.controller.ts +++ b/src/controllers/shared/common.resume.submission.controller.ts @@ -3,21 +3,16 @@ import { v4 as uuidv4 } from "uuid"; import { Session } from "@companieshouse/node-session-handler"; import * as config from "../../config"; - import { ApplicationData } from "../../model"; import { createAndLogErrorRequest, logger } from "../../utils/logger"; import { setExtraData } from "../../utils/application.data"; import { isActiveFeature } from "../../utils/feature.flag"; import { getOverseasEntity } from "../../service/overseas.entities.service"; +import { startPaymentsSession } from "../../service/payment.service"; +import { getTransaction } from "../../service/transaction.service"; +import { mapTrustApiReturnModelToWebModel } from "../../utils/trusts"; +import { isRegistrationJourney } from "../../utils/url"; -import { - HasSoldLandKey, - ID, - NonLegalFirmNoc, - IsSecureRegisterKey, - OverseasEntityKey, - Transactionkey -} from "../../model/data.types.model"; import { WhoIsRegisteringKey, WhoIsRegisteringType } from "../../model/who.is.making.filing.model"; import { OverseasEntityDueDiligenceKey } from "../../model/overseas.entity.due.diligence.model"; import { DueDiligenceKey } from "../../model/due.diligence.model"; @@ -27,9 +22,14 @@ import { BeneficialOwnerOther, BeneficialOwnerOtherKey } from "../../model/benef import { ManagingOfficerCorporate, ManagingOfficerCorporateKey } from "../../model/managing.officer.corporate.model"; import { ManagingOfficerIndividual, ManagingOfficerKey } from "../../model/managing.officer.model"; -import { startPaymentsSession } from "../../service/payment.service"; -import { getTransaction } from "../../service/transaction.service"; -import { mapTrustApiReturnModelToWebModel } from "../../utils/trusts"; +import { + ID, + HasSoldLandKey, + NonLegalFirmNoc, + IsSecureRegisterKey, + OverseasEntityKey, + Transactionkey +} from "../../model/data.types.model"; export const getResumePage = async (req: Request, res: Response, next: NextFunction, resumePage: string) => { try { @@ -37,7 +37,7 @@ export const getResumePage = async (req: Request, res: Response, next: NextFunct const { transactionId, overseaEntityId } = req.params; const infoMsg = `Transaction ID: ${transactionId}, OverseasEntity ID: ${overseaEntityId}`; - const isRegistration: boolean = req.path.startsWith(config.LANDING_URL); + const isRegistration: boolean = isRegistrationJourney(req); logger.infoRequest(req, `Resuming OE - ${infoMsg}`); @@ -48,7 +48,7 @@ export const getResumePage = async (req: Request, res: Response, next: NextFunct } const session = req.session as Session; - setWebApplicationData(session, appData, transactionId, overseaEntityId); + setWebApplicationData(session, appData, transactionId, overseaEntityId, isRegistration); const transactionResource = await getTransaction(req, transactionId); @@ -85,28 +85,33 @@ export const getResumePage = async (req: Request, res: Response, next: NextFunct * @param transactionId * @param overseaEntityId */ -const setWebApplicationData = (session: Session, appData: ApplicationData, transactionId: string, overseaEntityId: string) => { +const setWebApplicationData = (session: Session, appData: ApplicationData, transactionId: string, overseaEntityId: string, isRegistration: boolean) => { + appData[BeneficialOwnerIndividualKey] = (appData[BeneficialOwnerIndividualKey] as BeneficialOwnerIndividual[]) - .map( boi => { return { ...boi, [ID]: uuidv4() }; } ); - appData[BeneficialOwnerOtherKey] = (appData[BeneficialOwnerOtherKey] as BeneficialOwnerOther[] ) - .map( boo => { return { ...boo, [ID]: uuidv4() }; } ); + .map(boi => { return { ...boi, [ID]: uuidv4() }; }); + appData[BeneficialOwnerOtherKey] = (appData[BeneficialOwnerOtherKey] as BeneficialOwnerOther[]) + .map(boo => { return { ...boo, [ID]: uuidv4() }; }); appData[BeneficialOwnerGovKey] = (appData[BeneficialOwnerGovKey] as BeneficialOwnerGov[]) - .map( bog => { return { ...bog, [ID]: uuidv4() }; } ); + .map(bog => { return { ...bog, [ID]: uuidv4() }; }); appData[ManagingOfficerKey] = (appData[ManagingOfficerKey] as ManagingOfficerIndividual[]) - .map( moi => { return { ...moi, [ID]: uuidv4() }; } ); + .map(moi => { return { ...moi, [ID]: uuidv4() }; }); appData[ManagingOfficerCorporateKey] = (appData[ManagingOfficerCorporateKey] as ManagingOfficerCorporate[]) - .map( moc => { return { ...moc, [ID]: uuidv4() }; } ); + .map(moc => { return { ...moc, [ID]: uuidv4() }; }); - appData[HasSoldLandKey] = '0'; - appData[IsSecureRegisterKey] = '0'; - appData[Transactionkey] = transactionId; - appData[OverseasEntityKey] = overseaEntityId; + if (!isRegistration || !isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL)) { - if (appData[OverseasEntityDueDiligenceKey] && Object.keys(appData[OverseasEntityDueDiligenceKey]).length) { - appData[WhoIsRegisteringKey] = WhoIsRegisteringType.SOMEONE_ELSE; - } else if (appData[DueDiligenceKey] && Object.keys(appData[DueDiligenceKey]).length){ - appData[WhoIsRegisteringKey] = WhoIsRegisteringType.AGENT; + appData[HasSoldLandKey] = '0'; + appData[IsSecureRegisterKey] = '0'; + appData[Transactionkey] = transactionId; + appData[OverseasEntityKey] = overseaEntityId; + + if (appData[OverseasEntityDueDiligenceKey] && Object.keys(appData[OverseasEntityDueDiligenceKey]).length) { + appData[WhoIsRegisteringKey] = WhoIsRegisteringType.SOMEONE_ELSE; + } else if (appData[DueDiligenceKey] && Object.keys(appData[DueDiligenceKey]).length) { + appData[WhoIsRegisteringKey] = WhoIsRegisteringType.AGENT; + } } + if (isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB)) { mapTrustApiReturnModelToWebModel(appData); } diff --git a/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts b/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts index 7ebbabeb2..d82c9a6b0 100644 --- a/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts +++ b/src/controllers/update/update.manage.trusts.tell.us.about.the.legal.entity.controller.ts @@ -52,16 +52,15 @@ const getPagePropertiesRelevantPeriod = (isRelevantPeriod, trust, formData, url: }; export const get = async (req: Request, res: Response, next: NextFunction) => { - try { - logger.debugRequest(req, `${req.method} ${req.route.path}`); - const appData = await getApplicationData(req.session); const trusteeId = req.params[ROUTE_PARAM_TRUSTEE_ID]; const isRelevantPeriod = req.query['relevant-period']; + const trust = getTrustInReview(appData) as Trust; const trustee = getTrustee(trust, trusteeId, TrusteeType.LEGAL_ENTITY) as TrustCorporate; + const formData = trustee ? mapLegalEntityTrusteeFromSessionToPage(trustee) : {}; if (isRelevantPeriod || (trustee && trustee.relevant_period)) { diff --git a/src/model/trust.model.ts b/src/model/trust.model.ts index 9d47871fa..aea14c9cf 100644 --- a/src/model/trust.model.ts +++ b/src/model/trust.model.ts @@ -1,8 +1,8 @@ import { BeneficialOwnerIndividual } from '../model/beneficial.owner.individual.model'; import { BeneficialOwnerOther } from '../model/beneficial.owner.other.model'; import { BeneficialOwnerTypeChoice } from '../model/beneficial.owner.type.model'; +import { yesNoResponse } from './data.types.model'; import { RoleWithinTrustType } from './role.within.trust.type.model'; -import { Address, yesNoResponse } from './data.types.model'; export const TrustKey = "trusts"; @@ -89,8 +89,6 @@ export interface TrustIndividual { ceased_date_month?: string; ceased_date_year?: string; relevant_period?: boolean; - usual_residential_address?: Address - service_address?: Address } interface TrustHistoricalBeneficialOwnerCommon { @@ -174,8 +172,6 @@ export type TrustCorporate = { start_date_month?: string; start_date_year?: string; relevant_period?: boolean; - registered_office_address?: Address; - service_address?: Address }; export interface BeneficialOwnerItem { diff --git a/src/utils/change.link.ts b/src/utils/change.link.ts index f63fcefa1..375dd885c 100644 --- a/src/utils/change.link.ts +++ b/src/utils/change.link.ts @@ -22,12 +22,7 @@ export const createChangeLinkConfig = (href: string, text: string, dataEventId: /** * Return a change link with the transactionId and submissionId included - * - In case of an exception, return an HTML-safe hash(#) */ export const createChangeLinkWithIds = (link: string, transactionId: string, submissionId: string) => { - try { - return getUrlWithTransactionIdAndSubmissionId(link, transactionId, submissionId); - } catch (e) { - return "#"; - } + return getUrlWithTransactionIdAndSubmissionId(link, transactionId, submissionId); }; diff --git a/src/utils/trust.former.bo.ts b/src/utils/trust.former.bo.ts index ec494c9fe..d953ea3db 100644 --- a/src/utils/trust.former.bo.ts +++ b/src/utils/trust.former.bo.ts @@ -16,10 +16,16 @@ import { getUrlWithParamsToPath, isRegistrationJourney } from './url'; import { checkTrustLegalEntityBeneficialOwnerStillInvolved } from '../validation/stillInvolved.validation'; import { fetchApplicationData, setExtraData } from '../utils/application.data'; import { FormattedValidationErrors, formatValidationError } from '../middleware/validation.middleware'; -import { getTrustByIdFromApp, saveHistoricalBoInTrust, saveTrustInApp } from '../utils/trusts'; import { mapBeneficialOwnerToSession, mapFormerTrusteeByIdFromSessionToPage } from '../utils/trust/historical.beneficial.owner.mapper'; import { filingPeriodTrustCeaseDateValidations, filingPeriodTrustStartDateValidations } from '../validation/async'; import { updateOverseasEntity } from "../service/overseas.entities.service"; +import { mapTrustApiToWebWhenFlagsAreSet } from "../utils/trust/api.to.web.mapper"; + +import { + getTrustByIdFromApp, + saveHistoricalBoInTrust, + saveTrustInApp +} from '../utils/trusts'; export const HISTORICAL_BO_TEXTS = { title: 'Tell us about the former beneficial owner', @@ -76,16 +82,18 @@ export const getTrustFormerBo = async (req: Request, res: Response, next: NextFu logger.debugRequest(req, `${req.method} ${req.route.path}`); - const isRegistration = isRegistrationJourney(req); - const appData: ApplicationData = await fetchApplicationData(req, isRegistration); const trustId = req.params[config.ROUTE_PARAM_TRUST_ID]; const trusteeId = req.params[config.ROUTE_PARAM_TRUSTEE_ID]; + const isRegistration = isRegistrationJourney(req); + const appData: ApplicationData = await fetchApplicationData(req, isRegistration); + mapTrustApiToWebWhenFlagsAreSet(appData, isRegistration); const formData: PageModel.TrustHistoricalBeneficialOwnerForm = mapFormerTrusteeByIdFromSessionToPage( appData, trustId, trusteeId ); const pageProps = await getPageProperties(req, trustId, isUpdate, formData); + return res.render(pageProps.template, pageProps); } catch (error) { diff --git a/src/utils/trust.individual.beneficial.owner.ts b/src/utils/trust.individual.beneficial.owner.ts index 4c6805dcc..2a2faff24 100644 --- a/src/utils/trust.individual.beneficial.owner.ts +++ b/src/utils/trust.individual.beneficial.owner.ts @@ -13,11 +13,16 @@ import { isActiveFeature } from './feature.flag'; import { checkTrustIndividualCeasedDate } from '../validation/async'; import { checkTrustIndividualBeneficialOwnerStillInvolved } from '../validation/stillInvolved.validation'; import { getUrlWithParamsToPath, isRegistrationJourney } from './url'; +import { mapTrustApiToWebWhenFlagsAreSet } from "../utils/trust/api.to.web.mapper"; import { ValidationError, validationResult } from 'express-validator'; import { fetchApplicationData, setExtraData } from './application.data'; -import { getTrustByIdFromApp, saveTrustInApp, saveIndividualTrusteeInTrust } from './trusts'; import { mapIndividualTrusteeToSession, mapIndividualTrusteeByIdFromSessionToPage } from './trust/individual.trustee.mapper'; import { FormattedValidationErrors, formatValidationError } from '../middleware/validation.middleware'; +import { + getTrustByIdFromApp, + saveTrustInApp, + saveIndividualTrusteeInTrust, +} from './trusts'; export const INDIVIDUAL_BO_TEXTS = { title: 'Tell us about the individual', @@ -89,6 +94,7 @@ export const getTrustIndividualBo = async (req: Request, res: Response, next: Ne const trusteeId = req.params[config.ROUTE_PARAM_TRUSTEE_ID]; const isRegistration = isRegistrationJourney(req); const appData: ApplicationData = await fetchApplicationData(req, isRegistration); + mapTrustApiToWebWhenFlagsAreSet(appData, isRegistration); const isRelevantPeriod = req.query['relevant-period']; const formData: PageModel.IndividualTrusteesFormCommon = mapIndividualTrusteeByIdFromSessionToPage( appData, diff --git a/src/utils/trust.legal.entity.bo.ts b/src/utils/trust.legal.entity.bo.ts index 37c5f7cd8..1a422eb88 100644 --- a/src/utils/trust.legal.entity.bo.ts +++ b/src/utils/trust.legal.entity.bo.ts @@ -1,5 +1,6 @@ import { NextFunction, Request, Response } from 'express'; import { Session } from '@companieshouse/node-session-handler'; + import { logger } from './logger'; import * as config from '../config'; import { safeRedirect } from './http.ext'; @@ -18,6 +19,7 @@ import { CommonTrustData, TrustLegalEntityForm } from '../model/trust.page.model import { FormattedValidationErrors, formatValidationError } from '../middleware/validation.middleware'; import { ValidationError, validationResult } from 'express-validator'; import { getUrlWithParamsToPath, isRegistrationJourney } from './url'; +import { mapTrustApiToWebWhenFlagsAreSet } from "../utils/trust/api.to.web.mapper"; import { getTrustByIdFromApp, @@ -95,6 +97,7 @@ export const getTrustLegalEntityBo = async (req: Request, res: Response, next: N const isRegistration = isRegistrationJourney(req); const appData: ApplicationData = await fetchApplicationData(req, isRegistration); + mapTrustApiToWebWhenFlagsAreSet(appData, isRegistration); const trustId = req.params[config.ROUTE_PARAM_TRUST_ID]; const trusteeId = req.params[config.ROUTE_PARAM_TRUSTEE_ID]; const isRelevantPeriod = req.query ? req.query["relevant-period"] === "true" : false; diff --git a/src/utils/trust/api.to.web.mapper.ts b/src/utils/trust/api.to.web.mapper.ts new file mode 100644 index 000000000..e90734352 --- /dev/null +++ b/src/utils/trust/api.to.web.mapper.ts @@ -0,0 +1,12 @@ +import * as config from "../../config"; +import { isActiveFeature } from "../feature.flag"; +import { ApplicationData } from '../../model'; +import { mapTrustApiReturnModelToWebModel } from '../trusts'; + +export const mapTrustApiToWebWhenFlagsAreSet = (appData: ApplicationData, isRegistration: boolean) => { + if (isRegistration && isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL)) { + if (isActiveFeature(config.FEATURE_FLAG_ENABLE_TRUSTS_WEB)) { + mapTrustApiReturnModelToWebModel(appData); + } + } +}; diff --git a/src/utils/trust/common.trust.data.mapper.ts b/src/utils/trust/common.trust.data.mapper.ts index 1f3cac5d1..8f5a36fc5 100644 --- a/src/utils/trust/common.trust.data.mapper.ts +++ b/src/utils/trust/common.trust.data.mapper.ts @@ -1,7 +1,7 @@ import { ApplicationData } from '../../model'; import { CommonTrustData } from '../../model/trust.page.model'; -import { getTrustByIdFromApp } from '../trusts'; import { getReviewTrustById } from '../../utils/update/review_trusts'; +import { getTrustByIdFromApp } from '../trusts'; const mapCommonTrustDataToPage = ( appData: ApplicationData, @@ -9,12 +9,12 @@ const mapCommonTrustDataToPage = ( isReview: boolean ): CommonTrustData => { const trustData = isReview ? getReviewTrustById(appData, trustId) : getTrustByIdFromApp(appData, trustId); - return { trustId: trustData.trust_id, trustName: trustData.trust_name, }; }; + export { mapCommonTrustDataToPage, }; diff --git a/src/utils/trust/individual.trustee.mapper.ts b/src/utils/trust/individual.trustee.mapper.ts index d275bfcdc..3780faf4d 100644 --- a/src/utils/trust/individual.trustee.mapper.ts +++ b/src/utils/trust/individual.trustee.mapper.ts @@ -120,21 +120,21 @@ export const mapIndividualTrusteeFromSessionToPage = ( dateOfBirthYear: trustee.dob_year, nationality: trustee.nationality, second_nationality: trustee.second_nationality, - usual_residential_address_property_name_number: trustee.ura_address_premises ?? trustee?.usual_residential_address?.property_name_number, - usual_residential_address_line_1: trustee.ura_address_line_1 ?? trustee?.usual_residential_address?.line_1, - usual_residential_address_line_2: trustee.ura_address_line_2 ?? trustee?.usual_residential_address?.line_2, - usual_residential_address_town: trustee.ura_address_locality ?? trustee?.usual_residential_address?.town, - usual_residential_address_county: trustee.ura_address_region ?? trustee?.usual_residential_address?.county, - usual_residential_address_country: trustee.ura_address_country ?? trustee?.usual_residential_address?.country, - usual_residential_address_postcode: trustee.ura_address_postal_code ?? trustee?.usual_residential_address?.postcode, + usual_residential_address_property_name_number: trustee.ura_address_premises, + usual_residential_address_line_1: trustee.ura_address_line_1, + usual_residential_address_line_2: trustee.ura_address_line_2, + usual_residential_address_town: trustee.ura_address_locality, + usual_residential_address_county: trustee.ura_address_region, + usual_residential_address_country: trustee.ura_address_country, + usual_residential_address_postcode: trustee.ura_address_postal_code, is_service_address_same_as_usual_residential_address: trustee.is_service_address_same_as_usual_residential_address, - service_address_property_name_number: trustee.sa_address_premises ?? trustee?.service_address?.property_name_number, - service_address_line_1: trustee.sa_address_line_1 ?? trustee?.service_address?.line_1, - service_address_line_2: trustee.sa_address_line_2 ?? trustee?.service_address?.line_2, - service_address_town: trustee.sa_address_locality ?? trustee?.service_address?.town, - service_address_county: trustee.sa_address_region ?? trustee?.service_address?.county, - service_address_country: trustee.sa_address_country ?? trustee?.service_address?.country, - service_address_postcode: trustee.sa_address_postal_code ?? trustee?.service_address?.postcode, + service_address_property_name_number: trustee.sa_address_premises, + service_address_line_1: trustee.sa_address_line_1, + service_address_line_2: trustee.sa_address_line_2, + service_address_town: trustee.sa_address_locality, + service_address_county: trustee.sa_address_region, + service_address_country: trustee.sa_address_country, + service_address_postcode: trustee.sa_address_postal_code, stillInvolved: stillInvolvedInTrust, ceasedDateDay: trustee.ceased_date_day, ceasedDateMonth: trustee.ceased_date_month, diff --git a/src/utils/trust/legal.entity.beneficial.owner.mapper.ts b/src/utils/trust/legal.entity.beneficial.owner.mapper.ts index c20943168..961ec1711 100644 --- a/src/utils/trust/legal.entity.beneficial.owner.mapper.ts +++ b/src/utils/trust/legal.entity.beneficial.owner.mapper.ts @@ -125,20 +125,20 @@ const mapLegalEntityTrusteeFromSessionToPage = ( is_newly_added: trustee.ch_references ? false : true, roleWithinTrust: trustee.type, legalEntityName: trustee.name, - principal_address_property_name_number: trustee.ro_address_premises ?? trustee?.registered_office_address?.property_name_number, - principal_address_line_1: trustee.ro_address_line_1 ?? trustee?.registered_office_address?.line_1, - principal_address_line_2: trustee.ro_address_line_2 ?? trustee?.registered_office_address?.line_2, - principal_address_town: trustee.ro_address_locality ?? trustee?.registered_office_address?.town, - principal_address_county: trustee.ro_address_region ?? trustee?.registered_office_address?.county, - principal_address_country: trustee.ro_address_country ?? trustee?.registered_office_address?.country, - principal_address_postcode: trustee.ro_address_postal_code ?? trustee?.registered_office_address?.postcode, - service_address_property_name_number: trustee.sa_address_premises ?? trustee?.service_address?.property_name_number, - service_address_line_1: trustee.sa_address_line_1 ?? trustee?.service_address?.line_1, - service_address_line_2: trustee.sa_address_line_2 ?? trustee?.service_address?.line_2, - service_address_town: trustee.sa_address_locality ?? trustee?.service_address?.town, - service_address_county: trustee.sa_address_region ?? trustee?.service_address?.county, - service_address_country: trustee.sa_address_country ?? trustee?.service_address?.country, - service_address_postcode: trustee.sa_address_postal_code ?? trustee?.service_address?.postcode, + principal_address_property_name_number: trustee.ro_address_premises, + principal_address_line_1: trustee.ro_address_line_1, + principal_address_line_2: trustee.ro_address_line_2, + principal_address_town: trustee.ro_address_locality, + principal_address_county: trustee.ro_address_region, + principal_address_country: trustee.ro_address_country, + principal_address_postcode: trustee.ro_address_postal_code, + service_address_property_name_number: trustee.sa_address_premises, + service_address_line_1: trustee.sa_address_line_1, + service_address_line_2: trustee.sa_address_line_2, + service_address_town: trustee.sa_address_locality, + service_address_county: trustee.sa_address_region, + service_address_country: trustee.sa_address_country, + service_address_postcode: trustee.sa_address_postal_code, governingLaw: trustee.identification_legal_authority, legalForm: trustee.identification_legal_form, public_register_name: trustee.identification_place_registered, @@ -158,13 +158,13 @@ const mapLegalEntityTrusteeFromSessionToPage = ( const stillInvolvedInTrust: string = !trustee.still_involved || !isYesOrNo(trustee.still_involved) ? "" : YesOrNo[trustee.still_involved]; - if (trustee?.type && (trustee.type.toLowerCase() === RoleWithinTrustType.INTERESTED_PERSON.toLowerCase())) { + if (trustee.type === RoleWithinTrustType.INTERESTED_PERSON) { return { ...data, interestedPersonStartDateDay: trustee.date_became_interested_person_day, interestedPersonStartDateMonth: trustee.date_became_interested_person_month, interestedPersonStartDateYear: trustee.date_became_interested_person_year, - principal_address_property_name_number: trustee.ro_address_premises ?? trustee?.registered_office_address?.property_name_number, + principal_address_property_name_number: trustee.ro_address_premises, stillInvolved: stillInvolvedInTrust, } as Page.TrustLegalEntityForm; } diff --git a/src/utils/trusts.ts b/src/utils/trusts.ts index 404805eba..f846c5b8a 100644 --- a/src/utils/trusts.ts +++ b/src/utils/trusts.ts @@ -1,10 +1,16 @@ import { Request } from "express"; -import { RoleWithinTrustType } from "../model/role.within.trust.type.model"; import { v4 as uuidv4 } from "uuid"; import * as config from "../config"; +import { RoleWithinTrustType } from "../model/role.within.trust.type.model"; import { ApplicationData } from "../model"; +import { yesNoResponse } from "../model/data.types.model"; +import { isActiveFeature } from "./feature.flag"; +import { getUrlWithParamsToPath } from "./url"; + +import { ReviewTrustKey, UpdateKey } from "../model/update.type.model"; import { BeneficialOwnerIndividual, BeneficialOwnerIndividualKey } from "../model/beneficial.owner.individual.model"; import { BeneficialOwnerOther, BeneficialOwnerOtherKey } from "../model/beneficial.owner.other.model"; + import { BeneficialOwnerItem, Trust, @@ -14,10 +20,6 @@ import { TrustKey, TrustCorporate, } from "../model/trust.model"; -import { yesNoResponse } from "../model/data.types.model"; -import { isActiveFeature } from "./feature.flag"; -import { getUrlWithParamsToPath } from "./url"; -import { ReviewTrustKey, UpdateKey } from "../model/update.type.model"; /** * Checks whether any beneficial owners requires trust data due to at least one of them diff --git a/test/controllers/check.your.answers.controller.spec.ts b/test/controllers/check.your.answers.controller.spec.ts index e253f28c1..52579c385 100644 --- a/test/controllers/check.your.answers.controller.spec.ts +++ b/test/controllers/check.your.answers.controller.spec.ts @@ -191,7 +191,6 @@ describe("GET tests", () => { test(`renders the ${CHECK_YOUR_ANSWERS_PAGE} page including presenter details`, async () => { mockFetchApplicationData.mockReturnValueOnce({ ...APPLICATION_DATA_MOCK }); const resp = await request(app).get(CHECK_YOUR_ANSWERS_URL); - expect(resp.status).toEqual(200); expect(resp.text).toContain(LANDING_PAGE_URL); expect(resp.text).toContain(CHECK_YOUR_ANSWERS_PAGE_TITLE); diff --git a/test/controllers/resume.submission.controller.spec.ts b/test/controllers/resume.submission.controller.spec.ts index c4e615cff..1e82f5eb9 100644 --- a/test/controllers/resume.submission.controller.spec.ts +++ b/test/controllers/resume.submission.controller.spec.ts @@ -10,20 +10,44 @@ jest.mock("../../src/utils/logger"); jest.mock("../../src/utils/trusts"); jest.mock("../../src/utils/url"); -import { describe, expect, test, jest, beforeEach } from '@jest/globals'; import { NextFunction, Request, Response } from "express"; import request from "supertest"; import app from "../../src/app"; +import * as config from '../../src/config'; +import { createAndLogErrorRequest, logger } from "../../src/utils/logger"; +import { serviceAvailabilityMiddleware } from "../../src/middleware/service.availability.middleware"; +import { authentication } from "../../src/middleware/authentication.middleware"; +import { setExtraData } from "../../src/utils/application.data"; +import { getOverseasEntity } from "../../src/service/overseas.entities.service"; +import { getTransaction } from "../../src/service/transaction.service"; +import { startPaymentsSession } from "../../src/service/payment.service"; +import { isActiveFeature } from "../../src/utils/feature.flag"; +import { WhoIsRegisteringKey, WhoIsRegisteringType } from '../../src/model/who.is.making.filing.model'; +import { DueDiligenceKey } from '../../src/model/due.diligence.model'; +import { OverseasEntityDueDiligenceKey } from '../../src/model/overseas.entity.due.diligence.model'; +import { OVERSEAS_ENTITY_DUE_DILIGENCE_OBJECT_MOCK } from '../__mocks__/overseas.entity.due.diligence.mock'; +import { MOCK_GET_TRANSACTION_RESPONSE } from '../__mocks__/transaction.mock'; +import { mapTrustApiReturnModelToWebModel } from '../../src/utils/trusts'; +import { getUrlWithTransactionIdAndSubmissionId, isRegistrationJourney } from "../../src/utils/url"; + +import { + beneficialOwnerIndividualType, + beneficialOwnerOtherType, + beneficialOwnerGovType +} from "../../src/model"; + import { SOLD_LAND_FILTER_URL, SOLD_LAND_FILTER_PAGE } from "../../src/config"; + import { ANY_MESSAGE_ERROR, FOUND_REDIRECT_TO, SERVICE_UNAVAILABLE } from '../__mocks__/text.mock'; + import { APPLICATION_DATA_MOCK, BENEFICIAL_OWNER_INDIVIDUAL_OBJECT_MOCK, @@ -35,24 +59,15 @@ import { FULL_PAYMENT_REDIRECT_PATH, PAYMENT_HEADER } from '../__mocks__/session.mock'; -import * as config from '../../src/config'; -import { createAndLogErrorRequest, logger } from "../../src/utils/logger"; -import { serviceAvailabilityMiddleware } from "../../src/middleware/service.availability.middleware"; -import { authentication } from "../../src/middleware/authentication.middleware"; -import { setExtraData } from "../../src/utils/application.data"; -import { getOverseasEntity } from "../../src/service/overseas.entities.service"; -import { getTransaction } from "../../src/service/transaction.service"; -import { startPaymentsSession } from "../../src/service/payment.service"; -import { isActiveFeature } from "../../src/utils/feature.flag"; -import { WhoIsRegisteringKey, WhoIsRegisteringType } from '../../src/model/who.is.making.filing.model'; -import { DueDiligenceKey } from '../../src/model/due.diligence.model'; -import { EntityNumberKey, HasSoldLandKey, IsSecureRegisterKey, NatureOfControlType, OverseasEntityKey, Transactionkey } from '../../src/model/data.types.model'; -import { OverseasEntityDueDiligenceKey } from '../../src/model/overseas.entity.due.diligence.model'; -import { OVERSEAS_ENTITY_DUE_DILIGENCE_OBJECT_MOCK } from '../__mocks__/overseas.entity.due.diligence.mock'; -import { MOCK_GET_TRANSACTION_RESPONSE } from '../__mocks__/transaction.mock'; -import { mapTrustApiReturnModelToWebModel } from '../../src/utils/trusts'; -import { getUrlWithTransactionIdAndSubmissionId } from "../../src/utils/url"; -import { beneficialOwnerIndividualType, beneficialOwnerOtherType, beneficialOwnerGovType } from "../../src/model"; + +import { + EntityNumberKey, + HasSoldLandKey, + IsSecureRegisterKey, + NatureOfControlType, + OverseasEntityKey, + Transactionkey +} from '../../src/model/data.types.model'; const mockServiceAvailabilityMiddleware = serviceAvailabilityMiddleware as jest.Mock; mockServiceAvailabilityMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); @@ -80,6 +95,9 @@ const mockMapTrustApiReturnModelToWebModel = mapTrustApiReturnModelToWebModel as const mockGetUrlWithTransactionIdAndSubmissionId = getUrlWithTransactionIdAndSubmissionId as jest.Mock; +const mockIsRegistrationJourney = isRegistrationJourney as jest.Mock; +mockIsRegistrationJourney.mockReturnValue(true); + const baseURL = `${config.CHS_URL}${config.REGISTER_AN_OVERSEAS_ENTITY_URL}`; const mockNocAppData = { @@ -116,6 +134,7 @@ describe("Resume submission controller", () => { [IsSecureRegisterKey]: "", }; mockGetOverseasEntity.mockReturnValueOnce( mockAppData ); + const resp = await request(app).get(RESUME_SUBMISSION_URL); expect(resp.status).toEqual(302); @@ -184,8 +203,10 @@ describe("Resume submission controller", () => { }); test(`Redirect to starting payment page after resuming the OverseasEntity object and trusts feature flag on and REDIS_flag set to OFF`, async () => { + mockIsActiveFeature.mockReturnValueOnce( false ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( false ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( true ); // trusts feature flag + mockIsActiveFeature.mockReturnValueOnce( true ); // FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC mockGetOverseasEntity.mockReturnValueOnce( { ...APPLICATION_DATA_MOCK, [OverseasEntityDueDiligenceKey]: {} @@ -211,13 +232,15 @@ describe("Resume submission controller", () => { expect(mockSetExtraData).toHaveBeenCalledTimes(1); expect(mockCreateAndLogErrorRequest).not.toHaveBeenCalled(); expect(mockMapTrustApiReturnModelToWebModel).toHaveBeenCalledTimes(1); - expect(mockIsActiveFeature).toHaveBeenCalledTimes(3); + expect(mockIsActiveFeature).toHaveBeenCalledTimes(4); expect(mockGetUrlWithTransactionIdAndSubmissionId).not.toHaveBeenCalled(); }); test(`Redirect to starting payment page after resuming the OverseasEntity object and trusts feature flag on and REDIS_flag set to ON`, async () => { + mockIsActiveFeature.mockReturnValueOnce( true ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( true ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( true ); // trusts feature flag + mockIsActiveFeature.mockReturnValueOnce( false ); // FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC mockGetOverseasEntity.mockReturnValueOnce( { ...APPLICATION_DATA_MOCK, [OverseasEntityDueDiligenceKey]: {} @@ -243,7 +266,7 @@ describe("Resume submission controller", () => { expect(mockSetExtraData).toHaveBeenCalledTimes(1); expect(mockCreateAndLogErrorRequest).not.toHaveBeenCalled(); expect(mockMapTrustApiReturnModelToWebModel).toHaveBeenCalledTimes(1); - expect(mockIsActiveFeature).toHaveBeenCalledTimes(3); + expect(mockIsActiveFeature).toHaveBeenCalledTimes(4); expect(mockGetUrlWithTransactionIdAndSubmissionId).toHaveBeenCalledTimes(1); }); @@ -265,12 +288,12 @@ describe("Resume submission controller", () => { test("Catch error when resuming Overseas Entity", async () => { mockGetOverseasEntity.mockReturnValueOnce( () => { throw new Error(ANY_MESSAGE_ERROR); }); const resp = await request(app).get(RESUME_SUBMISSION_URL); - expect(resp.status).toEqual(500); expect(resp.text).toContain(SERVICE_UNAVAILABLE); }); test(`Remove old NOCs after resuming the OverseasEntity Registration submission and FEATURE_FLAG_ENABLE_PROPERTY_OR_LAND_OWNER_NOC is ON`, async () => { + mockIsActiveFeature.mockReturnValueOnce( true ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( true ); // REDIS flag mockIsActiveFeature.mockReturnValueOnce( true ); // trusts feature flag mockIsActiveFeature.mockReturnValueOnce( true ); // new NOCs diff --git a/test/utils/change.link.spec.ts b/test/utils/change.link.spec.ts index 2d6dc04ac..b03b0008a 100644 --- a/test/utils/change.link.spec.ts +++ b/test/utils/change.link.spec.ts @@ -15,9 +15,6 @@ import { DATA_EVENT_ID } from '../__mocks__/text.mock'; -const transcationId = "123abc"; -const submissionId = "abc123"; - describe('createChangeLinkConfig test suite', () => { test('should check if the object returned is correct, and contains the change link configs', () => { @@ -29,14 +26,10 @@ describe('createChangeLinkConfig test suite', () => { }); test('should correctly substitute the transactionId and submissionId in a url ', () => { + const transcationId = "123abc"; + const submissionId = "abc123"; const substitutedUrl = createChangeLinkWithIds(REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL, transcationId, submissionId); expect(substitutedUrl).toEqual(`${LANDING_URL}/transaction/${transcationId}/submission/${submissionId}/`); }); - test('should return a hash value if the substitution for transactionId and submissionId fails', () => { - // eslint-disable-next-line - const substitutedUrl = createChangeLinkWithIds(undefined, transcationId, submissionId); - expect(substitutedUrl).toEqual('#'); - }); - }); diff --git a/test/utils/trust.spec.ts b/test/utils/trust.spec.ts index ab7e17898..4a4407c8e 100644 --- a/test/utils/trust.spec.ts +++ b/test/utils/trust.spec.ts @@ -1,8 +1,31 @@ jest.mock('../../src/utils/feature.flag'); jest.mock('../../src/utils/url'); -import { describe, expect, test } from '@jest/globals'; -import { TRUST_DETAILS_URL, TRUST_INTERRUPT_URL, TRUST_ENTRY_URL, ADD_TRUST_URL, TRUST_ENTRY_WITH_PARAMS_URL } from "../../src/config"; +import { TrustIndividual } from '@companieshouse/api-sdk-node/dist/services/overseas-entities'; +import { isActiveFeature } from '../../src/utils/feature.flag'; +import { Request } from 'express'; +import { getUrlWithParamsToPath } from '../../src/utils/url'; +import { ApplicationData } from '../../src/model'; +import { NatureOfControlType } from '../../src/model/data.types.model'; + +import { + BeneficialOwnerOther, + BeneficialOwnerOtherKey +} from '../../src/model/beneficial.owner.other.model'; + +import { + BeneficialOwnerIndividual, + BeneficialOwnerIndividualKey, +} from '../../src/model/beneficial.owner.individual.model'; + +import { + TRUST_DETAILS_URL, + TRUST_INTERRUPT_URL, + TRUST_ENTRY_URL, + ADD_TRUST_URL, + TRUST_ENTRY_WITH_PARAMS_URL +} from "../../src/config"; + import { addTrustToBeneficialOwner, getBoIndividualAssignableToTrust, @@ -26,18 +49,15 @@ import { getFormerTrustee, mapTrustApiReturnModelToWebModel, } from '../../src/utils/trusts'; -import { ApplicationData } from '../../src/model'; -import { NatureOfControlType } from '../../src/model/data.types.model'; -import { Trust, TrustBeneficialOwner, TrustHistoricalBeneficialOwner, TrustKey, TrustCorporate, IndividualTrustee } from '../../src/model/trust.model'; + import { - BeneficialOwnerIndividual, - BeneficialOwnerIndividualKey, -} from '../../src/model/beneficial.owner.individual.model'; -import { BeneficialOwnerOther, BeneficialOwnerOtherKey } from '../../src/model/beneficial.owner.other.model'; -import { TrustIndividual } from '@companieshouse/api-sdk-node/dist/services/overseas-entities'; -import { isActiveFeature } from '../../src/utils/feature.flag'; -import { Request } from 'express'; -import { getUrlWithParamsToPath } from '../../src/utils/url'; + Trust, + TrustBeneficialOwner, + TrustHistoricalBeneficialOwner, + TrustKey, + TrustCorporate, + IndividualTrustee +} from '../../src/model/trust.model'; const mockIsActiveFeature = isActiveFeature as jest.Mock; mockIsActiveFeature.mockReturnValue(false); @@ -49,6 +69,12 @@ mockGetUrlWithParamsToPath.mockReturnValue(MOCKED_URL); const mockRequest = {} as Request; describe('Trust Utils method tests', () => { + + beforeEach(() => { + jest.clearAllMocks(); + mockIsActiveFeature.mockReset(); + }); + const trustId = 'dummyExistsTrustId'; const newTrustId = 'dummyTrustId'; @@ -167,7 +193,6 @@ describe('Trust Utils method tests', () => { ...mockAppData }; mockAppDataWithACeasedIndividualBO[BeneficialOwnerIndividualKey].push(mockBoCeasedIndividualWithTrusteeNoc); - expect(getBoIndividualAssignableToTrust(mockAppDataWithACeasedIndividualBO)).toEqual([mockBoIndividual1]); }); @@ -176,7 +201,6 @@ describe('Trust Utils method tests', () => { ...mockAppData }; mockAppDataWithACeasedIndividualBO[BeneficialOwnerIndividualKey].push(mockBoCeasedIndividualWithTrusteeNocRelevantPeriod); - expect(getBoIndividualAssignableToTrust(mockAppDataWithACeasedIndividualBO)).toEqual([mockBoIndividual1, mockBoCeasedIndividualWithTrusteeNocRelevantPeriod]); }); @@ -189,7 +213,6 @@ describe('Trust Utils method tests', () => { ...mockAppData }; mockAppDataWithACeasedOtherBO[BeneficialOwnerOtherKey].push(mockBoCeasedOleWithTrusteeNoc); - expect(getBoOtherAssignableToTrust(mockAppDataWithACeasedOtherBO)).toEqual([mockBoOle2]); }); @@ -198,7 +221,6 @@ describe('Trust Utils method tests', () => { ...mockAppData }; mockAppDataWithACeasedOtherBO[BeneficialOwnerOtherKey].push(mockBoCeasedOleWithTrusteeNocRelevantPeriod); - expect(getBoOtherAssignableToTrust(mockAppDataWithACeasedOtherBO)).toEqual([mockBoOle2, mockBoCeasedOleWithTrusteeNocRelevantPeriod]); }); @@ -210,7 +232,6 @@ describe('Trust Utils method tests', () => { const mockBo = { id: '9999', } as TrustBeneficialOwner; - expect(addTrustToBeneficialOwner(mockBo, newTrustId)).toEqual({ ...mockBo, trust_ids: [newTrustId], @@ -624,13 +645,11 @@ describe('Trust Utils method tests', () => { describe('test if overseas entity requires trust data', () => { test("test checkEntityRequiresTrusts with application data and trustee nature of control", () => { - const result = checkEntityRequiresTrusts(mockAppData); expect(result).toEqual(true); }); test("test checkEntityRequiresTrusts with application data and no trustee nature of control", () => { - const appData = { [TrustKey]: [ mockTrust1Data, @@ -662,19 +681,16 @@ describe('Trust Utils method tests', () => { describe('test if overseas entity contains any trust data', () => { test("test getBeneficialOwnerList with application data and trustee nature of control", () => { - const result = getTrustLandingUrl(mockAppData); expect(result).toEqual(`${TRUST_ENTRY_URL + ADD_TRUST_URL}`); }); test("test getTrustLandingUrl with bo having trust data", () => { - const result = getTrustLandingUrl(mockAppData); expect(result).toEqual(`${TRUST_ENTRY_URL + ADD_TRUST_URL}`); }); test("test getTrustLandingUrl with bo having trust nature of control but no trust data", () => { - const mockBoIndividualNoTrustData = { id: '9001', trustees_nature_of_control_types: ['dummyType' as NatureOfControlType], @@ -699,7 +715,6 @@ describe('Trust Utils method tests', () => { const result = getTrustLandingUrl(appData); expect(result).toEqual(`${TRUST_DETAILS_URL}${TRUST_INTERRUPT_URL}`); }); - }); describe('test if overseas entity contains any trust data with params for redis removal', () => { @@ -942,7 +957,7 @@ describe('Trust Utils method tests', () => { ] }; - test("test Web Model OK for multi-trust app data with all trusees types", () => { + test("test Web Model OK for multi-trust app data with all trustee types", () => { const trusts = apiData.trusts ?? []; @@ -1114,8 +1129,8 @@ describe('Trust Utils method tests', () => { expect(historicalTrusteesWebModel[1]["ceased_date_month"]).toEqual("02"); expect(historicalTrusteesWebModel[1]["ceased_date_year"]).toEqual("2022"); }); - }); + test("no trust data so nothing happens in mapTrustApiReturnModelToWebModel", () => { mapTrustApiReturnModelToWebModel({}); }); @@ -1125,14 +1140,12 @@ describe('Trust Utils method tests', () => { test('when no BOs have trustee of a trust noc returns false', () => { const appData = { }; - const result = checkEntityRequiresTrusts(appData as ApplicationData); expect(result).toBe(false); }); test('when no app data returns false', () => { const appData = undefined; - const result = checkEntityRequiresTrusts(appData); expect(result).toBe(false); }); @@ -1141,7 +1154,6 @@ describe('Trust Utils method tests', () => { const appData = { beneficial_owners_corporate: [{ trustees_nature_of_control_types: [NatureOfControlType.OVER_25_PERCENT_OF_SHARES] }] }; - const result = checkEntityRequiresTrusts(appData as ApplicationData); expect(result).toBe(true); }); @@ -1157,25 +1169,20 @@ describe('Trust Utils method tests', () => { test('when no BOs to review have trustee of a trust noc returns false', () => { const appData = { - update: { - } + update: {} }; - const result = checkEntityReviewRequiresTrusts(appData as ApplicationData); expect(result).toBe(false); }); test('when no BOs to review as no update in app data returns false', () => { - const appData = { - }; - + const appData = {}; const result = checkEntityReviewRequiresTrusts(appData as ApplicationData); expect(result).toBe(false); }); test('when no BOs to review as no app data returns false', () => { const appData = undefined; - const result = checkEntityReviewRequiresTrusts(appData); expect(result).toBe(false); }); @@ -1186,7 +1193,6 @@ describe('Trust Utils method tests', () => { review_beneficial_owners_corporate: [{ trustees_nature_of_control_types: [NatureOfControlType.OVER_25_PERCENT_OF_SHARES, NatureOfControlType.SIGNIFICANT_INFLUENCE_OR_CONTROL] }] } }; - const result = checkEntityReviewRequiresTrusts(appData as ApplicationData); expect(result).toBe(true); }); @@ -1197,7 +1203,6 @@ describe('Trust Utils method tests', () => { review_beneficial_owners_individual: [{ trustees_nature_of_control_types: [NatureOfControlType.OVER_25_PERCENT_OF_SHARES] }] } }; - const result = checkEntityReviewRequiresTrusts(appData as ApplicationData); expect(result).toBe(true); }); diff --git a/test/utils/trust/api.to.web.mapper.spec.ts b/test/utils/trust/api.to.web.mapper.spec.ts new file mode 100644 index 000000000..f5673d8d4 --- /dev/null +++ b/test/utils/trust/api.to.web.mapper.spec.ts @@ -0,0 +1,56 @@ +jest.mock("../../../src/utils/trusts"); +jest.mock("../../../src/utils/feature.flag"); + +import { mapTrustApiReturnModelToWebModel } from "../../../src/utils/trusts"; +import { isActiveFeature } from "../../../src/utils/feature.flag"; +import { APPLICATION_DATA_MOCK } from "../../__mocks__/session.mock"; +import { mapTrustApiToWebWhenFlagsAreSet } from "../../../src/utils/trust/api.to.web.mapper"; + +const mockMapTrustApiReturnModelToWebModel = mapTrustApiReturnModelToWebModel as jest.Mock; +const mockIsActiveFeature = isActiveFeature as jest.Mock; + +describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { + + beforeEach(() => { + jest.clearAllMocks(); + mockIsActiveFeature.mockReset(); + mockMapTrustApiReturnModelToWebModel.mockReset(); + }); + + test('is not invoked when isRegistration flag is false', () => { + mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK, false); + expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); + }); + + test('is not invoked when REDIS_removal flag is set to OFF', () => { + mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL + mockIsActiveFeature.mockReturnValueOnce(true); // FEATURE_FLAG_ENABLE_TRUSTS_WEB + mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); + expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); + }); + + test('is not invoked when Trusts_web flag is set to OFF', () => { + mockIsActiveFeature.mockReturnValueOnce(true); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL + mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_TRUSTS_WEB + mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); + expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); + }); + + test('is not invoked when REDIS_removal flag is set to OFF and Trusts_web flag is set to OFF', () => { + mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL + mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_TRUSTS_WEB + mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); + expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); + }); + + test('is invoked when isRegistration is set to TRUE and both flags are set to ON', () => { + mockIsActiveFeature.mockReturnValue(true); // ALL_FLAGS + mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); + expect(mockMapTrustApiReturnModelToWebModel).toHaveBeenCalledTimes(1); + }); +}); diff --git a/test/utils/trust/common.trust.data.mapper.spec.ts b/test/utils/trust/common.trust.data.mapper.spec.ts index fec78cdba..adcbb499f 100644 --- a/test/utils/trust/common.trust.data.mapper.spec.ts +++ b/test/utils/trust/common.trust.data.mapper.spec.ts @@ -1,4 +1,3 @@ -import { beforeEach, describe, expect, jest, test } from "@jest/globals"; import { mapCommonTrustDataToPage } from "../../../src/utils/trust/common.trust.data.mapper"; import { TrustKey } from '../../../src/model/trust.model'; diff --git a/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts b/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts index 6ff257bd2..749b94744 100644 --- a/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts +++ b/test/utils/trust/legal.entity.beneficial.owner.mapper.spec.ts @@ -1,7 +1,8 @@ jest.mock('uuid'); -import * as uuid from 'uuid'; -import { yesNoResponse } from "@companieshouse/api-sdk-node/dist/services/overseas-entities"; + +import { beforeEach, describe, expect, jest, test } from "@jest/globals"; import { ApplicationData } from "../../../src/model"; +import * as uuid from 'uuid'; import { TrustLegalEntityForm } from '../../../src/model/trust.page.model'; import { TrustCorporate, TrustKey } from "../../../src/model/trust.model"; import { TrusteeType } from "../../../src/model/trustee.type.model"; @@ -12,15 +13,14 @@ import { mapLegalEntityToSession, mapLegalEntityTrusteeByIdFromSessionToPage, } from '../../../src/utils/trust/legal.entity.beneficial.owner.mapper'; +import { yesNoResponse } from "@companieshouse/api-sdk-node/dist/services/overseas-entities"; describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { - beforeEach(() => { jest.clearAllMocks(); }); describe('Test session mapper methods', () => { - describe('Test trust legal entity form to session mapping', () => { const mockFormDataBasic = { legalEntityId: "9999", @@ -148,9 +148,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { still_involved: "No", }); }); - test('Map start_date to session when relevant_period is true', () => { - const mockFormData = { ...mockFormDataBasic, roleWithinTrust: RoleWithinTrustType.INTERESTED_PERSON, @@ -205,10 +203,10 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { still_involved: "No", }); }); - test('test generateId', () => { const expectNewId = '9999'; jest.spyOn(uuid, 'v4').mockReturnValue(expectNewId); + expect(generateId()).toBe(expectNewId); }); }); @@ -248,7 +246,6 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceased_date_year: "2020", still_involved: "No" }; - test("Map legal entity trustee session data to page", () => { const trustId = '987'; @@ -355,7 +352,6 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { stillInvolved: "0" }); }); - test("Map legal entity trustee session data to page trustee item", () => { expect( mapLegalEntityItemToPage(mockSessionDataBasic as TrustCorporate) @@ -371,18 +367,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; + const mockSessionData = { ...mockSessionDataBasic, still_involved: "Yes", - type: RoleWithinTrustType.GRANTOR }; + const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; - expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -413,12 +409,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "1", - relevant_period: undefined, - roleWithinTrust: RoleWithinTrustType.GRANTOR, - startDateDay: undefined, - startDateMonth: undefined, - startDateYear: undefined, + stillInvolved: "1" }); }); @@ -426,18 +417,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; + const mockSessionData = { ...mockSessionDataBasic, still_involved: "No", - type: RoleWithinTrustType.BENEFICIARY }; + const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; - expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -468,12 +459,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "0", - relevant_period: undefined, - roleWithinTrust: "Beneficiary", - startDateDay: undefined, - startDateMonth: undefined, - startDateYear: undefined + stillInvolved: "0" }); }); @@ -481,18 +467,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; + const mockSessionData = { ...mockSessionDataBasic, still_involved: undefined, - type: RoleWithinTrustType.BENEFICIARY }; + const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; - expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -523,12 +509,7 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "", - relevant_period: undefined, - roleWithinTrust: RoleWithinTrustType.BENEFICIARY, - startDateDay: undefined, - startDateMonth: undefined, - startDateYear: undefined, + stillInvolved: "" }); }); @@ -536,18 +517,18 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { const trustId = '987'; const trusteeId = '9998'; + const mockSessionData = { ...mockSessionDataBasic, still_involved: "Wrong", - type: RoleWithinTrustType.BENEFICIARY }; + const appData = { [TrustKey]: [{ 'trust_id': trustId, 'CORPORATES': [ mockSessionData ] as TrustCorporate[], }] } as ApplicationData; - expect( mapLegalEntityTrusteeByIdFromSessionToPage(appData, trustId, trusteeId) ).toEqual({ @@ -578,14 +559,10 @@ describe('Trust Legal Entity Beneficial Owner Page Mapper Service', () => { ceasedDateDay: mockSessionData.ceased_date_day, ceasedDateMonth: mockSessionData.ceased_date_month, ceasedDateYear: mockSessionData.ceased_date_year, - stillInvolved: "", - relevant_period: undefined, - roleWithinTrust: RoleWithinTrustType.BENEFICIARY, - startDateDay: undefined, - startDateMonth: undefined, - startDateYear: undefined, + stillInvolved: "" }); }); + }); }); }); diff --git a/views/includes/check-your-answers/beneficial-owner-gov.html b/views/includes/check-your-answers/beneficial-owner-gov.html index 7da6acfbe..9306fd476 100644 --- a/views/includes/check-your-answers/beneficial-owner-gov.html +++ b/views/includes/check-your-answers/beneficial-owner-gov.html @@ -83,7 +83,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_GOV_URL + "/" + bog.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_GOV_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + bog.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.BENEFICIAL_OWNER_GOV_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + bog.id %} {% endif %} {% else %} {% if bog.ch_reference %} diff --git a/views/includes/check-your-answers/beneficial-owner-individual.html b/views/includes/check-your-answers/beneficial-owner-individual.html index 310739740..eb0f9f5a9 100644 --- a/views/includes/check-your-answers/beneficial-owner-individual.html +++ b/views/includes/check-your-answers/beneficial-owner-individual.html @@ -102,7 +102,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_URL + "/" + boi.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boi.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.BENEFICIAL_OWNER_INDIVIDUAL_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boi.id %} {% endif %} {% else %} {% if boi.ch_reference %} diff --git a/views/includes/check-your-answers/beneficial-owner-other.html b/views/includes/check-your-answers/beneficial-owner-other.html index f80eab332..7f93285d8 100644 --- a/views/includes/check-your-answers/beneficial-owner-other.html +++ b/views/includes/check-your-answers/beneficial-owner-other.html @@ -98,7 +98,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_OTHER_URL + "/" + boc.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_OTHER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boc.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.BENEFICIAL_OWNER_OTHER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + boc.id %} {% endif %} {% else %} {% if boc.ch_reference %} diff --git a/views/includes/check-your-answers/beneficial-owner-statements.html b/views/includes/check-your-answers/beneficial-owner-statements.html index 18b96e826..d7dcd435e 100644 --- a/views/includes/check-your-answers/beneficial-owner-statements.html +++ b/views/includes/check-your-answers/beneficial-owner-statements.html @@ -21,7 +21,7 @@

Has the overseas entity identified any registrable b {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_URL %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.BENEFICIAL_OWNER_STATEMENTS_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {{ govukSummaryList({ diff --git a/views/includes/check-your-answers/historical-trustee.html b/views/includes/check-your-answers/historical-trustee.html index b8b95605c..ded1aa21e 100644 --- a/views/includes/check-your-answers/historical-trustee.html +++ b/views/includes/check-your-answers/historical-trustee.html @@ -17,7 +17,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_HISTORICAL_BENEFICIAL_OWNER_PAGE + "/" + formerTrustee.id %} {% endif %} {% else %} {% if manageTrusts %} diff --git a/views/includes/check-your-answers/individual-trustee.html b/views/includes/check-your-answers/individual-trustee.html index cc55bd2c9..eb4bb5884 100644 --- a/views/includes/check-your-answers/individual-trustee.html +++ b/views/includes/check-your-answers/individual-trustee.html @@ -9,14 +9,14 @@ {% set interestedPersonDate = dateMacros.formatDate(individualTrustee.date_became_interested_person_day, individualTrustee.date_became_interested_person_month, individualTrustee.date_became_interested_person_year) %} {% set individualTrusteeFormattedResidentialAddressHtml %} - {% set address = { - property_name_number: individualTrustee.ura_address_premises or individualTrustee.usual_residential_address.property_name_number, - line_1: individualTrustee.ura_address_line_1 or individualTrustee.usual_residential_address.line_1, - line_2: individualTrustee.ura_address_line_2 or individualTrustee.usual_residential_address.line_2, - town: individualTrustee.ura_address_locality or individualTrustee.usual_residential_address.town, - county: individualTrustee.ura_address_region or individualTrustee.usual_residential_address.county, - country: individualTrustee.ura_address_country or individualTrustee.usual_residential_address.country, - postcode: individualTrustee.ura_address_postal_code or individualTrustee.usual_residential_address.postcode + {% set address = { + property_name_number: individualTrustee.ura_address_premises, + line_1: individualTrustee.ura_address_line_1, + line_2: individualTrustee.ura_address_line_2, + town: individualTrustee.ura_address_locality, + county: individualTrustee.ura_address_region, + country: individualTrustee.ura_address_country, + postcode: individualTrustee.ura_address_postal_code } %} {% include "includes/display_address.html" %} {% endset %} @@ -30,12 +30,12 @@ {% set individualTrusteeChangeServiceAddressHtml = OE_CONFIGS.CHANGE_SERVICE_ADDRESS %} {% set address = { property_name_number: individualTrustee.sa_address_premises, - line_1: individualTrustee.sa_address_line_1 or individualTrustee.service_address.line_1, - line_2: individualTrustee.sa_address_line_2 or individualTrustee.service_address.line_2, - town: individualTrustee.sa_address_locality or individualTrustee.service_address.town, - county: individualTrustee.sa_address_region or individualTrustee.service_address.county, - country: individualTrustee.sa_address_country or individualTrustee.service_address.country, - postcode: individualTrustee.sa_address_postal_code or individualTrustee.service_address.postcode + line_1: individualTrustee.sa_address_line_1, + line_2: individualTrustee.sa_address_line_2, + town: individualTrustee.sa_address_locality, + county: individualTrustee.sa_address_region, + country: individualTrustee.sa_address_country, + postcode: individualTrustee.sa_address_postal_code } %} {% include "includes/display_address.html" %} {% endif %} @@ -45,7 +45,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_INDIVIDUAL_BENEFICIAL_OWNER_PAGE + "/" + individualTrustee.id %} {% endif %} {% else %} {% set stillInvolved = individualTrustee.still_involved %} diff --git a/views/includes/check-your-answers/legal-entity-trustee.html b/views/includes/check-your-answers/legal-entity-trustee.html index 13f13724a..e6d70f9a3 100644 --- a/views/includes/check-your-answers/legal-entity-trustee.html +++ b/views/includes/check-your-answers/legal-entity-trustee.html @@ -8,13 +8,13 @@ {% set legalEntityFormattedResidentialAddressHtml %} {% set address = { - property_name_number: legalEntity.registered_office_address.property_name_number, - line_1: legalEntity.ro_address_line_1 or legalEntity.registered_office_address.line_1, - line_2: legalEntity.ro_address_line_2 or legalEntity.registered_office_address.line_2, - town: legalEntity.ro_address_locality or legalEntity.registered_office_address.town, - county: legalEntity.ro_address_region or legalEntity.registered_office_address.county, - country: legalEntity.ro_address_country or legalEntity.registered_office_address.country, - postcode: legalEntity.ro_address_postal_code or legalEntity.registered_office_address.postcode + property_name_number: legalEntity.ro_address_premises, + line_1: legalEntity.ro_address_line_1, + line_2: legalEntity.ro_address_line_2, + town: legalEntity.ro_address_locality, + county: legalEntity.ro_address_region, + country: legalEntity.ro_address_country, + postcode: legalEntity.ro_address_postal_code } %} {% include "includes/display_address.html" %} {% endset %} @@ -27,13 +27,13 @@ {% else %} {% set legalEntityChangeServiceAddressHtml = OE_CONFIGS.CHANGE_SERVICE_ADDRESS %} {% set address = { - property_name_number: legalEntity.sa_address_premises or legalEntity.service_address.property_name_number, - line_1: legalEntity.sa_address_line_1 or legalEntity.service_address.line_1, - line_2: legalEntity.sa_address_line_2 or legalEntity.service_address.line_2, - town: legalEntity.sa_address_locality or legalEntity.service_address.town, - county: legalEntity.sa_address_region or legalEntity.service_address.county, - country: legalEntity.sa_address_country or legalEntity.service_address.country, - postcode: legalEntity.sa_address_postal_code or legalEntity.service_address.postcode + property_name_number: legalEntity.sa_address_premises, + line_1: legalEntity.sa_address_line_1, + line_2: legalEntity.sa_address_line_2, + town: legalEntity.sa_address_locality, + county: legalEntity.sa_address_region, + country: legalEntity.sa_address_country, + postcode: legalEntity.sa_address_postal_code } %} {% include "includes/display_address.html" %} {% endif %} @@ -55,7 +55,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.TRUSTS_URL + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + trust.trust_id + "/" + OE_CONFIGS.TRUST_LEGAL_ENTITY_BENEFICIAL_OWNER_PAGE + "/" + legalEntity.id %} {% endif %} {% else %} {% set stillInvolved = legalEntity.still_involved %} diff --git a/views/includes/check-your-answers/managing-officer-corporate.html b/views/includes/check-your-answers/managing-officer-corporate.html index 5c5b593de..5779e356a 100644 --- a/views/includes/check-your-answers/managing-officer-corporate.html +++ b/views/includes/check-your-answers/managing-officer-corporate.html @@ -29,7 +29,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_CORPORATE_URL + "/" + moc.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.MANAGING_OFFICER_CORPORATE_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moc.id %} %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.MANAGING_OFFICER_CORPORATE_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moc.id %} %} {% endif %}

Corporate managing officer

diff --git a/views/includes/check-your-answers/managing-officer-individual.html b/views/includes/check-your-answers/managing-officer-individual.html index f44db6d09..8bc369e50 100644 --- a/views/includes/check-your-answers/managing-officer-individual.html +++ b/views/includes/check-your-answers/managing-officer-individual.html @@ -29,7 +29,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.MANAGING_OFFICER_URL + "/" + moi.id %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.MANAGING_OFFICER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moi.id %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.MANAGING_OFFICER_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) + "/" + moi.id %} {% endif %} {# Build and add each govukSummaryList row separately so that some rows can be optional #} diff --git a/views/includes/check-your-answers/presenter.html b/views/includes/check-your-answers/presenter.html index 6e7fa6eae..1498a18b6 100644 --- a/views/includes/check-your-answers/presenter.html +++ b/views/includes/check-your-answers/presenter.html @@ -8,8 +8,8 @@ {% set presenterNameChangeLink = OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME %} {% set presenterEmailChangeLink = OE_CONFIGS.PRESENTER_CHANGE_EMAIL %} {% else %} - {% set presenterNameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set presenterEmailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.PRESENTER_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set presenterNameChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set presenterEmailChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.PRESENTER_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {% else %} {% set contactDetailsSubText %} diff --git a/views/includes/check-your-answers/trusts.html b/views/includes/check-your-answers/trusts.html index 64a42f2ae..115539922 100644 --- a/views/includes/check-your-answers/trusts.html +++ b/views/includes/check-your-answers/trusts.html @@ -19,7 +19,7 @@

{{ trust_heading }}

{% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkUrl = OE_CONFIGS.TRUST_DETAILS_URL %} {% else %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.TRUST_ENTRY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {% else %} {% set trustStillInvolved = trust.trust_still_involved_in_overseas_entity %} diff --git a/views/includes/check-your-answers/verification-checks.html b/views/includes/check-your-answers/verification-checks.html index a4237b23e..26e2904d7 100644 --- a/views/includes/check-your-answers/verification-checks.html +++ b/views/includes/check-your-answers/verification-checks.html @@ -29,23 +29,24 @@ {% else %} {% if who_is_registering == "agent" %} {% set whoIsCompleting = ukAgent %} - {% set agentChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set agentChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% else %} {% set whoIsCompleting = someoneElse %} - {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} - {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set agentChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set dateChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set nameChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set addressChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_IDENTITY_ADDRESS_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set emailChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_EMAIL_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set supervisoryChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set amlChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set partnerChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {% endif %} {% else %} diff --git a/views/includes/entity.html b/views/includes/entity.html index c2da32a85..ae6d46fd0 100644 --- a/views/includes/entity.html +++ b/views/includes/entity.html @@ -2,7 +2,7 @@ {% set inChangeJourney = not inNoChangeJourney %} {% if pageParams.isRegistration and IS_REDIS_REMOVAL_ENABLED %} - {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.ENTITY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set changeLinkUrl = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.ENTITY_WITH_PARAMS_URL, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {% set formattedPrincipalAddressHtml %} @@ -36,7 +36,7 @@ {% if not IS_REDIS_REMOVAL_ENABLED %} {% set changeLinkEntityName = OE_CONFIGS.ENTITY_CHANGE_NAME %} {% else %} - {% set changeLinkEntityName = CREATE_CHANGE_LINK_WITH_IDs(OE_CONFIGS.ENTITY_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} + {% set changeLinkEntityName = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.ENTITY_CHANGE_NAME_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% endif %} {% set entityNameLink = CREATE_CHANGE_LINK( changeLinkEntityName, diff --git a/views/includes/page-templates/trust-historical-bo.html b/views/includes/page-templates/trust-historical-bo.html index 7dbdc175a..e58b25803 100644 --- a/views/includes/page-templates/trust-historical-bo.html +++ b/views/includes/page-templates/trust-historical-bo.html @@ -1,13 +1,12 @@
- {% include "includes/list/errors.html" %} {{ pageData.trustData.trustName }}

{{ pageParams.title }}


You can add more later.


- + {% include "includes/csrf_token.html" %} {% set legalEntityHtml %} @@ -52,7 +51,7 @@

{{ pageParams.title }}

{ value: pageData.trusteeType.LEGAL_ENTITY, text: "Legal Entity", - checked: (formData.type | lower) === (pageData.trusteeType.LEGAL_ENTITY | lower), + checked: formData.type == pageData.trusteeType.LEGAL_ENTITY, conditional: { html: legalEntityHtml } @@ -60,7 +59,7 @@

{{ pageParams.title }}

{ value: pageData.trusteeType.INDIVIDUAL, text: "Individual", - checked: (formData.type | lower) === (pageData.trusteeType.INDIVIDUAL | lower), + checked: formData.type == pageData.trusteeType.INDIVIDUAL, conditional: { html: individualBoHtml } diff --git a/views/includes/page-templates/trust-individual-beneficial-owner.html b/views/includes/page-templates/trust-individual-beneficial-owner.html index a07b66c83..22824b766 100644 --- a/views/includes/page-templates/trust-individual-beneficial-owner.html +++ b/views/includes/page-templates/trust-individual-beneficial-owner.html @@ -1,4 +1,5 @@ {% set pageTitle = pageParams.title %} + {% set trustName = pageData.trustData.trustName %} {% set trusteeId = formData.trusteeId %} @@ -120,28 +121,28 @@

What is their date of birth?

{ value: pageData.roleWithinTrustType.BENEFICIARY, text: "Beneficiary", - checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.BENEFICIARY | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.BENEFICIARY, attributes: { "data-event-id": "beneficiary-type-radio-option" } }, { value: pageData.roleWithinTrustType.SETTLOR, text: "Settlor", - checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.SETTLOR | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.SETTLOR, attributes: { "data-event-id": "settlor-type-radio-option" } }, { value: pageData.roleWithinTrustType.GRANTOR, text: "Grantor", - checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.GRANTOR | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.GRANTOR, attributes: { "data-event-id": "grantor-type-radio-option" } }, { value: pageData.roleWithinTrustType.INTERESTED_PERSON, text: "Interested Person", - checked: (formData.roleWithinTrust | lower) === (pageData.roleWithinTrustType.INTERESTED_PERSON | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.INTERESTED_PERSON, attributes: { "data-event-id": "interested-person-type-radio-option" }, diff --git a/views/includes/page-templates/trust-legal-entity-bo.html b/views/includes/page-templates/trust-legal-entity-bo.html index 91d8920f2..94081c7a3 100644 --- a/views/includes/page-templates/trust-legal-entity-bo.html +++ b/views/includes/page-templates/trust-legal-entity-bo.html @@ -61,28 +61,28 @@

{{ pageParams.title }}

{ value: pageData.roleWithinTrustType.BENEFICIARY, text: "Beneficiary", - checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.BENEFICIARY | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.BENEFICIARY, attributes: { "data-event-id": "beneficiaries-type-radio-option" } }, { value: pageData.roleWithinTrustType.SETTLOR, text: "Settlor", - checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.SETTLOR | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.SETTLOR, attributes: { "data-event-id": "settlors-type-radio-option" } }, { value: pageData.roleWithinTrustType.GRANTOR, text: "Grantor", - checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.GRANTOR | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.GRANTOR, attributes: { "data-event-id": "grantors-type-radio-option" } }, { value: pageData.roleWithinTrustType.INTERESTED_PERSON, text: "Interested Person", - checked: (formData.roleWithinTrust | lower) == (pageData.roleWithinTrustType.INTERESTED_PERSON | lower), + checked: formData.roleWithinTrust == pageData.roleWithinTrustType.INTERESTED_PERSON, attributes: { "data-event-id": "interested-persons-type-radio-option" }, From b1780b81ae0377352c19f46a53dc1a051bf53043 Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Thu, 19 Dec 2024 19:59:07 +0000 Subject: [PATCH 6/9] test: centralise mock method definition --- test/utils/trust/api.to.web.mapper.spec.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/utils/trust/api.to.web.mapper.spec.ts b/test/utils/trust/api.to.web.mapper.spec.ts index f5673d8d4..ad1dda782 100644 --- a/test/utils/trust/api.to.web.mapper.spec.ts +++ b/test/utils/trust/api.to.web.mapper.spec.ts @@ -7,6 +7,8 @@ import { APPLICATION_DATA_MOCK } from "../../__mocks__/session.mock"; import { mapTrustApiToWebWhenFlagsAreSet } from "../../../src/utils/trust/api.to.web.mapper"; const mockMapTrustApiReturnModelToWebModel = mapTrustApiReturnModelToWebModel as jest.Mock; +mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); + const mockIsActiveFeature = isActiveFeature as jest.Mock; describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { @@ -18,7 +20,6 @@ describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { }); test('is not invoked when isRegistration flag is false', () => { - mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK, false); expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); }); @@ -26,7 +27,6 @@ describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { test('is not invoked when REDIS_removal flag is set to OFF', () => { mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL mockIsActiveFeature.mockReturnValueOnce(true); // FEATURE_FLAG_ENABLE_TRUSTS_WEB - mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); }); @@ -34,7 +34,6 @@ describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { test('is not invoked when Trusts_web flag is set to OFF', () => { mockIsActiveFeature.mockReturnValueOnce(true); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_TRUSTS_WEB - mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); }); @@ -42,14 +41,12 @@ describe("mapTrustApiToWebWhenFlagsAreSet tests", () => { test('is not invoked when REDIS_removal flag is set to OFF and Trusts_web flag is set to OFF', () => { mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_REDIS_REMOVAL mockIsActiveFeature.mockReturnValueOnce(false); // FEATURE_FLAG_ENABLE_TRUSTS_WEB - mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); expect(mockMapTrustApiReturnModelToWebModel).not.toHaveBeenCalled(); }); test('is invoked when isRegistration is set to TRUE and both flags are set to ON', () => { mockIsActiveFeature.mockReturnValue(true); // ALL_FLAGS - mockMapTrustApiReturnModelToWebModel.mockReturnValue(true); mapTrustApiToWebWhenFlagsAreSet(APPLICATION_DATA_MOCK as any, true); expect(mockMapTrustApiReturnModelToWebModel).toHaveBeenCalledTimes(1); }); From 0f327671101f73739bdcd088982e2eb9133d54fa Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Fri, 20 Dec 2024 12:03:12 +0000 Subject: [PATCH 7/9] refactor: re-use email variabe in config and add full_name config --- src/config/index.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/config/index.ts b/src/config/index.ts index cf5ef0327..a1f99fb40 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -351,6 +351,7 @@ export const CHANGE_RESIDENTIAL_ADDRESS = "#usual_residential_address_property_n export const IS_SERVICE_ADDRESS_SAME_AS_USUAL_RESIDENTIAL_ADDRESS = "#is_service_address_same_as_usual_residential_address"; export const IDENTITY_ADDRESS = "#identity_address_property_name_number"; export const NAME = "#name"; +export const FULL_NAME = "#full_name"; export const HAS_FORMER_NAMES = "#has_former_names"; export const FORMER_NAMES = "#former_names"; export const EMAIL = "#email"; @@ -404,7 +405,7 @@ export const TRUST_STILL_INVOLVED = "#stillInvolved"; export const TRUST_CEASED_DATE = "#ceasedDateDay"; export const ENTITY_CHANGE_NAME = OVERSEAS_NAME_URL + ENTITY_NAME; -export const PRESENTER_CHANGE_FULL_NAME = PRESENTER_URL + "#full_name"; +export const PRESENTER_CHANGE_FULL_NAME = PRESENTER_URL + FULL_NAME; export const PRESENTER_CHANGE_EMAIL = PRESENTER_URL + EMAIL; export const ENTITY_CHANGE_COUNTRY = ENTITY_URL + "#incorporation_country"; export const ENTITY_CHANGE_PRINCIPAL_ADDRESS = ENTITY_URL + CHANGE_PRINCIPAL_ADDRESS; @@ -451,8 +452,8 @@ export const UPDATE_OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_SUPERVISORY_NAME = UPDA export const UPDATE_OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_AML_NUMBER = UPDATE_DUE_DILIGENCE_OVERSEAS_ENTITY_URL + AML_NUMBER; export const UPDATE_OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME = UPDATE_DUE_DILIGENCE_OVERSEAS_ENTITY_URL + PARTNER_NAME; -export const UPDATE_PRESENTER_CHANGE_FULL_NAME = OVERSEAS_ENTITY_PRESENTER_URL + "#full_name"; -export const UPDATE_PRESENTER_CHANGE_EMAIL = OVERSEAS_ENTITY_PRESENTER_URL + "#email"; +export const UPDATE_PRESENTER_CHANGE_FULL_NAME = OVERSEAS_ENTITY_PRESENTER_URL + FULL_NAME; +export const UPDATE_PRESENTER_CHANGE_EMAIL = OVERSEAS_ENTITY_PRESENTER_URL + EMAIL; export const SECURE_UPDATE_FILTER_CHANGELINK = SECURE_UPDATE_FILTER_URL + SECURE_FILTER; export const UPDATE_FILING_DATE_CHANGELINK = UPDATE_FILING_DATE_URL + FILING_DATE; export const UPDATE_DO_YOU_WANT_TO_MAKE_OE_CHANGE_CHANGELINK = UPDATE_DO_YOU_WANT_TO_MAKE_OE_CHANGE_URL + NO_CHANGE; @@ -500,8 +501,8 @@ export const SUBMISSION_ID_URL_KEY = "/submission/"; // Check-your-answers page links export const ENTITY_CHANGE_NAME_WITH_PARAMS = OVERSEAS_NAME_WITH_PARAMS_URL + ENTITY_NAME; -export const PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + "#full_name"; -export const PRESENTER_CHANGE_EMAIL_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + "#email"; +export const PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + FULL_NAME; +export const PRESENTER_CHANGE_EMAIL_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + EMAIL; export const DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + AGENT_CODE; export const DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_DATE; export const DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + NAME; From d9182e800823232365f2b99d4f536cd4e3c5016d Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Fri, 20 Dec 2024 12:22:10 +0000 Subject: [PATCH 8/9] refactor: remove unnecessay method from change-link utility --- src/app.ts | 10 ++++++---- src/utils/change.link.ts | 9 --------- test/utils/change.link.spec.ts | 21 ++------------------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/app.ts b/src/app.ts index a113da94e..b28d2f8b0 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,13 +18,15 @@ import router from "./routes"; import errorHandler from "./controllers/error.controller"; import { countryFilter } from "./utils/country.filter"; import { ErrorMessages } from "./validation/error.messages"; -import { getTransactionIdAndSubmissionIdFromOriginalUrl } from "./utils/url"; +import { isActiveFeature } from "./utils/feature.flag"; +import { + getTransactionIdAndSubmissionIdFromOriginalUrl, + getUrlWithTransactionIdAndSubmissionId +} from "./utils/url"; import { createChangeLinkConfig, createSummaryListLink, - createChangeLinkWithIds, } from "./utils/change.link"; -import { isActiveFeature } from "./utils/feature.flag"; const app = express(); @@ -53,7 +55,7 @@ nunjucksEnv.addGlobal("OE_CONFIGS", config); nunjucksEnv.addGlobal("ERROR_MESSAGES", ErrorMessages); nunjucksEnv.addGlobal("COUNTRY_FILTER", countryFilter ); nunjucksEnv.addGlobal("CREATE_CHANGE_LINK", createChangeLinkConfig); -nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDS", createChangeLinkWithIds); +nunjucksEnv.addGlobal("CREATE_CHANGE_LINK_WITH_IDS", getUrlWithTransactionIdAndSubmissionId); nunjucksEnv.addGlobal("SUMMARY_LIST_LINK", createSummaryListLink); nunjucksEnv.addGlobal("IS_REDIS_REMOVAL_ENABLED", isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL)); nunjucksEnv.addGlobal("PIWIK_URL", config.PIWIK_URL); diff --git a/src/utils/change.link.ts b/src/utils/change.link.ts index 375dd885c..fa451d75e 100644 --- a/src/utils/change.link.ts +++ b/src/utils/change.link.ts @@ -1,5 +1,3 @@ -import { getUrlWithTransactionIdAndSubmissionId } from "./url"; - export const createSummaryListLink = ( text: string, href: string, @@ -19,10 +17,3 @@ export const createSummaryListLink = ( export const createChangeLinkConfig = (href: string, text: string, dataEventId: string) => { return createSummaryListLink('Change', href, text, dataEventId); }; - -/** - * Return a change link with the transactionId and submissionId included - */ -export const createChangeLinkWithIds = (link: string, transactionId: string, submissionId: string) => { - return getUrlWithTransactionIdAndSubmissionId(link, transactionId, submissionId); -}; diff --git a/test/utils/change.link.spec.ts b/test/utils/change.link.spec.ts index b03b0008a..4aeb91126 100644 --- a/test/utils/change.link.spec.ts +++ b/test/utils/change.link.spec.ts @@ -1,14 +1,5 @@ -import { - createChangeLinkConfig, - createChangeLinkWithIds, -} from '../../src/utils/change.link'; - -import { - LANDING_URL, - PRESENTER_CHANGE_FULL_NAME, - REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL, -} from '../../src/config'; - +import { createChangeLinkConfig } from '../../src/utils/change.link'; +import { PRESENTER_CHANGE_FULL_NAME } from '../../src/config'; import { CHANGE_LINK, CHANGE_LINK_NAME_PRESENTER, @@ -24,12 +15,4 @@ describe('createChangeLinkConfig test suite', () => { expect(testChangeLinkConfig.visuallyHiddenText).toEqual(CHANGE_LINK_NAME_PRESENTER); expect(testChangeLinkConfig.attributes['data-event-id']).toEqual(DATA_EVENT_ID); }); - - test('should correctly substitute the transactionId and submissionId in a url ', () => { - const transcationId = "123abc"; - const submissionId = "abc123"; - const substitutedUrl = createChangeLinkWithIds(REGISTER_AN_OVERSEAS_ENTITY_WITH_PARAMS_URL, transcationId, submissionId); - expect(substitutedUrl).toEqual(`${LANDING_URL}/transaction/${transcationId}/submission/${submissionId}/`); - }); - }); From 6de77539f213d29a16364c5d1abe37b4119c56bd Mon Sep 17 00:00:00 2001 From: Moses Wejuli Date: Fri, 20 Dec 2024 14:45:07 +0000 Subject: [PATCH 9/9] refactor: update `whoIsCompletingChangeLink` in the "check-your-answers" view so as to be consistent with the other change links --- src/config/index.ts | 3 +++ views/includes/check-your-answers/verification-checks.html | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/config/index.ts b/src/config/index.ts index a1f99fb40..09d2c9406 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -355,6 +355,7 @@ export const FULL_NAME = "#full_name"; export const HAS_FORMER_NAMES = "#has_former_names"; export const FORMER_NAMES = "#former_names"; export const EMAIL = "#email"; +export const WHO_IS_MAKING_FILING = "#who_is_registering"; export const LEGAL_FORM = "#legal_form"; export const LAW_GOVERNED = "#law_governed"; export const FIRST_NAME = "#first_name"; @@ -404,6 +405,7 @@ export const REGISTRABLE_BENEFICIAL_OWNER = "#registrable_beneficial_owner"; export const TRUST_STILL_INVOLVED = "#stillInvolved"; export const TRUST_CEASED_DATE = "#ceasedDateDay"; +export const WHO_IS_MAKING_FILING_CHANGE = WHO_IS_MAKING_FILING_URL + WHO_IS_MAKING_FILING; export const ENTITY_CHANGE_NAME = OVERSEAS_NAME_URL + ENTITY_NAME; export const PRESENTER_CHANGE_FULL_NAME = PRESENTER_URL + FULL_NAME; export const PRESENTER_CHANGE_EMAIL = PRESENTER_URL + EMAIL; @@ -503,6 +505,7 @@ export const SUBMISSION_ID_URL_KEY = "/submission/"; export const ENTITY_CHANGE_NAME_WITH_PARAMS = OVERSEAS_NAME_WITH_PARAMS_URL + ENTITY_NAME; export const PRESENTER_CHANGE_FULL_NAME_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + FULL_NAME; export const PRESENTER_CHANGE_EMAIL_WITH_PARAMS = PRESENTER_WITH_PARAMS_URL + EMAIL; +export const WHO_IS_MAKING_FILING_CHANGE_WITH_PARAMS = WHO_IS_MAKING_FILING_WITH_PARAMS_URL + WHO_IS_MAKING_FILING; export const DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + AGENT_CODE; export const DUE_DILIGENCE_CHANGE_IDENTITY_DATE_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + IDENTITY_DATE; export const DUE_DILIGENCE_CHANGE_NAME_WITH_PARAMS = DUE_DILIGENCE_WITH_PARAMS_URL + NAME; diff --git a/views/includes/check-your-answers/verification-checks.html b/views/includes/check-your-answers/verification-checks.html index 26e2904d7..871461973 100644 --- a/views/includes/check-your-answers/verification-checks.html +++ b/views/includes/check-your-answers/verification-checks.html @@ -5,6 +5,7 @@ {% if pageParams.isRegistration %} {% set whoIsCompletingText = "Who is completing this registration" %} + {% set whoIsCompletingChangeLink = OE_CONFIGS.WHO_IS_MAKING_FILING_CHANGE %} {% if not IS_REDIS_REMOVAL_ENABLED %} {% if who_is_registering == "agent" %} {% set whoIsCompleting = ukAgent %} @@ -27,6 +28,7 @@ {% set partnerChangeLink = OE_CONFIGS.OVERSEAS_ENTITY_DUE_DILIGENCE_CHANGE_PARTNER_NAME %} {% endif %} {% else %} + {% set whoIsCompletingChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.WHO_IS_MAKING_FILING_CHANGE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %} {% if who_is_registering == "agent" %} {% set whoIsCompleting = ukAgent %} {% set agentChangeLink = CREATE_CHANGE_LINK_WITH_IDS(OE_CONFIGS.DUE_DILIGENCE_CHANGE_AGENT_CODE_WITH_PARAMS, OE_TRANSACTION_ID, OE_SUBMISSION_ID) %}