@getjones/test-infra 4.4.0 → 4.4.2
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 +35 -3
- package/src/common/consts/s3FileTypes.js +2 -1
- package/src/common/utils/complianceUtil.js +3 -1
- package/src/defaults/configs/auditConfigs.js +25 -0
- package/src/defaults/configs/polices.js +6 -1
- package/src/factory/records/records.js +18 -13
- package/src/resources/coi/coi2.pdf +0 -0
- package/src/resources/policy/policy.pdf +0 -0
- package/src/resources/virusFile.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/agreement/api/agreement.api.js +8 -2
- package/src/saas/internal-api/agreement/api/agreement.service.js +13 -1
- 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 +48 -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 +47 -4
- 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/models/audit/audit.model.js +2 -1
- package/src/saas/internal-api/compliance/utils/auditUtil.js +35 -3
- package/src/saas/internal-api/contractors/api/contractors.api.js +6 -0
- package/src/saas/internal-api/contractors/api/contractors.service.js +25 -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();
|
|
@@ -35,7 +39,7 @@ const editRequestAndRecordDetails = async function(request, recordConfig, contex
|
|
|
35
39
|
const editRequestResponse = await requests.services.editRequestAndRecordDetails(requestEditModel, context);
|
|
36
40
|
|
|
37
41
|
if (editRequestResponse.status !== httpResponseStatusCodes.OK) {
|
|
38
|
-
throw Error(`Failed to edit record
|
|
42
|
+
throw Error(`Failed to edit record \n${editRequestResponse.data.message}`);
|
|
39
43
|
}
|
|
40
44
|
};
|
|
41
45
|
|
|
@@ -115,6 +119,31 @@ const getHistoryEvents = async function(recordId, context) {
|
|
|
115
119
|
return recordHistory.data.map(item => item.itemTitle).reverse();
|
|
116
120
|
};
|
|
117
121
|
|
|
122
|
+
const getFirstHistoryEventId = async function(recordId, context) {
|
|
123
|
+
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
124
|
+
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
125
|
+
return recordHistory.data[recordHistory.data.length - 1].itemId;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const getLatestHistoryEventId = async function(recordId, context) {
|
|
129
|
+
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
130
|
+
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
131
|
+
return recordHistory.data[0].itemId;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const getLatestRecordHistoryEventIdByItemTitle = async function(recordId, itemTitle, context) {
|
|
135
|
+
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
136
|
+
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
137
|
+
|
|
138
|
+
const latestHistoryByTitle = recordHistory.data.find(historyItem => historyItem.itemTitle === itemTitle);
|
|
139
|
+
|
|
140
|
+
if (!latestHistoryByTitle) {
|
|
141
|
+
throw new Error(`History event with title ${itemTitle} not found`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return latestHistoryByTitle.itemId;
|
|
145
|
+
};
|
|
146
|
+
|
|
118
147
|
const waitForOcrStatus = async function(recordId, context, { expectedStatus = ocrStatuses.SUCCESS } = {}) {
|
|
119
148
|
let { data: recordOcrStatus } = await contractors.services.getRecordOcrStatus(recordId, context);
|
|
120
149
|
let maxRetries = 25;
|
|
@@ -156,8 +185,11 @@ module.exports = {
|
|
|
156
185
|
updateInviteDate,
|
|
157
186
|
updatePolicyExpiryDateForRecord,
|
|
158
187
|
getHistoryEvents,
|
|
188
|
+
getFirstHistoryEventId,
|
|
189
|
+
getLatestHistoryEventId,
|
|
159
190
|
updateLastInviteActionDate,
|
|
160
191
|
waitForOcrStatus,
|
|
161
192
|
generateSubscriptionModelFromMail,
|
|
162
|
-
deleteAllRequestsInProject
|
|
193
|
+
deleteAllRequestsInProject,
|
|
194
|
+
getLatestRecordHistoryEventIdByItemTitle
|
|
163
195
|
};
|
|
@@ -56,11 +56,13 @@ const prepareMetadataForAudit = async (
|
|
|
56
56
|
const auditResponse = await auditApi.getAuditMetadata(recordDetails.auditId, auditorContext);
|
|
57
57
|
const { currentAudit } = auditResponse.data;
|
|
58
58
|
|
|
59
|
+
const enterAuditResponse = await auditApi.enterAudit(recordId, auditorContext);
|
|
60
|
+
|
|
59
61
|
metadata.certificateId = recordDetails.certificateDetails.certificateuploadId;
|
|
60
62
|
metadata.auditDates = {
|
|
61
63
|
contractorId: recordId,
|
|
62
64
|
contractorDateModified: recordDetails.dateModified,
|
|
63
|
-
dateStartedAudit:
|
|
65
|
+
dateStartedAudit: enterAuditResponse.data.dateStartedAudit,
|
|
64
66
|
contractorOverrideDateModified: recordDetails.contractorOverrideDateModified,
|
|
65
67
|
contractCreateDate: recordDetails.contractCreateDate,
|
|
66
68
|
auditDateModified: currentAudit.dateModified
|
|
@@ -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,11 +14,10 @@ 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
|
|
|
21
|
-
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber } = {}) => {
|
|
20
|
+
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { inviterEmail = credentials.superUser, expiryStatus, shouldSendNotificationToPM = false, recordConfig, glPolicyNumber } = {}) => {
|
|
22
21
|
validateInsuranceAndExpiryStatus(status, expiryStatus);
|
|
23
22
|
|
|
24
23
|
const requestData = await requests.services.getOrCreateRequest(
|
|
@@ -26,7 +25,7 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
26
25
|
tabId,
|
|
27
26
|
requirementId,
|
|
28
27
|
{ // record
|
|
29
|
-
inviterEmail
|
|
28
|
+
inviterEmail,
|
|
30
29
|
email: recordEmail,
|
|
31
30
|
companyName: recordCompany
|
|
32
31
|
}
|
|
@@ -90,8 +89,8 @@ const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId
|
|
|
90
89
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.compliant, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { shouldSendNotificationToPM = false, recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
94
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, {
|
|
92
|
+
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, shouldSendNotificationToPM = false, recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
93
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, { inviterEmail, shouldSendNotificationToPM, recordConfig, expiryStatus, glPolicyNumber });
|
|
95
94
|
};
|
|
96
95
|
|
|
97
96
|
const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
@@ -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
|
|
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
|
};
|
|
@@ -6,7 +6,8 @@ const AGREEMENT_API_URL = `${backendUrl}/saas/contractor/agreement`;
|
|
|
6
6
|
const Endpoints = {
|
|
7
7
|
create: AGREEMENT_API_URL,
|
|
8
8
|
createByAuditor: `${backendUrl}/UpdateSnippetService`,
|
|
9
|
-
getAgreementPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/agreement
|
|
9
|
+
getAgreementPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/agreement`,
|
|
10
|
+
getAgreementLinkByRecordId: recordId => `${backendUrl}/saas/contractor/${recordId}/agreement`
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
const getAgreementPreSignedUrl = (formData, context) => {
|
|
@@ -25,9 +26,14 @@ const createAgreementByAuditor = (createAgreementModel, context) => {
|
|
|
25
26
|
return requests.postRequestHandler(Endpoints.createByAuditor, createAgreementModel, context);
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
const getAgreementLinkByRecordId = (recordId, context) => {
|
|
30
|
+
return requests.getRequestHandler(Endpoints.getAgreementLinkByRecordId(recordId), null, context);
|
|
31
|
+
};
|
|
32
|
+
|
|
28
33
|
module.exports = {
|
|
29
34
|
createAgreement,
|
|
30
35
|
createAgreementByAuditor,
|
|
31
36
|
uploadAgreementToS3,
|
|
32
|
-
getAgreementPreSignedUrl
|
|
37
|
+
getAgreementPreSignedUrl,
|
|
38
|
+
getAgreementLinkByRecordId
|
|
33
39
|
};
|
|
@@ -102,8 +102,20 @@ const uploadAgreementByAuditor = async (
|
|
|
102
102
|
|
|
103
103
|
return createResponse;
|
|
104
104
|
};
|
|
105
|
+
|
|
106
|
+
const getAgreementLinkByRecordId = async (recordId, context) => {
|
|
107
|
+
const linkResponse = await agreementAPI.getAgreementLinkByRecordId(recordId, context);
|
|
108
|
+
|
|
109
|
+
if (linkResponse.status !== httpResponseStatusCodes.OK) {
|
|
110
|
+
throw new Error(`Failed to get agreement for record ${recordId}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return linkResponse.data;
|
|
114
|
+
};
|
|
115
|
+
|
|
105
116
|
module.exports = {
|
|
106
117
|
createAgreement,
|
|
107
118
|
uploadAgreementByPM,
|
|
108
|
-
uploadAgreementByAuditor
|
|
119
|
+
uploadAgreementByAuditor,
|
|
120
|
+
getAgreementLinkByRecordId
|
|
109
121
|
};
|
|
@@ -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 };
|