Inception here means onboarding employees and dependents from an Excel upload (files.action = inception or related actions like missed_inception, addition, dependent_addition). The same three-step pipeline runs for those actions; this page focuses on the inception path.

Manual policy inception (form UI under policy_tranction/inception) is a separate flow in PolicyTransactionController — not covered by these three functions.

Overview

flowchart LR A["Upload Excel on employee upload"] --> B["excelFileFormatValidation"] B --> C["excelFileDataValidation"] C --> D["employeesOnboardPreprocess"] D --> E["employeesOnboardProcess plus policy_transaction"] B -->|errors| F["files.status failed"] C -->|errors| F D -->|no families inserted| F D -->|OK| G["files.status success"]

In short:

Key files and routes

AreaLocation
UI app/Views/employee_upload.php — client, branch, policy, action Inception, file upload
Upload handler EmployeeController::employeesUplodWithEvents
Pipeline logic EmployeeServiceController — the three functions on this page
Job dispatch app/Controllers/JobWorker.php — maps job names to EmployeeServiceController
Column / Excel helpers app/Helpers/excel_util_helper.phpcheck_columns_name, custom validators
Upload record files table via FileModelstatus, action, reason
Premium EB rack rate calculationcalculate_premium_new, employeesOnboardProcess

Routes (group /employee, filter authMVC):

REST upload (mobile/HR): POST employeeRest/employeeUpload — same pipeline via EmployeeRestController.

i
files.policy_id stores client policy id (client_policies.id), not the insurer policy master id. Slab/rack lookups use this id with client_id.

Sync vs background jobs

File sizeStep 1Steps 2–3
< 1 MB excelFileFormatValidation runs inline in the upload request Always queued: excelFileDataValidationemployeesOnboardPreprocess
≥ 1 MB Job excelFileFormatValidation Same job chain after format passes

After upload the UI usually shows files.status = inprogress until jobs finish. Poll notifications or refresh the upload list; use /employee/excel_error/{id} when status is failed.

Entry points

Job chain for inception (and missed_inception / addition / dependent_addition):

excelFileFormatValidationexcelFileDataValidationemployeesOnboardPreprocess

Step 1: excelFileFormatValidation

Runs on the uploaded sheet before any DB business rules.

Common format error codes

CodeMeaning
1Mandatory value missing
2Wrong format (e.g. date, mobile)
3Value not in allowed list
4Custom validation failed (DOB, relationship, SI, etc.)
5File / policy / slab configuration problem
6Column headers wrong or out of order

On failure: files.status = failed, reason JSON with row/column errors; user notification via pull notification.

Lead-policy branch: If inception file is for a policy created from leads (policy_entry_from == 3 and is_from_lead set), format validation queues compareMemberDataAndInceptionData instead of going straight to data validation.

files.reason shape (debugging)

Stored as JSON string on files.reason. Typical failure payload:

{
  "error_type": 1,
  "error_summary": { "4": 2, "1": 1 },
  "error_data": {
    "3": {
      "dob": { "error": ["Invalid date format"], "value": "01/01/1990" }
    }
  }
}

Step 2: excelFileDataValidation

Runs after format passes. Groups rows by EMP ID (family) and applies business rules.

flowchart TD A["Group rows by emp_id"] --> B{"Self in family?"} B -->|No| C["Error: Self not found"] B -->|Yes| D{"Duplicate name in family?"} D -->|Yes| E["Error: Twofold name"] D -->|No| F{"Emp code already in DB?"} F -->|Yes| G["Error: duplicate emp code"] F -->|No| H{"Dependents match policy terms?"} H -->|No| I["Dependent conflict errors"] H -->|Yes| J["Row OK for this family"]

Typical inception checks:

On success for inception: queues job employeesOnboardPreprocess. Other actions queue different jobs (deletion, correction, etc.).

Common data-validation error codes

CodeMeaning
7Duplicate name within same family in the Excel file
9Record already exists in DB (inception / addition)
10Record not found (used on deletion flows)
14Self row missing in family
26Duplicate employee code in file or DB

Step 3: employeesOnboardPreprocess

Calculates premium and writes members to the database.

  1. Reload Excel; group by emp_id.
  2. For each family: calculate_premium_new() using policy terms + slab rates + rack config.
  3. employeesOnboardProcess() — insert/update employees, employee_polices, create policy_transaction (inception).
  4. If at least one family inserted → files.status = success; else failed with rack-rate message.

Optional second path: client_policy_id without file_id — converts enrolled DB members to inception (enrollment → inception), not from Excel.

TPA batch: When batch_file_id is present on the job payload, success also queues updateEmployeeDataFromTpa, reconTpaApiDataWithEmployeepolicies, and initializeDeletionProcessForTpaApiData (multi-file TPA reconcile flow).

Inception Excel columns

Defined in EmployeeServiceController::$inception_excel_columns. Header row must match exactly — 19 columns (A–S), row 1 only. Dates use format d-M-Y (e.g. 4-Apr-1990). One Self row per EMP ID; other rows are dependents.

ColHeaderRequired (inception)Notes
AS.NoYes
BEMP IDYesFamily key
CNAME OF EMP/DEPYes
DDOBYesd-M-Y; age vs relationship checked
EGenderYesM / F (several casings allowed)
FRELATIONSHIPYesSelf, Spouse, Son, Daughter, …
GBASIC COVER SIConditionalValidated against slab when applicable
HDate of CoverageNoMandatory for addition / DA only
IDOJNo
JBasic PayNoUsed when policy terms need it
KBand/GradeNo
LDesignationNo
MPhoneNoMobile format; duplicate check
NEmailNoDuplicate check in file
OPRE EXISTING AILMENTSYes0 or 1
PChange eventNoNot used for pure inception
QDate of exitNoDeletion only
RReason for exitNoDeletion only
SUnitNoMust match branch units when filled

Sample file: use the download link on the employee upload screen (environment-specific).

Family row layout example

All rows with the same EMP ID (column B) are treated as one family. Step 2 requires exactly one Self row in that group; dependents share the same EMP ID. Step 3 runs premium and DB insert once per family.

Example: one employee (EMP001) with spouse and son — three data rows plus header.

Row S.No EMP ID NAME DOB Gender RELATIONSHIP BASIC COVER SI PED
1Header row (all 19 columns A–S required in file)
2 1 EMP001 Raj Kumar 15-Jan-1985 M Self 500000 0
3 2 EMP001 Priya Kumar 20-Mar-1988 F Spouse 500000 0
4 3 EMP001 Arjun Kumar 10-Jun-2015 M Son 500000 0

Rules illustrated:

A second employee in the same file uses a different EMP ID (e.g. EMP002) with its own Self row — each EMP ID is a separate family loop in preprocess.

Developer steps

  1. Confirm policy has policy_terms JSON and slab/rack rates for the client policy.
  2. Upload via /employee/upload with action inception; note file_id in response or files table.
  3. If status = failed, call GET /employee/excel_error/{file_id} or read files.reason.
  4. Map error_data row keys back to Excel (row 1 = header).
  5. If format passes but preprocess fails with rack message, debug calculate_premium_new (see rack-rate doc) and SI/slab config.
  6. For stuck inprogress, check job queue / JobWorker logs for the three job names.

Common pitfalls