@getjones/test-infra 4.5.3 → 4.5.5
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/common/commonFlows/records/records.js +9 -0
- package/src/common/consts/constantsForRecordsSortingAndFilters.js +0 -1
- package/src/defaults/configs/coverage.js +20 -103
- package/src/factory/records/records.js +82 -30
- package/src/index.js +4 -0
- package/src/resources/virusFile.pdf +0 -0
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +3 -5
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +22 -16
- package/src/saas/internal-api/compliance/consts/audit.js +3 -1
- package/src/saas/internal-api/compliance/utils/auditUtil.js +6 -9
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +18 -13
- package/src/saas/internal-api/notificationCenter/api/notification.center.api.js +32 -0
- package/src/saas/internal-api/notificationCenter/api/notification.center.service.js +49 -0
- package/src/saas/internal-api/notificationCenter/index.js +3 -0
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +2 -2
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +14 -5
- package/src/saas/internal-api/tabs/api/tabs.service.js +6 -0
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ const requests = require('../../../saas/internal-api/requests');
|
|
|
10
10
|
const dbEmails = require('../../../saas/internal-api/dbEmails');
|
|
11
11
|
const activationStatuses = require('../../../common/consts/activationStatuses');
|
|
12
12
|
const recordTypes = require('../../../common/consts/recordTypes');
|
|
13
|
+
const { policyNames } = require('../../../defaults/index').polices;
|
|
13
14
|
|
|
14
15
|
const makeRecordNotResponsive = async function(recordId, context) {
|
|
15
16
|
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
@@ -24,6 +25,13 @@ const makeRecordNotResponsive = async function(recordId, context) {
|
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
const makeRecordAboutToExpire = async (recordId, policyExpiryDate, { policyName = policyNames.generalLiability } = {}) => {
|
|
29
|
+
await contractors.services.updateExpiryDate(recordId, policyExpiryDate, policyName);
|
|
30
|
+
|
|
31
|
+
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
32
|
+
expect(threadSchedulerResponse.status, 'Run thread scheduler has failed.').to.equal(httpResponseStatusCodes.OK);
|
|
33
|
+
};
|
|
34
|
+
|
|
27
35
|
const resendInvitationByRecordId = async (recordId, tabId, context) => {
|
|
28
36
|
const { id: requestId } = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
29
37
|
const recordModifyDateVerificationModel = await contractors.services.getRecordVerificationModel(recordId, context);
|
|
@@ -239,6 +247,7 @@ const waiveAllGaps = async (recordId, context) => {
|
|
|
239
247
|
|
|
240
248
|
module.exports = {
|
|
241
249
|
makeRecordNotResponsive,
|
|
250
|
+
makeRecordAboutToExpire,
|
|
242
251
|
resendInvitationByRecordId,
|
|
243
252
|
runOverAllRenewalDatesForRecord,
|
|
244
253
|
editRequestAndRecordDetails,
|
|
@@ -3,7 +3,7 @@ const policies = require('../configs/polices');
|
|
|
3
3
|
const defaultExpiryDate = '2030-10-10T00:00:00.000Z';
|
|
4
4
|
const defaultEffectiveDate = '2020-10-10T00:00:00.000Z';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const policiesCoverageConfig = {
|
|
7
7
|
[policies.policyNames.generalLiability]: {
|
|
8
8
|
key: 'generalLiability',
|
|
9
9
|
policyEntities: [
|
|
@@ -17,58 +17,9 @@ const policiesConfig = {
|
|
|
17
17
|
{
|
|
18
18
|
key: 'eachOccurrence',
|
|
19
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
|
|
40
20
|
}
|
|
41
21
|
],
|
|
42
|
-
provisions: [
|
|
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
|
-
}
|
|
71
|
-
]
|
|
22
|
+
provisions: []
|
|
72
23
|
},
|
|
73
24
|
[policies.policyNames.automobileLiability]: {
|
|
74
25
|
key: 'automobileLiability',
|
|
@@ -81,24 +32,11 @@ const policiesConfig = {
|
|
|
81
32
|
],
|
|
82
33
|
limits: [
|
|
83
34
|
{
|
|
84
|
-
key: '
|
|
35
|
+
key: 'eachOccurrence',
|
|
85
36
|
value: 1000000
|
|
86
37
|
}
|
|
87
38
|
],
|
|
88
|
-
provisions: [
|
|
89
|
-
{
|
|
90
|
-
key: 'anyAuto',
|
|
91
|
-
value: true
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
key: 'waiverOfSubrogation',
|
|
95
|
-
value: true
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
key: 'hired',
|
|
99
|
-
value: true
|
|
100
|
-
}
|
|
101
|
-
]
|
|
39
|
+
provisions: []
|
|
102
40
|
},
|
|
103
41
|
[policies.policyNames.excessLiability]: {
|
|
104
42
|
key: 'excessLiability',
|
|
@@ -109,18 +47,8 @@ const policiesConfig = {
|
|
|
109
47
|
policyNumber: 'EL-12345'
|
|
110
48
|
}
|
|
111
49
|
],
|
|
112
|
-
limits: [
|
|
113
|
-
|
|
114
|
-
key: 'eachOccurrence',
|
|
115
|
-
value: 1000000
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
provisions: [
|
|
119
|
-
{
|
|
120
|
-
key: 'occur',
|
|
121
|
-
value: true
|
|
122
|
-
}
|
|
123
|
-
]
|
|
50
|
+
limits: [],
|
|
51
|
+
provisions: []
|
|
124
52
|
},
|
|
125
53
|
[policies.policyNames.umbrella]: {
|
|
126
54
|
key: 'umbrellaLiability',
|
|
@@ -135,18 +63,9 @@ const policiesConfig = {
|
|
|
135
63
|
{
|
|
136
64
|
key: 'eachOccurrence',
|
|
137
65
|
value: 5000000
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
key: 'aggregate',
|
|
141
|
-
value: 5000000
|
|
142
66
|
}
|
|
143
67
|
],
|
|
144
|
-
provisions: [
|
|
145
|
-
{
|
|
146
|
-
key: 'occur',
|
|
147
|
-
value: true
|
|
148
|
-
}
|
|
149
|
-
]
|
|
68
|
+
provisions: []
|
|
150
69
|
},
|
|
151
70
|
[policies.policyNames.workersCompensation]: {
|
|
152
71
|
key: 'workersCompensation',
|
|
@@ -161,18 +80,9 @@ const policiesConfig = {
|
|
|
161
80
|
{
|
|
162
81
|
key: 'employersLiabilityEachAccident',
|
|
163
82
|
value: 1000000
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
key: 'employersLiabilityDiseaseEachEmployee',
|
|
167
|
-
value: 1000000
|
|
168
83
|
}
|
|
169
84
|
],
|
|
170
|
-
provisions: [
|
|
171
|
-
{
|
|
172
|
-
key: 'statutoryLimitsRequired',
|
|
173
|
-
value: true
|
|
174
|
-
}
|
|
175
|
-
]
|
|
85
|
+
provisions: []
|
|
176
86
|
},
|
|
177
87
|
[policies.policyNames.fidelityCrime]: {
|
|
178
88
|
key: 'fidelityCrime',
|
|
@@ -212,16 +122,23 @@ const policiesConfig = {
|
|
|
212
122
|
}
|
|
213
123
|
};
|
|
214
124
|
|
|
215
|
-
const
|
|
125
|
+
const getAllAvailablePolicyNamesForCoverage = () => Object.keys(policiesCoverageConfig);
|
|
216
126
|
|
|
217
|
-
const getRequiredPoliciesMinimumForAutocomplete = () => {
|
|
218
|
-
const policies =
|
|
127
|
+
const getRequiredPoliciesMinimumForAutocomplete = () => { //is being used in automation
|
|
128
|
+
const policies = getAllAvailablePolicyNamesForCoverage();
|
|
219
129
|
policies.length = 2;
|
|
220
130
|
return policies;
|
|
221
131
|
};
|
|
222
132
|
|
|
133
|
+
const getMinimumPoliciesCoverageConfigForAutocomplete = () => {
|
|
134
|
+
const policiesNames = getAllAvailablePolicyNamesForCoverage();
|
|
135
|
+
policiesNames.length = 2;
|
|
136
|
+
const minimumPoliciesCoverageConfig = policiesNames.map(policyName => policiesCoverageConfig[policyName]);
|
|
137
|
+
return minimumPoliciesCoverageConfig;
|
|
138
|
+
};
|
|
139
|
+
|
|
223
140
|
module.exports = {
|
|
224
|
-
getAllAvailablePolicies,
|
|
225
141
|
getRequiredPoliciesMinimumForAutocomplete,
|
|
226
|
-
|
|
142
|
+
getMinimumPoliciesCoverageConfigForAutocomplete,
|
|
143
|
+
policiesCoverageConfig
|
|
227
144
|
};
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const env = require('../../../src/env');
|
|
4
|
+
const { getEnv } = env;
|
|
4
5
|
const { credentials } = getEnv();
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const 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');
|
|
7
|
+
const { internalAPI } = require('../../../src')(env);
|
|
8
|
+
const { auth, requests, contractors, compliance, coi, defaults } = internalAPI;
|
|
11
9
|
|
|
12
10
|
const { complianceStatuses, getAuditConfigByStatus, expiryStatuses } = require('../../common/utils/complianceUtil');
|
|
13
11
|
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
14
12
|
const activationStatuses = require('../../common/consts/activationStatuses');
|
|
15
13
|
const timeUtils = require('../../common/utils/timeUtils');
|
|
16
14
|
const recordFlows = require('../../common/commonFlows/records/records');
|
|
15
|
+
const auditConfigs = require('../../defaults/configs/auditConfigs');
|
|
17
16
|
|
|
18
17
|
const filePath = path.join(__dirname, '../../resources/coi/coi.pdf');
|
|
19
18
|
|
|
20
|
-
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { inviterEmail = credentials.superUser, expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber } = {}) => {
|
|
19
|
+
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { inviterEmail = credentials.superUser, expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber, policyOwnerRecordId } = {}) => {
|
|
21
20
|
validateInsuranceAndExpiryStatus(status, expiryStatus);
|
|
22
21
|
|
|
23
22
|
const requestData = await requests.services.getOrCreateRequest(
|
|
@@ -28,6 +27,10 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
28
27
|
inviterEmail,
|
|
29
28
|
email: recordEmail,
|
|
30
29
|
companyName: recordCompany
|
|
30
|
+
},
|
|
31
|
+
activationStatuses.ACTIVE,
|
|
32
|
+
{
|
|
33
|
+
policyOwnerRecordId
|
|
31
34
|
}
|
|
32
35
|
);
|
|
33
36
|
|
|
@@ -45,16 +48,7 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
45
48
|
return recordId;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
recordId,
|
|
50
|
-
filePath,
|
|
51
|
-
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
52
|
-
uploaderEmail = credentials.superUser
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
if (!(coiUpload && coiUpload.name)) {
|
|
56
|
-
throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
57
|
-
}
|
|
51
|
+
await uploadCoiByRecordId(recordId);
|
|
58
52
|
|
|
59
53
|
if (complianceStatuses.underReview === status) {
|
|
60
54
|
return recordId;
|
|
@@ -131,8 +125,8 @@ const prepareNoCoiRequireRecord = async (recordCompany, recordEmail, tabId, cont
|
|
|
131
125
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.noCoiRequire, tabId, null, context, { inviterEmail, recordConfig });
|
|
132
126
|
};
|
|
133
127
|
|
|
134
|
-
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig } = {}) => {
|
|
135
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { inviterEmail, recordConfig });
|
|
128
|
+
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig, policyOwnerRecordId } = {}) => {
|
|
129
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { inviterEmail, recordConfig, policyOwnerRecordId });
|
|
136
130
|
};
|
|
137
131
|
|
|
138
132
|
const sendGaps = async (recordId, tabId, context) => {
|
|
@@ -200,20 +194,77 @@ const prepareDraftRecord = async (recordCompany, tabId, context, { recordEmail,
|
|
|
200
194
|
|
|
201
195
|
if (uploadCoi) {
|
|
202
196
|
const recordId = requestData.record.contractorId;
|
|
197
|
+
await uploadCoiByRecordId(recordId);
|
|
198
|
+
}
|
|
203
199
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
filePath,
|
|
207
|
-
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
208
|
-
uploaderEmail = credentials.superUser
|
|
209
|
-
);
|
|
200
|
+
return requestData;
|
|
201
|
+
};
|
|
210
202
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
203
|
+
const prepareRecordForAutocomplete = async (
|
|
204
|
+
accountId,
|
|
205
|
+
projectId,
|
|
206
|
+
tabId,
|
|
207
|
+
requirementId, //Requirements should include "General Liability"
|
|
208
|
+
recordCompany,
|
|
209
|
+
recordEmail,
|
|
210
|
+
context,
|
|
211
|
+
{
|
|
212
|
+
policyOwnerRecordId,
|
|
213
|
+
inviterEmail,
|
|
214
|
+
recordConfig,
|
|
215
|
+
glPolicyNumber
|
|
216
|
+
} = {}) => {
|
|
217
|
+
const auditorContext = await auth.services.getAuditorCookie();
|
|
218
|
+
|
|
219
|
+
const recordId = await prepareUnderReviewRecord(recordCompany, recordEmail, tabId, requirementId, context, { policyOwnerRecordId, inviterEmail, recordConfig, glPolicyNumber });
|
|
220
|
+
|
|
221
|
+
const recordDetails = await contractors.services.getContractorById(recordId, context);
|
|
222
|
+
|
|
223
|
+
if (recordDetails.status !== httpResponseStatusCodes.OK) {
|
|
224
|
+
throw new Error(`Failed to get record by id: ${recordId}`);
|
|
214
225
|
}
|
|
215
226
|
|
|
216
|
-
|
|
227
|
+
const coveragePoliciesConfig = defaults.coverage.getMinimumPoliciesCoverageConfigForAutocomplete();
|
|
228
|
+
const coverageResponse = await compliance.services.coverage.addCoverage(auditorContext, accountId, projectId, requirementId, recordDetails.data, coveragePoliciesConfig);
|
|
229
|
+
|
|
230
|
+
if (coverageResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
231
|
+
throw new Error(`Failed to add coverage to record: ${recordId}`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const auditConfig = auditConfigs.getCompliantAuditConfig({ glPolicyNumber });
|
|
235
|
+
const auditResponse = await compliance.services.audit.auditRecord(
|
|
236
|
+
auditorContext,
|
|
237
|
+
accountId,
|
|
238
|
+
projectId,
|
|
239
|
+
requirementId,
|
|
240
|
+
recordId,
|
|
241
|
+
auditConfig
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
if (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
245
|
+
throw Error(`Failed to audit record ${recordCompany}\n${JSON.stringify(auditResponse)}`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const updatedRequest = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
249
|
+
|
|
250
|
+
if (!(updatedRequest && updatedRequest.id)) {
|
|
251
|
+
throw Error(`Failed to create record ${recordCompany}\n${requestData}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return updatedRequest;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const uploadCoiByRecordId = async recordId => {
|
|
258
|
+
const coiUpload = await coi.utils.uploadCoi(
|
|
259
|
+
recordId,
|
|
260
|
+
filePath,
|
|
261
|
+
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
262
|
+
uploaderEmail = credentials.superUser
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
if (!(coiUpload && coiUpload.name)) {
|
|
266
|
+
throw Error(`Failed to upload COI for record ${recordId}\n${coiUpload}`);
|
|
267
|
+
}
|
|
217
268
|
};
|
|
218
269
|
|
|
219
270
|
module.exports = {
|
|
@@ -225,5 +276,6 @@ module.exports = {
|
|
|
225
276
|
prepareUnderReviewRecord,
|
|
226
277
|
prepareAwaitingCoiRecord,
|
|
227
278
|
prepareNoCoiRequireRecord,
|
|
228
|
-
prepareDraftRecord
|
|
279
|
+
prepareDraftRecord,
|
|
280
|
+
prepareRecordForAutocomplete
|
|
229
281
|
};
|
package/src/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const getInternalAPI = () => {
|
|
|
19
19
|
const requirements = require('./saas/internal-api/requirements');
|
|
20
20
|
const contractors = require('./saas/internal-api/contractors');
|
|
21
21
|
const requests = require('./saas/internal-api/requests');
|
|
22
|
+
const recordTeamNotes = require('./saas/internal-api/recordNotes');
|
|
22
23
|
|
|
23
24
|
const coi = require('./saas/internal-api/coi');
|
|
24
25
|
const compliance = require('./saas/internal-api/compliance');
|
|
@@ -31,6 +32,7 @@ const getInternalAPI = () => {
|
|
|
31
32
|
const charts = require('./saas/internal-api/homepageCharts');
|
|
32
33
|
const dashboard = require('./saas/internal-api/dashboard');
|
|
33
34
|
const accountDirectory = require('./saas/internal-api/accountDirectory');
|
|
35
|
+
const notificationCenter = require('./saas/internal-api/notificationCenter');
|
|
34
36
|
|
|
35
37
|
const globalRecord = require('./saas/internal-api/globalRecord');
|
|
36
38
|
const vendorProfile = require('./saas/internal-api/vendorProfile');
|
|
@@ -56,6 +58,7 @@ const getInternalAPI = () => {
|
|
|
56
58
|
requirements,
|
|
57
59
|
contractors,
|
|
58
60
|
requests,
|
|
61
|
+
recordTeamNotes,
|
|
59
62
|
coi,
|
|
60
63
|
compliance,
|
|
61
64
|
auditNotes,
|
|
@@ -65,6 +68,7 @@ const getInternalAPI = () => {
|
|
|
65
68
|
charts,
|
|
66
69
|
dashboard,
|
|
67
70
|
accountDirectory,
|
|
71
|
+
notificationCenter,
|
|
68
72
|
globalRecord,
|
|
69
73
|
vendorProfile,
|
|
70
74
|
serviceArea,
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const coverageApi = require('./coverage.api');
|
|
2
2
|
const { prepareMetadataForAudit } = require('../../../../../common/utils/complianceUtil');
|
|
3
|
-
const { getCoverageConfig
|
|
3
|
+
const { getCoverageConfig } = require('../../utils/coverageUtil');
|
|
4
4
|
|
|
5
5
|
const saveCoverageNode = coverage => {
|
|
6
6
|
return coverageApi.saveCoverageNode(coverage);
|
|
@@ -24,16 +24,14 @@ const addCoverage = async function(
|
|
|
24
24
|
projectId,
|
|
25
25
|
requirementId,
|
|
26
26
|
record,
|
|
27
|
-
|
|
27
|
+
policiesCoverageConfig //If automation is passing "true" - will no longer work, can pass an array of policy names instead
|
|
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
|
-
getCoverageConfig(coiId, coveragePolicesList) :
|
|
36
|
-
getCoverageConfig(coiId, getAllAvailablePolicies());
|
|
34
|
+
const coverageConfig = getCoverageConfig(coiId, policiesCoverageConfig);
|
|
37
35
|
|
|
38
36
|
const coverageResponse = await saveCoverageJava(auditorContext, auditDates, coverageConfig);
|
|
39
37
|
return coverageResponse;
|
|
@@ -37,9 +37,10 @@ const getAllWaiveModels = (
|
|
|
37
37
|
remarks,
|
|
38
38
|
{
|
|
39
39
|
userId,
|
|
40
|
-
userRole
|
|
40
|
+
userRole,
|
|
41
|
+
auditId
|
|
41
42
|
} = {}) => {
|
|
42
|
-
const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
|
|
43
|
+
const auditIds = auditId ? [auditId] : getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
|
|
43
44
|
userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
|
|
44
45
|
userRole = userRole || userTypes.ICS;
|
|
45
46
|
|
|
@@ -70,11 +71,13 @@ const getWaiveModel = (
|
|
|
70
71
|
remarks,
|
|
71
72
|
{
|
|
72
73
|
userId,
|
|
73
|
-
userRole
|
|
74
|
+
userRole,
|
|
75
|
+
auditId
|
|
74
76
|
} = {}) => {
|
|
75
|
-
return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole })[0];
|
|
77
|
+
return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole, auditId })[0];
|
|
76
78
|
};
|
|
77
79
|
|
|
80
|
+
// used by automation. has to return a single model
|
|
78
81
|
const getWaiveModelByGap = (
|
|
79
82
|
record,
|
|
80
83
|
policyName,
|
|
@@ -85,24 +88,27 @@ const getWaiveModelByGap = (
|
|
|
85
88
|
userId,
|
|
86
89
|
userRole
|
|
87
90
|
} = {}) => {
|
|
88
|
-
const attributeName = auditUtil.
|
|
91
|
+
const { attributeName, auditId } = auditUtil.getAttributeNameAndAuditIdByGap(record, policyName, gap);
|
|
89
92
|
|
|
90
|
-
return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole });
|
|
93
|
+
return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole, auditId });
|
|
91
94
|
};
|
|
92
95
|
|
|
93
|
-
const getRetractModel = (record, policyName, attributeName) => {
|
|
94
|
-
const
|
|
96
|
+
const getRetractModel = (record, policyName, attributeName, { isAttributeMultipleComments } = {}) => {
|
|
97
|
+
const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
|
|
95
98
|
const userId = env.getSystemUserIdentity(credentials.superUser).id;
|
|
96
99
|
const userRole = userTypes.ICS;
|
|
97
100
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
const retractModels = [];
|
|
102
|
+
for (const auditId of auditIds) {
|
|
103
|
+
const model = new RetractRequestModel({
|
|
104
|
+
contractorId: record.id,
|
|
105
|
+
auditId,
|
|
106
|
+
userId,
|
|
107
|
+
userRole
|
|
108
|
+
});
|
|
109
|
+
retractModels.push(model);
|
|
110
|
+
}
|
|
111
|
+
return isAttributeMultipleComments ? retractModels : retractModels[0];
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
const getPolicyAuditIdsFromRecord = (record, policyName, attributeName) => {
|
|
@@ -93,7 +93,9 @@ const auditOnHoldReason = {
|
|
|
93
93
|
ESCALATION_TO_PM: 'Escalation to PM',
|
|
94
94
|
ISSUE_WITH_REQUIREMENTS: 'Issue with Requirements',
|
|
95
95
|
REQUIREMENTS_UPDATE: 'Requirements Update',
|
|
96
|
-
INTERNAL_DISCUSSION: 'Internal Discussion'
|
|
96
|
+
INTERNAL_DISCUSSION: 'Internal Discussion',
|
|
97
|
+
POLICY_VERIFICATION: 'Policy Verification',
|
|
98
|
+
COI_REVIEW: 'COI Review (For Policy Analysts\' Use Only)'
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
module.exports = {
|
|
@@ -26,7 +26,7 @@ const getWaiveReason = reason => {
|
|
|
26
26
|
return waiveReasons[reason] || reason;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const getAttributeNameAndAuditIdByGap = function(record, policyName, gap) {
|
|
30
30
|
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
31
31
|
contractorCoverage.insuranceName === policyName);
|
|
32
32
|
|
|
@@ -40,7 +40,7 @@ const getAttributeNameByGap = function(record, policyName, gap) {
|
|
|
40
40
|
throw new Error(`Gap ${gap} don't exist in record`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
return attribute.
|
|
43
|
+
return { attributeName: attribute.limitName, auditId: attribute.auditId };
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const getAllWaivablePolicies = function(record) {
|
|
@@ -121,16 +121,13 @@ const parseAuditConfig = function(config) {
|
|
|
121
121
|
if (isArray(attributes[attributeName])) {
|
|
122
122
|
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
|
|
123
123
|
|
|
124
|
-
const auditValue = attributes[attributeName][1];
|
|
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
125
|
|
|
126
126
|
if (multipleErrorsEndorsementAndAttributesList.includes(attributeName) && isArray(auditValue)) {
|
|
127
127
|
// in case of multiple comments when selecting "Other" in "regular" policies attributes like 'Full Policy copy'
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const copiedSelection = { ... selection };
|
|
131
|
-
copiedSelection.value = auditValue[i];
|
|
128
|
+
for (const value of auditValue) {
|
|
129
|
+
const copiedSelection = { ... selection, value };
|
|
132
130
|
auditDataArr.push(copiedSelection);
|
|
133
|
-
i++;
|
|
134
131
|
}
|
|
135
132
|
continue;
|
|
136
133
|
} else {
|
|
@@ -216,7 +213,7 @@ module.exports = {
|
|
|
216
213
|
getPolicyId,
|
|
217
214
|
createAuditEntity,
|
|
218
215
|
getAttributeKey,
|
|
219
|
-
|
|
216
|
+
getAttributeNameAndAuditIdByGap,
|
|
220
217
|
getWaiveReason,
|
|
221
218
|
getAllWaivablePolicies
|
|
222
219
|
};
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
const { cloneObject } = require('../../../../common/utils/objectUtils');
|
|
2
|
-
const {
|
|
2
|
+
const { policiesCoverageConfig } = require('../../../../defaults/configs/coverage');
|
|
3
3
|
|
|
4
|
-
const getCoverageConfig = function(coiId,
|
|
5
|
-
const
|
|
4
|
+
const getCoverageConfig = function(coiId, policiesForCoverage) {
|
|
5
|
+
const coverageConfig = cloneObject(baseCoverageConfig);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const coveragePolicies = config.documents[0].pages[0].policies;
|
|
7
|
+
coverageConfig.coiId = coiId;
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
const
|
|
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;
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
}
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
coveragePolicies.push(cloneObject(policy));
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
coverageConfig.documents[0].pages[0].policies = policiesForCoverage; //when getting the policies coverage config prepared
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
return
|
|
25
|
+
return coverageConfig;
|
|
21
26
|
};
|
|
22
27
|
|
|
23
|
-
const
|
|
28
|
+
const baseCoverageConfig = {
|
|
24
29
|
'coiId': 'REPLACE_WITH_REAL_VALUE',
|
|
25
30
|
'documents': [
|
|
26
31
|
{
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getNotificationsPage: `${backendUrl}/saas/notifications`,
|
|
6
|
+
getLatestNotifications: `${backendUrl}/saas/notifications/newest`,
|
|
7
|
+
markNotificationAsRead: notificationId => `${backendUrl}/saas/notifications/${notificationId}/read`,
|
|
8
|
+
markNotificationsAsSeen: latestSeenNotificationId => `${backendUrl}/saas/notifications/${latestSeenNotificationId}/seen`
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getNotificationsPage = async (lastNotificationId, context) => {
|
|
12
|
+
return requests.getRequestHandler(Endpoints.getNotificationsPage, { lastNotificationId }, context);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getLatestNotifications = async context => {
|
|
16
|
+
return requests.getRequestHandler(Endpoints.getLatestNotifications, {}, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const markNotificationAsRead = async (notificationId, context) => {
|
|
20
|
+
return requests.postRequestHandler(Endpoints.markNotificationAsRead(notificationId), {}, context);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const markNotificationsAsSeen = async (latestSeenNotificationId, context) => {
|
|
24
|
+
return requests.postRequestHandler(Endpoints.markNotificationsAsSeen(latestSeenNotificationId), {}, context);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
getNotificationsPage,
|
|
29
|
+
getLatestNotifications,
|
|
30
|
+
markNotificationAsRead,
|
|
31
|
+
markNotificationsAsSeen
|
|
32
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const notificationCenterApi = require('./notification.center.api');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
+
|
|
4
|
+
const getNotificationsPage = async (lastNotificationId, context, { shouldExpectError } = {}) => {
|
|
5
|
+
const notificationPageResponse = await notificationCenterApi.getNotificationsPage(lastNotificationId, context);
|
|
6
|
+
|
|
7
|
+
if (notificationPageResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
8
|
+
throw new Error(`Failed to get notifications page, cause by : ${notificationPageResponse.message}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return shouldExpectError ? notificationPageResponse : notificationPageResponse.data;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getLatestNotifications = async (context, { shouldExpectError } = {}) => {
|
|
15
|
+
const latestNotificationResponse = await notificationCenterApi.getLatestNotifications(context);
|
|
16
|
+
|
|
17
|
+
if (latestNotificationResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
18
|
+
throw new Error(`Failed to get latest notifications, cause by : ${latestNotificationResponse.message}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return shouldExpectError ? latestNotificationResponse : latestNotificationResponse.data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const markNotificationAsRead = async (notificationId, context, { shouldExpectError } = {}) => {
|
|
25
|
+
const response = await notificationCenterApi.markNotificationAsRead(notificationId, context);
|
|
26
|
+
|
|
27
|
+
if (response.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
28
|
+
throw new Error(`Failed to mark notifications as read, cause by : ${response.message}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return response;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const markNotificationsAsSeen = async (latestSeenNotificationId, context, { shouldExpectError } = {}) => {
|
|
35
|
+
const response = await notificationCenterApi.markNotificationsAsSeen(latestSeenNotificationId, context);
|
|
36
|
+
|
|
37
|
+
if (response.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
38
|
+
throw new Error(`Failed to mark notifications as seen, cause by : ${response.message}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
getNotificationsPage,
|
|
46
|
+
getLatestNotifications,
|
|
47
|
+
markNotificationAsRead,
|
|
48
|
+
markNotificationsAsSeen
|
|
49
|
+
};
|
|
@@ -75,13 +75,13 @@ const getPolicyDetailsForPublishModel = async (requestId, policyFileId, context)
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
const getPolicyFilesIfExist = async (recordId, context) => {
|
|
78
|
-
let retries =
|
|
78
|
+
let retries = 15;
|
|
79
79
|
let policiesToReviewResponse;
|
|
80
80
|
let policyFiles = [];
|
|
81
81
|
|
|
82
82
|
while (policyFiles.length === 0 && retries > 0) {
|
|
83
83
|
//Busy wait for it takes time to get policy file to review
|
|
84
|
-
await timeUtils.waitFor(1).seconds;
|
|
84
|
+
await timeUtils.waitFor(1.5).seconds;
|
|
85
85
|
|
|
86
86
|
policiesToReviewResponse = await policyFileApi.getPolicyFilesRequireAudit(recordId, context);
|
|
87
87
|
policyFiles = policiesToReviewResponse.data;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const recordNotesAPI = require('./record.notes.api');
|
|
2
2
|
const utils = require('./record.notes.utils');
|
|
3
|
+
const httpStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
4
|
|
|
4
|
-
const createRecordNote = (
|
|
5
|
-
|
|
5
|
+
const createRecordNote = ({ requestId, content, notificationCenterContent, dateModified }, context, { tagUsers, multipleParagraphs } = {}) => {
|
|
6
|
+
const contentToSend = tagUsers ? utils.getMentionedNoteContent(tagUsers, content, { multipleParagraphs }) : content;
|
|
7
|
+
const data = { requestId, content: contentToSend, notificationCenterContent: notificationCenterContent || contentToSend, dateModified };
|
|
6
8
|
|
|
7
9
|
return recordNotesAPI.createRecordNote(data, context);
|
|
8
10
|
};
|
|
@@ -31,10 +33,17 @@ const deleteByNoteId = (noteId, data, context) => {
|
|
|
31
33
|
return recordNotesAPI.deleteByNoteId(noteId, data, context);
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
const updateByNoteId = (noteId,
|
|
35
|
-
|
|
36
|
+
const updateByNoteId = async (noteId, { requestId, content, notificationCenterContent, dateModified }, context, { tagUsers, multipleParagraphs, expectError } = {}) => {
|
|
37
|
+
const contentToSend = tagUsers ? utils.getMentionedNoteContent(tagUsers, content, { multipleParagraphs }) : content;
|
|
38
|
+
const data = { requestId, content: contentToSend, notificationCenterContent: notificationCenterContent || contentToSend, dateModified };
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
const updateResponse = await recordNotesAPI.updateByNoteId(noteId, data, context);
|
|
41
|
+
|
|
42
|
+
if (updateResponse.status != httpStatusCodes.OK && !expectError) {
|
|
43
|
+
throw new Error(`Failed to update note with id: ${noteId}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return updateResponse;
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
module.exports = {
|
|
@@ -14,6 +14,11 @@ const getTabsByProjectId = async (projectId, context) => {
|
|
|
14
14
|
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const getFirstTabIdByProjectId = async (projectId, context) => {
|
|
18
|
+
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
19
|
+
return tabs[0].tabId;
|
|
20
|
+
};
|
|
21
|
+
|
|
17
22
|
const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
|
|
18
23
|
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
19
24
|
const requestedTab = tabType ?
|
|
@@ -47,6 +52,7 @@ module.exports = {
|
|
|
47
52
|
createTab,
|
|
48
53
|
getTabById,
|
|
49
54
|
getTabsByProjectId,
|
|
55
|
+
getFirstTabIdByProjectId,
|
|
50
56
|
getTabsByName,
|
|
51
57
|
getOrCreateTab,
|
|
52
58
|
updateTab,
|