@getjones/test-infra 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -29
- package/src/common/commonFlows/index.js +3 -3
- package/src/common/commonFlows/records/records.js +71 -71
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +38 -38
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/requestHandlers.js +60 -60
- package/src/common/utils/dataTypeUtils.js +41 -0
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/timeUtils.js +167 -162
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/env.js +45 -45
- package/src/index.js +71 -69
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
- package/src/saas/internal-api/accounts/index.js +20 -20
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -19
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +12 -12
- package/src/saas/internal-api/auth/api/auth.service.js +63 -47
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +34 -34
- package/src/saas/internal-api/coi/api/coi.service.js +22 -22
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
- package/src/saas/internal-api/coi/index.js +13 -13
- package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
- package/src/saas/internal-api/coi/utils/utils.js +48 -48
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +41 -40
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +152 -33
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
- package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
- package/src/saas/internal-api/compliance/consts/audit.js +81 -0
- package/src/saas/internal-api/compliance/index.js +28 -22
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -110
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
- package/src/saas/internal-api/compliance/utils/util.js +173 -0
- package/src/saas/internal-api/contractors/api/contractors.api.js +141 -147
- package/src/saas/internal-api/contractors/api/contractors.service.js +123 -129
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -0
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -0
- package/src/saas/internal-api/dashboardInnerPage/index.js +5 -0
- package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -0
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
- package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
- package/src/saas/internal-api/dbEmails/index.js +4 -4
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
- package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
- package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
- package/src/saas/internal-api/projects/utils/utils.js +82 -82
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/reports/api/reports.api.js +39 -39
- package/src/saas/internal-api/reports/api/reports.service.js +34 -34
- package/src/saas/internal-api/reports/consts/consts.js +63 -63
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +54 -34
- package/src/saas/internal-api/requests/api/requests.service.js +51 -30
- package/src/saas/internal-api/requests/index.js +14 -11
- package/src/saas/internal-api/requests/models/create.request.model.js +22 -0
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +8 -8
- package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
- package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -0
- package/src/saas/internal-api/requirements/index.js +6 -6
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
- package/src/saas/internal-api/requirements/utils/utils.js +88 -0
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
- package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
- package/src/saas/internal-api/users/api/users.api.js +77 -77
- package/src/saas/internal-api/users/api/users.service.js +101 -101
- package/src/saas/internal-api/users/index.js +4 -4
- package/src/saas/internal-api/users/models/users.model.js +31 -31
- package/src/saas/internal-api/users/utils/util.js +14 -14
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/projects/projects.api.js +59 -59
- package/src/saas/openapi/projects/projects.service.js +44 -44
- package/src/saas/openapi/requests/index.js +6 -6
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +20 -20
- package/src/saas/openapi/requests/requests.service.js +18 -18
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +12 -12
- package/src/saas/openapi/requirements/requirements.service.js +20 -20
- package/src/saas/openapi/tabs/tabs.api.js +13 -13
- package/src/saas/openapi/tabs/tabs.service.js +7 -7
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
|
@@ -1,110 +1,84 @@
|
|
|
1
|
-
const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
auditDates =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
validateInteger(page, { min: 1 });
|
|
86
|
-
validateArray(accountIds);
|
|
87
|
-
|
|
88
|
-
if (fromDate) {
|
|
89
|
-
validateDateString(fromDate);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (toDate) {
|
|
93
|
-
validateDateString(toDate);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.page = page;
|
|
97
|
-
this.filters = { accountIds, fromDate, toDate };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
module.exports = {
|
|
102
|
-
AuditRequestModel,
|
|
103
|
-
AuditEntityModel,
|
|
104
|
-
AuditDatesModel,
|
|
105
|
-
AuditListParametersModel,
|
|
106
|
-
COI_AUDIT_STATUSES,
|
|
107
|
-
AUDIT_ENTITY_STATUSES,
|
|
108
|
-
AUDIT_ATTRIBUTE_NAMES,
|
|
109
|
-
AUDIT_POLICY_NAMES
|
|
110
|
-
};
|
|
1
|
+
const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
|
|
2
|
+
const { AUDITOR_ROLE, COI_AUDIT_STATUSES } = require('../../consts/audit');
|
|
3
|
+
|
|
4
|
+
class AuditRequestModel {
|
|
5
|
+
constructor(
|
|
6
|
+
accountId = null,
|
|
7
|
+
projectId = null,
|
|
8
|
+
requirementId = null,
|
|
9
|
+
contractorId = null,
|
|
10
|
+
certificateId = null,
|
|
11
|
+
auditorId = null,
|
|
12
|
+
auditEntities = null,
|
|
13
|
+
isReaudit = null,
|
|
14
|
+
isProjectOnboarding = false,
|
|
15
|
+
shouldSendNotificationToPM = true,
|
|
16
|
+
auditDates = {},
|
|
17
|
+
auditStatus = null,
|
|
18
|
+
auditorRole = AUDITOR_ROLE
|
|
19
|
+
) {
|
|
20
|
+
const auditData = {
|
|
21
|
+
userId: accountId,
|
|
22
|
+
projectId: projectId,
|
|
23
|
+
requirementId: requirementId,
|
|
24
|
+
contractorId: contractorId,
|
|
25
|
+
certificateId: certificateId,
|
|
26
|
+
auditorId: auditorId,
|
|
27
|
+
policyDetails: auditEntities,
|
|
28
|
+
auditorStatus: COI_AUDIT_STATUSES.NOT_AUDITED,
|
|
29
|
+
isReaudit: isReaudit,
|
|
30
|
+
projectOnboarding: isProjectOnboarding,
|
|
31
|
+
role: auditorRole,
|
|
32
|
+
sendNotificationToPM: shouldSendNotificationToPM,
|
|
33
|
+
auditStatus
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
validateType(auditDates, AuditDatesModel);
|
|
37
|
+
this.auditData = auditData;
|
|
38
|
+
this.auditDates = auditDates;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class AuditEntityModel {
|
|
43
|
+
constructor(policyId, attributeName, status, value) {
|
|
44
|
+
this.contractorInsuranceId = policyId;
|
|
45
|
+
this.limitname = attributeName;
|
|
46
|
+
this.status = status;
|
|
47
|
+
this.value = value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class AuditDatesModel {
|
|
52
|
+
constructor(contractorId, contractorDateModified, dateStartedAudit, contractorOverrideDateModified, contractCreateDate) {
|
|
53
|
+
this.contractorId = contractorId;
|
|
54
|
+
this.contractorDateModified = contractorDateModified;
|
|
55
|
+
this.dateStartedAudit = dateStartedAudit;
|
|
56
|
+
this.contractorOverrideDateModified = contractorOverrideDateModified;
|
|
57
|
+
this.contractCreateDate = contractCreateDate;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class AuditListParametersModel {
|
|
62
|
+
constructor(page, accountIds, { fromDate, toDate } = {}) {
|
|
63
|
+
validateInteger(page, { min: 1 });
|
|
64
|
+
validateArray(accountIds);
|
|
65
|
+
|
|
66
|
+
if (fromDate) {
|
|
67
|
+
validateDateString(fromDate);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (toDate) {
|
|
71
|
+
validateDateString(toDate);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.page = page;
|
|
75
|
+
this.filters = { accountIds, fromDate, toDate };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
AuditRequestModel,
|
|
81
|
+
AuditEntityModel,
|
|
82
|
+
AuditDatesModel,
|
|
83
|
+
AuditListParametersModel
|
|
84
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const DEFAULT_USER_ROLE = 'ICS';
|
|
2
|
-
|
|
3
|
-
const WAIVE_ACTIONS = {
|
|
4
|
-
WAIVE: 'ignored',
|
|
5
|
-
RETRACT: 'notIgnored'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const WAIVER_REASONS = {
|
|
9
|
-
BUSINESS_DECISION: 'Business_Decision',
|
|
10
|
-
NO_EXPOSURE: 'No_Exposure',
|
|
11
|
-
EXECUTIVE_APPROVAL: 'Executive_Approval'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function WaiveRequestModel({
|
|
15
|
-
userId,
|
|
16
|
-
contractorId,
|
|
17
|
-
auditId,
|
|
18
|
-
waiverReason,
|
|
19
|
-
remarks = '',
|
|
20
|
-
userRole = DEFAULT_USER_ROLE
|
|
21
|
-
}) {
|
|
22
|
-
this.auditorContractorId = auditId;
|
|
23
|
-
this.contractorId = contractorId;
|
|
24
|
-
this.userId = userId;
|
|
25
|
-
this.waiverReason = waiverReason;
|
|
26
|
-
this.remarks = remarks;
|
|
27
|
-
|
|
28
|
-
this.userRole = userRole;
|
|
29
|
-
this.status = WAIVE_ACTIONS.WAIVE;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function RetractRequestModel({ userId, contractorId, auditId, userRole = DEFAULT_USER_ROLE }) {
|
|
33
|
-
this.auditorContractorId = auditId;
|
|
34
|
-
this.contractorId = contractorId;
|
|
35
|
-
this.userId = userId;
|
|
36
|
-
this.userRole = userRole;
|
|
37
|
-
this.status = WAIVE_ACTIONS.RETRACT;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = {
|
|
41
|
-
WaiveRequestModel,
|
|
42
|
-
RetractRequestModel,
|
|
43
|
-
WAIVE_ACTIONS,
|
|
44
|
-
WAIVER_REASONS
|
|
45
|
-
};
|
|
1
|
+
const DEFAULT_USER_ROLE = 'ICS';
|
|
2
|
+
|
|
3
|
+
const WAIVE_ACTIONS = {
|
|
4
|
+
WAIVE: 'ignored',
|
|
5
|
+
RETRACT: 'notIgnored'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const WAIVER_REASONS = {
|
|
9
|
+
BUSINESS_DECISION: 'Business_Decision',
|
|
10
|
+
NO_EXPOSURE: 'No_Exposure',
|
|
11
|
+
EXECUTIVE_APPROVAL: 'Executive_Approval'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function WaiveRequestModel({
|
|
15
|
+
userId,
|
|
16
|
+
contractorId,
|
|
17
|
+
auditId,
|
|
18
|
+
waiverReason,
|
|
19
|
+
remarks = '',
|
|
20
|
+
userRole = DEFAULT_USER_ROLE
|
|
21
|
+
}) {
|
|
22
|
+
this.auditorContractorId = auditId;
|
|
23
|
+
this.contractorId = contractorId;
|
|
24
|
+
this.userId = userId;
|
|
25
|
+
this.waiverReason = waiverReason;
|
|
26
|
+
this.remarks = remarks;
|
|
27
|
+
|
|
28
|
+
this.userRole = userRole;
|
|
29
|
+
this.status = WAIVE_ACTIONS.WAIVE;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function RetractRequestModel({ userId, contractorId, auditId, userRole = DEFAULT_USER_ROLE }) {
|
|
33
|
+
this.auditorContractorId = auditId;
|
|
34
|
+
this.contractorId = contractorId;
|
|
35
|
+
this.userId = userId;
|
|
36
|
+
this.userRole = userRole;
|
|
37
|
+
this.status = WAIVE_ACTIONS.RETRACT;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
WaiveRequestModel,
|
|
42
|
+
RetractRequestModel,
|
|
43
|
+
WAIVE_ACTIONS,
|
|
44
|
+
WAIVER_REASONS
|
|
45
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../consts/audit');
|
|
2
|
+
const { isObject, isArray } = require('../../../../common/utils/dataTypeUtils');
|
|
3
|
+
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
4
|
+
const auditModels = require('../models/audit/audit.model');
|
|
5
|
+
const auth = require('../../auth');
|
|
6
|
+
|
|
7
|
+
const emptyValue = '';
|
|
8
|
+
|
|
9
|
+
const getValueBySelection = selection => {
|
|
10
|
+
return ['Yes', 'No', 'Empty', 'Claims'].includes(selection) ? emptyValue : selection;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getDateInApiFormat = date => {
|
|
14
|
+
return timeUtils.convertDateToNewFormat(
|
|
15
|
+
date,
|
|
16
|
+
timeUtils.formats.dayMonthYear,
|
|
17
|
+
timeUtils.formats.numericMonthDayYear
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getAttributeKey = attribute => {
|
|
22
|
+
return specialAttributes[attribute] || attribute;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getPolicyId = (policyName, requirement) => {
|
|
26
|
+
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
27
|
+
return DEFAULT_POLICY_ID;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const policy = requirement.policies.find(policy => policy.name === policyName);
|
|
31
|
+
|
|
32
|
+
if (!policy) {
|
|
33
|
+
let policiesList = emptyValue;
|
|
34
|
+
requirement.policies.forEach(policy => policiesList += `${policy.name},`);
|
|
35
|
+
|
|
36
|
+
throw Error(`Policy '${policyName}' not found in the Requirement. List: ${policiesList.slice(0, -1)}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return policy.id;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getParsedConfig = function(config) {
|
|
43
|
+
const auditDataArr = [];
|
|
44
|
+
for (const field in config) {
|
|
45
|
+
if (!config.hasOwnProperty(field)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isObject(config[field])) {
|
|
50
|
+
const attributes = config[field];
|
|
51
|
+
for (const attributeName in attributes) {
|
|
52
|
+
if (attributeName === 'Policy Expiry') {
|
|
53
|
+
attributes[attributeName] = getDateInApiFormat(attributes[attributeName]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const selection = { policyName: field };
|
|
57
|
+
|
|
58
|
+
// Special attribute names switch
|
|
59
|
+
switch (attributeName) {
|
|
60
|
+
case 'Occur':
|
|
61
|
+
const occurKeys = getAttributeKey(attributeName);
|
|
62
|
+
selection.attributeName = occurKeys[field];
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
selection.attributeName = getAttributeKey(attributeName);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (isArray(attributes[attributeName])) {
|
|
70
|
+
selection.status = AUDIT_ENTITY_STATUSES[ attributes[attributeName][0] ];
|
|
71
|
+
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
72
|
+
} else {
|
|
73
|
+
// Special statuses switch
|
|
74
|
+
switch (selection.attributeName) {
|
|
75
|
+
case getAttributeKey('Policy Number'):
|
|
76
|
+
selection.status = emptyValue;
|
|
77
|
+
break;
|
|
78
|
+
case getAttributeKey('Policy Expiry'):
|
|
79
|
+
selection.status = AUDIT_ENTITY_STATUSES.YES;
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
selection.status = AUDIT_ENTITY_STATUSES[ (attributes[attributeName]).toUpperCase() ];
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
selection.value = getValueBySelection(attributes[attributeName]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
auditDataArr.push(selection);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
if (field === 'Certificate issue date') {
|
|
93
|
+
config[field] = getDateInApiFormat(config[field]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const selection = { attributeName: getAttributeKey(field) };
|
|
97
|
+
certificateEndorsmentsList.includes(field) && (selection.policyName = field);
|
|
98
|
+
|
|
99
|
+
if (isArray(config[field])) {
|
|
100
|
+
selection.status = AUDIT_ENTITY_STATUSES[ config[field][0] ];
|
|
101
|
+
selection.value = config[field][1]; // Ok to be undefined
|
|
102
|
+
} else {
|
|
103
|
+
selection.status = AUDIT_ENTITY_STATUSES[ config[field] ] || AUDIT_ENTITY_STATUSES.YES;
|
|
104
|
+
selection.value = getValueBySelection(config[field]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (field === 'AM Score') {
|
|
108
|
+
selection.status = VALID_SCORES.includes(selection.value) ? AUDIT_ENTITY_STATUSES.YES : AUDIT_ENTITY_STATUSES.NO;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
auditDataArr.push(selection);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return auditDataArr;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const createAuditEntity = (
|
|
118
|
+
requirement, {
|
|
119
|
+
policyName = null,
|
|
120
|
+
attributeName = null,
|
|
121
|
+
value = emptyValue,
|
|
122
|
+
status = emptyValue
|
|
123
|
+
}) => {
|
|
124
|
+
const policyId = getPolicyId(policyName, requirement);
|
|
125
|
+
const auditEntityModel = new auditModels.AuditEntityModel(policyId, attributeName, status, value);
|
|
126
|
+
return auditEntityModel;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const getAuditorId = () => {
|
|
130
|
+
return auth.services.getAuditorId();
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
module.exports = {
|
|
134
|
+
getParsedConfig,
|
|
135
|
+
getPolicyId,
|
|
136
|
+
createAuditEntity,
|
|
137
|
+
getAuditorId
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const certificateEndorsmentsList = [
|
|
141
|
+
'Waiver Of Subrogation',
|
|
142
|
+
'Certificate Holder',
|
|
143
|
+
'Additional Information',
|
|
144
|
+
'Additional Insured',
|
|
145
|
+
'Agreement'
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
const specialAttributes = {
|
|
149
|
+
'Certificate issue date': 'certIssueDate',
|
|
150
|
+
'Cancellation Terms': 'cancellationTerms',
|
|
151
|
+
'COI authentication': 'COIauthentication',
|
|
152
|
+
'AM Score': 'AMBestRating',
|
|
153
|
+
'Signature': 'signature',
|
|
154
|
+
|
|
155
|
+
'Insured Address': 'Insured Address',
|
|
156
|
+
'Insured Name': 'Insured Name',
|
|
157
|
+
|
|
158
|
+
'Additional Information': 'additionalInformation',
|
|
159
|
+
'Waiver Of Subrogation': 'waiverofsubrogation',
|
|
160
|
+
'Additional Insured': 'additionalInsured',
|
|
161
|
+
'Certificate Holder': 'certificateHolder',
|
|
162
|
+
|
|
163
|
+
'Coverage Exists': 'coverageexists',
|
|
164
|
+
'Coverage exists': 'coverageexists',
|
|
165
|
+
'Policy Number': 'policynumber',
|
|
166
|
+
'Policy Expiry': 'expirydate',
|
|
167
|
+
'Per Occur': 'PerOccur',
|
|
168
|
+
|
|
169
|
+
'Occur': {
|
|
170
|
+
'Excess Liability': 'EXoccur',
|
|
171
|
+
'Umbrella': 'UMoccur'
|
|
172
|
+
}
|
|
173
|
+
};
|