Salary Components (مكونات الراتب)
Define earnings and deductions that make up an employee's salary structure — basic salary allowance, housing, transportation, social insurance deduction, etc.
Attributes
| Field | Type | Description |
|---|---|---|
id | integer | Primary key |
name_ar | string | Arabic name |
name_en | string | English name (nullable) |
code | string | Unique code |
component_type | enum | earning or deduction |
calculation_type | enum | fixed or percentage |
default_amount | decimal | Default fixed amount |
percentage_of | string | Base field for percentage calculation (nullable) |
is_mandatory | boolean | Auto-applied to all employees |
is_taxable | boolean | Subject to tax |
is_active | boolean | Active status |
display_order | integer | Sort order on payslip |
API Endpoints
| Method | URL | Description |
|---|---|---|
GET | /api/hr/salary-components | List components |
POST | /api/hr/salary-components | Create component |
GET | /api/hr/salary-components/{id} | Show component |
PUT | /api/hr/salary-components/{id} | Update component |
DELETE | /api/hr/salary-components/{id} | Delete component |
Examples
bash
# Create an earning component
curl -X POST "https://moon-erp.elbaset.com/api/hr/salary-components" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name_ar": "بدل سكن",
"name_en": "Housing Allowance",
"code": "HOUSING",
"component_type": "earning",
"calculation_type": "percentage",
"percentage_of": "basic_salary",
"default_amount": 25,
"is_mandatory": true,
"is_taxable": false
}'
# Create a deduction component
curl -X POST "https://moon-erp.elbaset.com/api/hr/salary-components" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name_ar": "تأمينات اجتماعية",
"name_en": "Social Insurance",
"code": "GOSI",
"component_type": "deduction",
"calculation_type": "percentage",
"percentage_of": "basic_salary",
"default_amount": 10,
"is_mandatory": true
}'dart
final response = await dio.post('/api/hr/salary-components', data: {
'name_ar': 'بدل سكن',
'name_en': 'Housing Allowance',
'code': 'HOUSING',
'component_type': 'earning',
'calculation_type': 'percentage',
'percentage_of': 'basic_salary',
'default_amount': 25,
'is_mandatory': true,
});Business Rules
calculation_type: percentageusesdefault_amountas the percentage value (e.g., 25 = 25%)percentage_ofspecifies which base field the percentage applies to (typicallybasic_salary)- Mandatory components are auto-applied via the "Apply Mandatory" salary structure endpoint
- Components are ordered by
display_orderon payslips