@getjones/test-infra 4.5.11 → 4.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +30 -30
- package/src/common/commonFlows/auth/auth.js +40 -40
- package/src/common/commonFlows/index.js +4 -4
- package/src/common/commonFlows/records/records.js +269 -269
- package/src/common/consts/accountSettings.js +44 -44
- package/src/common/consts/activationStatuses.js +6 -6
- package/src/common/consts/autocomplete.js +10 -10
- package/src/common/consts/constantsForRecordsSortingAndFilters.js +49 -49
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/homepage/AttentionTab.js +6 -6
- package/src/common/consts/homepage/sortOptions.js +19 -19
- package/src/common/consts/ocrStatuses.js +6 -6
- package/src/common/consts/projectSettings.js +21 -21
- package/src/common/consts/recordTypes.js +5 -5
- package/src/common/consts/requirementActions.js +10 -10
- package/src/common/consts/s3FileTypes.js +13 -13
- package/src/common/consts/userRoles.js +18 -18
- package/src/common/consts/userTypes.js +8 -8
- package/src/common/errorCodes.js +3 -3
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/httpResponseTypes.json +2 -2
- package/src/common/requests/apiKeyAuth/requests.js +44 -44
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/internalAuth/requests.js +48 -48
- package/src/common/requests/requestHandlers.js +80 -80
- package/src/common/utils/complianceUtil.js +113 -113
- package/src/common/utils/configsUtil.js +22 -22
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +7 -7
- package/src/common/utils/timeUtils.js +177 -177
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/auditConfigs.js +125 -125
- package/src/defaults/configs/coverage.js +144 -144
- package/src/defaults/configs/polices.js +76 -76
- package/src/defaults/configs/requirement.js +32 -32
- package/src/defaults/index.js +6 -6
- package/src/env.js +57 -57
- package/src/factory/globalRecord/globalRecord.js +43 -43
- package/src/factory/index.js +8 -8
- package/src/factory/records/records.js +281 -281
- package/src/factory/users/users.js +69 -69
- package/src/index.js +103 -103
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +50 -50
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +182 -182
- package/src/saas/internal-api/accountDirectory/index.js +4 -4
- package/src/saas/internal-api/accountDirectory/models/accountDirectory.model.js +40 -40
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
- package/src/saas/internal-api/accounts/consts/consts.js +8 -8
- package/src/saas/internal-api/accounts/index.js +22 -22
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +53 -53
- package/src/saas/internal-api/accounts/utils/utils.js +61 -61
- package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
- package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
- package/src/saas/internal-api/agreement/consts/consts.js +11 -11
- package/src/saas/internal-api/agreement/index.js +12 -12
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
- package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
- package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
- package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
- package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
- package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
- package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
- package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
- package/src/saas/internal-api/auditNotes/index.js +4 -4
- package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
- package/src/saas/internal-api/auth/api/auth.api.js +27 -27
- package/src/saas/internal-api/auth/api/auth.service.js +90 -90
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +58 -58
- package/src/saas/internal-api/coi/api/coi.service.js +61 -61
- package/src/saas/internal-api/coi/consts/hashes.js +5 -5
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
- package/src/saas/internal-api/coi/index.js +14 -14
- package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
- package/src/saas/internal-api/coi/models/submit.coi.model.js +19 -19
- package/src/saas/internal-api/coi/utils/utils.js +117 -117
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.api.js +12 -12
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.service.js +14 -14
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +112 -106
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +318 -307
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +46 -46
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +38 -38
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +189 -189
- package/src/saas/internal-api/compliance/consts/audit.js +113 -113
- package/src/saas/internal-api/compliance/index.js +36 -36
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +96 -96
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
- package/src/saas/internal-api/compliance/utils/auditUtil.js +269 -269
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +45 -45
- package/src/saas/internal-api/contractors/api/contractors.api.js +209 -209
- package/src/saas/internal-api/contractors/api/contractors.service.js +361 -361
- package/src/saas/internal-api/contractors/consts/consts.js +6 -6
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +73 -73
- package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
- package/src/saas/internal-api/contractors/models/subscription.contractor.model.js +13 -13
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/contractors/utils.js +25 -25
- package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
- package/src/saas/internal-api/dashboard/index.js +5 -5
- package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +156 -156
- package/src/saas/internal-api/dbEmails/consts/consts.js +56 -56
- package/src/saas/internal-api/dbEmails/index.js +6 -6
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
- package/src/saas/internal-api/dbEmails/utils/util.js +87 -87
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
- package/src/saas/internal-api/emailCustomization/index.js +3 -3
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +112 -112
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
- package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/jonesNetworkTab/api/jones.network.tab.api.js +14 -14
- package/src/saas/internal-api/jonesNetworkTab/api/jones.network.tab.service.js +16 -16
- package/src/saas/internal-api/jonesNetworkTab/index.js +3 -3
- package/src/saas/internal-api/notificationCenter/api/notification.center.api.js +32 -32
- package/src/saas/internal-api/notificationCenter/api/notification.center.service.js +49 -49
- package/src/saas/internal-api/notificationCenter/index.js +3 -3
- package/src/saas/internal-api/policyFile/api/policy.file.api.js +43 -43
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +117 -117
- package/src/saas/internal-api/policyFile/consts.js +21 -21
- package/src/saas/internal-api/policyFile/index.js +11 -11
- package/src/saas/internal-api/policyFile/models/create.policy.file.model.js +11 -11
- package/src/saas/internal-api/policyFile/models/set.publish.flag.to.policy.model.js +13 -13
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +77 -77
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +40 -40
- package/src/saas/internal-api/projects/utils/utils.js +155 -155
- package/src/saas/internal-api/recordHub/api/record.hub.api.js +14 -14
- package/src/saas/internal-api/recordHub/api/record.hub.service.js +32 -32
- package/src/saas/internal-api/recordHub/index.js +3 -3
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +56 -56
- package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/reports/api/reports.api.js +62 -62
- package/src/saas/internal-api/reports/api/reports.service.js +79 -79
- package/src/saas/internal-api/reports/consts/consts.js +74 -74
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +132 -132
- package/src/saas/internal-api/requests/api/requests.service.js +312 -312
- package/src/saas/internal-api/requests/index.js +21 -21
- package/src/saas/internal-api/requests/models/create.request.model.js +36 -36
- package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
- package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/homepageRequestCriteriaModel.js +19 -19
- package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +16 -16
- package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
- package/src/saas/internal-api/requestsTable/index.js +3 -3
- package/src/saas/internal-api/requirements/api/requirements.api.js +57 -57
- package/src/saas/internal-api/requirements/api/requirements.service.js +184 -184
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
- package/src/saas/internal-api/requirements/consts/consts.js +6 -6
- package/src/saas/internal-api/requirements/index.js +10 -10
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
- package/src/saas/internal-api/requirements/utils/utils.js +129 -129
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +60 -60
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
- package/src/saas/internal-api/thread-scheduler/runner.js +55 -55
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +43 -43
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +107 -107
- package/src/saas/internal-api/uploadFiles/consts.js +12 -12
- package/src/saas/internal-api/uploadFiles/index.js +5 -5
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +108 -108
- package/src/saas/internal-api/users/api/users.api.js +127 -127
- package/src/saas/internal-api/users/api/users.service.js +258 -258
- package/src/saas/internal-api/users/index.js +16 -16
- package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
- package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
- package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
- package/src/saas/internal-api/users/models/users.model.js +43 -43
- package/src/saas/internal-api/users/utils/util.js +39 -39
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +26 -26
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +19 -19
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/coi/coi.api.js +30 -30
- package/src/saas/openapi/coi/coi.service.js +43 -43
- package/src/saas/openapi/projects/projects.api.js +83 -83
- package/src/saas/openapi/projects/projects.service.js +64 -64
- package/src/saas/openapi/requests/index.js +7 -7
- package/src/saas/openapi/requests/models/invite.request.model.js +40 -40
- package/src/saas/openapi/requests/models/update.request.model.js +35 -35
- package/src/saas/openapi/requests/requests.api.js +93 -93
- package/src/saas/openapi/requests/requests.service.js +94 -94
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +41 -41
- package/src/saas/openapi/requirements/requirements.service.js +49 -49
- package/src/saas/openapi/tabs/index.js +6 -6
- package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
- package/src/saas/openapi/tabs/tabs.api.js +27 -27
- package/src/saas/openapi/tabs/tabs.service.js +19 -19
- package/src/saas/openapi/users/user.model.js +10 -10
- package/src/saas/openapi/users/users.api.js +33 -33
- package/src/saas/openapi/users/users.service.js +51 -51
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
- package/src/resources/virusFile.pdf +0 -0
|
@@ -1,269 +1,269 @@
|
|
|
1
|
-
const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../consts/audit');
|
|
2
|
-
const { isObject, isArray } = require('../../../../common/utils/dataTypeUtils');
|
|
3
|
-
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
4
|
-
const auditModels = require('../models/audit/audit.model');
|
|
5
|
-
const waiveModels = require('../models/waive/waive.model');
|
|
6
|
-
|
|
7
|
-
const emptyValue = '';
|
|
8
|
-
|
|
9
|
-
const getValueBySelection = selection => {
|
|
10
|
-
return ['Yes', 'No', 'Empty', 'Claims'].includes(selection) ? emptyValue : selection;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getDateInApiFormat = date => {
|
|
14
|
-
return timeUtils.convertDateToNewFormat(
|
|
15
|
-
date,
|
|
16
|
-
timeUtils.formats.dayMonthYear,
|
|
17
|
-
timeUtils.formats.numericMonthDayYear
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const getAttributeKey = attribute => {
|
|
22
|
-
return specialAttributes[attribute] || attribute;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getWaiveReason = reason => {
|
|
26
|
-
return waiveReasons[reason] || reason;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getAttributeNameAndAuditIdByGap = function(record, policyName, gap) {
|
|
30
|
-
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
31
|
-
contractorCoverage.insuranceName === policyName);
|
|
32
|
-
|
|
33
|
-
if (!policy) {
|
|
34
|
-
throw new Error(`Policy name ${policyName} don't exist in record`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const attribute = policy.errorList.find(error => error.errorHeadline === gap);
|
|
38
|
-
|
|
39
|
-
if (!attribute) {
|
|
40
|
-
throw new Error(`Gap ${gap} don't exist in record`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return { attributeName: attribute.limitName, auditId: attribute.auditId };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getAllWaivablePolicies = function(record) {
|
|
47
|
-
const waivable = [];
|
|
48
|
-
|
|
49
|
-
const policies = record.reviewbyAuditor;
|
|
50
|
-
for (const policy of policies) {
|
|
51
|
-
const {
|
|
52
|
-
insuranceName: policyName,
|
|
53
|
-
errorList: errorList
|
|
54
|
-
} = policy;
|
|
55
|
-
|
|
56
|
-
for (const error of errorList) {
|
|
57
|
-
if (error.warningStatus === 'POLICYERROR' && error.errorStatus === 'notIgnored') {
|
|
58
|
-
waivable.push({
|
|
59
|
-
policyName: policyName,
|
|
60
|
-
attributeName: error.limitname
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return waivable;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getPolicyId = (policyName, requirement) => {
|
|
70
|
-
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
71
|
-
return DEFAULT_POLICY_ID;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const policy = requirement.policies.find(policy => policy.name === policyName);
|
|
75
|
-
|
|
76
|
-
if (!policy) {
|
|
77
|
-
let policiesList = emptyValue;
|
|
78
|
-
requirement.policies.forEach(policy => policiesList += `${policy.name},`);
|
|
79
|
-
|
|
80
|
-
throw Error(`Policy '${policyName}' not found in the Requirement. List: ${policiesList.slice(0, -1)}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return policy.id;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const getAuditorReviewIdFromPreviousAudit = (policyId, attributeName, previousAuditData) => {
|
|
87
|
-
const reviewField = previousAuditData.
|
|
88
|
-
find(reviewField => reviewField.insuranceTypeId === policyId && reviewField.limitName === attributeName);
|
|
89
|
-
|
|
90
|
-
return reviewField?.auditorcontractorId;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const parseAuditConfig = function(config) {
|
|
94
|
-
const auditDataArr = [];
|
|
95
|
-
for (const field in config) {
|
|
96
|
-
if (!config.hasOwnProperty(field)) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//for "regular" policies (passes as an object)
|
|
101
|
-
if (isObject(config[field])) {
|
|
102
|
-
const attributes = config[field];
|
|
103
|
-
for (const attributeName in attributes) {
|
|
104
|
-
if (attributeName === 'Policy Expiry') {
|
|
105
|
-
attributes[attributeName] = getDateInApiFormat(attributes[attributeName]);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const selection = { policyName: field };
|
|
109
|
-
|
|
110
|
-
// Special attribute names switch
|
|
111
|
-
switch (attributeName) {
|
|
112
|
-
case 'Occur':
|
|
113
|
-
const occurKeys = getAttributeKey(attributeName);
|
|
114
|
-
selection.attributeName = occurKeys[field];
|
|
115
|
-
break;
|
|
116
|
-
default:
|
|
117
|
-
selection.attributeName = getAttributeKey(attributeName);
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (isArray(attributes[attributeName])) {
|
|
122
|
-
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
|
|
123
|
-
|
|
124
|
-
const auditValue = attributes[attributeName][1]; //must be passed as an array of comments -> ['Other', ['comment1', 'comment2']]. when one comment can also be passed as ['Other', 'comment1']
|
|
125
|
-
|
|
126
|
-
if (multipleErrorsEndorsementAndAttributesList.includes(attributeName) && isArray(auditValue)) {
|
|
127
|
-
// in case of multiple comments when selecting "Other" in "regular" policies attributes like 'Full Policy copy'
|
|
128
|
-
for (const value of auditValue) {
|
|
129
|
-
const copiedSelection = { ... selection, value };
|
|
130
|
-
auditDataArr.push(copiedSelection);
|
|
131
|
-
}
|
|
132
|
-
continue;
|
|
133
|
-
} else {
|
|
134
|
-
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
// Special statuses switch
|
|
138
|
-
switch (selection.attributeName) {
|
|
139
|
-
case getAttributeKey('Policy Number'):
|
|
140
|
-
selection.status = emptyValue;
|
|
141
|
-
break;
|
|
142
|
-
case getAttributeKey('Policy Expiry'):
|
|
143
|
-
selection.status = AUDIT_ENTITY_STATUSES.YES;
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName]).toUpperCase()];
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
selection.value = getValueBySelection(attributes[attributeName]);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
auditDataArr.push(selection);
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
if (field === 'Certificate issue date') {
|
|
157
|
-
config[field] = getDateInApiFormat(config[field]);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const selection = { attributeName: getAttributeKey(field) };
|
|
161
|
-
certificateEndorsementsList.includes(field) && (selection.policyName = field);
|
|
162
|
-
|
|
163
|
-
//For endorsements / certificate of insurance fields
|
|
164
|
-
if (isArray(config[field])) {
|
|
165
|
-
selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
|
|
166
|
-
|
|
167
|
-
const auditValue = config[field][1];
|
|
168
|
-
|
|
169
|
-
if (multipleErrorsEndorsementAndAttributesList.includes(field) && isArray(auditValue)) {
|
|
170
|
-
// in case of 'Other' with multiple errors in special policies (Additional Information, Certificate Holder, etc)
|
|
171
|
-
let i = 0;
|
|
172
|
-
while (i < auditValue.length) {
|
|
173
|
-
const copiedSelection = { ... selection };
|
|
174
|
-
copiedSelection.value = auditValue[i];
|
|
175
|
-
auditDataArr.push(copiedSelection);
|
|
176
|
-
i++;
|
|
177
|
-
}
|
|
178
|
-
continue;
|
|
179
|
-
} else {
|
|
180
|
-
selection.value = auditValue; // Ok to be undefined
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
selection.status = AUDIT_ENTITY_STATUSES[(config[field]).toUpperCase()] || AUDIT_ENTITY_STATUSES.YES;
|
|
184
|
-
selection.value = getValueBySelection(config[field]);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (field === 'AM Score') {
|
|
188
|
-
selection.status = VALID_SCORES.includes(selection.value) ? AUDIT_ENTITY_STATUSES.YES : AUDIT_ENTITY_STATUSES.NO;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
auditDataArr.push(selection);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return auditDataArr;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const createAuditEntity = (
|
|
198
|
-
requirement, previousAuditData, {
|
|
199
|
-
policyName = null,
|
|
200
|
-
attributeName = null,
|
|
201
|
-
value = emptyValue,
|
|
202
|
-
status = emptyValue
|
|
203
|
-
}) => {
|
|
204
|
-
const policyId = getPolicyId(policyName, requirement);
|
|
205
|
-
const auditorReviewId = getAuditorReviewIdFromPreviousAudit(policyId, attributeName, previousAuditData);
|
|
206
|
-
const auditEntityModel = new auditModels.AuditEntityModel(policyId, attributeName, status, value, auditorReviewId);
|
|
207
|
-
|
|
208
|
-
return auditEntityModel;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
module.exports = {
|
|
212
|
-
parseAuditConfig,
|
|
213
|
-
getPolicyId,
|
|
214
|
-
createAuditEntity,
|
|
215
|
-
getAttributeKey,
|
|
216
|
-
getAttributeNameAndAuditIdByGap,
|
|
217
|
-
getWaiveReason,
|
|
218
|
-
getAllWaivablePolicies
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const certificateEndorsementsList = [
|
|
222
|
-
'Waiver Of Subrogation',
|
|
223
|
-
'Certificate Holder',
|
|
224
|
-
'Additional Information',
|
|
225
|
-
'Additional Insured',
|
|
226
|
-
'Agreement'
|
|
227
|
-
];
|
|
228
|
-
|
|
229
|
-
const multipleErrorsEndorsementAndAttributesList = [
|
|
230
|
-
'Certificate Holder',
|
|
231
|
-
'Additional Information',
|
|
232
|
-
'Additional Insured',
|
|
233
|
-
'Agreement',
|
|
234
|
-
'Other',
|
|
235
|
-
'Full Policy Copy'
|
|
236
|
-
];
|
|
237
|
-
|
|
238
|
-
const specialAttributes = {
|
|
239
|
-
'Certificate issue date': 'certIssueDate',
|
|
240
|
-
'Cancellation Terms': 'cancellationTerms',
|
|
241
|
-
'COI authentication': 'COIauthentication',
|
|
242
|
-
'AM Score': 'AMBestRating',
|
|
243
|
-
'Signature': 'signature',
|
|
244
|
-
|
|
245
|
-
'Insured Address': 'Insured Address',
|
|
246
|
-
'Insured Name': 'Insured Name',
|
|
247
|
-
|
|
248
|
-
'Additional Information': 'additionalInformation',
|
|
249
|
-
'Waiver Of Subrogation': 'waiverofsubrogation',
|
|
250
|
-
'Additional Insured': 'additionalInsured',
|
|
251
|
-
'Certificate Holder': 'certificateHolder',
|
|
252
|
-
|
|
253
|
-
'Coverage Exists': 'coverageexists',
|
|
254
|
-
'Coverage exists': 'coverageexists',
|
|
255
|
-
'Policy Number': 'policynumber',
|
|
256
|
-
'Policy Expiry': 'expirydate',
|
|
257
|
-
'Per Occur': 'PerOccur',
|
|
258
|
-
|
|
259
|
-
'Occur': {
|
|
260
|
-
'Excess Liability': 'EXoccur',
|
|
261
|
-
'Umbrella': 'UMoccur'
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const waiveReasons = {
|
|
266
|
-
'No Exposure': waiveModels.WAIVER_REASONS.NO_EXPOSURE,
|
|
267
|
-
'Business Decision': waiveModels.WAIVER_REASONS.BUSINESS_DECISION,
|
|
268
|
-
'Executive Approval': waiveModels.WAIVER_REASONS.EXECUTIVE_APPROVAL
|
|
269
|
-
};
|
|
1
|
+
const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../consts/audit');
|
|
2
|
+
const { isObject, isArray } = require('../../../../common/utils/dataTypeUtils');
|
|
3
|
+
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
4
|
+
const auditModels = require('../models/audit/audit.model');
|
|
5
|
+
const waiveModels = require('../models/waive/waive.model');
|
|
6
|
+
|
|
7
|
+
const emptyValue = '';
|
|
8
|
+
|
|
9
|
+
const getValueBySelection = selection => {
|
|
10
|
+
return ['Yes', 'No', 'Empty', 'Claims'].includes(selection) ? emptyValue : selection;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getDateInApiFormat = date => {
|
|
14
|
+
return timeUtils.convertDateToNewFormat(
|
|
15
|
+
date,
|
|
16
|
+
timeUtils.formats.dayMonthYear,
|
|
17
|
+
timeUtils.formats.numericMonthDayYear
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getAttributeKey = attribute => {
|
|
22
|
+
return specialAttributes[attribute] || attribute;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getWaiveReason = reason => {
|
|
26
|
+
return waiveReasons[reason] || reason;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getAttributeNameAndAuditIdByGap = function(record, policyName, gap) {
|
|
30
|
+
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
31
|
+
contractorCoverage.insuranceName === policyName);
|
|
32
|
+
|
|
33
|
+
if (!policy) {
|
|
34
|
+
throw new Error(`Policy name ${policyName} don't exist in record`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const attribute = policy.errorList.find(error => error.errorHeadline === gap);
|
|
38
|
+
|
|
39
|
+
if (!attribute) {
|
|
40
|
+
throw new Error(`Gap ${gap} don't exist in record`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return { attributeName: attribute.limitName, auditId: attribute.auditId };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getAllWaivablePolicies = function(record) {
|
|
47
|
+
const waivable = [];
|
|
48
|
+
|
|
49
|
+
const policies = record.reviewbyAuditor;
|
|
50
|
+
for (const policy of policies) {
|
|
51
|
+
const {
|
|
52
|
+
insuranceName: policyName,
|
|
53
|
+
errorList: errorList
|
|
54
|
+
} = policy;
|
|
55
|
+
|
|
56
|
+
for (const error of errorList) {
|
|
57
|
+
if (error.warningStatus === 'POLICYERROR' && error.errorStatus === 'notIgnored') {
|
|
58
|
+
waivable.push({
|
|
59
|
+
policyName: policyName,
|
|
60
|
+
attributeName: error.limitname
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return waivable;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getPolicyId = (policyName, requirement) => {
|
|
70
|
+
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
71
|
+
return DEFAULT_POLICY_ID;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const policy = requirement.policies.find(policy => policy.name === policyName);
|
|
75
|
+
|
|
76
|
+
if (!policy) {
|
|
77
|
+
let policiesList = emptyValue;
|
|
78
|
+
requirement.policies.forEach(policy => policiesList += `${policy.name},`);
|
|
79
|
+
|
|
80
|
+
throw Error(`Policy '${policyName}' not found in the Requirement. List: ${policiesList.slice(0, -1)}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return policy.id;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const getAuditorReviewIdFromPreviousAudit = (policyId, attributeName, previousAuditData) => {
|
|
87
|
+
const reviewField = previousAuditData.
|
|
88
|
+
find(reviewField => reviewField.insuranceTypeId === policyId && reviewField.limitName === attributeName);
|
|
89
|
+
|
|
90
|
+
return reviewField?.auditorcontractorId;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const parseAuditConfig = function(config) {
|
|
94
|
+
const auditDataArr = [];
|
|
95
|
+
for (const field in config) {
|
|
96
|
+
if (!config.hasOwnProperty(field)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//for "regular" policies (passes as an object)
|
|
101
|
+
if (isObject(config[field])) {
|
|
102
|
+
const attributes = config[field];
|
|
103
|
+
for (const attributeName in attributes) {
|
|
104
|
+
if (attributeName === 'Policy Expiry') {
|
|
105
|
+
attributes[attributeName] = getDateInApiFormat(attributes[attributeName]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const selection = { policyName: field };
|
|
109
|
+
|
|
110
|
+
// Special attribute names switch
|
|
111
|
+
switch (attributeName) {
|
|
112
|
+
case 'Occur':
|
|
113
|
+
const occurKeys = getAttributeKey(attributeName);
|
|
114
|
+
selection.attributeName = occurKeys[field];
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
selection.attributeName = getAttributeKey(attributeName);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (isArray(attributes[attributeName])) {
|
|
122
|
+
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
|
|
123
|
+
|
|
124
|
+
const auditValue = attributes[attributeName][1]; //must be passed as an array of comments -> ['Other', ['comment1', 'comment2']]. when one comment can also be passed as ['Other', 'comment1']
|
|
125
|
+
|
|
126
|
+
if (multipleErrorsEndorsementAndAttributesList.includes(attributeName) && isArray(auditValue)) {
|
|
127
|
+
// in case of multiple comments when selecting "Other" in "regular" policies attributes like 'Full Policy copy'
|
|
128
|
+
for (const value of auditValue) {
|
|
129
|
+
const copiedSelection = { ... selection, value };
|
|
130
|
+
auditDataArr.push(copiedSelection);
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
} else {
|
|
134
|
+
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
// Special statuses switch
|
|
138
|
+
switch (selection.attributeName) {
|
|
139
|
+
case getAttributeKey('Policy Number'):
|
|
140
|
+
selection.status = emptyValue;
|
|
141
|
+
break;
|
|
142
|
+
case getAttributeKey('Policy Expiry'):
|
|
143
|
+
selection.status = AUDIT_ENTITY_STATUSES.YES;
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName]).toUpperCase()];
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
selection.value = getValueBySelection(attributes[attributeName]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
auditDataArr.push(selection);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
if (field === 'Certificate issue date') {
|
|
157
|
+
config[field] = getDateInApiFormat(config[field]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const selection = { attributeName: getAttributeKey(field) };
|
|
161
|
+
certificateEndorsementsList.includes(field) && (selection.policyName = field);
|
|
162
|
+
|
|
163
|
+
//For endorsements / certificate of insurance fields
|
|
164
|
+
if (isArray(config[field])) {
|
|
165
|
+
selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
|
|
166
|
+
|
|
167
|
+
const auditValue = config[field][1];
|
|
168
|
+
|
|
169
|
+
if (multipleErrorsEndorsementAndAttributesList.includes(field) && isArray(auditValue)) {
|
|
170
|
+
// in case of 'Other' with multiple errors in special policies (Additional Information, Certificate Holder, etc)
|
|
171
|
+
let i = 0;
|
|
172
|
+
while (i < auditValue.length) {
|
|
173
|
+
const copiedSelection = { ... selection };
|
|
174
|
+
copiedSelection.value = auditValue[i];
|
|
175
|
+
auditDataArr.push(copiedSelection);
|
|
176
|
+
i++;
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
} else {
|
|
180
|
+
selection.value = auditValue; // Ok to be undefined
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
selection.status = AUDIT_ENTITY_STATUSES[(config[field]).toUpperCase()] || AUDIT_ENTITY_STATUSES.YES;
|
|
184
|
+
selection.value = getValueBySelection(config[field]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (field === 'AM Score') {
|
|
188
|
+
selection.status = VALID_SCORES.includes(selection.value) ? AUDIT_ENTITY_STATUSES.YES : AUDIT_ENTITY_STATUSES.NO;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
auditDataArr.push(selection);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return auditDataArr;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const createAuditEntity = (
|
|
198
|
+
requirement, previousAuditData, {
|
|
199
|
+
policyName = null,
|
|
200
|
+
attributeName = null,
|
|
201
|
+
value = emptyValue,
|
|
202
|
+
status = emptyValue
|
|
203
|
+
}) => {
|
|
204
|
+
const policyId = getPolicyId(policyName, requirement);
|
|
205
|
+
const auditorReviewId = getAuditorReviewIdFromPreviousAudit(policyId, attributeName, previousAuditData);
|
|
206
|
+
const auditEntityModel = new auditModels.AuditEntityModel(policyId, attributeName, status, value, auditorReviewId);
|
|
207
|
+
|
|
208
|
+
return auditEntityModel;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
module.exports = {
|
|
212
|
+
parseAuditConfig,
|
|
213
|
+
getPolicyId,
|
|
214
|
+
createAuditEntity,
|
|
215
|
+
getAttributeKey,
|
|
216
|
+
getAttributeNameAndAuditIdByGap,
|
|
217
|
+
getWaiveReason,
|
|
218
|
+
getAllWaivablePolicies
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const certificateEndorsementsList = [
|
|
222
|
+
'Waiver Of Subrogation',
|
|
223
|
+
'Certificate Holder',
|
|
224
|
+
'Additional Information',
|
|
225
|
+
'Additional Insured',
|
|
226
|
+
'Agreement'
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
const multipleErrorsEndorsementAndAttributesList = [
|
|
230
|
+
'Certificate Holder',
|
|
231
|
+
'Additional Information',
|
|
232
|
+
'Additional Insured',
|
|
233
|
+
'Agreement',
|
|
234
|
+
'Other',
|
|
235
|
+
'Full Policy Copy'
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
const specialAttributes = {
|
|
239
|
+
'Certificate issue date': 'certIssueDate',
|
|
240
|
+
'Cancellation Terms': 'cancellationTerms',
|
|
241
|
+
'COI authentication': 'COIauthentication',
|
|
242
|
+
'AM Score': 'AMBestRating',
|
|
243
|
+
'Signature': 'signature',
|
|
244
|
+
|
|
245
|
+
'Insured Address': 'Insured Address',
|
|
246
|
+
'Insured Name': 'Insured Name',
|
|
247
|
+
|
|
248
|
+
'Additional Information': 'additionalInformation',
|
|
249
|
+
'Waiver Of Subrogation': 'waiverofsubrogation',
|
|
250
|
+
'Additional Insured': 'additionalInsured',
|
|
251
|
+
'Certificate Holder': 'certificateHolder',
|
|
252
|
+
|
|
253
|
+
'Coverage Exists': 'coverageexists',
|
|
254
|
+
'Coverage exists': 'coverageexists',
|
|
255
|
+
'Policy Number': 'policynumber',
|
|
256
|
+
'Policy Expiry': 'expirydate',
|
|
257
|
+
'Per Occur': 'PerOccur',
|
|
258
|
+
|
|
259
|
+
'Occur': {
|
|
260
|
+
'Excess Liability': 'EXoccur',
|
|
261
|
+
'Umbrella': 'UMoccur'
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const waiveReasons = {
|
|
266
|
+
'No Exposure': waiveModels.WAIVER_REASONS.NO_EXPOSURE,
|
|
267
|
+
'Business Decision': waiveModels.WAIVER_REASONS.BUSINESS_DECISION,
|
|
268
|
+
'Executive Approval': waiveModels.WAIVER_REASONS.EXECUTIVE_APPROVAL
|
|
269
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const { cloneObject } = require('../../../../common/utils/objectUtils');
|
|
2
|
-
const { policiesCoverageConfig } = require('../../../../defaults/configs/coverage');
|
|
3
|
-
|
|
4
|
-
const getCoverageConfig = function(coiId, policiesForCoverage) {
|
|
5
|
-
const coverageConfig = cloneObject(baseCoverageConfig);
|
|
6
|
-
|
|
7
|
-
coverageConfig.coiId = coiId;
|
|
8
|
-
|
|
9
|
-
if (Array.isArray(policiesForCoverage) && typeof policiesForCoverage[0] !== 'object') { //when getting a list of policy names (from automation)
|
|
10
|
-
const coveragePolicies = coverageConfig.documents[0].pages[0].policies;
|
|
11
|
-
|
|
12
|
-
for (const policyName of policiesForCoverage) {
|
|
13
|
-
const policy = policiesCoverageConfig[policyName];
|
|
14
|
-
|
|
15
|
-
if (! policy) {
|
|
16
|
-
throw Error(`There is no config for ${policyName}. Config available for policies: ${Object.keys(policiesCoverageConfig).join(', ')}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
coveragePolicies.push(cloneObject(policy));
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
coverageConfig.documents[0].pages[0].policies = policiesForCoverage; //when getting the policies coverage config prepared
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return coverageConfig;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const baseCoverageConfig = {
|
|
29
|
-
'coiId': 'REPLACE_WITH_REAL_VALUE',
|
|
30
|
-
'documents': [
|
|
31
|
-
{
|
|
32
|
-
'documentType': 'accord25',
|
|
33
|
-
'pages': [
|
|
34
|
-
{
|
|
35
|
-
'pageNumber': 1,
|
|
36
|
-
'policies': []
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
getCoverageConfig
|
|
45
|
-
};
|
|
1
|
+
const { cloneObject } = require('../../../../common/utils/objectUtils');
|
|
2
|
+
const { policiesCoverageConfig } = require('../../../../defaults/configs/coverage');
|
|
3
|
+
|
|
4
|
+
const getCoverageConfig = function(coiId, policiesForCoverage) {
|
|
5
|
+
const coverageConfig = cloneObject(baseCoverageConfig);
|
|
6
|
+
|
|
7
|
+
coverageConfig.coiId = coiId;
|
|
8
|
+
|
|
9
|
+
if (Array.isArray(policiesForCoverage) && typeof policiesForCoverage[0] !== 'object') { //when getting a list of policy names (from automation)
|
|
10
|
+
const coveragePolicies = coverageConfig.documents[0].pages[0].policies;
|
|
11
|
+
|
|
12
|
+
for (const policyName of policiesForCoverage) {
|
|
13
|
+
const policy = policiesCoverageConfig[policyName];
|
|
14
|
+
|
|
15
|
+
if (! policy) {
|
|
16
|
+
throw Error(`There is no config for ${policyName}. Config available for policies: ${Object.keys(policiesCoverageConfig).join(', ')}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
coveragePolicies.push(cloneObject(policy));
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
coverageConfig.documents[0].pages[0].policies = policiesForCoverage; //when getting the policies coverage config prepared
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return coverageConfig;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const baseCoverageConfig = {
|
|
29
|
+
'coiId': 'REPLACE_WITH_REAL_VALUE',
|
|
30
|
+
'documents': [
|
|
31
|
+
{
|
|
32
|
+
'documentType': 'accord25',
|
|
33
|
+
'pages': [
|
|
34
|
+
{
|
|
35
|
+
'pageNumber': 1,
|
|
36
|
+
'policies': []
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
getCoverageConfig
|
|
45
|
+
};
|