Frontend
Masters
Sub Department

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 NameTypeDescription
SearchText InputPerforms 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 NameDescription
S NoSerial number.
Sub Department NameThe official name of the sub-department.
ActionsEdit and Delete options.

Row Actions

ActionDescription
EditOpens the Edit Sub Department drawer/form with pre-filled data.
DeleteOpens 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 NameTypeMandatoryDescription
Sub Department NameText InputYesEnter the unique name for the sub-department.

Actions

ActionBehavior
SaveValidates the name and saves the new record.
ResetClears the input field.
CancelReturns 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 NameEditable
Sub Department NameYes

Actions

ActionBehavior
UpdateSaves the modified name and refreshes the list view.
CancelDiscards 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.status to true.
  • Cancel → Closes the alert.

Field Definitions, Usage, and Calculation Logic

1. Technical Field Definitions

Field NameData TypeDescriptionExample Value
subdepartmentNameStringOfficial name of the sub-department (Required).Quality Control
companyIdObjectIdReference to the parent Company.60d8a...

2. Field Usage & System Impact

CategoryValidation / RuleSystem Behavior
MappingEmployeeProfileUsed as a primary filter in HR reports and payroll group generation.
Data PartitioningcompanyIdMulti-tenant isolation; sub-departments are company-specific.
Search EngineRegex SearchBackend 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

EndpointMethodDescriptionParameters/Body
${SUBDEPARTMENT_URL}POSTCreate a new sub-departmentBody: data
${SUBDEPARTMENT_URL}GETGet all active recordsQuery: page, limit
${SUBDEPARTMENT_URL}/:idGETGet details by IDPath: subdepartmentId
${SUBDEPARTMENT_URL}/:idPATCHUpdate an existing recordPath: id, Body: body
${SUBDEPARTMENT_URL}/delete/:idPATCHSoft delete a recordPath: id
${SUBDEPARTMENT_URL}/searchGETFiltered searchQuery: search, page

RTK Query Hooks

Available in subdepartmentMasterSlice.js:

  • useCreateSubdepartmentMutation
  • useGetAllSubdepartmentsQuery
  • useGetSubdepartmentByIdQuery
  • useUpdateSubdepartmentMutation
  • useDeleteSubdepartmentMutation
  • useSearchSubdepartmentsQuery

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