@getjones/test-infra 4.4.0 → 4.4.1
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 +5 -1
- package/src/common/consts/s3FileTypes.js +2 -1
- package/src/defaults/configs/auditConfigs.js +25 -0
- package/src/defaults/configs/polices.js +6 -1
- package/src/factory/records/records.js +14 -9
- package/src/resources/coi/coi2.pdf +0 -0
- package/src/resources/policy/policy.pdf +0 -0
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +32 -2
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +131 -5
- package/src/saas/internal-api/accountDirectory/models/accountDirectory.model.js +18 -3
- package/src/saas/internal-api/coi/api/coi.api.js +7 -2
- package/src/saas/internal-api/coi/api/coi.service.js +14 -1
- package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -0
- package/src/saas/internal-api/coi/utils/utils.js +26 -1
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +14 -2
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +35 -3
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +7 -2
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +62 -21
- package/src/saas/internal-api/compliance/consts/audit.js +8 -2
- package/src/saas/internal-api/compliance/utils/auditUtil.js +24 -1
- package/src/saas/internal-api/contractors/api/contractors.service.js +12 -1
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +6 -0
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +13 -0
- package/src/saas/openapi/coi/coi.service.js +0 -1
- package/src/saas/openapi/requirements/requirements.api.js +11 -2
- package/src/saas/openapi/requirements/requirements.service.js +13 -1
package/package.json
CHANGED
|
@@ -9,8 +9,12 @@ const compliance = require('../../../saas/internal-api/compliance');
|
|
|
9
9
|
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
|
+
const recordTypes = require('../../../common/consts/recordTypes');
|
|
13
|
+
|
|
14
|
+
const makeRecordNotResponsive = async function(recordId, context) {
|
|
15
|
+
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
16
|
+
const isTenant = record.recordType === recordTypes.TENANTS;
|
|
12
17
|
|
|
13
|
-
const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
|
|
14
18
|
const offsetInDaysList = isTenant ?
|
|
15
19
|
timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
|
|
16
20
|
timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
|
|
@@ -3,6 +3,8 @@ const { cloneObject } = require('../../common/utils/objectUtils');
|
|
|
3
3
|
const { getOneWeekAgoDate, getOneWeekAheadDate } = require('../../common/utils/timeUtils');
|
|
4
4
|
|
|
5
5
|
const DEFAULT_POLICY_DATE = '24/05/2030';
|
|
6
|
+
const DEFAULT_EXPIRED_POLICY_DATE = '17/08/2022';
|
|
7
|
+
|
|
6
8
|
const DEFAULT_AM_SCORE = 'A';
|
|
7
9
|
|
|
8
10
|
//Excluded from creating global record: 'ABC-12345-XYZ', 'ABC-123-XYZ', 'ABC-123'. When GR is needed - use different GL number.
|
|
@@ -59,6 +61,26 @@ const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}
|
|
|
59
61
|
return config;
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
const getCompliantAuditConfigWithoutPolicies = () => {
|
|
65
|
+
const config = cloneObject({
|
|
66
|
+
[certificateIssueDate]: `${DEFAULT_POLICY_DATE}`,
|
|
67
|
+
[insuredAddress]: policySelections.YES,
|
|
68
|
+
[insuredName]: policySelections.YES,
|
|
69
|
+
[amScore]: DEFAULT_AM_SCORE,
|
|
70
|
+
[cancellationTerms]: policySelections.YES,
|
|
71
|
+
[coiAuthentication]: policySelections.YES,
|
|
72
|
+
[signature]: policySelections.YES
|
|
73
|
+
});
|
|
74
|
+
return config;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const getNotCompliantAuditConfigWithoutPolicies = () => {
|
|
78
|
+
const compliantConfig = getCompliantAuditConfigWithoutPolicies();
|
|
79
|
+
compliantConfig[signature] = policySelections.NO;
|
|
80
|
+
|
|
81
|
+
return compliantConfig;
|
|
82
|
+
};
|
|
83
|
+
|
|
62
84
|
const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
|
|
63
85
|
const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
|
|
64
86
|
compliantConfig[signature] = policySelections.NO;
|
|
@@ -87,13 +109,16 @@ const setExpiredConfig = config =>
|
|
|
87
109
|
|
|
88
110
|
module.exports = {
|
|
89
111
|
getCompliantAuditConfig,
|
|
112
|
+
getCompliantAuditConfigWithoutPolicies,
|
|
90
113
|
getNotCompliantConfig,
|
|
114
|
+
getNotCompliantAuditConfigWithoutPolicies,
|
|
91
115
|
getAboutExpiredConfig,
|
|
92
116
|
getExpiredConfig,
|
|
93
117
|
setExpiredConfig,
|
|
94
118
|
setAboutExpiredConfig,
|
|
95
119
|
policySelections,
|
|
96
120
|
defaultPolicyDate: DEFAULT_POLICY_DATE,
|
|
121
|
+
defaultExpiredPolicyDate: DEFAULT_EXPIRED_POLICY_DATE,
|
|
97
122
|
defaultAMScore: DEFAULT_AM_SCORE,
|
|
98
123
|
defaultPolicyNumber: DEFAULT_POLICY_NUMBER
|
|
99
124
|
};
|
|
@@ -61,7 +61,12 @@ const attributeNames = {
|
|
|
61
61
|
waiverOfSubrogation: 'Waiver of Subrogation',
|
|
62
62
|
waiverOfSubrogationEndorsement: 'Waiver of Subrogation Endorsement',
|
|
63
63
|
amBestRating: 'AM Best Rating',
|
|
64
|
-
amBestFinancialSizeCategory: 'AM Best Financial Size Category'
|
|
64
|
+
amBestFinancialSizeCategory: 'AM Best Financial Size Category',
|
|
65
|
+
additionalInsuredEndorsementCoveringOngoingOperations: 'Additional Insured Endorsement Covering Ongoing Operations',
|
|
66
|
+
anyAuto: 'Any Auto',
|
|
67
|
+
scheduled: 'Scheduled',
|
|
68
|
+
multiple: 'multiple',
|
|
69
|
+
other: 'Other'
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
module.exports = {
|
|
@@ -14,7 +14,6 @@ const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.js
|
|
|
14
14
|
const activationStatuses = require('../../common/consts/activationStatuses');
|
|
15
15
|
const timeUtils = require('../../common/utils/timeUtils');
|
|
16
16
|
const recordFlows = require('../../common/commonFlows/records/records');
|
|
17
|
-
const recordTypes = require('../../common/consts/recordTypes');
|
|
18
17
|
|
|
19
18
|
const filePath = path.join(__dirname, '../../resources/coi/coi.pdf');
|
|
20
19
|
|
|
@@ -100,13 +99,19 @@ const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requiremen
|
|
|
100
99
|
return recordId;
|
|
101
100
|
};
|
|
102
101
|
|
|
102
|
+
const prepareAcceptedRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
103
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
104
|
+
await acceptAllGaps(recordId, context);
|
|
105
|
+
return recordId;
|
|
106
|
+
};
|
|
107
|
+
|
|
103
108
|
const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, isNotResponsive = false, glPolicyNumber } = {}) => {
|
|
104
109
|
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingNewCoi, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
105
110
|
|
|
106
111
|
await sendGaps(recordId, tabId, context);
|
|
107
112
|
|
|
108
113
|
if (isNotResponsive) {
|
|
109
|
-
await makeRecordNotResponsive(recordId, context);
|
|
114
|
+
await recordFlows.makeRecordNotResponsive(recordId, context);
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
return recordId;
|
|
@@ -116,7 +121,7 @@ const prepareAwaitingCoiRecord = async (recordCompany, recordEmail, tabId, requi
|
|
|
116
121
|
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingCoi, tabId, requirementId, context, { recordConfig });
|
|
117
122
|
|
|
118
123
|
if (isNotResponsive) {
|
|
119
|
-
await makeRecordNotResponsive(recordId, context);
|
|
124
|
+
await recordFlows.makeRecordNotResponsive(recordId, context);
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
return recordId;
|
|
@@ -130,12 +135,6 @@ const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirement
|
|
|
130
135
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { recordConfig });
|
|
131
136
|
};
|
|
132
137
|
|
|
133
|
-
const makeRecordNotResponsive = async (recordId, context) => {
|
|
134
|
-
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
135
|
-
const isTenant = record.recordType === recordTypes.TENANTS;
|
|
136
|
-
await recordFlows.makeRecordNotResponsive(recordId, context, { isTenant });
|
|
137
|
-
};
|
|
138
|
-
|
|
139
138
|
const sendGaps = async (recordId, tabId, context) => {
|
|
140
139
|
const { id: requestId } = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
141
140
|
const recordVerificationModel = await contractors.services.getRecordVerificationModel(recordId, context);
|
|
@@ -151,6 +150,11 @@ const waiveAllGaps = async (recordId, context) => {
|
|
|
151
150
|
await compliance.services.overrideGap.waiveAll(record, context);
|
|
152
151
|
};
|
|
153
152
|
|
|
153
|
+
const acceptAllGaps = async (recordId, context) => {
|
|
154
|
+
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
155
|
+
await compliance.services.overrideGap.acceptAll(record, context);
|
|
156
|
+
};
|
|
157
|
+
|
|
154
158
|
const validateInsuranceAndExpiryStatus = async (insuranceStatus, expiryStatus) => {
|
|
155
159
|
let isValid = false;
|
|
156
160
|
const isWithoutExpiryStatus = !Boolean(expiryStatus);
|
|
@@ -218,6 +222,7 @@ module.exports = {
|
|
|
218
222
|
prepareCompliantRecord,
|
|
219
223
|
prepareNotCompliantRecord,
|
|
220
224
|
prepareWaivedRecord,
|
|
225
|
+
prepareAcceptedRecord,
|
|
221
226
|
prepareAwaitingNewCoiRecord,
|
|
222
227
|
prepareUnderReviewRecord,
|
|
223
228
|
prepareAwaitingCoiRecord,
|
|
Binary file
|
|
Binary file
|
|
@@ -2,13 +2,43 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
recordTable: `${backendUrl}/saas/account-directory/record-table
|
|
5
|
+
recordTable: `${backendUrl}/saas/account-directory/record-table`,
|
|
6
|
+
recordsCount: `${backendUrl}/saas/account-directory/records-count`,
|
|
7
|
+
projectLocations: `${backendUrl}/saas/account-directory/filter/location`,
|
|
8
|
+
requestTable: `${backendUrl}/saas/account-directory/request-table`,
|
|
9
|
+
requestTableFilters: `${backendUrl}/saas/account-directory/request-table/filters`,
|
|
10
|
+
requestActivityCount: `${backendUrl}/saas/account-directory/request-activity-count`
|
|
6
11
|
};
|
|
7
12
|
|
|
8
13
|
const getRecordTable = (accountDirectoryRecordTableFilterModel, context) => {
|
|
9
14
|
return requests.postRequestHandler(Endpoints.recordTable, accountDirectoryRecordTableFilterModel, context);
|
|
10
15
|
};
|
|
11
16
|
|
|
17
|
+
const getRecordsCount = (accountId, context) => {
|
|
18
|
+
return requests.getRequestHandler(Endpoints.recordsCount, { accountId }, context);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getProjectLocations = (accountId, context) => {
|
|
22
|
+
return requests.getRequestHandler(Endpoints.projectLocations, { accountId }, context);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getRequestTable = (accountDirectoryRequestTableFilterModel, context) => {
|
|
26
|
+
return requests.postRequestHandler(Endpoints.requestTable, accountDirectoryRequestTableFilterModel, context);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getRequestTableFilters = (accountDirectoryRequestTableFilterModel, context) => {
|
|
30
|
+
return requests.postRequestHandler(Endpoints.requestTableFilters, accountDirectoryRequestTableFilterModel, context);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getRequestActivityCount = (accountDirectoryRequestTableFilterModel, context) => {
|
|
34
|
+
return requests.postRequestHandler(Endpoints.requestActivityCount, accountDirectoryRequestTableFilterModel, context);
|
|
35
|
+
};
|
|
36
|
+
|
|
12
37
|
module.exports = {
|
|
13
|
-
getRecordTable
|
|
38
|
+
getRecordTable,
|
|
39
|
+
getRecordsCount,
|
|
40
|
+
getProjectLocations,
|
|
41
|
+
getRequestTable,
|
|
42
|
+
getRequestTableFilters,
|
|
43
|
+
getRequestActivityCount
|
|
14
44
|
};
|
|
@@ -8,11 +8,20 @@ const RECORD_TABLE_SORT_BY = {
|
|
|
8
8
|
PROJECTS_COUNT: 'PROJECTS_COUNT'
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const activationStatuses = {
|
|
12
|
+
ACTIVE: 'ACTIVE',
|
|
13
|
+
IN_ACTIVE: 'IN_ACTIVE'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getRecordTableData = async (accountDirectoryRecordTableFilterModel, context, { expectError } = {}) => {
|
|
12
17
|
validateType(accountDirectoryRecordTableFilterModel, accountDirectoryModels.AccountDirectoryRecordTableFilterModel);
|
|
13
18
|
|
|
14
19
|
const recordTableResponse = await accountDirectoryAPI.getRecordTable(accountDirectoryRecordTableFilterModel, context);
|
|
15
20
|
|
|
21
|
+
if (expectError) {
|
|
22
|
+
return recordTableResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
if (recordTableResponse.status !== httpResponseStatusCodes.OK) {
|
|
17
26
|
throw Error(`Failed to get main page record table. Status code: ${recordTableResponse.status}`);
|
|
18
27
|
}
|
|
@@ -20,13 +29,130 @@ const getRecordTableData = async (accountDirectoryRecordTableFilterModel, contex
|
|
|
20
29
|
return recordTableResponse.data.tableRowsData;
|
|
21
30
|
};
|
|
22
31
|
|
|
23
|
-
const getRecordTableByAccountId = (accountId, context, { sortBy } = {}) => {
|
|
24
|
-
const accountDirectoryRecordTableFilterModel = new accountDirectoryModels.AccountDirectoryRecordTableFilterModel(
|
|
32
|
+
const getRecordTableByAccountId = (accountId, context, { sortBy, selectedRecordTypes, selectedStates, searchTerm, pageNum, rowsPerPage, sortOrder, expectError } = {}) => {
|
|
33
|
+
const accountDirectoryRecordTableFilterModel = new accountDirectoryModels.AccountDirectoryRecordTableFilterModel(
|
|
34
|
+
{
|
|
35
|
+
accountId,
|
|
36
|
+
sortBy,
|
|
37
|
+
selectedRecordTypes,
|
|
38
|
+
selectedStates,
|
|
39
|
+
searchTerm,
|
|
40
|
+
pageNum,
|
|
41
|
+
rowsPerPage,
|
|
42
|
+
sortOrder
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return getRecordTableData(accountDirectoryRecordTableFilterModel, context, { expectError });
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getProjectLocations = async (accountId, context) => {
|
|
49
|
+
const locationFilterResponse = await accountDirectoryAPI.getProjectLocations(accountId, context);
|
|
50
|
+
|
|
51
|
+
if (locationFilterResponse.status !== httpResponseStatusCodes.OK) {
|
|
52
|
+
throw Error(`Failed to get projects locations. Status code: ${locationFilterResponse.status}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return locationFilterResponse.data;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getRecordsCount = async (accountId, context) => {
|
|
59
|
+
const recordsCountResponse = await accountDirectoryAPI.getRecordsCount(accountId, context);
|
|
60
|
+
|
|
61
|
+
if (recordsCountResponse.status !== httpResponseStatusCodes.OK) {
|
|
62
|
+
throw Error(`Failed to get records count. Status code: ${recordsCountResponse.status}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return recordsCountResponse.data;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const getRequestTableData = async (accountDirectoryRequestTableFilterModel, context, { expectError } = {}) => {
|
|
69
|
+
validateType(accountDirectoryRequestTableFilterModel, accountDirectoryModels.AccountDirectoryRequestTableFilterModel);
|
|
70
|
+
|
|
71
|
+
const requestTableResponse = await accountDirectoryAPI.getRequestTable(accountDirectoryRequestTableFilterModel, context);
|
|
72
|
+
|
|
73
|
+
if (expectError) {
|
|
74
|
+
return requestTableResponse;
|
|
75
|
+
} else if (requestTableResponse.status !== httpResponseStatusCodes.OK) {
|
|
76
|
+
throw Error(`Failed to get inner page request table. Status code: ${requestTableResponse.status}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return requestTableResponse.data;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getRequestTableByRecordId = (accountId, context, { globalRecordId, recordId, activityStatus, expectError } = {}) => {
|
|
83
|
+
const accountDirectoryRequestTableFilterModel = new accountDirectoryModels.AccountDirectoryRequestTableFilterModel(
|
|
84
|
+
{
|
|
85
|
+
accountId,
|
|
86
|
+
globalRecordId,
|
|
87
|
+
recordId,
|
|
88
|
+
activityStatus
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return getRequestTableData(accountDirectoryRequestTableFilterModel, context, { expectError });
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const getRequestTableFilters = async (accountDirectoryRequestTableFilterModel, context, { expectError } = {}) => {
|
|
95
|
+
validateType(accountDirectoryRequestTableFilterModel, accountDirectoryModels.AccountDirectoryRequestTableFilterModel);
|
|
96
|
+
|
|
97
|
+
const requestTableFiltersResponse = await accountDirectoryAPI.getRequestTableFilters(accountDirectoryRequestTableFilterModel, context);
|
|
98
|
+
|
|
99
|
+
if (expectError) {
|
|
100
|
+
return requestTableFiltersResponse;
|
|
101
|
+
} else if (requestTableFiltersResponse.status !== httpResponseStatusCodes.OK) {
|
|
102
|
+
throw Error(`Failed to get request table filters. Status code: ${requestTableFiltersResponse.status}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return requestTableFiltersResponse.data;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const getRequestTableFiltersByRecordId = (accountId, context, { globalRecordId, recordId, activityStatus, expectError } = {}) => {
|
|
109
|
+
const accountDirectoryRequestTableFilterModel = new accountDirectoryModels.AccountDirectoryRequestTableFilterModel(
|
|
110
|
+
{
|
|
111
|
+
accountId,
|
|
112
|
+
globalRecordId,
|
|
113
|
+
recordId,
|
|
114
|
+
activityStatus
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return getRequestTableFilters(accountDirectoryRequestTableFilterModel, context, { expectError });
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const getRequestActivityCount = async (accountDirectoryRequestTableFilterModel, context, { expectError } = {}) => {
|
|
121
|
+
validateType(accountDirectoryRequestTableFilterModel, accountDirectoryModels.AccountDirectoryRequestTableFilterModel);
|
|
122
|
+
|
|
123
|
+
const activityCountResponse = await accountDirectoryAPI.getRequestActivityCount(accountDirectoryRequestTableFilterModel, context);
|
|
124
|
+
|
|
125
|
+
if (expectError) {
|
|
126
|
+
return activityCountResponse;
|
|
127
|
+
} else if (activityCountResponse.status !== httpResponseStatusCodes.OK) {
|
|
128
|
+
throw Error(`Failed to get request activity count. Status code: ${activityCountResponse.status}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return activityCountResponse.data;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const getRequestActivityCountByRecordId = (accountId, context, { globalRecordId, recordId, activityStatus, expectError } = {}) => {
|
|
135
|
+
const accountDirectoryRequestTableFilterModel = new accountDirectoryModels.AccountDirectoryRequestTableFilterModel(
|
|
136
|
+
{
|
|
137
|
+
accountId,
|
|
138
|
+
globalRecordId,
|
|
139
|
+
recordId,
|
|
140
|
+
activityStatus
|
|
141
|
+
});
|
|
25
142
|
|
|
26
|
-
return
|
|
143
|
+
return getRequestActivityCount(accountDirectoryRequestTableFilterModel, context, { expectError });
|
|
27
144
|
};
|
|
28
145
|
|
|
29
146
|
module.exports = {
|
|
30
147
|
RECORD_TABLE_SORT_BY,
|
|
31
|
-
|
|
148
|
+
activationStatuses,
|
|
149
|
+
getRecordTableByAccountId,
|
|
150
|
+
getRecordsCount,
|
|
151
|
+
getProjectLocations,
|
|
152
|
+
getRequestTableData,
|
|
153
|
+
getRequestTableByRecordId,
|
|
154
|
+
getRequestTableFilters,
|
|
155
|
+
getRequestTableFiltersByRecordId,
|
|
156
|
+
getRequestActivityCount,
|
|
157
|
+
getRequestActivityCountByRecordId
|
|
32
158
|
};
|
|
@@ -7,7 +7,7 @@ class AccountDirectoryRecordTableFilterModel {
|
|
|
7
7
|
sortBy = null,
|
|
8
8
|
sortOrder = null,
|
|
9
9
|
rowsPerPage = null,
|
|
10
|
-
|
|
10
|
+
pageNum = null
|
|
11
11
|
} = {}) {
|
|
12
12
|
this.accountId = accountId;
|
|
13
13
|
this.searchTerm = searchTerm;
|
|
@@ -16,10 +16,25 @@ class AccountDirectoryRecordTableFilterModel {
|
|
|
16
16
|
this.sortBy = sortBy;
|
|
17
17
|
this.sortOrder = sortOrder;
|
|
18
18
|
this.rowsPerPage = rowsPerPage;
|
|
19
|
-
this.
|
|
19
|
+
this.pageNum = pageNum;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class AccountDirectoryRequestTableFilterModel {
|
|
24
|
+
constructor({
|
|
25
|
+
accountId,
|
|
26
|
+
globalRecordId,
|
|
27
|
+
recordId,
|
|
28
|
+
activityStatus
|
|
29
|
+
} = {}) {
|
|
30
|
+
this.accountId = accountId;
|
|
31
|
+
this.globalRecordId = globalRecordId;
|
|
32
|
+
this.recordId = recordId;
|
|
33
|
+
this.activityStatus = activityStatus;
|
|
20
34
|
}
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
module.exports = {
|
|
24
|
-
AccountDirectoryRecordTableFilterModel
|
|
38
|
+
AccountDirectoryRecordTableFilterModel,
|
|
39
|
+
AccountDirectoryRequestTableFilterModel
|
|
25
40
|
};
|
|
@@ -9,7 +9,8 @@ const Endpoints = {
|
|
|
9
9
|
submitCoi: `${backendUrl}/coi/merge`,
|
|
10
10
|
completeScan: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/complete-scan`,
|
|
11
11
|
getCoiPresignedUrl: fileName => `${backendUrl}/saas/coi/${fileName}`,
|
|
12
|
-
getCoiHashes: recordId => `${backendUrl}/jcsc/record/${recordId}/coi/hashes
|
|
12
|
+
getCoiHashes: recordId => `${backendUrl}/jcsc/record/${recordId}/coi/hashes`,
|
|
13
|
+
combineLastTwoCOIs: `${backendUrl}/saas/auditor/record/coi/merge-last-two`
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const uploadToS3 = (contractorId, fileData) => {
|
|
@@ -37,4 +38,8 @@ const getCoiHashes = recordId => {
|
|
|
37
38
|
return internalRequests.getRequestHandler(Endpoints.getCoiHashes(recordId));
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
const combineLastTwoCOIs = (combineLastTwoCOIsModel, context) => {
|
|
42
|
+
return requests.postRequestHandler(Endpoints.combineLastTwoCOIs, combineLastTwoCOIsModel, context);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = { uploadToS3, submitCoi, completeScan, getCoiPreSignedUrl, getCoiHashes, combineLastTwoCOIs };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const coiApi = require('./coi.api');
|
|
2
2
|
const { SubmitCoiModel } = require('../models/submit.coi.model');
|
|
3
|
+
const { CombineLastTwoCOIsModel } = require('../models/Combine.last.two.cois.model');
|
|
3
4
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
4
6
|
|
|
5
7
|
const uploadToS3 = (contractorId, fileData) => {
|
|
6
8
|
return coiApi.uploadToS3(contractorId, fileData);
|
|
@@ -23,4 +25,15 @@ const getCoiHashes = recordId => {
|
|
|
23
25
|
return coiApi.getCoiHashes(recordId);
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
const combineLastTwoCOIs = async (combineLastTwoCOIsModel, auditorContext) => {
|
|
29
|
+
validateType(combineLastTwoCOIsModel, CombineLastTwoCOIsModel);
|
|
30
|
+
const response = await coiApi.combineLastTwoCOIs(combineLastTwoCOIsModel, auditorContext);
|
|
31
|
+
|
|
32
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
33
|
+
throw new Error(`Failed to combine last two COIs for recordId ${combineLastTwoCOIsModel.contractorId}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return response;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = { uploadToS3, submitCoi, getCoiPreSignedUrl, completeScan, getCoiHashes, combineLastTwoCOIs };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { SubmitCoiModel } = require('../models/submit.coi.model');
|
|
2
|
+
|
|
3
|
+
class CombineLastTwoCOIsModel extends SubmitCoiModel {
|
|
4
|
+
constructor({
|
|
5
|
+
recordId,
|
|
6
|
+
fileIds,
|
|
7
|
+
uploadedBy,
|
|
8
|
+
uploaderEmail,
|
|
9
|
+
recordDateModified,
|
|
10
|
+
isContractorExist,
|
|
11
|
+
isNewCoiOnTop = true
|
|
12
|
+
}) {
|
|
13
|
+
super({
|
|
14
|
+
recordId,
|
|
15
|
+
fileIds,
|
|
16
|
+
uploadedBy,
|
|
17
|
+
uploaderEmail,
|
|
18
|
+
recordDateModified,
|
|
19
|
+
isContractorExist
|
|
20
|
+
});
|
|
21
|
+
this.isNewCoiOnTop = isNewCoiOnTop;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { CombineLastTwoCOIsModel };
|
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
|
|
3
3
|
const services = require('../api/coi.service');
|
|
4
4
|
const { SubmitCoiModel } = require('../models/submit.coi.model');
|
|
5
|
+
const { CombineLastTwoCOIsModel } = require('../models/Combine.last.two.cois.model');
|
|
5
6
|
const { getContractorById } = require('../../contractors/api/contractors.service');
|
|
6
7
|
const { getIcsCookie } = require('../../auth/api/auth.service');
|
|
7
8
|
|
|
@@ -63,8 +64,32 @@ const uploadCoi = async (
|
|
|
63
64
|
return uploadedCoi;
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
const combineLastTwoCOIs = async ({
|
|
68
|
+
recordId,
|
|
69
|
+
fileIds,
|
|
70
|
+
uploadedBy,
|
|
71
|
+
uploaderEmail,
|
|
72
|
+
isContractorExist,
|
|
73
|
+
icsContext,
|
|
74
|
+
auditorContext
|
|
75
|
+
}) => {
|
|
76
|
+
const recordResponse = await getContractorById(recordId, icsContext);
|
|
77
|
+
const recordDateModified = recordResponse.data.dateModified;
|
|
78
|
+
|
|
79
|
+
const combineLastTwoCOIsModel = new CombineLastTwoCOIsModel({
|
|
80
|
+
recordId,
|
|
81
|
+
fileIds,
|
|
82
|
+
uploadedBy,
|
|
83
|
+
uploaderEmail,
|
|
84
|
+
recordDateModified,
|
|
85
|
+
isContractorExist
|
|
86
|
+
});
|
|
87
|
+
return services.combineLastTwoCOIs(combineLastTwoCOIsModel, auditorContext);
|
|
88
|
+
};
|
|
89
|
+
|
|
66
90
|
module.exports = {
|
|
67
91
|
uploadCoi,
|
|
68
92
|
uploadFileToStorage,
|
|
69
|
-
submitCoiFilesUpload
|
|
93
|
+
submitCoiFilesUpload,
|
|
94
|
+
combineLastTwoCOIs
|
|
70
95
|
};
|
|
@@ -5,6 +5,7 @@ const Endpoints = {
|
|
|
5
5
|
auditorContractorList: `${backendUrl}/saas/auditor/contractors`,
|
|
6
6
|
audit: `${backendUrl}/saas/auditor/contractors/submit/audits`,
|
|
7
7
|
enterAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
|
|
8
|
+
verifyAudit: contractorId => `${backendUrl}/saas/auditor/audit/${contractorId}/verify`,
|
|
8
9
|
getAuditRecordModelByRecordId: recordId => `${backendUrl}/saas/auditor/record/${recordId}/audit-record`,
|
|
9
10
|
getComplianceJsonByRecordId: recordId => `${backendUrl}/saas/contractors/${recordId}/compliance-json`,
|
|
10
11
|
requirementDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractor/${contractorId}/requirement`,
|
|
@@ -15,7 +16,8 @@ const Endpoints = {
|
|
|
15
16
|
putAuditOnHold: `${backendUrl}/saas/auditor/put-on-hold`,
|
|
16
17
|
resumeAudit: onHoldId => `${backendUrl}/saas/auditor/on-hold/${onHoldId}/resume`,
|
|
17
18
|
getAuditMetadata: auditId => `${backendUrl}/saas/auditor/audit-metadata/${auditId}`,
|
|
18
|
-
updateComplianceAuditActionsDate: recordId => `${backendUrl}/saas/automation/record/${recordId}/update-audit-actions-date
|
|
19
|
+
updateComplianceAuditActionsDate: recordId => `${backendUrl}/saas/automation/record/${recordId}/update-audit-actions-date`,
|
|
20
|
+
auditRawData: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/raw`
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const audit = async (contractorId, auditRequestModel, context) => {
|
|
@@ -46,6 +48,10 @@ const enterAudit = (contractorId, context) => {
|
|
|
46
48
|
return requests.getRequestHandler(Endpoints.enterAudit(contractorId), {}, context);
|
|
47
49
|
};
|
|
48
50
|
|
|
51
|
+
const verifyAuditBeforeEnter = (contractorId, context) => {
|
|
52
|
+
return requests.getRequestHandler(Endpoints.verifyAudit(contractorId), {}, context);
|
|
53
|
+
};
|
|
54
|
+
|
|
49
55
|
const getAuditRecordModel = (recordId, context) => {
|
|
50
56
|
return requests.getRequestHandler(Endpoints.getAuditRecordModelByRecordId(recordId), {}, context);
|
|
51
57
|
};
|
|
@@ -84,6 +90,10 @@ const getComplianceJson = (recordId, context) => {
|
|
|
84
90
|
return requests.getRequestHandler(Endpoints.getComplianceJsonByRecordId(recordId), {}, context);
|
|
85
91
|
};
|
|
86
92
|
|
|
93
|
+
const getAuditRawData = (recordId, context) => {
|
|
94
|
+
return requests.getRequestHandler(Endpoints.auditRawData(recordId), {}, context);
|
|
95
|
+
};
|
|
96
|
+
|
|
87
97
|
module.exports = {
|
|
88
98
|
audit,
|
|
89
99
|
submitAudit,
|
|
@@ -99,5 +109,7 @@ module.exports = {
|
|
|
99
109
|
putAuditOnHold,
|
|
100
110
|
resumeAudit,
|
|
101
111
|
getAuditMetadata,
|
|
102
|
-
updateComplianceAuditActionsDate
|
|
112
|
+
updateComplianceAuditActionsDate,
|
|
113
|
+
getAuditRawData,
|
|
114
|
+
verifyAuditBeforeEnter
|
|
103
115
|
};
|
|
@@ -35,8 +35,24 @@ const getAuditorContractorList = (auditListParametersModel, context) => {
|
|
|
35
35
|
return auditApi.getAuditorContractorList(auditListParametersModel, context);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const getAuditRequestModelAfterEnterAudit = async (auditConfigForModelAfterEnterAudit, accountId, projectId, requirementId, recordId, context) => {
|
|
39
|
+
const metadata = await prepareMetadataForAudit(context, accountId, projectId, requirementId, recordId);
|
|
40
|
+
const auditEntities = await getAuditEntities(recordId, auditConfigForModelAfterEnterAudit, context);
|
|
41
|
+
const auditRequestModel = getAuditRequestModel(metadata, auditEntities);
|
|
42
|
+
|
|
43
|
+
return auditRequestModel;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const enterAudit = async (recordId, context, { auditConfigForModelAfterEnterAudit, accountId, projectId, requirementId } = {}) => {
|
|
47
|
+
const enterAuditResponse = await auditApi.enterAudit(recordId, context);
|
|
48
|
+
|
|
49
|
+
if (enterAuditResponse.status !== httpResponseStatusCodes.OK) {
|
|
50
|
+
throw Error(`Failed to enter audit\n$response - ${enterAuditResponse.status}\n${JSON.stringify(enterAuditResponse.data)}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return auditConfigForModelAfterEnterAudit ?
|
|
54
|
+
getAuditRequestModelAfterEnterAudit(auditConfigForModelAfterEnterAudit, accountId, projectId, requirementId, recordId, context) :
|
|
55
|
+
enterAuditResponse;
|
|
40
56
|
};
|
|
41
57
|
|
|
42
58
|
const getAuditRecordModel = (recordId, context) => {
|
|
@@ -231,6 +247,20 @@ const getCurrentAuditUniqueCoiId = async function(recordId, auditorContext) {
|
|
|
231
247
|
return uniqueCoiId;
|
|
232
248
|
};
|
|
233
249
|
|
|
250
|
+
const getAuditRawData = async function(recordId, context) {
|
|
251
|
+
const responseAudit = await auditApi.getAuditRawData(recordId, context);
|
|
252
|
+
|
|
253
|
+
if (responseAudit.status !== httpResponseStatusCodes.OK) {
|
|
254
|
+
throw Error(`Failed to get audit raw data by record id\n${responseAudit}`);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return responseAudit.data;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const getAttributeKey = attributeName => {
|
|
261
|
+
return auditUtil.getAttributeKey(attributeName);
|
|
262
|
+
};
|
|
263
|
+
|
|
234
264
|
module.exports = {
|
|
235
265
|
audit,
|
|
236
266
|
submitAudit,
|
|
@@ -253,5 +283,7 @@ module.exports = {
|
|
|
253
283
|
getAuditOnHoldData,
|
|
254
284
|
getLastAuditDateBeforeAgreementAudit,
|
|
255
285
|
updateComplianceAuditActionsDate,
|
|
256
|
-
getCurrentAuditUniqueCoiId
|
|
286
|
+
getCurrentAuditUniqueCoiId,
|
|
287
|
+
getAuditRawData,
|
|
288
|
+
getAttributeKey
|
|
257
289
|
};
|
|
@@ -5,7 +5,8 @@ const Endpoints = {
|
|
|
5
5
|
waive: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
6
6
|
retract: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
7
7
|
overrideGap: `${backendUrl}/saas/record/override-gap`,
|
|
8
|
-
retractOverride: `${backendUrl}/saas/record/retract-override
|
|
8
|
+
retractOverride: `${backendUrl}/saas/record/retract-override`,
|
|
9
|
+
getOverridesByRecordId: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/override`
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const waive = async (contractorId, waiveRequestModel, context) => {
|
|
@@ -30,4 +31,8 @@ const retractOverride = (retractRequestModel, context) => {
|
|
|
30
31
|
return requests.postRequestHandler(Endpoints.retractOverride, retractRequestModel, context);
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
const getOverridesByRecordId = (recordId, context) => {
|
|
35
|
+
return requests.getRequestHandler(Endpoints.getOverridesByRecordId(recordId), {}, context);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = { waive, retract, overrideGap, retractOverride, getOverridesByRecordId };
|
|
@@ -29,7 +29,7 @@ const retractOverride = (retractRequestModel, context) => {
|
|
|
29
29
|
return overrideGapApi.retractOverride(retractRequestModel, context);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const getAllWaiveModels = (
|
|
33
33
|
record,
|
|
34
34
|
policyName,
|
|
35
35
|
attributeName,
|
|
@@ -39,20 +39,40 @@ const getWaiveModel = (
|
|
|
39
39
|
userId,
|
|
40
40
|
userRole
|
|
41
41
|
} = {}) => {
|
|
42
|
-
const
|
|
42
|
+
const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
|
|
43
43
|
userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
|
|
44
44
|
userRole = userRole || userTypes.ICS;
|
|
45
45
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const waiverModels = [];
|
|
47
|
+
let i = 0;
|
|
48
|
+
while (i < auditIds.length) {
|
|
49
|
+
const auditId = auditIds[i];
|
|
50
|
+
const waiveModel = new WaiveRequestModel({
|
|
51
|
+
contractorId: record.id,
|
|
52
|
+
auditId,
|
|
53
|
+
waiverReason,
|
|
54
|
+
remarks,
|
|
55
|
+
userId,
|
|
56
|
+
userRole
|
|
57
|
+
});
|
|
58
|
+
waiverModels.push(waiveModel);
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return waiverModels;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const getWaiveModel = (
|
|
66
|
+
record,
|
|
67
|
+
policyName,
|
|
68
|
+
attributeName,
|
|
69
|
+
waiverReason,
|
|
70
|
+
remarks,
|
|
71
|
+
{
|
|
51
72
|
userId,
|
|
52
73
|
userRole
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
return waiveModel;
|
|
74
|
+
} = {}) => {
|
|
75
|
+
return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole })[0];
|
|
56
76
|
};
|
|
57
77
|
|
|
58
78
|
const getWaiveModelByGap = (
|
|
@@ -71,7 +91,7 @@ const getWaiveModelByGap = (
|
|
|
71
91
|
};
|
|
72
92
|
|
|
73
93
|
const getRetractModel = (record, policyName, attributeName) => {
|
|
74
|
-
const auditId =
|
|
94
|
+
const auditId = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName))[0];
|
|
75
95
|
const userId = env.getSystemUserIdentity(credentials.superUser).id;
|
|
76
96
|
const userRole = userTypes.ICS;
|
|
77
97
|
|
|
@@ -85,7 +105,7 @@ const getRetractModel = (record, policyName, attributeName) => {
|
|
|
85
105
|
return retractModel;
|
|
86
106
|
};
|
|
87
107
|
|
|
88
|
-
const
|
|
108
|
+
const getPolicyAuditIdsFromRecord = (record, policyName, attributeName) => {
|
|
89
109
|
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
90
110
|
contractorCoverage.insuranceName === policyName);
|
|
91
111
|
|
|
@@ -93,25 +113,35 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
|
93
113
|
throw new Error(`Policy name: ${policyName} don't exist in record`);
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
const
|
|
116
|
+
const attributes = policy.errorList.filter(error => error.limitname === attributeName);
|
|
97
117
|
|
|
98
|
-
if (!
|
|
118
|
+
if (!attributes.length) {
|
|
99
119
|
throw new Error(`Attribute name: ${attributeName} don't exist in record`);
|
|
100
120
|
}
|
|
101
121
|
|
|
102
|
-
|
|
122
|
+
const auditIds = attributes.map(a => a.auditId);
|
|
123
|
+
|
|
124
|
+
return auditIds;
|
|
103
125
|
};
|
|
104
126
|
|
|
105
127
|
// private method - please refer to waiveAll / acceptAll
|
|
106
128
|
const overrideAll = async (record, reason, context, { note = 'OVERRIDDEN AUTOMATICALLY' } = {}) => {
|
|
107
|
-
|
|
129
|
+
let allWaivablePolicies = auditUtil.getAllWaivablePolicies(record, context);
|
|
130
|
+
// Remove duplicates, this can happen for example in case of multiple errors on Additional Insured, Certificate Holder or Additional Information
|
|
131
|
+
allWaivablePolicies = allWaivablePolicies.filter((value, index, self) =>
|
|
132
|
+
index === self.findIndex(t => (
|
|
133
|
+
t.policyName === value.policyName && t.attributeName === value.attributeName
|
|
134
|
+
))
|
|
135
|
+
);
|
|
108
136
|
|
|
109
137
|
for (const waivable of allWaivablePolicies) {
|
|
110
|
-
const
|
|
111
|
-
|
|
138
|
+
const waiveModels = getAllWaiveModels(record, waivable.policyName, waivable.attributeName, reason, note);
|
|
139
|
+
for (waiveModel of waiveModels) {
|
|
140
|
+
const waiveResponse = await overrideGap({ waiveRequestModel: waiveModel, context });
|
|
112
141
|
|
|
113
|
-
|
|
114
|
-
|
|
142
|
+
if (waiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
143
|
+
throw Error(`Failed to waive ${waivable.policyName} - ${waivable.attributeName} for ${record.company}`);
|
|
144
|
+
}
|
|
115
145
|
}
|
|
116
146
|
}
|
|
117
147
|
};
|
|
@@ -128,6 +158,16 @@ const acceptAll = async (record, context, { note = 'ACCEPTED AUTOMATICALLY' } =
|
|
|
128
158
|
await overrideAll(record, WAIVER_REASONS.ACCEPT_NO_EXPOSURE, context, { note });
|
|
129
159
|
};
|
|
130
160
|
|
|
161
|
+
const getOverridesByRecordId = async function(recordId, context) {
|
|
162
|
+
const responseAudit = await overrideGapApi.getOverridesByRecordId(recordId, context);
|
|
163
|
+
|
|
164
|
+
if (responseAudit.status !== httpResponseStatusCodes.OK) {
|
|
165
|
+
throw Error(`Failed to get overrides by record id\n${responseAudit}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return responseAudit.data;
|
|
169
|
+
};
|
|
170
|
+
|
|
131
171
|
module.exports = {
|
|
132
172
|
waive,
|
|
133
173
|
waiveAll,
|
|
@@ -137,5 +177,6 @@ module.exports = {
|
|
|
137
177
|
getRetractModel,
|
|
138
178
|
getWaiveModelByGap,
|
|
139
179
|
overrideGap,
|
|
140
|
-
retractOverride
|
|
180
|
+
retractOverride,
|
|
181
|
+
getOverridesByRecordId
|
|
141
182
|
};
|
|
@@ -47,7 +47,7 @@ const ATTRIBUTE_NAMES_MAP = {
|
|
|
47
47
|
isPolicyExist: 'coverageexists',
|
|
48
48
|
eachOccurrence: 'Each Occurrence',
|
|
49
49
|
expiryDate: 'expirydate',
|
|
50
|
-
policyNumber: '
|
|
50
|
+
policyNumber: 'policynumber',
|
|
51
51
|
perOccurrence: 'PerOccur',
|
|
52
52
|
perPolicy: 'Per Policy',
|
|
53
53
|
perProject: 'Per Project',
|
|
@@ -83,6 +83,11 @@ const auditStatus = {
|
|
|
83
83
|
canceled: 'CANCELED'
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
const auditTypes = {
|
|
87
|
+
manual: 'MANUAL',
|
|
88
|
+
automatic: 'AUTOMATIC'
|
|
89
|
+
};
|
|
90
|
+
|
|
86
91
|
const auditOnHoldReason = {
|
|
87
92
|
ESCALATION_TO_PM: 'Escalation to PM',
|
|
88
93
|
ISSUE_WITH_REQUIREMENTS: 'Issue with Requirements',
|
|
@@ -100,5 +105,6 @@ module.exports = {
|
|
|
100
105
|
VALID_SCORES,
|
|
101
106
|
auditTriggerType,
|
|
102
107
|
auditStatus,
|
|
103
|
-
auditOnHoldReason
|
|
108
|
+
auditOnHoldReason,
|
|
109
|
+
auditTypes
|
|
104
110
|
};
|
|
@@ -142,7 +142,22 @@ const parseAuditConfig = function(config) {
|
|
|
142
142
|
|
|
143
143
|
if (isArray(config[field])) {
|
|
144
144
|
selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
|
|
145
|
-
|
|
145
|
+
|
|
146
|
+
const auditValue = config[field][1];
|
|
147
|
+
|
|
148
|
+
if (multipleErrorsEndorsementList.includes(field) && isArray(auditValue)) {
|
|
149
|
+
// in case of 'Other' with multiple errors in special policies (Additional Information, Certificate Holder, etc)
|
|
150
|
+
let i = 0;
|
|
151
|
+
while (i < auditValue.length) {
|
|
152
|
+
const copiedSelection = { ... selection };
|
|
153
|
+
copiedSelection.value = auditValue[i];
|
|
154
|
+
auditDataArr.push(copiedSelection);
|
|
155
|
+
i++;
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
} else {
|
|
159
|
+
selection.value = auditValue; // Ok to be undefined
|
|
160
|
+
}
|
|
146
161
|
} else {
|
|
147
162
|
selection.status = AUDIT_ENTITY_STATUSES[(config[field]).toUpperCase()] || AUDIT_ENTITY_STATUSES.YES;
|
|
148
163
|
selection.value = getValueBySelection(config[field]);
|
|
@@ -188,6 +203,14 @@ const certificateEndorsementsList = [
|
|
|
188
203
|
'Agreement'
|
|
189
204
|
];
|
|
190
205
|
|
|
206
|
+
const multipleErrorsEndorsementList = [
|
|
207
|
+
'Certificate Holder',
|
|
208
|
+
'Additional Information',
|
|
209
|
+
'Additional Insured',
|
|
210
|
+
'Agreement',
|
|
211
|
+
'Other' //not endorsement
|
|
212
|
+
];
|
|
213
|
+
|
|
191
214
|
const specialAttributes = {
|
|
192
215
|
'Certificate issue date': 'certIssueDate',
|
|
193
216
|
'Cancellation Terms': 'cancellationTerms',
|
|
@@ -274,6 +274,16 @@ const linkDraftRequestToAccountRecord = async (requestToLink, targetAccountRecor
|
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
+
const changeRequirementsDirectly = async (recordId, newRequirementId, context) => {
|
|
278
|
+
const recordVerificationModel = await getRecordVerificationModel(recordId, context);
|
|
279
|
+
recordVerificationModel.requirementId = newRequirementId;
|
|
280
|
+
const changeRequirementRes = await changeRequirement(recordVerificationModel, context);
|
|
281
|
+
|
|
282
|
+
if (changeRequirementRes.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
283
|
+
throw Error(`Failed to change requirement for record: ${recordId}`);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
277
287
|
module.exports = {
|
|
278
288
|
changeRequirement,
|
|
279
289
|
getContractorsByAccountId,
|
|
@@ -314,5 +324,6 @@ module.exports = {
|
|
|
314
324
|
getContractorDetailsModel,
|
|
315
325
|
getBasicDetailsById,
|
|
316
326
|
getRecordsFromInsuredName,
|
|
317
|
-
linkDraftRequestToAccountRecord
|
|
327
|
+
linkDraftRequestToAccountRecord,
|
|
328
|
+
changeRequirementsDirectly
|
|
318
329
|
};
|
|
@@ -3,6 +3,7 @@ const { backendUrl } = require('../../../../env').getEnv();
|
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getRelatedDocPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/document`,
|
|
6
|
+
getCreatePolicyPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/policy`,
|
|
6
7
|
uploadRelatedDoc: recordId => `${backendUrl}/saas/contractor/${recordId}/document`,
|
|
7
8
|
fileUpload: `${backendUrl}/file/finalize-upload`
|
|
8
9
|
};
|
|
@@ -11,6 +12,10 @@ const getRelatedDocPreSignedUrl = (formData, context) => {
|
|
|
11
12
|
return requests.postRequestHandler(Endpoints.getRelatedDocPreSignedUrl, formData, context, formData.getHeaders());
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const getCreatePolicyPreSignedUrl = (formData, context) => {
|
|
16
|
+
return requests.postRequestHandler(Endpoints.getCreatePolicyPreSignedUrl, formData, context, formData.getHeaders());
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
const uploadFileToS3 = (preSignedUrl, file) => {
|
|
15
20
|
return requests.putRequestHandler(preSignedUrl, file);
|
|
16
21
|
};
|
|
@@ -25,6 +30,7 @@ const uploadFile = data => {
|
|
|
25
30
|
|
|
26
31
|
module.exports = {
|
|
27
32
|
getRelatedDocPreSignedUrl,
|
|
33
|
+
getCreatePolicyPreSignedUrl,
|
|
28
34
|
uploadRelatedDoc,
|
|
29
35
|
uploadFileToS3,
|
|
30
36
|
uploadFile
|
|
@@ -18,6 +18,18 @@ const getRelatedDocPreSignedUrl = (recordId, context, { filePath }) => {
|
|
|
18
18
|
return uploadFileApi.getRelatedDocPreSignedUrl(formData, context);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const getCreatePolicyPreSignedUrl = async (requestId, context, { shouldExpectError } = {}) => {
|
|
22
|
+
const formData = new FormData();
|
|
23
|
+
formData.append('requestId', requestId);
|
|
24
|
+
const policyPreSignedUrlResponse = await uploadFileApi.getCreatePolicyPreSignedUrl(formData, context);
|
|
25
|
+
|
|
26
|
+
if (policyPreSignedUrlResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
27
|
+
throw new Error('Failed to get policy pre-signed url');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return policyPreSignedUrlResponse;
|
|
31
|
+
};
|
|
32
|
+
|
|
21
33
|
const uploadFileToS3 = async (preSignedUrl, filePath) => {
|
|
22
34
|
const uploadFileToS3Response = await uploadFileApi.uploadFileToS3(preSignedUrl, fs.readFileSync(filePath));
|
|
23
35
|
|
|
@@ -46,6 +58,7 @@ const uploadFile = (recordId, type, fileName) => {
|
|
|
46
58
|
};
|
|
47
59
|
|
|
48
60
|
module.exports = {
|
|
61
|
+
getCreatePolicyPreSignedUrl,
|
|
49
62
|
uploadRelatedDoc,
|
|
50
63
|
uploadFileToS3
|
|
51
64
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
const requests = require('../../../common/requests/apiKeyAuth/requests');
|
|
2
2
|
const { openapiUrl } = require('../../../env').getEnv();
|
|
3
|
+
const { isLocalhost } = require('../../../env');
|
|
4
|
+
|
|
5
|
+
const recordsPathSegment = isLocalhost() ? 'contractors' : 'records';
|
|
3
6
|
|
|
4
7
|
const Endpoints = {
|
|
5
8
|
copyRequirement: sourceRequirementId => `${openapiUrl}/requirement/${sourceRequirementId}/copy`,
|
|
6
9
|
getRequirementsByTabId: tabId => `${openapiUrl}/tabs/${tabId}/requirements`,
|
|
7
10
|
getRequirementsByProjectId: projectId => `${openapiUrl}/properties/${projectId}/requirements`,
|
|
8
|
-
getRequirementsList: `${openapiUrl}/requirement/all
|
|
11
|
+
getRequirementsList: `${openapiUrl}/requirement/all`,
|
|
12
|
+
changeRequirements: (requestId, newReqId) => `${openapiUrl}/${recordsPathSegment}/${requestId}/requirement/${newReqId}`
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
const copyRequirement = (apiKey, sourceRequirementId, newRequirementOverrides) => {
|
|
@@ -24,9 +28,14 @@ const getRequirementsList = (apiKey, params) => {
|
|
|
24
28
|
return requests.getRequestHandler(Endpoints.getRequirementsList, apiKey, params);
|
|
25
29
|
};
|
|
26
30
|
|
|
31
|
+
const changeRequirements = (apiKey, requestId, newReqId) => {
|
|
32
|
+
return requests.putRequestHandler(Endpoints.changeRequirements(requestId, newReqId), apiKey);
|
|
33
|
+
};
|
|
34
|
+
|
|
27
35
|
module.exports = {
|
|
28
36
|
copyRequirement,
|
|
29
37
|
getRequirementsByTabId,
|
|
30
38
|
getRequirementsByProjectId,
|
|
31
|
-
getRequirementsList
|
|
39
|
+
getRequirementsList,
|
|
40
|
+
changeRequirements
|
|
32
41
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const requirementsApi = require('./requirements.api');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
2
3
|
|
|
3
4
|
const { validateType } = require('../../../common/validations/typeValidations');
|
|
4
5
|
const CopyRequirementModel = require('./models/copy.requirement.model');
|
|
@@ -29,9 +30,20 @@ const getRequirementsList = (apiKey, params) => {
|
|
|
29
30
|
return requirementsApi.getRequirementsList(apiKey, params);
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
const changeRequirements = async (apiKey, requestId, newReqId) => {
|
|
34
|
+
const response = await requirementsApi.changeRequirements(apiKey, requestId, newReqId);
|
|
35
|
+
|
|
36
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
37
|
+
throw new Error(`Failed to change requirements for requestId ${requestId} and newReqId ${newReqId}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
|
|
32
43
|
module.exports = {
|
|
33
44
|
copyRequirement,
|
|
34
45
|
getRequirementsByTabId,
|
|
35
46
|
getRequirementsByProjectId,
|
|
36
|
-
getRequirementsList
|
|
47
|
+
getRequirementsList,
|
|
48
|
+
changeRequirements
|
|
37
49
|
};
|