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

fix(EMS-3508): no pdf - application submission - XLSX - buyer conditions #2647

Merged
merged 2 commits into from
Jun 27, 2024
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
@@ -0,0 +1,32 @@
import { APPLICATION } from '../../../../../../../constants';

context('Insurance - submit an application - multiple policy type, minimal buyer', () => {
let referenceNumber;

before(() => {
cy.completeSignInAndSubmitAnApplication({
policyType: APPLICATION.POLICY_TYPE.MULTIPLE,
hasConnectionToBuyer: false,
ttbarnes marked this conversation as resolved.
Show resolved Hide resolved
exporterHasTradedWithBuyer: false,
buyerOutstandingPayments: false,
buyerFailedToPayOnTime: false,
hasHadCreditInsuranceCoverWithBuyer: false,
exporterHasBuyerFinancialAccounts: false,
totalContractValueOverThreshold: false,
}).then((refNumber) => {
referenceNumber = refNumber;
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

it('should successfully submit the application and redirect to `application submitted`', () => {
cy.assertApplicationSubmittedUrl(referenceNumber);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
context('Insurance - submit an application - Single policy type, minimal buyer', () => {
let referenceNumber;

before(() => {
cy.completeSignInAndSubmitAnApplication({
hasConnectionToBuyer: false,
exporterHasTradedWithBuyer: false,
buyerOutstandingPayments: false,
buyerFailedToPayOnTime: false,
hasHadCreditInsuranceCoverWithBuyer: false,
exporterHasBuyerFinancialAccounts: false,
totalContractValueOverThreshold: false,
}).then((refNumber) => {
referenceNumber = refNumber;
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

it('should successfully submit the application and redirect to `application submitted`', () => {
cy.assertApplicationSubmittedUrl(referenceNumber);
});
});
19 changes: 14 additions & 5 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 @@ -50,7 +50,7 @@ describe(`api/constants/XLSX-CONFIG - XLSX_ROW_INDEXES - ${APPLICATION.POLICY_TY
TITLES: {
...indexes.TITLES,
BUYER: indexes.TITLES.BUYER + 1,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 12,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 13,
EXPORT_CONTRACT: indexes.TITLES.EXPORT_CONTRACT + 2,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe(`api/constants/XLSX-CONFIG - XLSX_ROW_INDEXES - ${APPLICATION.POLICY_TY
TITLES: {
...indexes.TITLES,
BUYER: indexes.TITLES.BUYER + 1,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 2,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 3,
EXPORT_CONTRACT: indexes.TITLES.EXPORT_CONTRACT + 2,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe(`api/constants/XLSX-CONFIG - XLSX_ROW_INDEXES - ${APPLICATION.POLICY_TY
AGENT_ADDRESS: 79,
TITLES: {
...indexes.TITLES,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 10,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 11,
EXPORT_CONTRACT: indexes.TITLES.EXPORT_CONTRACT + 1,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe(`api/constants/XLSX-CONFIG - XLSX_ROW_INDEXES - ${APPLICATION.POLICY_TY
AGENT_ADDRESS: indexes.AGENT_ADDRESS + 1,
TITLES: {
...indexes.TITLES,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 1,
DECLARATIONS: indexes.TITLES.DECLARATIONS + 2,
EXPORT_CONTRACT: indexes.TITLES.EXPORT_CONTRACT + 1,
},
};
Expand Down
32 changes: 23 additions & 9 deletions src/api/constants/XLSX-CONFIG/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const {
* - If "policy - using a nominated loss payee" is true, the XLSX has 5 additional rows.
* - If "buyer section - traded with buyer before" is true, the XLSX has 2 additional rows.
* - If "buyer section - traded with buyer before" is true and "buyer has outstanding payments" is true, the XLSX has 2 additional rows.
* - If "total contract value over threshold", the buyer section has 2 additional rows.
* - If "total contract value over threshold" and has previous credit insurance with buyer, the buyer section has 2 additional rows.
* - If "buyer section - has previous credit insurance cover with buyer" is true, the XLSX has 1 additional row.
* - If "export contract section - final destination is known" is true, the XLSX has 1 additional row.
* - If "export contract section - has attempted private market cover" is true, the XLSX has 1 additional row.
Expand All @@ -38,7 +40,7 @@ export const XLSX_ROW_INDEXES = (application: Application): XLSXRowIndexes => {
broker,
buyer: {
buyerTradingHistory: { exporterHasTradedWithBuyer, outstandingPayments: buyerHasOutstandingPayments },
relationship: { exporterHasPreviousCreditInsuranceWithBuyer },
relationship: { exporterHasPreviousCreditInsuranceWithBuyer, exporterIsConnectedWithBuyer },
},
company: {
differentTradingAddress: { fullAddress: hasDifferentTradingAddress },
Expand Down Expand Up @@ -149,6 +151,11 @@ export const XLSX_ROW_INDEXES = (application: Application): XLSXRowIndexes => {
* Increment some specific indexes,
* depending on answers in the "Buyer" section of an application.
*/
if (exporterIsConnectedWithBuyer) {
indexes.TITLES.DECLARATIONS += 1;
indexes.TITLES.EXPORT_CONTRACT += 1;
}

if (exporterHasTradedWithBuyer) {
indexes.TITLES.DECLARATIONS += 2;
indexes.TITLES.EXPORT_CONTRACT += 2;
Expand All @@ -159,9 +166,17 @@ export const XLSX_ROW_INDEXES = (application: Application): XLSXRowIndexes => {
}
}

if (exporterHasPreviousCreditInsuranceWithBuyer) {
// TODO: EMS-3467: move to getPopulatedApplication.
const totalContractValueOverThreshold = totalContractValue.value === TOTAL_CONTRACT_VALUE.MORE_THAN_250K.VALUE;

if (totalContractValueOverThreshold) {
indexes.TITLES.DECLARATIONS += 1;
indexes.TITLES.EXPORT_CONTRACT += 1;

if (exporterHasPreviousCreditInsuranceWithBuyer) {
indexes.TITLES.DECLARATIONS += 1;
indexes.TITLES.EXPORT_CONTRACT += 1;
}
}

/**
Expand Down Expand Up @@ -199,23 +214,22 @@ export const XLSX_ROW_INDEXES = (application: Application): XLSXRowIndexes => {
indexes.AGENT_ADDRESS += 1;
}

if (totalContractValueOverThreshold) {
indexes.AGENT_ADDRESS += 1;
}

if (finalDestinationKnown) {
indexes.TITLES.DECLARATIONS += 1;
indexes.AGENT_ADDRESS += 1;
}

/**
* Increment some specific indexes,
* depending on generic answers in the application.
* depending on generic answers in the application,
* that affect the final "declarations" section of an application.
*/
// TODO: EMS-3467: move to getPopulatedApplication.
const totalContractValueOverThreshold = totalContractValue.value === TOTAL_CONTRACT_VALUE.MORE_THAN_250K.VALUE;

if (totalContractValueOverThreshold) {
indexes.TITLES.DECLARATIONS += 1;
indexes.TITLES.EXPORT_CONTRACT += 1;

indexes.AGENT_ADDRESS += 1;
}

return indexes;
Expand Down
1 change: 1 addition & 0 deletions src/api/test-mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const mockApplicationMinimalBrokerBuyerAndCompany = {
relationship: {
...mockApplication.buyer.relationship,
exporterHasPreviousCreditInsuranceWithBuyer: false,
exporterIsConnectedWithBuyer: false,
},
},
company: companyScenarios.noDifferentTradingNameOrAddress,
Expand Down
Loading