From ccde6e4af8d4253063a356a6aabbc8171706f7bf Mon Sep 17 00:00:00 2001 From: Matt <173997080+sw-mattw@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:03:08 +0000 Subject: [PATCH 1/4] feat(FN-3669): map reported fees amount to monetary value --- ...ee-record-correction-review-information.ts | 2 +- .../check-the-information.component-test.js | 8 +++--- .../check-the-information/index.test.ts | 25 +++++++++++++++++-- .../check-the-information/index.ts | 15 +++++++++-- ...ilisation-report-correction-information.ts | 7 ++++-- ...eport-correction-information-view-model.ts | 2 +- 6 files changed, 46 insertions(+), 13 deletions(-) diff --git a/libs/common/src/test-helpers/fee-record-correction-review-information.ts b/libs/common/src/test-helpers/fee-record-correction-review-information.ts index 92d30761d9..00d6da9bbc 100644 --- a/libs/common/src/test-helpers/fee-record-correction-review-information.ts +++ b/libs/common/src/test-helpers/fee-record-correction-review-information.ts @@ -7,7 +7,7 @@ export const aFeeRecordCorrectionReviewInformation = (): FeeRecordCorrectionRevi exporter: 'An exporter', reportedFees: { currency: 'GBP', - amount: 123, + amount: 1234.56, }, }, reasons: [RECORD_CORRECTION_REASON.FACILITY_ID_INCORRECT, RECORD_CORRECTION_REASON.REPORTED_CURRENCY_INCORRECT, RECORD_CORRECTION_REASON.OTHER], diff --git a/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js b/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js index d1cdad5292..6f89ee0198 100644 --- a/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js +++ b/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js @@ -64,17 +64,15 @@ describe('page', () => { it('should render the original reported fees paid', () => { // Arrange - const reportedFees = 12345.67; + const reportedFeesPaid = '12,345.67'; const viewModel = aUtilisationReportCorrectionInformationViewModel(); - viewModel.feeRecord.reportedFees.amount = reportedFees; - - const expectedReportedFees = '12345.67'; + viewModel.feeRecord.reportedFees.amount = reportedFeesPaid; // Act const wrapper = render(viewModel); // Assert - wrapper.expectText(definitionDescriptionSelector(originalValuesSelector, 'Reported fees paid')).toRead(expectedReportedFees); + wrapper.expectText(definitionDescriptionSelector(originalValuesSelector, 'Reported fees paid')).toRead(reportedFeesPaid); }); it('should render the record correction details table heading', () => { diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts index 06652792f8..714b820dae 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts @@ -4,7 +4,9 @@ import { aFeeRecordCorrectionReviewInformation, aPortalSessionBank, aPortalSessionUser, + CURRENCY, FeeRecordCorrectionReviewInformation, + getFormattedMonetaryValue, mapReasonsToDisplayValues, PORTAL_LOGIN_STATUS, } from '@ukef/dtfs2-common'; @@ -58,18 +60,37 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati it('should render the "utilisation report correction - check the information" page', async () => { // Arrange, + const exporter = 'An exporter'; + const reportedFeesCurrency = CURRENCY.GBP; + const reportedFeesAmount = 1234.56; const bankCommentary = 'Some bank commentary'; + const feeRecordCorrectionReviewResponse = { ...aFeeRecordCorrectionReviewInformation(), bankCommentary, + feeRecord: { + exporter, + reportedFees: { + currency: reportedFeesCurrency, + amount: reportedFeesAmount, + }, + }, }; jest.mocked(api.getFeeRecordCorrectionReview).mockResolvedValue(feeRecordCorrectionReviewResponse); - const { errorSummary, feeRecord, formattedOldValues, formattedNewValues, reasons } = feeRecordCorrectionReviewResponse; + const { errorSummary, formattedOldValues, formattedNewValues, reasons } = feeRecordCorrectionReviewResponse; const expectedFormattedReasons = mapReasonsToDisplayValues(reasons).join(', '); + const expectedFeeRecord = { + exporter, + reportedFees: { + currency: reportedFeesCurrency, + amount: getFormattedMonetaryValue(reportedFeesAmount), + }, + }; + // Act await getUtilisationReportCorrectionReview(req, res); @@ -78,7 +99,7 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati user: mockUser, primaryNav: PRIMARY_NAV_KEY.UTILISATION_REPORT_UPLOAD, backLinkHref: `/utilisation-reports/provide-correction/${correctionId}`, - feeRecord, + feeRecord: expectedFeeRecord, formattedReasons: expectedFormattedReasons, errorSummary, formattedOldValues, diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts index 9a56f1f6a6..4966f43843 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts @@ -1,5 +1,5 @@ import { Response, Request } from 'express'; -import { mapReasonsToDisplayValues } from '@ukef/dtfs2-common'; +import { getFormattedMonetaryValue, mapReasonsToDisplayValues } from '@ukef/dtfs2-common'; import api from '../../../../api'; import { asLoggedInUserSession } from '../../../../helpers/express-session'; import { PRIMARY_NAV_KEY } from '../../../../constants'; @@ -34,11 +34,22 @@ export const getUtilisationReportCorrectionReview = async (req: GetUtilisationRe const backLinkHref = `/utilisation-reports/provide-correction/${correctionId}`; + const { exporter, reportedFees } = feeRecord; + const { currency, amount } = reportedFees; + + const mappedFeeRecord = { + exporter, + reportedFees: { + currency, + amount: getFormattedMonetaryValue(amount), + }, + }; + const viewModel: UtilisationReportCorrectionInformationViewModel = { user, primaryNav: PRIMARY_NAV_KEY.UTILISATION_REPORT_UPLOAD, backLinkHref, - feeRecord, + feeRecord: mappedFeeRecord, formattedReasons: mapReasonsToDisplayValues(reasons).join(', '), errorSummary, formattedOldValues, diff --git a/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts b/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts index fec44fdacb..43da6240ac 100644 --- a/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts +++ b/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts @@ -1,11 +1,14 @@ -import { CurrencyAndAmount } from '@ukef/dtfs2-common'; +import { Currency } from '@ukef/dtfs2-common'; import { BaseViewModel } from '../base-view-model'; export type UtilisationReportCorrectionInformationViewModel = BaseViewModel & { backLinkHref: string; feeRecord: { exporter: string; - reportedFees: CurrencyAndAmount; + reportedFees: { + currency: Currency; + amount: string; + }; }; formattedReasons: string; errorSummary: string; diff --git a/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts b/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts index c923f2d199..da870197f5 100644 --- a/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts +++ b/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts @@ -10,7 +10,7 @@ export const aUtilisationReportCorrectionInformationViewModel = (): UtilisationR exporter: 'An exporter', reportedFees: { currency: 'GBP', - amount: 123, + amount: '1,234.56', }, }, formattedReasons: 'Facility ID is incorrect, Reported currency is incorrect', From 473ac1b5939c8e286358c3b915709a39c1382698 Mon Sep 17 00:00:00 2001 From: Matt <173997080+sw-mattw@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:08:24 +0000 Subject: [PATCH 2/4] feat(FN-3669): use hardcoded expected value --- .../record-correction/check-the-information/index.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts index 714b820dae..ad581a62a1 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts @@ -6,7 +6,6 @@ import { aPortalSessionUser, CURRENCY, FeeRecordCorrectionReviewInformation, - getFormattedMonetaryValue, mapReasonsToDisplayValues, PORTAL_LOGIN_STATUS, } from '@ukef/dtfs2-common'; @@ -87,7 +86,7 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati exporter, reportedFees: { currency: reportedFeesCurrency, - amount: getFormattedMonetaryValue(reportedFeesAmount), + amount: '1,234.56', }, }; From 67c54867f4ec45260452313b90dc90a8f803e094 Mon Sep 17 00:00:00 2001 From: Matt <173997080+sw-mattw@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:19:53 +0000 Subject: [PATCH 3/4] feat(FN-3669): add "formatted" prefix to amount --- .../record-correction/check-the-information.component-test.js | 2 +- .../record-correction/check-the-information/index.test.ts | 4 ++-- .../record-correction/check-the-information/index.ts | 2 +- .../utilisation-report-correction-information.ts | 2 +- .../record-correction/check-the-information.njk | 2 +- .../utilisation-report-correction-information-view-model.ts | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js b/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js index 6f89ee0198..506f9494a8 100644 --- a/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js +++ b/portal/component-tests/utilisation-report-service/record-correction/check-the-information.component-test.js @@ -66,7 +66,7 @@ describe('page', () => { // Arrange const reportedFeesPaid = '12,345.67'; const viewModel = aUtilisationReportCorrectionInformationViewModel(); - viewModel.feeRecord.reportedFees.amount = reportedFeesPaid; + viewModel.feeRecord.reportedFees.formattedAmount = reportedFeesPaid; // Act const wrapper = render(viewModel); diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts index ad581a62a1..2cf35aca29 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts @@ -58,7 +58,7 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati }); it('should render the "utilisation report correction - check the information" page', async () => { - // Arrange, + // Arrange const exporter = 'An exporter'; const reportedFeesCurrency = CURRENCY.GBP; const reportedFeesAmount = 1234.56; @@ -86,7 +86,7 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati exporter, reportedFees: { currency: reportedFeesCurrency, - amount: '1,234.56', + formattedAmount: '1,234.56', }, }; diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts index 4966f43843..8e58581d43 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts @@ -41,7 +41,7 @@ export const getUtilisationReportCorrectionReview = async (req: GetUtilisationRe exporter, reportedFees: { currency, - amount: getFormattedMonetaryValue(amount), + formattedAmount: getFormattedMonetaryValue(amount), }, }; diff --git a/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts b/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts index 43da6240ac..fe4ed5b50d 100644 --- a/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts +++ b/portal/server/types/view-models/record-correction/utilisation-report-correction-information.ts @@ -7,7 +7,7 @@ export type UtilisationReportCorrectionInformationViewModel = BaseViewModel & { exporter: string; reportedFees: { currency: Currency; - amount: string; + formattedAmount: string; }; }; formattedReasons: string; diff --git a/portal/templates/utilisation-report-service/record-correction/check-the-information.njk b/portal/templates/utilisation-report-service/record-correction/check-the-information.njk index 05d656f60e..d12cb71872 100644 --- a/portal/templates/utilisation-report-service/record-correction/check-the-information.njk +++ b/portal/templates/utilisation-report-service/record-correction/check-the-information.njk @@ -36,7 +36,7 @@ text: "Reported fees paid" }, value: { - text: feeRecord.reportedFees.amount + text: feeRecord.reportedFees.formattedAmount } } ], diff --git a/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts b/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts index da870197f5..3c5ab53174 100644 --- a/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts +++ b/portal/test-helpers/test-data/view-models/record-corrections/utilisation-report-correction-information-view-model.ts @@ -10,7 +10,7 @@ export const aUtilisationReportCorrectionInformationViewModel = (): UtilisationR exporter: 'An exporter', reportedFees: { currency: 'GBP', - amount: '1,234.56', + formattedAmount: '1,234.56', }, }, formattedReasons: 'Facility ID is incorrect, Reported currency is incorrect', From 3acb528ab0a93a66c35b0696970a509781953b33 Mon Sep 17 00:00:00 2001 From: Matt <173997080+sw-mattw@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:49:39 +0000 Subject: [PATCH 4/4] feat(FN-3669): use getFormattedMonetaryValue helper instead of hardcoded -- review comment --- .../record-correction/check-the-information/index.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts index 11e78d7814..993091f8a7 100644 --- a/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts +++ b/portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts @@ -6,6 +6,7 @@ import { aPortalSessionUser, CURRENCY, FeeRecordCorrectionReviewInformation, + getFormattedMonetaryValue, mapReasonsToDisplayValues, PORTAL_LOGIN_STATUS, } from '@ukef/dtfs2-common'; @@ -88,7 +89,7 @@ describe('controllers/utilisation-reports/record-corrections/check-the-informati exporter, reportedFees: { currency: reportedFeesCurrency, - formattedAmount: '1,234.56', + formattedAmount: getFormattedMonetaryValue(reportedFeesAmount), }, };