Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FN-3669): map reported fees amount to monetary value #4142

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.formattedAmount = 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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
aFeeRecordCorrectionReviewInformation,
aPortalSessionBank,
aPortalSessionUser,
CURRENCY,
FeeRecordCorrectionReviewInformation,
getFormattedMonetaryValue,
mapReasonsToDisplayValues,
PORTAL_LOGIN_STATUS,
} from '@ukef/dtfs2-common';
Expand Down Expand Up @@ -59,19 +61,38 @@

describe('getUtilisationReportCorrectionReview', () => {
it('should render the "utilisation report correction - check the information" page', async () => {
// Arrange,
// Arrange
const exporter = 'An exporter';
const reportedFeesCurrency = CURRENCY.GBP;

Check failure on line 66 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L66

Unsafe assignment of an error typed value.

Check failure on line 66 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L66

Unsafe member access .GBP on an `error` typed value.
const reportedFeesAmount = 1234.56;
const bankCommentary = 'Some bank commentary';

const feeRecordCorrectionReviewResponse = {
...aFeeRecordCorrectionReviewInformation(),
bankCommentary,
feeRecord: {
exporter,
reportedFees: {
currency: reportedFeesCurrency,

Check failure on line 76 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L76

Unsafe assignment of an error typed value.
amount: reportedFeesAmount,
},
},
};

jest.mocked(api.getFeeRecordCorrectionReview).mockResolvedValue(feeRecordCorrectionReviewResponse);

const { errorSummary, feeRecord, formattedOldValues, formattedNewValues, reasons } = feeRecordCorrectionReviewResponse;
const { errorSummary, formattedOldValues, formattedNewValues, reasons } = feeRecordCorrectionReviewResponse;

Check failure on line 84 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L84

Unsafe assignment of an `any` value.

const expectedFormattedReasons = mapReasonsToDisplayValues(reasons).join(', ');

const expectedFeeRecord = {
exporter,
reportedFees: {
currency: reportedFeesCurrency,
formattedAmount: getFormattedMonetaryValue(reportedFeesAmount),

Check failure on line 92 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L92

Unsafe assignment of an error typed value.

Check failure on line 92 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.test.ts#L92

Unsafe call of an `error` type typed value.
},
};

// Act
await getUtilisationReportCorrectionReview(req, res);

Expand All @@ -80,7 +101,7 @@
user: mockUser,
primaryNav: PRIMARY_NAV_KEY.UTILISATION_REPORT_UPLOAD,
backLinkHref: `/utilisation-reports/provide-correction/${correctionId}`,
feeRecord,
feeRecord: expectedFeeRecord,
formattedReasons: expectedFormattedReasons,
errorSummary,
formattedOldValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -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, LoggedInUserSession } from '../../../../helpers/express-session';
import { PRIMARY_NAV_KEY } from '../../../../constants';
Expand Down Expand Up @@ -34,11 +34,22 @@

const backLinkHref = `/utilisation-reports/provide-correction/${correctionId}`;

const { exporter, reportedFees } = feeRecord;

Check failure on line 37 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts#L37

Unsafe assignment of an error typed value.
const { currency, amount } = reportedFees;

Check failure on line 38 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts#L38

Unsafe assignment of an error typed value.

const mappedFeeRecord = {
exporter,
reportedFees: {
currency,

Check failure on line 43 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts#L43

Unsafe assignment of an error typed value.
formattedAmount: getFormattedMonetaryValue(amount),

Check failure on line 44 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts#L44

Unsafe assignment of an error typed value.

Check failure on line 44 in portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

portal/server/controllers/utilisation-report-service/record-correction/check-the-information/index.ts#L44

Unsafe call of an `error` type typed value.
},
};

const viewModel: UtilisationReportCorrectionInformationViewModel = {
user,
primaryNav: PRIMARY_NAV_KEY.UTILISATION_REPORT_UPLOAD,
backLinkHref,
feeRecord,
feeRecord: mappedFeeRecord,
formattedReasons: mapReasonsToDisplayValues(reasons).join(', '),
errorSummary,
formattedOldValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
formattedAmount: string;
};
};
formattedReasons: string;
errorSummary: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
text: "Reported fees paid"
},
value: {
text: feeRecord.reportedFees.amount
text: feeRecord.reportedFees.formattedAmount
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const aUtilisationReportCorrectionInformationViewModel = (): UtilisationR
exporter: 'An exporter',
reportedFees: {
currency: 'GBP',
amount: 123,
formattedAmount: '1,234.56',
},
},
formattedReasons: 'Facility ID is incorrect, Reported currency is incorrect',
Expand Down
Loading