Frontend
Masters
Department

Department Master

Navigation Path

Company → Masters → Department Master


1. Department List Page

URL

/masters/department-master

Page Description

  • Displays a list of all departments configured in the system
  • Allows admins to manage organizational departments
  • Provides actions to add, edit, and delete department records

List Table Columns

Column NameDescription
S NoSerial number
Department NameName of the department
DescriptionDepartment description
ActionsEdit and Delete options

Row Actions

ActionDescription
EditOpens Edit Department page with pre-filled data
DeleteOpens delete confirmation alert

2. Add Department Page

Triggered From

Department List Page → Add Department button

Page Description

  • Allows admins to create a new department
  • Used for employee mapping, reporting, and organizational structure

Add Department – Fields

Field NameTypeMandatoryDescription
Department NameText InputYesEnter department name
DescriptionText InputNoEnter department description

Actions

ActionBehavior
SaveValidates and saves the department
ResetClears all entered values
CancelReturns to Department List page

Validation Rules

  • Department Name is mandatory
  • Duplicate department names are not allowed

3. Edit Department Page

Triggered From

Department List Page → Edit icon

Page Description

  • Allows updating existing department details
  • All fields are pre-filled with saved data

Editable Fields

Field NameEditable
Department NameYes
DescriptionYes

Actions

ActionBehavior
UpdateSaves changes
CancelDiscards changes and navigates back

4. Delete Department Confirmation Alert

Triggered From

Department List Page → Delete icon

Alert Content

  • Confirmation message before deletion

Actions:

  • Confirm / Yes → Deletes the department
  • Cancel → Closes the alert without action

Delete Behavior

  • Department is removed permanently after confirmation
  • Deletion may be restricted if the department is mapped to employees or other records


Field Definitions, Usage, and Calculation Logic

This section provides a technical analysis of the Department Master's data structure and its role in organizational hierarchy.

1. Field Definitions

Field NameData TypeDescriptionExample Value
departmentNameStringOfficial name of the department (Required).Human Resources
companyIdObjectIdReference to the parent Company.60a8b...
isDeletedObjectSoft-delete state and audit metadata.{ status: false, ... }

2. Field Usage & System Impact

CategoryValidation / RuleSystem Behavior
CategorizationdepartmentNamePrimary label for grouping employees in reports and organizational charts.
IntegrityUnique IndexA partial index ensures departmentName is unique for active records within a company.
LifecycleSoft-DeleteEnsures historical data (e.g., old payroll runs) keeps its reference to the department even after it's deactivated.

3. Business & Calculation Logic

The Department Master operates as a foundational entity for organizational reporting.

A. Unique Identity Management

The system enforces department uniqueness using a MongoDB partial index:

  • Scope: The uniqueness of departmentName is only evaluated where isDeleted.status is false.
  • Tenant Isolation: All operations are strictly partitioned by companyId, allowing different tenants to have overlapping department names.

B. Bulk Import Engine

The allInOneDepartmentImport logic facilitates the mass upload of organizational structures:

  • Mapping: It maps the Excel description column directly to departmentName.
  • Upsert Strategy: If a department with the same name exists (and is not deleted), it updates the existing record with any new metadata; otherwise, a new department is initialized.
  • Error Handling: Missing descriptions or duplicate names in the import file are captured in an error log returned to the user, ensuring partial success for valid rows.

C. Relational Integrity

Departments are a mandatory reference in Designations, Units, and Employee Profiles. Deletion is logically restricted at the controller level if active employee records are still assigned to the department.


The Department Master module interacts with the following API endpoints:

Base URL

export const DEPARTMENT_URL = '/api/departmentMaster'

Endpoints

EndpointMethodDescriptionParameters/Body
${DEPARTMENT_URL}POSTCreate a new departmentBody: data
${DEPARTMENT_URL}GETGet all departmentsQuery: page, limit
${DEPARTMENT_URL}/:departmentIdGETGet department by IDPath: departmentId
${DEPARTMENT_URL}/:departmentIdPATCHUpdate an existing departmentPath: departmentId, Body: body
${DEPARTMENT_URL}/delete/:departmentIdPATCHDelete a departmentPath: departmentId

RTK Query Hooks

The following hooks are available for frontend integration:

  • useCreateDepartmentMutation
  • useGetAllDepartmentsQuery
  • useGetDepartmentByIdQuery
  • useUpdateDepartmentMutation
  • useDeleteDepartmentMutation

End of Documentation