Skip to content

Salary Components (مكونات الراتب)

Define earnings and deductions that make up an employee's salary structure — basic salary allowance, housing, transportation, social insurance deduction, etc.

Attributes

FieldTypeDescription
idintegerPrimary key
name_arstringArabic name
name_enstringEnglish name (nullable)
codestringUnique code
component_typeenumearning or deduction
calculation_typeenumfixed or percentage
default_amountdecimalDefault fixed amount
percentage_ofstringBase field for percentage calculation (nullable)
is_mandatorybooleanAuto-applied to all employees
is_taxablebooleanSubject to tax
is_activebooleanActive status
display_orderintegerSort order on payslip

API Endpoints

MethodURLDescription
GET/api/hr/salary-componentsList components
POST/api/hr/salary-componentsCreate 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: percentage uses default_amount as the percentage value (e.g., 25 = 25%)
  • percentage_of specifies which base field the percentage applies to (typically basic_salary)
  • Mandatory components are auto-applied via the "Apply Mandatory" salary structure endpoint
  • Components are ordered by display_order on payslips

Moon ERP API Documentation