-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6413 from NMDSdevopsServiceAdm/spike/poc-for-bu-t…
…ransfer-staff-record-column Bulk upload - Transfer staff record
- Loading branch information
Showing
18 changed files
with
969 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
backend/server/models/BulkImport/csv/crossValidateErrors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const MAIN_JOB_ROLE_ERROR_CODE = 1280; | ||
const TRANSFER_STAFF_RECORD_BASE_ERROR_CODE = 1400; | ||
|
||
const MAIN_JOB_ERRORS = { | ||
RegisteredManagerWithoutCqcRegulatedService: Object.freeze({ | ||
errCode: MAIN_JOB_ROLE_ERROR_CODE, | ||
errType: 'MAIN_JOB_ROLE_ERROR', | ||
column: 'MAINJOBROLE', | ||
_sourceFieldName: 'mainJobRoleId', | ||
error: | ||
'Workers MAINJOBROLE is Registered Manager but you are not providing a CQC regulated service. Please change to another Job Role', | ||
}), | ||
}; | ||
|
||
const TRANSFER_STAFF_RECORD_ERRORS = { | ||
NewWorkplaceNotFound: Object.freeze({ | ||
errCode: TRANSFER_STAFF_RECORD_BASE_ERROR_CODE + 1, | ||
errType: 'TRANSFERSTAFFRECORD_ERROR', | ||
column: 'TRANSFERSTAFFRECORD', | ||
_sourceFieldName: 'transferStaffRecord', | ||
error: 'The LOCALESTID in TRANSFERSTAFFRECORD does not exist', | ||
}), | ||
SameLocalIdExistInNewWorkplace: Object.freeze({ | ||
errCode: TRANSFER_STAFF_RECORD_BASE_ERROR_CODE + 2, | ||
errType: 'TRANSFERSTAFFRECORD_ERROR', | ||
column: 'UNIQUEWORKERID', | ||
_sourceFieldName: 'uniqueWorkerId', | ||
error: | ||
"The UNIQUEWORKERID already exists in the LOCALESTID given in TRANSFERSTAFFRECORD. Use CHGUNIQUEWRKID to change this worker's UNIQUEWORKERID", | ||
}), | ||
SameRefsMovingToWorkplace: Object.freeze({ | ||
errCode: TRANSFER_STAFF_RECORD_BASE_ERROR_CODE + 3, | ||
errType: 'TRANSFERSTAFFRECORD_ERROR', | ||
column: 'UNIQUEWORKERID', | ||
_sourceFieldName: 'uniqueWorkerId', | ||
error: 'Duplicate UNIQUEWORKERID’s are being moved to the same LOCALESTID in TRANSFERSTAFFRECORD', | ||
}), | ||
}; | ||
|
||
const addCrossValidateError = (errorsArray, errorType, JSONWorker) => { | ||
const newErrorObject = { | ||
...errorType, | ||
worker: JSONWorker.uniqueWorkerId, | ||
name: JSONWorker.localId, | ||
lineNumber: JSONWorker.lineNumber, | ||
source: JSONWorker[errorType._sourceFieldName], | ||
}; | ||
delete newErrorObject._sourceFieldName; | ||
|
||
errorsArray.unshift(newErrorObject); | ||
}; | ||
|
||
module.exports = { | ||
addCrossValidateError, | ||
MAIN_JOB_ERRORS, | ||
TRANSFER_STAFF_RECORD_ERRORS, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.