@getjones/test-infra 4.5.1 → 4.5.3
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 +1 -1
- package/src/defaults/configs/auditConfigs.js +0 -21
- package/src/defaults/configs/coverage.js +93 -102
- package/src/defaults/configs/polices.js +2 -1
- package/src/factory/records/records.js +29 -97
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +5 -7
- package/src/saas/internal-api/compliance/utils/auditUtil.js +20 -2
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +13 -28
- package/src/resources/virusFile.pdf +0 -0
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@ const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
|
|
|
13
13
|
const {
|
|
14
14
|
certificateIssueDate,
|
|
15
15
|
generalLiability
|
|
16
|
-
// umbrella
|
|
17
16
|
} = policyNames;
|
|
18
17
|
|
|
19
18
|
const {
|
|
@@ -109,25 +108,6 @@ const setAboutExpiredConfig = config =>
|
|
|
109
108
|
const setExpiredConfig = config =>
|
|
110
109
|
config[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
|
|
111
110
|
|
|
112
|
-
// const getMinimumRequiredCompliantConfigForAutocomplete = () => { //maybe no need, just use regular one? which req?
|
|
113
|
-
// const baseAuditConfig = getCompliantAuditConfigWithoutPolicies();
|
|
114
|
-
// return {
|
|
115
|
-
// ... baseAuditConfig,
|
|
116
|
-
// [generalLiability]: {
|
|
117
|
-
// [coverageExists]: policySelections.YES,
|
|
118
|
-
// [policyNumber]: DEFAULT_POLICY_NUMBER,
|
|
119
|
-
// [policyExpired]: `${DEFAULT_POLICY_DATE}`,
|
|
120
|
-
// [eachOccurrence]: policySelections.YES
|
|
121
|
-
// },
|
|
122
|
-
// [umbrella]: {
|
|
123
|
-
// [coverageExists]: policySelections.YES,
|
|
124
|
-
// [policyNumber]: DEFAULT_POLICY_NUMBER,
|
|
125
|
-
// [policyExpired]: `${DEFAULT_POLICY_DATE}`,
|
|
126
|
-
// [eachOccurrence]: policySelections.YES
|
|
127
|
-
// }
|
|
128
|
-
// };
|
|
129
|
-
// };
|
|
130
|
-
|
|
131
111
|
module.exports = {
|
|
132
112
|
getCompliantAuditConfig,
|
|
133
113
|
getCompliantAuditConfigWithoutPolicies,
|
|
@@ -137,7 +117,6 @@ module.exports = {
|
|
|
137
117
|
getExpiredConfig,
|
|
138
118
|
setExpiredConfig,
|
|
139
119
|
setAboutExpiredConfig,
|
|
140
|
-
// getMinimumRequiredCompliantConfigForAutocomplete,
|
|
141
120
|
policySelections,
|
|
142
121
|
defaultPolicyDate: DEFAULT_POLICY_DATE,
|
|
143
122
|
defaultExpiredPolicyDate: DEFAULT_EXPIRED_POLICY_DATE,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const policies = require('../configs/polices');
|
|
2
|
-
// const { cloneObject } = require('../../common/utils/objectUtils');
|
|
3
2
|
|
|
4
3
|
const defaultExpiryDate = '2030-10-10T00:00:00.000Z';
|
|
5
4
|
const defaultEffectiveDate = '2020-10-10T00:00:00.000Z';
|
|
6
5
|
|
|
7
|
-
const
|
|
6
|
+
const policiesConfig = {
|
|
8
7
|
[policies.policyNames.generalLiability]: {
|
|
9
8
|
key: 'generalLiability',
|
|
10
9
|
policyEntities: [
|
|
@@ -18,57 +17,57 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
18
17
|
{
|
|
19
18
|
key: 'eachOccurrence',
|
|
20
19
|
value: 1000000
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: 'productsCompletedOperationsAggregate',
|
|
23
|
+
value: 3000000
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: 'personalAdvertisingInjury',
|
|
27
|
+
value: 1000000
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'medicalExpenses',
|
|
31
|
+
value: 5000
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: 'damageToRentedPremises',
|
|
35
|
+
value: 50000
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'generalAggregate',
|
|
39
|
+
value: 2000000
|
|
21
40
|
}
|
|
22
|
-
// {
|
|
23
|
-
// key: 'productsCompletedOperationsAggregate',
|
|
24
|
-
// value: 3000000
|
|
25
|
-
// },
|
|
26
|
-
// {
|
|
27
|
-
// key: 'personalAdvertisingInjury',
|
|
28
|
-
// value: 1000000
|
|
29
|
-
// },
|
|
30
|
-
// {
|
|
31
|
-
// key: 'medicalExpenses',
|
|
32
|
-
// value: 5000
|
|
33
|
-
// },
|
|
34
|
-
// {
|
|
35
|
-
// key: 'damageToRentedPremises',
|
|
36
|
-
// value: 50000
|
|
37
|
-
// },
|
|
38
|
-
// {
|
|
39
|
-
// key: 'generalAggregate',
|
|
40
|
-
// value: 2000000
|
|
41
|
-
// }
|
|
42
41
|
],
|
|
43
42
|
provisions: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
{
|
|
44
|
+
key: 'primaryNonContributoryProvision',
|
|
45
|
+
value: true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: 'primaryNonContributoryForAdditionalInsured',
|
|
49
|
+
value: true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: '10DaysNoticeOfCancellation',
|
|
53
|
+
value: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'contractualLiability',
|
|
57
|
+
value: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: 'perOccur',
|
|
61
|
+
value: true
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: 'perPolicy',
|
|
65
|
+
value: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: 'perProject',
|
|
69
|
+
value: true
|
|
70
|
+
}
|
|
72
71
|
]
|
|
73
72
|
},
|
|
74
73
|
[policies.policyNames.automobileLiability]: {
|
|
@@ -82,23 +81,23 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
82
81
|
],
|
|
83
82
|
limits: [
|
|
84
83
|
{
|
|
85
|
-
key: '
|
|
84
|
+
key: 'combinedSingleLimit',
|
|
86
85
|
value: 1000000
|
|
87
86
|
}
|
|
88
87
|
],
|
|
89
88
|
provisions: [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
{
|
|
90
|
+
key: 'anyAuto',
|
|
91
|
+
value: true
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: 'waiverOfSubrogation',
|
|
95
|
+
value: true
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: 'hired',
|
|
99
|
+
value: true
|
|
100
|
+
}
|
|
102
101
|
]
|
|
103
102
|
},
|
|
104
103
|
[policies.policyNames.excessLiability]: {
|
|
@@ -111,16 +110,16 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
111
110
|
}
|
|
112
111
|
],
|
|
113
112
|
limits: [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
{
|
|
114
|
+
key: 'eachOccurrence',
|
|
115
|
+
value: 1000000
|
|
116
|
+
}
|
|
118
117
|
],
|
|
119
118
|
provisions: [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
{
|
|
120
|
+
key: 'occur',
|
|
121
|
+
value: true
|
|
122
|
+
}
|
|
124
123
|
]
|
|
125
124
|
},
|
|
126
125
|
[policies.policyNames.umbrella]: {
|
|
@@ -136,17 +135,17 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
136
135
|
{
|
|
137
136
|
key: 'eachOccurrence',
|
|
138
137
|
value: 5000000
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: 'aggregate',
|
|
141
|
+
value: 5000000
|
|
139
142
|
}
|
|
140
|
-
// {
|
|
141
|
-
// key: 'aggregate',
|
|
142
|
-
// value: 5000000
|
|
143
|
-
// }
|
|
144
143
|
],
|
|
145
144
|
provisions: [
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
{
|
|
146
|
+
key: 'occur',
|
|
147
|
+
value: true
|
|
148
|
+
}
|
|
150
149
|
]
|
|
151
150
|
},
|
|
152
151
|
[policies.policyNames.workersCompensation]: {
|
|
@@ -162,17 +161,17 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
162
161
|
{
|
|
163
162
|
key: 'employersLiabilityEachAccident',
|
|
164
163
|
value: 1000000
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: 'employersLiabilityDiseaseEachEmployee',
|
|
167
|
+
value: 1000000
|
|
165
168
|
}
|
|
166
|
-
// {
|
|
167
|
-
// key: 'employersLiabilityDiseaseEachEmployee',
|
|
168
|
-
// value: 1000000
|
|
169
|
-
// }
|
|
170
169
|
],
|
|
171
170
|
provisions: [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
{
|
|
172
|
+
key: 'statutoryLimitsRequired',
|
|
173
|
+
value: true
|
|
174
|
+
}
|
|
176
175
|
]
|
|
177
176
|
},
|
|
178
177
|
[policies.policyNames.fidelityCrime]: {
|
|
@@ -213,24 +212,16 @@ const policiesCoverageConfig = { //rename - coverage policies config
|
|
|
213
212
|
}
|
|
214
213
|
};
|
|
215
214
|
|
|
216
|
-
const getAllAvailablePolicies = () => Object.keys(
|
|
217
|
-
|
|
218
|
-
// const getRequiredPoliciesMinimumForAutocomplete = () => {
|
|
219
|
-
// const policies = getAllAvailablePolicies();
|
|
220
|
-
// policies.length = 2;
|
|
221
|
-
// return policies;
|
|
222
|
-
// };
|
|
215
|
+
const getAllAvailablePolicies = () => Object.keys(policiesConfig);
|
|
223
216
|
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return minimumPoliciesCoverageConfig;
|
|
217
|
+
const getRequiredPoliciesMinimumForAutocomplete = () => {
|
|
218
|
+
const policies = getAllAvailablePolicies();
|
|
219
|
+
policies.length = 2;
|
|
220
|
+
return policies;
|
|
229
221
|
};
|
|
230
222
|
|
|
231
223
|
module.exports = {
|
|
232
224
|
getAllAvailablePolicies,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
policiesCoverageConfig
|
|
225
|
+
getRequiredPoliciesMinimumForAutocomplete,
|
|
226
|
+
policiesConfig
|
|
236
227
|
};
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const { getEnv } = env;
|
|
5
|
-
// const { getEnv } = require('../../env');
|
|
3
|
+
const { getEnv } = require('../../env');
|
|
6
4
|
const { credentials } = getEnv();
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// const compliance = require('../../saas/internal-api/compliance');
|
|
14
|
-
// const contractors = require('../../saas/internal-api/contractors');
|
|
15
|
-
// const requests = require('../../saas/internal-api/requests');
|
|
6
|
+
const auth = require('../../saas/internal-api/auth');
|
|
7
|
+
const coi = require('../../saas/internal-api/coi');
|
|
8
|
+
const compliance = require('../../saas/internal-api/compliance');
|
|
9
|
+
const contractors = require('../../saas/internal-api/contractors');
|
|
10
|
+
const requests = require('../../saas/internal-api/requests');
|
|
16
11
|
|
|
17
12
|
const { complianceStatuses, getAuditConfigByStatus, expiryStatuses } = require('../../common/utils/complianceUtil');
|
|
18
13
|
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
19
14
|
const activationStatuses = require('../../common/consts/activationStatuses');
|
|
20
15
|
const timeUtils = require('../../common/utils/timeUtils');
|
|
21
16
|
const recordFlows = require('../../common/commonFlows/records/records');
|
|
22
|
-
const auditConfigs = require('../../defaults/configs/auditConfigs');
|
|
23
17
|
|
|
24
18
|
const filePath = path.join(__dirname, '../../resources/coi/coi.pdf');
|
|
25
19
|
|
|
26
|
-
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { inviterEmail = credentials.superUser, expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber
|
|
20
|
+
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { inviterEmail = credentials.superUser, expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber } = {}) => {
|
|
27
21
|
validateInsuranceAndExpiryStatus(status, expiryStatus);
|
|
28
22
|
|
|
29
23
|
const requestData = await requests.services.getOrCreateRequest(
|
|
@@ -34,10 +28,6 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
34
28
|
inviterEmail,
|
|
35
29
|
email: recordEmail,
|
|
36
30
|
companyName: recordCompany
|
|
37
|
-
},
|
|
38
|
-
activationStatuses.ACTIVE,
|
|
39
|
-
{
|
|
40
|
-
policyOwnerRecordId
|
|
41
31
|
}
|
|
42
32
|
);
|
|
43
33
|
|
|
@@ -55,17 +45,16 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
55
45
|
return recordId;
|
|
56
46
|
}
|
|
57
47
|
|
|
58
|
-
await
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// );
|
|
48
|
+
const coiUpload = await coi.utils.uploadCoi(
|
|
49
|
+
recordId,
|
|
50
|
+
filePath,
|
|
51
|
+
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
52
|
+
uploaderEmail = credentials.superUser
|
|
53
|
+
);
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
if (!(coiUpload && coiUpload.name)) {
|
|
56
|
+
throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
57
|
+
}
|
|
69
58
|
|
|
70
59
|
if (complianceStatuses.underReview === status) {
|
|
71
60
|
return recordId;
|
|
@@ -142,8 +131,8 @@ const prepareNoCoiRequireRecord = async (recordCompany, recordEmail, tabId, cont
|
|
|
142
131
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.noCoiRequire, tabId, null, context, { inviterEmail, recordConfig });
|
|
143
132
|
};
|
|
144
133
|
|
|
145
|
-
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig
|
|
146
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { inviterEmail, recordConfig
|
|
134
|
+
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig } = {}) => {
|
|
135
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { inviterEmail, recordConfig });
|
|
147
136
|
};
|
|
148
137
|
|
|
149
138
|
const sendGaps = async (recordId, tabId, context) => {
|
|
@@ -211,76 +200,20 @@ const prepareDraftRecord = async (recordCompany, tabId, context, { recordEmail,
|
|
|
211
200
|
|
|
212
201
|
if (uploadCoi) {
|
|
213
202
|
const recordId = requestData.record.contractorId;
|
|
214
|
-
await uploadCoiToRecord(recordId);
|
|
215
|
-
|
|
216
|
-
// const coiUpload = await coi.utils.uploadCoi(
|
|
217
|
-
// recordId,
|
|
218
|
-
// filePath,
|
|
219
|
-
// uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
220
|
-
// uploaderEmail = credentials.superUser
|
|
221
|
-
// );
|
|
222
|
-
|
|
223
|
-
// if (!(coiUpload && coiUpload.name)) {
|
|
224
|
-
// throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
225
|
-
// }
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return requestData;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const prepareRecordThatFitsAutocomplete = async (accountId, projectId, tabId, requirementId, recordCompany, recordEmail, context, { policyOwnerRecordId, inviterEmail, recordConfig, glPolicyNumber } = {}) => {
|
|
232
|
-
//Requirements should include "General Liability"
|
|
233
|
-
const auditorContext = await auth.services.getAuditorCookie();
|
|
234
|
-
|
|
235
|
-
const recordId = await prepareUnderReviewRecord(recordCompany, recordEmail, tabId, requirementId, context, { policyOwnerRecordId, inviterEmail, recordConfig, glPolicyNumber });
|
|
236
|
-
|
|
237
|
-
const recordDetails = await contractors.services.getContractorById(recordId, context);
|
|
238
|
-
|
|
239
|
-
if (recordDetails.status !== httpResponseStatusCodes.OK) {
|
|
240
|
-
throw new Error(`Failed to get record by id: ${recordId}`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const coveragePoliciesConfig = defaults.coverage.getMinimumPoliciesCoverageForAutocomplete();
|
|
244
|
-
const coverageResponse = await compliance.services.coverage.addCoverage(auditorContext, accountId, projectId, requirementId, recordDetails.data, coveragePoliciesConfig);
|
|
245
|
-
|
|
246
|
-
if (coverageResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
247
|
-
throw new Error(`Failed to add coverage to record: ${recordId}`);
|
|
248
|
-
}
|
|
249
203
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
recordId,
|
|
257
|
-
auditConfig
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
if (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
261
|
-
throw Error(`Failed to audit record ${recordCompany}\n${JSON.stringify(auditResponse)}`);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const updatedRequest = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
204
|
+
const coiUpload = await coi.utils.uploadCoi(
|
|
205
|
+
recordId,
|
|
206
|
+
filePath,
|
|
207
|
+
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
208
|
+
uploaderEmail = credentials.superUser
|
|
209
|
+
);
|
|
265
210
|
|
|
266
|
-
|
|
267
|
-
|
|
211
|
+
if (!(coiUpload && coiUpload.name)) {
|
|
212
|
+
throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
213
|
+
}
|
|
268
214
|
}
|
|
269
215
|
|
|
270
|
-
return
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const uploadCoiToRecord = async recordId => {
|
|
274
|
-
const coiUpload = await coi.utils.uploadCoi(
|
|
275
|
-
recordId,
|
|
276
|
-
filePath,
|
|
277
|
-
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
278
|
-
uploaderEmail = credentials.superUser
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
if (!(coiUpload && coiUpload.name)) {
|
|
282
|
-
throw Error(`Failed to upload COI for record ${recordId}\n${coiUpload}`);
|
|
283
|
-
}
|
|
216
|
+
return requestData;
|
|
284
217
|
};
|
|
285
218
|
|
|
286
219
|
module.exports = {
|
|
@@ -292,6 +225,5 @@ module.exports = {
|
|
|
292
225
|
prepareUnderReviewRecord,
|
|
293
226
|
prepareAwaitingCoiRecord,
|
|
294
227
|
prepareNoCoiRequireRecord,
|
|
295
|
-
prepareDraftRecord
|
|
296
|
-
prepareRecordThatFitsAutocomplete
|
|
228
|
+
prepareDraftRecord
|
|
297
229
|
};
|
|
@@ -18,24 +18,22 @@ const deleteCoverageByCoiId = (coiId, icsContext) => {
|
|
|
18
18
|
return coverageApi.deleteCoverageByCoiId(coiId, icsContext);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const addCoverage = async function(
|
|
21
|
+
const addCoverage = async function(
|
|
22
22
|
auditorContext,
|
|
23
23
|
accountId,
|
|
24
24
|
projectId,
|
|
25
25
|
requirementId,
|
|
26
26
|
record,
|
|
27
|
-
|
|
27
|
+
coveragePolicesList
|
|
28
28
|
) {
|
|
29
29
|
const coiId = record.certificatePdf.split('contractor').shift();
|
|
30
30
|
const recordId = record.contractorId;
|
|
31
31
|
|
|
32
32
|
const { auditDates } = await prepareMetadataForAudit(auditorContext, accountId, projectId, requirementId, recordId);
|
|
33
33
|
|
|
34
|
-
const coverageConfig =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// getCoverageConfig(coiId, policiesCoverageConfig) : //gets from automation only policy names, no limits and so on.. no use in integration
|
|
38
|
-
// getCoverageConfig(coiId, getAllAvailablePolicies()); //getAllAvailablePolicies is not located in current file and gets a format that doesn't fit the function getCoverageConfig - in automation this can happen only via persis
|
|
34
|
+
const coverageConfig = Array.isArray(coveragePolicesList) ?
|
|
35
|
+
getCoverageConfig(coiId, coveragePolicesList) :
|
|
36
|
+
getCoverageConfig(coiId, getAllAvailablePolicies());
|
|
39
37
|
|
|
40
38
|
const coverageResponse = await saveCoverageJava(auditorContext, auditDates, coverageConfig);
|
|
41
39
|
return coverageResponse;
|
|
@@ -97,6 +97,7 @@ const parseAuditConfig = function(config) {
|
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
//for "regular" policies (passes as an object)
|
|
100
101
|
if (isObject(config[field])) {
|
|
101
102
|
const attributes = config[field];
|
|
102
103
|
for (const attributeName in attributes) {
|
|
@@ -119,7 +120,22 @@ const parseAuditConfig = function(config) {
|
|
|
119
120
|
|
|
120
121
|
if (isArray(attributes[attributeName])) {
|
|
121
122
|
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
|
|
122
|
-
|
|
123
|
+
|
|
124
|
+
const auditValue = attributes[attributeName][1];
|
|
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
|
+
let i = 0;
|
|
129
|
+
while (i < auditValue.length) {
|
|
130
|
+
const copiedSelection = { ... selection };
|
|
131
|
+
copiedSelection.value = auditValue[i];
|
|
132
|
+
auditDataArr.push(copiedSelection);
|
|
133
|
+
i++;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
} else {
|
|
137
|
+
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
138
|
+
}
|
|
123
139
|
} else {
|
|
124
140
|
// Special statuses switch
|
|
125
141
|
switch (selection.attributeName) {
|
|
@@ -147,6 +163,7 @@ const parseAuditConfig = function(config) {
|
|
|
147
163
|
const selection = { attributeName: getAttributeKey(field) };
|
|
148
164
|
certificateEndorsementsList.includes(field) && (selection.policyName = field);
|
|
149
165
|
|
|
166
|
+
//For endorsements / certificate of insurance fields
|
|
150
167
|
if (isArray(config[field])) {
|
|
151
168
|
selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
|
|
152
169
|
|
|
@@ -217,7 +234,8 @@ const multipleErrorsEndorsementAndAttributesList = [
|
|
|
217
234
|
'Additional Information',
|
|
218
235
|
'Additional Insured',
|
|
219
236
|
'Agreement',
|
|
220
|
-
'Other'
|
|
237
|
+
'Other',
|
|
238
|
+
'Full Policy Copy'
|
|
221
239
|
];
|
|
222
240
|
|
|
223
241
|
const specialAttributes = {
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
const { cloneObject } = require('../../../../common/utils/objectUtils');
|
|
2
|
-
const {
|
|
2
|
+
const { policiesConfig } = require('../../../../defaults/configs/coverage');
|
|
3
3
|
|
|
4
|
-
const getCoverageConfig = function(coiId,
|
|
5
|
-
const
|
|
4
|
+
const getCoverageConfig = function(coiId, policiesArr) {
|
|
5
|
+
const config = cloneObject(configBase);
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
config.coiId = coiId;
|
|
8
|
+
const coveragePolicies = config.documents[0].pages[0].policies;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const
|
|
10
|
+
for (const policyName of policiesArr) {
|
|
11
|
+
const policy = policiesConfig[policyName];
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
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));
|
|
13
|
+
if (! policy) {
|
|
14
|
+
throw Error(`There is no config for ${policyName}. Config available for policies: ${Object.keys(policiesConfig).join(', ')}`);
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
|
|
17
|
+
coveragePolicies.push(cloneObject(policy));
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
return
|
|
20
|
+
return config;
|
|
26
21
|
};
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
// const config = cloneObject(configBase);
|
|
30
|
-
|
|
31
|
-
// config.coiId = coiId;
|
|
32
|
-
// config.documents[0].pages[0].policies = policiesConfig;
|
|
33
|
-
|
|
34
|
-
// return config;
|
|
35
|
-
// };
|
|
36
|
-
|
|
37
|
-
const baseCoverageConfig = {
|
|
23
|
+
const configBase = {
|
|
38
24
|
'coiId': 'REPLACE_WITH_REAL_VALUE',
|
|
39
25
|
'documents': [
|
|
40
26
|
{
|
|
@@ -51,5 +37,4 @@ const baseCoverageConfig = {
|
|
|
51
37
|
|
|
52
38
|
module.exports = {
|
|
53
39
|
getCoverageConfig
|
|
54
|
-
// getCoverageConfigByPolicies
|
|
55
40
|
};
|
|
Binary file
|