Sub Department Master
The Sub Department Master provides a finer level of organizational classification, allowing companies to divide primary departments into specialized functional units. This facilitates more granular employee mapping and precise operational reporting.
Navigation Path
Company → Masters → Sub Department Master
1. Sub Department List Page
URL
/masters/sub-department-master
Page Description
- Displays a flat list of all sub-departments configured within the current company.
- Allows administrators to manage functional units for employee assignments.
- Features a real-time search interface to handle organizational complexity.
Filter & Search Section
| Field Name | Type | Description |
|---|---|---|
| Search | Text Input | Performs a case-insensitive search across sub-department names. |
Actions:
- Search → Filters the list based on the search query.
- Reset → Clears search and reloads all records.
List Table Columns
| Column Name | Description |
|---|---|
| S No | Serial number. |
| Sub Department Name | The official name of the sub-department. |
| Actions | Edit and Delete options. |
Row Actions
| Action | Description |
|---|---|
| Edit | Opens the Edit Sub Department drawer/form with pre-filled data. |
| Delete | Opens a delete confirmation alert for soft-deletion. |
2. Add Sub Department Page
Triggered From
Sub Department List Page → Add Sub Department button
Page Description
- Allows administrators to create a new sub-department entry.
- Records created here are available for selection in the Employee and Client master modules.
Add Sub Department – Fields
| Field Name | Type | Mandatory | Description |
|---|---|---|---|
| Sub Department Name | Text Input | Yes | Enter the unique name for the sub-department. |
Actions
| Action | Behavior |
|---|---|
| Save | Validates the name and saves the new record. |
| Reset | Clears the input field. |
| Cancel | Returns to the Sub Department List page. |
Validation Rules
- Sub Department Name is mandatory.
- Duplicate names are not allowed within the same company context.
- System automatically trims whitespace to prevent identical-looking duplicates.
3. Edit Sub Department Page
Triggered From
Sub Department List Page → Edit icon
Page Description
- Allows administrators to rename existing sub-departments.
- Changes are propagated across the system to all linked records.
Editable Fields
| Field Name | Editable |
|---|---|
| Sub Department Name | Yes |
Actions
| Action | Behavior |
|---|---|
| Update | Saves the modified name and refreshes the list view. |
| Cancel | Discards changes and returns to the list. |
4. Delete Confirmation Alert
Triggered From
Sub Department List Page → Delete icon
Alert Content
- "Are you sure you want to delete this Sub Department?"
Actions:
- Confirm / Yes → Sets the
isDeleted.statustotrue. - Cancel → Closes the alert.
Field Definitions, Usage, and Calculation Logic
1. Technical Field Definitions
| Field Name | Data Type | Description | Example Value |
|---|---|---|---|
subdepartmentName | String | Official name of the sub-department (Required). | Quality Control |
companyId | ObjectId | Reference to the parent Company. | 60d8a... |
2. Field Usage & System Impact
| Category | Validation / Rule | System Behavior |
|---|---|---|
| Mapping | EmployeeProfile | Used as a primary filter in HR reports and payroll group generation. |
| Data Partitioning | companyId | Multi-tenant isolation; sub-departments are company-specific. |
| Search Engine | Regex Search | Backend uses $regex with i option for flexible searching. |
3. Business Logic
A. Soft Delete Implementation
Sub-departments are protected by a soft-delete mechanism. This prevents orphans in the employee master while ensuring that deleted sub-departments no longer appear in active dropdown selections.
B. Indexing & Performance
The system uses a compound unique index on { companyId, subdepartmentName, "isDeleted.status" }. This ensures that while a sub-department name is unique for active records, a previously deleted name can be recreated if necessary.
API Endpoints
Base URL
export const SUBDEPARTMENT_URL = '/api/subdepartmentMaster'
Endpoints
| Endpoint | Method | Description | Parameters/Body |
|---|---|---|---|
${SUBDEPARTMENT_URL} | POST | Create a new sub-department | Body: data |
${SUBDEPARTMENT_URL} | GET | Get all active records | Query: page, limit |
${SUBDEPARTMENT_URL}/:id | GET | Get details by ID | Path: subdepartmentId |
${SUBDEPARTMENT_URL}/:id | PATCH | Update an existing record | Path: id, Body: body |
${SUBDEPARTMENT_URL}/delete/:id | PATCH | Soft delete a record | Path: id |
${SUBDEPARTMENT_URL}/search | GET | Filtered search | Query: search, page |
RTK Query Hooks
Available in subdepartmentMasterSlice.js:
useCreateSubdepartmentMutationuseGetAllSubdepartmentsQueryuseGetSubdepartmentByIdQueryuseUpdateSubdepartmentMutationuseDeleteSubdepartmentMutationuseSearchSubdepartmentsQuery
Summary
The Sub Department Master provides the granular organizational structure needed for detailed employee tracking and departmental accountability in complex corporate environments.
End of Documentation