Method is used to register new employee or to update an existing one. There is 2 different flows of registration depend on whether the employee has tax_id or doesn't have.
Authorize user
Validate MIS API Key
Check MIS scopes employee_request:write in order to perform this action
In case error - generate 401 response
Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
See service specification
Validate DRFO
Check that DRFO in Certificate details exists and not empty
Check that DRFO in Certificate details is equal to DRFO of the user that creates employee_request in Party
Get party.tax_id using user_id in declaration payload
Compare DRFO in Certificate with party.tax_id
Convert DRFO and TAX_ID to uppercase
Compare DRFO and TAX_ID as Cyrillic letters
Convert DRFO to Cyrillic and compare as Cyrillic letters
In case validation fails - generate 422 error
Latin to Cyrillic mapping using legal table
Validate request (JSON schema)
Validate request using JSON schema
In case validation fails - generate 422 error
Validate $.party.documents.[].number according to regexp and document type:
PASSPORT -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
NATIONAL_ID -
^[0-9]{9}$
COMPLEMENTARY_PROTECTION_CERTIFICATE -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
REFUGEE_CERTIFICATE -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
TEMPORARY_CERTIFICATE -
^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$
TEMPORARY_PASSPORT -
^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$
in case of error - return 422 ('string does not match pattern') with the corresponding regexp
Validate request (Logic)
Check employee_type: Employee configurable validation rules and dictionaries
If employee_id is passed in the payload:
search employees by employee_id
if not found - return error 404
check that employee_type not in (OWNER, PHARMACY_OWNER)
in case of error - return 409 “Forbidden to create <employee_type>“
check employee_type and tax_id (or passport_id, if no_tax_id: true)
If dosn't match, return error 409 “<field> doesn't match"
check that employee is active (status = APPROVED and is_active = true)
in case of error - return 409 “employee is <status>“
Check allowed employee types for legal_entity type: Legal_Entity_Type vs Employee_Type validation rules
if not found - return error 404
Validate legal entity type status for current legal entity: status should be active or suspended
Check that documents.[x].type contain values from
IDENTITY_DOCUMENT_TYPESEMPLOYEE_IDENTITY_DOCUMENT_TYPES chart parameterin case of error - return 422 (“Submitted document type is not allowed“)
Check that document types NATIONAL_ID and PASSPORT both do not exist in request
in case of error - return 422 ('Employee can have only one of following document types [\"PASSPORT\", \"NATIONAL_ID\"]')
Alternative notation 2 of validation :
Save signed declaration to media storage
Get url for declaration upload.
Use Request a Secret WS
Parameter | Source |
---|---|
action | 'GET' |
bucket | 'EMPLOYEE_REQUESTS' |
resource_id | : EMPLOYEE_REQUEST_ID |
resource_name | : signed_employee_request |
Upload signed declaration to media storage
Create employee request
Create employee request in IL_DB table - employee_request.
generate GUID and writte in id column
write JSON object with employee request details
Send activation link on email
Generate activation link, which contains Employee request GUID
Send activation URL on user email
invoke service - Send message
See service specification