Salary Structures (هياكل الرواتب)
Assign salary components to individual employees with custom amounts, effective date ranges, and calculation overrides.
Attributes
| Field | Type | Description |
|---|---|---|
id | integer | Primary key |
employee_id | integer | Employee FK |
salary_component_id | integer | Salary Component FK |
amount | decimal | Fixed amount or percentage value |
calculation_type | enum | fixed or percentage |
percentage_value | decimal | Percentage value (nullable) |
effective_from | date | Start date |
effective_to | date | End date (nullable = ongoing) |
is_active | boolean | Active status |
API Endpoints
| Method | URL | Description |
|---|---|---|
GET | /api/hr/employees/{id}/salary-structure | List employee's salary components |
POST | /api/hr/employees/{id}/salary-structure | Assign component to employee |
POST | /api/hr/salary-structures/apply-mandatory | Apply all mandatory components to employees |
Examples
bash
# View employee salary breakdown
curl -X GET "https://moon-erp.elbaset.com/api/hr/employees/1/salary-structure" \
-H "Authorization: Bearer {token}"
# Assign a component
curl -X POST "https://moon-erp.elbaset.com/api/hr/employees/1/salary-structure" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"salary_component_id": 3,
"amount": 500,
"calculation_type": "fixed",
"effective_from": "2026-03-01"
}'
# Apply all mandatory components
curl -X POST "https://moon-erp.elbaset.com/api/hr/salary-structures/apply-mandatory" \
-H "Authorization: Bearer {token}"dart
// View employee salary breakdown
final response = await dio.get('/api/hr/employees/1/salary-structure');
// Assign a component
final response = await dio.post('/api/hr/employees/1/salary-structure', data: {
'salary_component_id': 3,
'amount': 500,
'calculation_type': 'fixed',
'effective_from': '2026-03-01',
});Business Rules
- Each employee can have multiple salary components with different effective dates
- The breakdown endpoint returns all active components for the employee with computed amounts
- "Apply Mandatory" auto-assigns all mandatory salary components to employees who don't have them
- When
effective_tois null, the component is considered ongoing - Historical structures (past
effective_to) are kept for payroll audit trail