State Master
Navigation Path
Company → Masters → State Master
1. State List Page
URL
/masters/state-master
Page Description
- Displays a list of all states configured in the system
- Allows filtering based on state name
- Provides actions to add, edit, and delete state records
Filter & Search Section
| Field Name | Type | Description |
|---|---|---|
| State Name | Text Input | Filters the list by state name |
Actions:
- Search → Filters states based on entered state name
- Reset → Clears filter and reloads the full list
List Table Columns
| Column Name | Description |
|---|---|
| S No | Serial number |
| Country | Country associated with the state |
| State Name | Name of the state |
| Company PF No | Company PF number mapped to the state |
| Actions | Edit and Delete options |
Row Actions
| Action | Description |
|---|---|
| Edit | Opens Edit State page with pre-filled data |
| Delete | Opens delete confirmation alert |
2. Add State Page
Triggered From
State List Page → Add State button
Page Description
- Allows admins to add a new state and associate it with a country
- Company PF number can be configured per state
Add State – Fields
| Field Name | Type | Mandatory | Description |
|---|---|---|---|
| Country | Dropdown | Yes | Select country from the list |
| State Name | Text Input | Yes | Enter the state name |
| Company PF No | Text Input | No | Enter Company PF number for the state |
Actions
| Action | Behavior |
|---|---|
| Save | Validates and saves the state |
| Reset | Clears all entered values |
| Cancel | Returns to State List page |
Validation Rules
- Country must be selected
- State Name cannot be empty
- Duplicate state names are not allowed within the same country
3. Edit State Page
/masters/state-master/edit/:id
Triggered From
State List Page → Edit icon
Page Description
- Allows updating existing state details
- All fields are pre-filled with saved data
Editable Fields
| Field Name | Editable |
|---|---|
| Country | Yes |
| State Name | Yes |
| Company PF No | Yes |
Actions
| Action | Behavior |
|---|---|
| Update | Saves changes |
| Cancel | Discards changes and navigates back |
4. Delete State Confirmation Alert
Triggered From
State List Page → Delete icon
Alert Content
- Confirmation message before deletion
Actions:
- Confirm / Yes → Deletes the state
- Cancel → Closes the alert without action
Delete Behavior
- State is removed permanently after confirmation
- If the state is mapped to other records, deletion may be restricted
5. Filter by State Name
Search Flow
- Enter State Name in the search field
- Click Search
Result
- Displays only states matching the entered state name
Field Definitions, Usage, and Calculation Logic
This section provides a technical analysis of the State Master's data structure and its role in geographical and statutory reporting.
1. Field Definitions
| Field Name | Data Type | Description | Example Value |
|---|---|---|---|
stateName | String | Official name of the state (Required). | Maharashtra |
Country | String | Parent country (Required). | INDIA |
CompanyPFNo | String | PF Registration Number specific to the state. | MH/BAN/12345 |
code | String | Internal alphanumeric code for the state. | ST001 |
companyId | ObjectId | Reference to the parent Company. | 60d8a... |
2. Field Usage & System Impact
| Category | Validation / Rule | System Behavior |
|---|---|---|
| Uniqueness | stateName + companyId | Enforced unique index to prevent duplicate states within the same company. |
| PF Compliance | CompanyPFNo | Used to populate statutory forms and PF return files for employees in this state. |
| Data Partitioning | companyId | Ensures multi-tenant isolation; states are company-specific. |
3. Business & Calculation Logic
The State Master serves as a foundational geographical entity with the following technical logic:
A. Bulk Import Engine
The system supports a consolidated import process via the /all-in-one-state-import endpoint:
- Mapping: The Excel column
descriptionis automatically mapped to thestateNamefield. - Deduplication: Before insertion, the system checks for existing records by
stateName. If found, it updates theCompanyPFNoandCountry; otherwise, it creates a new record. - Normalization: All inputs are processed using
.trim()to eliminate accidental duplicates caused by trailing spaces. - Defaulting: If the country is not specified in the import file, the system defaults it to
INDIA.
B. Relational Integrity
State records are primary parents for Districts and Cities. Deleting a state (via soft-delete isDeleted.status: true) hide it from selection dropdowns, but historical data in employee records remains intact for audit purposes.
The State Master module interacts with the following API endpoints:
Base URL
export const STATE_URL = '/api/stateMaster'
Endpoints
| Endpoint | Method | Description | Parameters/Body |
|---|---|---|---|
${STATE_URL} | POST | Create a new state master | Body: data |
${STATE_URL} | GET | Get all state masters | Query: page, limit |
${STATE_URL}/:stateId | GET | Get state master by ID | Path: stateId |
${STATE_URL}/:stateId | PATCH | Update an existing state master | Path: stateId, Body: body |
${STATE_URL}/delete/:stateId | PATCH | Delete a state master | Path: stateId |
RTK Query Hooks
The following hooks are available for frontend integration:
useCreateStateMasterMutationuseGetAllStateMastersQueryuseGetStateMasterByIdQueryuseUpdateStateMasterMutationuseDeleteStateMasterMutation
End of Documentation