Deletion removes active members from a client policy via Excel upload (files.action = deletion). Unlike inception, the final step does not delete rows immediately — it creates pending endorsement records on employee_polices for approval/processing later.

Core processing lives in EmployeeServiceController::employeeDisembark. EmployeeController::initializeDeletionProcessForTpaApiData is a separate TPA-reconcile path that builds a deletion Excel file and calls the same disembark function.

Overview

flowchart LR A["Upload Excel action deletion"] --> B["excelFileFormatValidation"] B --> C["excelFileDataValidation"] C --> D["employeeDisembark job"] D --> E["emp_endorsement pending rows"] B -->|errors| F["files.status failed"] C -->|errors| F D -->|always| G["files.status success"]

In short:

Key files and routes

AreaLocation
UI app/Views/employee_upload.php — action Deletion
Upload EmployeeController::employeesUplodWithEvents
Validation EmployeeServiceController::excelFileFormatValidation, excelFileDataValidation
Deletion process EmployeeServiceController::employeeDisembark
TPA auto-deletion EmployeeController::initializeDeletionProcessForTpaApiData
Job employeeDisembark in JobWorker.php
Endorsements EmpEndorsementModelemp_endorsement (actions = d, status = pending)

Routes (group /employee, authMVC):

i
files.policy_id is the client policy id. Member lookup joins employees + employee_polices on that policy and branch.

Sync vs background jobs

Step< 1 MB≥ 1 MB
Format validationInline on uploadJob excelFileFormatValidation
Data validationJob excelFileDataValidationSame
DisembarkJob employeeDisembarkSame

Step 1: excelFileFormatValidation

Format error codes

CodeMeaning
1Mandatory missing
2Wrong format
3Not in allowed list
4Custom validation failed
5File / policy problem
6Column headers wrong

Step 2: excelFileDataValidation

Rows are grouped by EMP ID. For deletion, the main check is name_and_empid_check_in_db:

On success → queues employeeDisembark (not employeesOnboardPreprocess).

Step 3: employeeDisembark

Loads the Excel again and processes each non-empty row.

flowchart TD A["Match emp_code plus name on active policy"] --> B{"Found?"} B -->|No| C["Log error skip row"] B -->|Yes| D{"Pending deletion endorsement?"} D -->|Yes| E["Log skip row"] D -->|No| F{"Relationship Self?"} F -->|No| G["Endorse this member only"] F -->|Yes| H["Endorse all active family members"] G --> I["emp_endorsement pending"] H --> I

Per matched member, four pending endorsement rows are inserted on employee_polices:

Returns an array of processed employee.id values. Sets files.status = success when the loop finishes (even if some rows were skipped — check logs for “not found” or “existing endorsement pending”).

TPA auto-deletion (EmployeeController)

initializeDeletionProcessForTpaApiData($file_id):

  1. Reads TPA reconcile file context (tpa_api_data, action_flag_status = D).
  2. Builds candidate members and writes writable/uploads/excel/tpa_auto_deletion_{fileId}_{timestamp}.xls.
  3. Inserts a new files row with action = deletion.
  4. Calls employeeDisembark(['file_id' => $newFileId]) synchronously.
  5. Exports endorsement data for TPA via getDeletionEmployeeDataForExportExcel.

Deletion Excel columns

ColHeaderRequiredNotes
AS.NoYes
BEMP IDYesEmployee / family code
CNAME OF EMP/DEPYesMust match DB name exactly
DChange eventYese.g. deletion
EDate of exitYesd-M-Y
FReason for exitYes
GClaim statusYes0 or 1

Row layout examples

Delete one dependent — only that name appears; Self row is not required in the file.

RowEMP IDNAMEChange eventDate of exitReasonClaim
2EMP001Arjun Kumardeletion19-May-2026Resigned0

Result: endorsements for Arjun only (relationship ≠ Self).

Delete entire family — list the Self row; disembark loads all active family members for that EMP ID.

RowEMP IDNAMEChange eventDate of exitReasonClaim
2EMP001Raj Kumardeletion19-May-2026Resigned0

Result: pending endorsements for Self + all active dependents on that policy (same exit date/reason/claim from the row).

Developer steps

  1. Upload via /employee/upload with action deletion; note file_id.
  2. If validation fails, use GET /employee/excel_error/{file_id} — look for code 10 (member not in DB).
  3. After success, query emp_endorsement where file_id = upload id, actions = 'd', status = 'pending'.
  4. If rows were skipped, search logs for not found or Existing endorsement pending.
  5. TPA path: trace initializeDeletionProcessForTpaApiData and the generated tpa_auto_deletion_*.xls file.

Common pitfalls

Related: Inception (onboard pipeline uses the same upload screen and first two validation steps).