Skip to content

m-hr-core Module

Core HR primitives: Employee, Designation, Department, PayScale.


class Employee(BaseDocType):
"""Legacy ERP Employee record."""
# Identity
personal_number: str = Field(max_length=20, unique=True)
first_name: str = Field(max_length=100)
middle_name: str | None = None
last_name: str = Field(max_length=100)
# Dates
date_of_birth: date
joining_date: date
confirmation_date: date | None = None
retirement_date: date | None = None # Calculated from DOB
# Classification
category: str | None = None # SC, ST, OBC, General
sex: str # M, F
employee_type: str = "Permanent" # Permanent, Casual, Deputationist
employee_group: str # A, B, C, D
# Posting
depot: str # FK to Depot
section: str # FK to Section/Department
designation: str # FK to Designation
pay_scale: str # FK to PayScale
# Pay
current_basic: Decimal = Decimal("0")
special_pay: Decimal = Decimal("0")
personal_pay: Decimal = Decimal("0")
# Contact
address_line_1: str | None = None
address_line_2: str | None = None
city: str | None = None
pincode: str | None = None
contact_number: str | None = None
home_town: str | None = None
# Qualifications
educational_qualification: str | None = None
# Status
status: str = "Active" # Active, Retired, Resigned, Deceased, Missing
seniority_position: int | None = None
# Recruitment
recruitment_type: str | None = None # SSC, LocalPanel, Compassionate
call_letter_number: str | None = None
# Flags
is_local: bool = False
is_temporarily_transferred: bool = False
from_surplus_cell: bool = False
remarks: str | None = None
class Meta:
table_name = "employee"
indexes = ["personal_number", "depot", "designation", "status"]
class EmployeeFamily(BaseDocType):
"""Employee family members for medical claims, pension nomination."""
employee: str # FK to Employee
serial_no: int
first_name: str
middle_name: str | None = None
surname: str | None = None
relationship: str # Spouse, Son, Daughter, Father, Mother
date_of_birth: date | None = None
is_nominee: bool = False
marital_status: str | None = None
educational_qualification: str | None = None
medical_history: str | None = None
class Meta:
table_name = "employee_family"
indexes = ["employee"]
class Designation(BaseDocType):
"""Job designation with qualification requirements."""
code: str = Field(max_length=20, unique=True)
name: str = Field(max_length=200)
group: str # A, B, C, D
# Requirements
essential_qualification: str | None = None
desirable_qualification: str | None = None
minimum_age: int | None = None
maximum_age: int | None = None
# Reservation relaxation
max_relaxation_sc: int | None = None
max_relaxation_st: int | None = None
# Promotion
mandatory_years_for_promotion: int | None = None
class Meta:
table_name = "designation"
class Department(BaseDocType):
"""Legacy ERP Section/Department hierarchy."""
code: str = Field(max_length=20, unique=True)
name: str = Field(max_length=200)
description: str | None = None
parent: str | None = None # FK self-referential
location: str = "HO" # HO, Depot, Both
class Meta:
table_name = "department"
class PayScale(BaseDocType):
"""Government pay scales with effective dates."""
code: str = Field(max_length=20, unique=True)
pay_scale: str # e.g., "15600-39100"
start_pay: Decimal
end_pay: Decimal
middle_pay: Decimal | None = None
starting_increment: Decimal
middle_increment: Decimal | None = None
effective_from: date
govt_order_number: str | None = None
class Meta:
table_name = "pay_scale"
class Roster200Point(BaseDocType):
"""200-point reservation roster for recruitment."""
point_number: int = Field(ge=1, le=200, unique=True)
reserved_for: str # SC, ST, OBC, UR (Unreserved)
class Meta:
table_name = "roster_200_point"

Endpoint Method Description
/api/v1/employee GET, POST List/Create employees
/api/v1/employee/{id} GET, PUT Employee CRUD
/api/v1/employee/{id}/family GET, POST Family members
/api/v1/designation GET, POST Designations
/api/v1/department GET, POST Departments
/api/v1/pay-scale GET, POST Pay scales

Event When
employee.created New employee added
employee.status_changed Status update (retired, etc.)
employee.transferred Depot/Section change
employee.promoted Designation change