# Employee Module — Rule-wise QA Test Cases

**Source:** [`EMPLOYEE_MODULE_GUIDE.md`](./EMPLOYEE_MODULE_GUIDE.md) / PDF  
**Style:** প্রতিটি job card / section → **What you can do** + **Rules → Test cases** (input কেমন behave করবে)  
**Permission / role** আলাদা ছোট অংশে আছে (শেষে) — এখানে মূল কাজ business rule verify করা।

**Marks:** ☐ Pass · ❌ Fail · N/A

---

# Card 0 — Prerequisites (Guide §3, §11)

### What must exist first
- Active employee-type user (login) in the company  
- Configuration masters: Departments, Designations, Employment types, Salary structures, Document types  

### Rules → Test cases

| ID | Rule | Test case (input → expected) | ☐ |
|---|---|---|---|
| TC-0.1 | Setup needs an eligible user | User missing / inactive / not `employee` type → not selectable or save rejected with clear message | |
| TC-0.2 | User already linked | User already has a profile in this company → cannot create second profile | |
| TC-0.3 | Department master required | No active department → organization assign fails / empty list | |
| TC-0.4 | Designation master required | No active designation → organization assign fails | |
| TC-0.5 | Employment type required | No active employment type → employment save fails | |
| TC-0.6 | Salary structure required | No active structure → salary create fails | |
| TC-0.7 | Document type required | No active document type → document upload fails | |
| TC-0.8 | Company scope | Data of company A never appears in company B | |

---

# Card 1 — Screens (Guide §4)

### What you can do
- Browse **Employee list**  
- **Setup / Create** new profile  
- **View** profile (read-only)  
- **Edit** profile (sections/tabs)  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-1.1 | List is searchable | Search by name / employee_no returns matching rows only | |
| TC-1.2 | View is read-only | On `/view`, no save; fields not editable | |
| TC-1.3 | Edit allows changes | On edit route, permitted fields save successfully | |
| TC-1.4 | Tabs = sections | Each section opens its own tab content | |

---

# Card 2 — New employee setup (Guide §5)

### What you can do
1. Pick unlinked company login  
2. Fill Personal → Contact → Address → Identities → Employment → Organization  
3. Optionally: bank, salary, tax, education, experience, documents, assets, managers, notes  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-2.1 | Happy path order | Complete core sections in order → profile created and editable | |
| TC-2.2 | Completion % rises | After each core section save, % increases | |
| TC-2.3 | Optional can wait | Skip bank/salary → still can finish core file | |
| TC-2.4 | Partial save | Stop after personal+contact → employee appears in list; % incomplete | |
| TC-2.5 | Import alternate path | Valid CSV/XLSX creates rows; invalid rows fail with downloadable errors | |

---

# Card 3 — Profile completion % (Guide §6)

### What counts
**Core (counts):** Personal, Contact, Address, Identities, Employment, Organization  
**Helpful (not required for core):** Bank, Salary  
**Does not count:** Education, Documents  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-3.1 | Core raises % | Fill only personal → % > 0; fill all six core → high/complete | |
| TC-3.2 | Missing one core | Leave Identities empty → % stays incomplete | |
| TC-3.3 | Education ignored | Add education only → % does **not** rise for completion formula | |
| TC-3.4 | Documents ignored | Upload documents only → % unchanged for core formula | |
| TC-3.5 | Bank/salary optional | Add bank/salary without claiming they are required for “core complete” | |

---

# Card 4 — Personal information (Guide §7.1)

### What you can do
- Link a login user  
- Set employee number, names, status, photo  
- See profile completion %  

### Rules → Test cases

| ID | Rule | Test case (input → expected) | ☐ |
|---|---|---|---|
| TC-4.1 | Employee number unique in company | Same `employee_no` twice → **rejected** | |
| TC-4.2 | Unique employee number OK | New unique `employee_no` → **accepted** | |
| TC-4.3 | One login = one profile | Link user already tied to a profile → **rejected** | |
| TC-4.4 | Linked user must be active employee-type | Inactive / wrong type user → **rejected** | |
| TC-4.5 | Photo allowed types | jpg / png / webp ≤ ~2MB → **accepted** | |
| TC-4.6 | Photo rejected | >2MB or unsupported type → **rejected** | |
| TC-4.7 | Remove photo | Remove → photo cleared | |
| TC-4.8 | DOB not in future | Future date of birth → **rejected** | |
| TC-4.9 | DOB today/past | Valid past/today DOB → **accepted** | |
| TC-4.10 | Employee number immutable on edit | Edit mode: `employee_no` disabled / change attempt ignored or rejected | |
| TC-4.11 | Own profile cannot change status | Self-update: status field blocked or stripped on save | |
| TC-4.12 | Required name fields | Empty required name → **rejected** | |

---

# Card 5 — Contact information (Guide §7.2)

### What you can do
- Maintain official/personal email, mobiles, emergency contact  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-5.1 | Only one contact per employee | Second contact create → **rejected** | |
| TC-5.2 | Official email unique | Duplicate official email in company → **rejected** | |
| TC-5.3 | Mobile unique (usual rule) | Duplicate mobile → **rejected** | |
| TC-5.4 | Emergency ≠ own mobile | Emergency phone = employee mobile → **rejected** | |
| TC-5.5 | Valid contact | Unique emails/phones, emergency different → **accepted** | |
| TC-5.6 | Update existing | Change email/phone on the single record → **accepted** | |

---

# Card 6 — Addresses (Guide §7.3)

### What you can do
- Create **Present** address  
- Create **Permanent** address  
- Copy present → permanent (“same as present”)  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-6.1 | Only one present | Second present → **rejected** | |
| TC-6.2 | Only one permanent | Second permanent → **rejected** | |
| TC-6.3 | Address line 1 required | Empty line 1 → **rejected** | |
| TC-6.4 | Line 1 filled | Valid present with line 1 → **accepted** | |
| TC-6.5 | Same as present | Create present + same-as-present, no permanent yet → permanent **created as copy** | |
| TC-6.6 | Same as present when permanent exists | Behaviour: no illegal duplicate permanent | |
| TC-6.7 | Both types | One present + one permanent → both stored | |

---

# Card 7 — Identities (Guide §7.4)

### What you can do
- Add NID / Passport / Birth certificate / Driving license  
- Attach scan  
- Remove/archive identity  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-7.1 | Types available | Each of the four types can be created | |
| TC-7.2 | Doc number unique per type in company | Same type + same number twice → **rejected** | |
| TC-7.3 | Different type same number | Allowed if product only uniques per type (verify) | |
| TC-7.4 | Expiry before issue | Expiry &lt; issue date → **rejected** | |
| TC-7.5 | Expiry on/after issue | Valid range → **accepted** | |
| TC-7.6 | Attachment allowed | pdf / image attach → **accepted** | |
| TC-7.7 | Bad attachment | Invalid type / oversize → **rejected** | |
| TC-7.8 | Remove archives | Delete/remove → archived/history kept (not silent hard wipe) | |

---

# Card 8 — Employment (Guide §7.5)

### What you can do
- Create the single employment record  
- Set status: Probation (default), Confirmed, Active, Resigned, Terminated  
- Set work mode: Onsite, Remote, Hybrid  
- Set joining, confirmation, probation  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-8.1 | One employment only | Second employment create → **rejected** | |
| TC-8.2 | Default status | New employment defaults to Probation (or configured default) | |
| TC-8.3 | Confirmation ≥ joining | Confirmation before joining → **rejected** | |
| TC-8.4 | Confirmation on/after joining | Valid → **accepted** | |
| TC-8.5 | Probation end ≥ joining | Probation end before joining → **rejected** | |
| TC-8.6 | Probation calculated | Enter period (days/weeks/months) → end date computed from joining | |
| TC-8.7 | Employment type from active master | Inactive type → not selectable / **rejected** | |
| TC-8.8 | Active type OK | Active employment type → **accepted** | |
| TC-8.9 | Own edit cannot change status | Self-update changes status → **blocked/stripped** | |
| TC-8.10 | Status change audited | HR changes Probation→Confirmed → activity/history recorded | |
| TC-8.11 | Work modes | Onsite / Remote / Hybrid each save correctly | |

---

# Card 9 — Organization assignment (Guide §7.6)

### What you can do
- **Create** first placement (department + designation + effective dates)  
- **Transfer** later (new dept/title, date, reason)  
- Keep history of old placements  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-9.1 | Department required | Missing department → **rejected** | |
| TC-9.2 | Designation required | Missing designation → **rejected** | |
| TC-9.3 | First create OK | No current assignment → Create succeeds; is current | |
| TC-9.4 | No second current | Current exists + Create again → **rejected**; message points to Transfer | |
| TC-9.5 | Transfer closes old | Transfer → old `is_current=false` / ended; new is current | |
| TC-9.6 | Transfer reason required | Empty reason → **rejected** | |
| TC-9.7 | Transfer date ≥ current start | Date before current start → **rejected** | |
| TC-9.8 | Same-day transfer | Transfer date = current start → **accepted** | |
| TC-9.9 | History kept | After transfer, old placement still visible in history | |
| TC-9.10 | Inactive masters | Inactive dept/designation → **rejected** | |

---

# Card 10 — Reporting managers & team leads (Guide §7.7)

### Who the employee reports to

**Two relationship types**

| Type | Meaning |
|---|---|
| Reporting Manager | Formal line manager |
| Team Lead | Team lead (more flexible) |

### What you can do
- **Assign** a manager / team lead  
- **Change** the current one  
- **End** the relationship without replacing  
- View **current** and **past** history  

### Rules → Test cases

| ID | Rule | Test case (input → expected) | ☐ |
|---|---|---|---|
| TC-10.1 | Same company only | Manager from another company → **rejected** | |
| TC-10.2 | Same company OK | Manager in same company → **accepted** | |
| TC-10.3 | Cannot be own manager | Select self as manager → **rejected** | |
| TC-10.4 | No circular reporting | A reports to B, then B reports to A → **rejected** | |
| TC-10.5 | Deeper cycle | A→B→C→A → **rejected** | |
| TC-10.6 | End date before start | End &lt; start → **rejected** | |
| TC-10.7 | End date on/after start | Valid range → **accepted** | |
| TC-10.8 | Change: new manager must differ | Change to same manager → **rejected** | |
| TC-10.9 | Change: date ≥ current start | Change date before current relationship start → **rejected** | |
| TC-10.10 | Change: valid new manager + date | Different manager, valid date → old ended, new current | |
| TC-10.11 | Only one current reporting manager | Second **Assign** while current RM exists → **rejected** (must use Change) | |
| TC-10.12 | Use Change not Assign | When RM exists, Change succeeds; Assign fails | |
| TC-10.13 | Assign when none | No current RM → Assign succeeds | |
| TC-10.14 | Multiple team leads allowed | Second Team Lead while one exists → **accepted** (per config) | |
| TC-10.15 | End without replace | End current RM → no current RM; history retained | |
| TC-10.16 | Timeline on Assign | Assign → timeline event created | |
| TC-10.17 | Timeline on Change | Change → timeline event created | |
| TC-10.18 | Timeline on End | End → timeline event created | |
| TC-10.19 | History view | Past + current relationships both visible | |
| TC-10.20 | Team Lead vs RM | Creating Team Lead does not block / replace Reporting Manager (independent types) | |

---

# Card 11 — Bank accounts (Guide §7.8)

### What you can do
- Add bank accounts (name, branch, account, routing, mobile banking, primary)  
- Set primary  
- Update / delete  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-11.1 | First account auto-primary | First create with no primary flag → becomes primary | |
| TC-11.2 | Set primary clears others | Mark B primary → A no longer primary | |
| TC-11.3 | Only one primary | After any set-primary, exactly one primary remains | |
| TC-11.4 | Delete primary promotes another | Delete primary while others exist → another becomes primary | |
| TC-11.5 | Delete last account | Last account delete → no accounts left | |
| TC-11.6 | Account number masked | UI shows masked number (not full cleartext) | |
| TC-11.7 | Approval on (if enabled) | Create/update/delete → **pending**; not final until approved | |
| TC-11.8 | Approval off | Create/update/delete → immediate final | |
| TC-11.9 | Reject approval | Pending change rejected → original data unchanged | |

---

# Card 12 — Salary (Guide §7.9)

### What you can do
- Create salary against active structure  
- Types: Gross, Basic, Hourly, Contract  
- Frequencies: Daily, Weekly, Bi-weekly, Monthly  
- Activate / deactivate  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-12.1 | Needs active structure | Inactive / missing structure → **rejected** | |
| TC-12.2 | Structure requires basic | `requires_basic` + empty basic → **rejected** | |
| TC-12.3 | Basic ≤ gross | Basic &gt; gross → **rejected** | |
| TC-12.4 | Amounts positive | Zero/negative amount where required → **rejected** | |
| TC-12.5 | Valid amounts | Basic &gt; 0 and ≤ gross → **accepted** | |
| TC-12.6 | Effective date ≥ joining | Effective before joining → **rejected** | |
| TC-12.7 | Employment must exist | No employment → salary create **rejected** | |
| TC-12.8 | One Active only | Create new Active while one Active exists → previous becomes Inactive | |
| TC-12.9 | Explicit deactivate | Deactivate Active → status Inactive | |
| TC-12.10 | Types / frequencies / currency | Each allowed value saves; default currency BDT | |

---

# Card 13 — Tax profile (Guide §7.10)

### What you can do
- Create TIN / zone / circle / exemption / remarks once  
- Later update same record  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-13.1 | Only one tax profile | Second create → **rejected** | |
| TC-13.2 | Create then update | First create OK; later update edits same row | |
| TC-13.3 | Fields persist | TIN, zone, circle, exemption, remarks round-trip correctly | |

---

# Card 14 — Education (Guide §7.11)

### What you can do
- Add degrees/certificates with optional PDF  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-14.1 | Passing year not future | Future year → **rejected** | |
| TC-14.2 | Passing year past/current | Valid year → **accepted** | |
| TC-14.3 | Attachment PDF ~2MB | Valid PDF → **accepted** | |
| TC-14.4 | Bad attachment | Non-PDF or &gt;2MB → **rejected** | |
| TC-14.5 | Does not raise core % | After add, completion % formula unchanged | |

---

# Card 15 — Experience (Guide §7.12)

### What you can do
- Add previous jobs with optional PDF  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-15.1 | Resignation ≥ joining | Resignation before joining → **rejected** | |
| TC-15.2 | Valid date range | Resignation on/after joining → **accepted** | |
| TC-15.3 | Attachment PDF ~2MB | Same as education limits | |

---

# Card 16 — Documents (Guide §7.13)

### What you can do
- Upload, preview, download  
- Replace (versioning)  
- See version history  
- Delete a version  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-16.1 | Active document type only | Inactive type → **rejected** | |
| TC-16.2 | Expiry required when type says so | `requires_expiry` + empty expiry → **rejected** | |
| TC-16.3 | Expiry provided | Required expiry filled → **accepted** | |
| TC-16.4 | Restricted without permission | Restricted type without special perm → **denied/filtered** | |
| TC-16.5 | Restricted with permission | With restricted perm → can view/upload | |
| TC-16.6 | Replace only current | Replace current → new current; old kept in history | |
| TC-16.7 | Delete current promotes previous | Delete current → latest remaining becomes current | |
| TC-16.8 | File type/size | pdf / image / Word ≤ ~5MB → OK; else **rejected** | |
| TC-16.9 | Preview / download | Current (and allowed versions) open/download | |
| TC-16.10 | Does not raise core % | Upload alone does not complete profile % | |

---

# Card 17 — Assets (Guide §7.14)

### What you can do
- Assign asset(s) (name, code, assigned date)  
- Return as returned / damaged / lost (+ remarks)  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-17.1 | Unique assignment of code | Same asset code already assigned to someone → **rejected** | |
| TC-17.2 | Assign free code | Unassigned code → **accepted** | |
| TC-17.3 | Assigned date not future | Future date → **rejected** | |
| TC-17.4 | Assigned date today/past | Valid → **accepted** | |
| TC-17.5 | Only current can return | Return already-returned asset → **rejected** | |
| TC-17.6 | Return statuses | returned / damaged / lost each succeed with remarks | |
| TC-17.7 | Inventory freed | After return, same code assignable again | |
| TC-17.8 | Timeline | Assign and return each create timeline events | |

---

# Card 18 — Notes (Guide §7.15)

### What you can do
- Create internal notes with visibility + optional attachment  
- Edit/delete (author / HR rules)  

### Visibility

| Visibility | Who can read |
|---|---|
| Private | Only author |
| HR | Author + users with employee create or update |
| Manager | Author + users with employee update |

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-18.1 | Private isolation | Other user cannot read Private note | |
| TC-18.2 | HR visibility | User with create/update can read HR notes | |
| TC-18.3 | Manager visibility | User with update can read Manager notes; create-only may not | |
| TC-18.4 | Create → timeline | New note creates timeline event | |
| TC-18.5 | Author edit/delete | Author can edit/delete own note | |
| TC-18.6 | Non-author blocked | Other employee cannot edit/delete author’s note | |
| TC-18.7 | Attachment limits | pdf/image/Word ≤ ~5MB OK; else rejected | |

---

# Card 19 — Timeline (Guide §7.16)

### What you can do
- See chronological HR events  
- Add manual events (title, type, date)  

### Event types
Join, Confirmation, Transfer, Promotion, Manager Change, Document Upload, Note Created, Asset Assigned, Asset Returned, Resignation, Termination, Other  

### Rules → Test cases

| ID | Rule | Test case | ☐ |
|---|---|---|---|
| TC-19.1 | Auto from manager | Assign/change/end manager → Manager Change (or equivalent) appears | |
| TC-19.2 | Auto from asset | Assign/return → Asset events appear | |
| TC-19.3 | Auto from note | Note create → Note Created appears | |
| TC-19.4 | Manual requires title+type+date | Missing any → **rejected** | |
| TC-19.5 | Manual complete | All required filled → **accepted** | |
| TC-19.6 | Chronological | Events ordered by date | |

---

# Card 20 — Day-to-day workflows (Guide §8)

এগুলো multi-step E2E — উপরের card rules একসাথে।

### WF-A — Transfer employee

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-A1 | Prerequisite | Current org assignment exists | |
| TC-WF-A2 | Transfer | New dept + designation + date + reason → success | |
| TC-WF-A3 | History | Old closed; new current | |

### WF-B — Change reporting manager

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-B1 | None → Assign | Assign works | |
| TC-WF-B2 | Exists → Change | Change works; Assign fails | |
| TC-WF-B3 | End | End leaves no current | |
| TC-WF-B4 | Timeline | Each action logged | |

### WF-C — Change salary

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-C1 | Joining exists | Employment present | |
| TC-WF-C2 | New Active | Previous Active → Inactive | |
| TC-WF-C3 | Deactivate | Active → Inactive without replacement | |

### WF-D — Replace document

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-D1 | Upload | Against correct type | |
| TC-WF-D2 | Replace | New current; old in history | |

### WF-E — Assign & return asset

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-E1 | Assign | With date | |
| TC-WF-E2 | Return | Status + remarks; code free | |

### WF-F — Bank with approval

| ID | Step / rule | Test case | ☐ |
|---|---|---|---|
| TC-WF-F1 | Submit | Pending if approval on | |
| TC-WF-F2 | Approve | Change becomes final | |
| TC-WF-F3 | Reject | Change not applied | |

### WF-G — New joiner checklist (Guide §14)

| ID | Check | ☐ |
|---|---|---|
| TC-WF-G1 | Active user exists | |
| TC-WF-G2 | Personal + unique employee_no | |
| TC-WF-G3 | Contact + address + identities | |
| TC-WF-G4 | Employment | |
| TC-WF-G5 | Dept + designation | |
| TC-WF-G6 | Reporting manager (if needed) | |
| TC-WF-G7 | Bank + salary (if payroll ready) | |
| TC-WF-G8 | Required documents | |
| TC-WF-G9 | Assets (if any) | |
| TC-WF-G10 | Profile % reviewed | |

### WF-H — Leave / exit (Guide §14)

| ID | Check | ☐ |
|---|---|---|
| TC-WF-H1 | Employment → Resigned / Terminated | |
| TC-WF-H2 | End/change manager | |
| TC-WF-H3 | Return assets | |
| TC-WF-H4 | Documents + timeline intact | |

---

# Card 21 — Common problems (Guide §12) — reproduce & confirm message

| ID | Symptom | Reproduce | Expected meaning | ☐ |
|---|---|---|---|---|
| TC-21.1 | Cannot find user in setup | Inactive / wrong type / already linked | Clear reason | |
| TC-21.2 | Cannot save dept/designation | Master missing/inactive | Clear reason | |
| TC-21.3 | Cannot create org again | Current exists | Use Transfer | |
| TC-21.4 | Cannot assign RM | Current exists / self / circular | Use Change or fix relation | |
| TC-21.5 | Salary date rejected | Before joining / no employment | Clear validation | |
| TC-21.6 | Document rejected | Type/size/expiry/restricted | Clear validation | |
| TC-21.7 | Bank not visible yet | Approval pending | Pending state shown | |
| TC-21.8 | Profile % stuck low | Core incomplete | Missing section identifiable | |

---

# Appendix — Permission / role checks (secondary)

এগুলো **আলাদা suite** — business rule cards পাস হওয়ার পর চালানো যায়।

| ID | Check | ☐ |
|---|---|---|
| PERM-01 | Without `employee.menu-view` → module hidden / denied | |
| PERM-02 | Setup/import need `employee.create` | |
| PERM-03 | Most mutations need `employee.update` | |
| PERM-04 | Bank section needs `employee.view-bank` | |
| PERM-05 | Salary section needs `employee.view-salary` | |
| PERM-06 | Documents need `employee.view-documents` | |
| PERM-07 | Restricted docs need `employee.view-restricted-documents` | |
| PERM-08 | `update-own-profile`: own personal/employment only; **no status** | |
| PERM-09 | Status dropdown in UI: `administrator` role slug | |
| PERM-10 | View-only role: all mutate APIs 403 | |
| PERM-11 | Cross-company IDOR blocked | |

Detail matrix: [`ROLE_BASED_QA_CHECKLIST.md`](./ROLE_BASED_QA_CHECKLIST.md)

---

## Suggested run order

1. Card 0 prerequisites  
2. Cards 4–10 **core rules** (especially Card 10 reporting — example style)  
3. Cards 11–19 supporting sections  
4. Card 20 workflows  
5. Card 21 common problems  
6. Appendix permissions  

---

*প্রতিটি TC = Guide-এর একটা rule। Fail হলে bug-এ Guide section + Rule + input + expected vs actual লিখবে।*
