Skip to main content

Task 18: Auto Employee Number Generation

Test Cases

IDScenarioExpected ResultStatus
T18-01Create a new employee under entity "Hayo" without entering an employee numberEmployee is created with number HAYO-001 (or next in sequence)
T18-02Create a second employee under entity "Hayo"Employee number is HAYO-002 (increments from previous)
T18-03Create an employee under a different entity (e.g., "Slick")Employee number starts with SLICK-001 (independent sequence)
T18-04Try to send employee_number manually in the create API payloadRequest is rejected with 422 validation error (employee_number is prohibited)
T18-05Try to update an existing employee's employee_number via APIRequest is rejected with 422 validation error (employee_number is prohibited)
T18-06Import CSV with blank employee_number columnEmployees are created with auto-generated numbers
T18-07Import CSV without the employee_number column at allImport succeeds; employees get auto-generated numbers
T18-08Import CSV with explicit employee_number values providedEmployees are created with the provided numbers (backward compatible)

Demo Walkthrough

Creating an Employee (UI)

  1. Navigate to Employees → click New Employee.
  2. Select an Entity (e.g., "Hayo") and a department.
  3. Notice the Employee Number field shows "Auto-generated after creation" — no manual input needed.
  4. Fill in required fields (work email, first name, last name, role).
  5. Click "Create & Next".
  6. Verify the created employee now shows an employee number like HAYO-001 in the detail view.
  7. Create another employee under the same entity → verify the number increments (e.g., HAYO-002).
  8. Switch entity to "Slick" → create an employee → verify the number is SLICK-001 (separate sequence).

Editing an Employee (UI)

  1. Open an existing employee in edit mode.
  2. Verify the Employee Number field is displayed but disabled (greyed out, read-only).
  3. Confirm you cannot type into it or change the value.

CSV Import with Auto-Generation

  1. Navigate to Employees → click Import CSV/Excel.
  2. Prepare a CSV with required columns but leave employee_number blank or remove the column entirely.
  3. Upload the file.
  4. Verify the import succeeds and imported employees have auto-generated numbers matching their entity prefix.

API Validation

  1. Send a POST to /api/employees with an employee_number field included → verify 422 error with employee_number in validation errors.
  2. Send a PATCH to /api/employees/{id} with an employee_number field → verify 422 error.