Skip to content

Commit

Permalink
fix(EMS-3633): data migration - xlsx - eligibility questions (#2932)
Browse files Browse the repository at this point in the history
* fix(EMS-3633): data migration - financial vectors

* chore(docs): data migration - documentation improvements

* fix(EMS-3633): data migration - xlsx - eligibility questions
  • Loading branch information
ttbarnes authored Aug 9, 2024
1 parent a64af4e commit f80ac41
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 43 deletions.
9 changes: 3 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

## [2.35.3](https://github.com/UK-Export-Finance/exip/compare/v2.35.2...v2.35.3) (2024-08-09)


### Bug Fixes

* **EMS-3633:** data migration - financial vector columns ([#2928](https://github.com/UK-Export-Finance/exip/issues/2928)) ([a3b1470](https://github.com/UK-Export-Finance/exip/commit/a3b1470c466314df9dbf549a91da8a152505938d))
- **EMS-3633:** data migration - financial vector columns ([#2928](https://github.com/UK-Export-Finance/exip/issues/2928)) ([a3b1470](https://github.com/UK-Export-Finance/exip/commit/a3b1470c466314df9dbf549a91da8a152505938d))

## [2.35.2](https://github.com/UK-Export-Finance/exip/compare/v2.35.1...v2.35.2) (2024-08-08)


### Bug Fixes

* **EMS-3633:** data migration - declaration versioning ([#2921](https://github.com/UK-Export-Finance/exip/issues/2921)) ([2e82c4f](https://github.com/UK-Export-Finance/exip/commit/2e82c4f2afc59b558d8e4faf89d573ae39dce594))
- **EMS-3633:** data migration - declaration versioning ([#2921](https://github.com/UK-Export-Finance/exip/issues/2921)) ([2e82c4f](https://github.com/UK-Export-Finance/exip/commit/2e82c4f2afc59b558d8e4faf89d573ae39dce594))

## [2.35.1](https://github.com/UK-Export-Finance/exip/compare/v2.35.0...v2.35.1) (2024-08-07)


### Bug Fixes

* **iac:** explicity RBAC authorisation to false for Azure KV ([#2910](https://github.com/UK-Export-Finance/exip/issues/2910)) ([d8370f7](https://github.com/UK-Export-Finance/exip/commit/d8370f79c9dd5f92cb355e79ce53ece463380702))
- **iac:** explicity RBAC authorisation to false for Azure KV ([#2910](https://github.com/UK-Export-Finance/exip/issues/2910)) ([d8370f7](https://github.com/UK-Export-Finance/exip/commit/d8370f79c9dd5f92cb355e79ce53ece463380702))

## [2.35.0](https://github.com/UK-Export-Finance/exip/compare/v2.34.0...v2.35.0) (2024-08-06)

Expand Down
22 changes: 14 additions & 8 deletions src/api/.keystone/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,64 @@ const {
IS_PARTY_TO_CONSORTIUM,
IS_MEMBER_OF_A_GROUP,
},
MIGRATED_FROM_V1_TO_V2,
} = INSURANCE_FIELD_IDS;

const { company, eligibility } = mockApplication;

const genericExpectedRows = [
xlsxRow(CONTENT_STRINGS[VALID_EXPORTER_LOCATION].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[VALID_EXPORTER_LOCATION] })),

xlsxRow(CONTENT_STRINGS[HAS_COMPANIES_HOUSE_NUMBER].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER] })),
xlsxRow(String(FIELDS[COMPANIES_HOUSE_NUMBER]), company[COMPANIES_HOUSE_NUMBER]),

xlsxRow(String(FIELDS[BUYER_COUNTRY]), eligibility[BUYER_COUNTRY].name),

xlsxRow(String(FIELDS[MORE_THAN_250K.VALUE]), mapYesNoField({ answer: eligibility[TOTAL_CONTRACT_VALUE_FIELD_ID].valueId === MORE_THAN_250K.DB_ID })),

xlsxRow(String(FIELDS[COVER_PERIOD]), eligibility[COVER_PERIOD_ELIGIBILITY].value),

xlsxRow(String(FIELDS[HAS_MINIMUM_UK_GOODS_OR_SERVICES]), mapYesNoField({ answer: eligibility[HAS_MINIMUM_UK_GOODS_OR_SERVICES] })),
];

describe('api/generate-xlsx/map-application-to-xlsx/map-eligibility', () => {
it('should return an array of mapped eligibility fields', () => {
const result = mapEligibility(mockApplication);
describe(`when application.${MIGRATED_FROM_V1_TO_V2} is true`, () => {
it('should return an array of mapped eligibility fields with some answers as null', () => {
const result = mapEligibility({
...mockApplication,
[MIGRATED_FROM_V1_TO_V2]: true,
});

const { company, eligibility } = mockApplication;
const expected = [
...genericExpectedRows,

const expected = [
xlsxRow(CONTENT_STRINGS[VALID_EXPORTER_LOCATION].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[VALID_EXPORTER_LOCATION] })),
xlsxRow(String(FIELDS[HAS_END_BUYER]), mapYesNoField({ answer: null })),

xlsxRow(CONTENT_STRINGS[HAS_COMPANIES_HOUSE_NUMBER].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER] })),
xlsxRow(String(FIELDS[COMPANIES_HOUSE_NUMBER]), company[COMPANIES_HOUSE_NUMBER]),
xlsxRow(String(FIELDS[IS_PARTY_TO_CONSORTIUM]), mapYesNoField({ answer: null })),
xlsxRow(String(FIELDS[IS_MEMBER_OF_A_GROUP]), mapYesNoField({ answer: null })),
];

xlsxRow(String(FIELDS[BUYER_COUNTRY]), eligibility[BUYER_COUNTRY].name),
expect(result).toEqual(expected);
});
});

xlsxRow(String(FIELDS[MORE_THAN_250K.VALUE]), mapYesNoField({ answer: eligibility[TOTAL_CONTRACT_VALUE_FIELD_ID].valueId === MORE_THAN_250K.DB_ID })),
describe(`when application.${MIGRATED_FROM_V1_TO_V2} is false`, () => {
it('should return an array of mapped eligibility fields', () => {
const result = mapEligibility({
...mockApplication,
[MIGRATED_FROM_V1_TO_V2]: false,
});

xlsxRow(String(FIELDS[COVER_PERIOD]), eligibility[COVER_PERIOD_ELIGIBILITY].value),
const expected = [
...genericExpectedRows,

xlsxRow(String(FIELDS[HAS_MINIMUM_UK_GOODS_OR_SERVICES]), mapYesNoField({ answer: eligibility[HAS_MINIMUM_UK_GOODS_OR_SERVICES] })),
xlsxRow(String(FIELDS[HAS_END_BUYER]), mapYesNoField({ answer: eligibility[HAS_END_BUYER] })),
xlsxRow(String(FIELDS[HAS_END_BUYER]), mapYesNoField({ answer: eligibility[HAS_END_BUYER] })),

xlsxRow(String(FIELDS[IS_PARTY_TO_CONSORTIUM]), mapYesNoField({ answer: eligibility[IS_PARTY_TO_CONSORTIUM] })),
xlsxRow(String(FIELDS[IS_MEMBER_OF_A_GROUP]), mapYesNoField({ answer: eligibility[IS_MEMBER_OF_A_GROUP] })),
];
xlsxRow(String(FIELDS[IS_PARTY_TO_CONSORTIUM]), mapYesNoField({ answer: eligibility[IS_PARTY_TO_CONSORTIUM] })),
xlsxRow(String(FIELDS[IS_MEMBER_OF_A_GROUP]), mapYesNoField({ answer: eligibility[IS_MEMBER_OF_A_GROUP] })),
];

expect(result).toEqual(expected);
expect(result).toEqual(expected);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ const {
/**
* mapEligibility
* Map an application's eligibility fields into an array of objects for XLSX generation
* If an application has been migrated from V1 to V2,
* the IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP and HAS_END_BUYER fields should have NULL answers.
* This is because, V1 eligibility does not have these fields available and so, the user has not provided an answer.
* @param {Application}
* @returns {Array<object>} Array of objects for XLSX generation
*/
const mapEligibility = (application: Application) => {
const { company, eligibility } = application;
const { company, eligibility, migratedV1toV2 } = application;

const mapped = [
let mapped = [
xlsxRow(CONTENT_STRINGS[VALID_EXPORTER_LOCATION].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[VALID_EXPORTER_LOCATION] })),

xlsxRow(CONTENT_STRINGS[HAS_COMPANIES_HOUSE_NUMBER].SUMMARY?.TITLE, mapYesNoField({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER] })),
Expand All @@ -48,10 +51,17 @@ const mapEligibility = (application: Application) => {
xlsxRow(String(FIELDS[COVER_PERIOD]), eligibility[COVER_PERIOD_ELIGIBILITY].value),

xlsxRow(String(FIELDS[HAS_MINIMUM_UK_GOODS_OR_SERVICES]), mapYesNoField({ answer: eligibility[HAS_MINIMUM_UK_GOODS_OR_SERVICES] })),
xlsxRow(String(FIELDS[HAS_END_BUYER]), mapYesNoField({ answer: eligibility[HAS_END_BUYER] })),
];

const endBuyerAnswer = migratedV1toV2 ? null : eligibility[HAS_END_BUYER];
const partyToConsortiumAnswer = migratedV1toV2 ? null : eligibility[IS_PARTY_TO_CONSORTIUM];
const memberOfGroupAnswer = migratedV1toV2 ? null : eligibility[IS_PARTY_TO_CONSORTIUM];

xlsxRow(String(FIELDS[IS_PARTY_TO_CONSORTIUM]), mapYesNoField({ answer: eligibility[IS_PARTY_TO_CONSORTIUM] })),
xlsxRow(String(FIELDS[IS_MEMBER_OF_A_GROUP]), mapYesNoField({ answer: eligibility[IS_MEMBER_OF_A_GROUP] })),
mapped = [
...mapped,
xlsxRow(String(FIELDS[HAS_END_BUYER]), mapYesNoField({ answer: endBuyerAnswer })),
xlsxRow(String(FIELDS[IS_PARTY_TO_CONSORTIUM]), mapYesNoField({ answer: partyToConsortiumAnswer })),
xlsxRow(String(FIELDS[IS_MEMBER_OF_A_GROUP]), mapYesNoField({ answer: memberOfGroupAnswer })),
];

return mapped;
Expand Down
4 changes: 2 additions & 2 deletions src/api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3705,10 +3705,10 @@ input ApplicationEligibility {
hasCompaniesHouseNumber: Boolean!
hasEndBuyer: Boolean!
hasMinimumUkGoodsOrServices: Boolean!
isMemberOfAGroup: Boolean!
isPartyToConsortium: Boolean!
totalContractValueId: Int!
validExporterLocation: Boolean!
isPartyToConsortium: Boolean!
isMemberOfAGroup: Boolean!
}

type CreateAnApplicationResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/api/types/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface MapYesNoFieldParams {
answer?: boolean;
answer?: boolean | null;
defaultValue?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('server/helpers/required-fields/eligibility', () => {
it('should return an object of irrelevant fields', () => {
const expected = {
V1: GENERIC_IRRELEVANT_FIELD_IDS,
V2: [...GENERIC_IRRELEVANT_FIELD_IDS, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP],
V2: [...GENERIC_IRRELEVANT_FIELD_IDS, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP, HAS_END_BUYER],
};

expect(IRRELEVANT_FIELD_IDS).toEqual(expected);
Expand Down
8 changes: 4 additions & 4 deletions src/ui/server/helpers/required-fields/eligibility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export const GENERIC_IRRELEVANT_FIELD_IDS = [BUYER_COUNTRY_ISO_CODE, COVER_PERIO
/**
* IRRELEVANT_FIELD_IDS
* List of field IDs that are not relevant for V1 or V2 applications.
* If an application has been migrated from V1 to V2, the IS_PARTY_TO_CONSORTIUM and IS_MEMBER_OF_A_GROUP fields are NOT required.
* If an application has been migrated from V1 to V2, the IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP and HAS_END_BUYER fields are NOT required.
* Otherwise, these 2x fields are required.
* This is because:
* - In V1, IS_PARTY_TO_CONSORTIUM and IS_MEMBER_OF_A_GROUP fields do NOT exist.
* - In V2, IS_PARTY_TO_CONSORTIUM and IS_MEMBER_OF_A_GROUP do exist.
* - In V1, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP and HAS_END_BUYER fields do NOT exist.
* - In V2, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP and HAS_END_BUYER do exist.
*/
export const IRRELEVANT_FIELD_IDS = {
V1: GENERIC_IRRELEVANT_FIELD_IDS,
V2: [...GENERIC_IRRELEVANT_FIELD_IDS, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP],
V2: [...GENERIC_IRRELEVANT_FIELD_IDS, IS_PARTY_TO_CONSORTIUM, IS_MEMBER_OF_A_GROUP, HAS_END_BUYER],
};

/**
Expand Down

0 comments on commit f80ac41

Please sign in to comment.