HRM Module - Complete Analysis Report

Generated: 2026-04-08 | Moon ERP v0.6.0 | Backend: Laravel | Frontend: Angular 21

1. Module Overview

33
Backend Models
138
API Endpoints
34
Database Tables
27
Enums
19
Frontend Components
23
Frontend Services
13
Frontend Models
175
Backend Tests

Sub-Modules (27 total)

#Sub-ModuleBackendFrontendEndpointsStatus
1DepartmentsCompleteComplete6Fully implemented
2PositionsCompleteComplete5Fully implemented
3EmployeesCompletePartial8Missing: documents, dependents, some fields
4ShiftsCompleteComplete5Fully implemented
5SchedulesCompleteMissing4No frontend implementation
6SettingsCompleteComplete2Fully implemented
7AttendanceCompleteComplete5Fully implemented
8Attendance CorrectionsCompleteMissing2No frontend implementation
9Leave TypesCompleteComplete5Fully implemented
10Leave BalancesCompleteMissing3No frontend implementation
11Leave RequestsCompleteComplete7Fully implemented
12Salary ComponentsCompleteComplete5Fully implemented
13Salary StructuresCompleteMissing3No frontend implementation
14PayrollCompleteComplete9Fully implemented
15LoansCompleteComplete6Fully implemented
16Job OpeningsCompleteComplete6Fully implemented
17CandidatesCompleteComplete5Fully implemented
18Job ApplicationsCompletePartial5Nested in candidates, no pipeline view
19Job OffersCompleteMissing5Service only, no UI component
20KPIsCompleteComplete5Fully implemented
21Review TemplatesCompleteComplete5Inside KPIs (2-tab view)
22Performance ReviewsCompleteComplete7Fully implemented
23Training ProgramsCompleteComplete5Inside Training (3-tab view)
24Training SessionsCompleteComplete5Inside Training (3-tab view)
25Training EnrollmentsCompleteComplete3Inside Training (3-tab view)
26End of ServiceCompleteComplete6Fully implemented
27ReportsCompleteComplete66 report types

2. Backend Architecture

Directory Structure

/home/moonerpelbaset/moon_erp/Modules/HRM/
├── app/
│   ├── Enums/          (27 enum classes)
│   ├── Http/
│   │   ├── Controllers/ (26 controllers)
│   │   ├── Requests/    (59 form request classes)
│   │   └── Resources/   (33 API resources)
│   ├── Models/          (33 Eloquent models)
│   └── Services/        (11 business logic services)
├── database/
│   ├── migrations/      (34 migration files)
│   └── seeders/         (4 seeder classes)
├── routes/
│   └── api.php          (180+ route definitions)
└── Providers/
    └── EventServiceProvider.php

Key Architectural Patterns

  • Service-Oriented: Business logic in dedicated Services (PayrollService, EosService, etc.)
  • Multi-Level Approval: Leave requests, loans, EOS settlements
  • Company Multi-tenancy: All models scoped by company_id
  • Audit Trail: created_by / updated_by on all tables
  • Soft Deletes: Data preserved with SoftDeletes trait
  • Enum Type Safety: All statuses use PHP Enums
  • Bilingual: name_ar + name_en on all entities
  • Accounting Integration: Payroll and EOS post journal entries

3. Frontend Architecture

Directory Structure

/home/moonui/public_html/moon-erp/src/app/
├── features/hr/
│   ├── attendance/          (hr-attendance.component)
│   ├── candidates/          (hr-candidates.component)
│   ├── dashboard/           (hr-dashboard.component)
│   ├── departments/         (hr-departments.component)
│   ├── employees/           (hr-employees.component)
│   ├── eos/                 (hr-eos.component)
│   ├── job-openings/        (hr-job-openings.component)
│   ├── kpis/                (hr-kpis.component - 2 tabs)
│   ├── leave-requests/      (hr-leave-requests.component)
│   ├── leave-types/         (hr-leave-types.component)
│   ├── loans/               (hr-loans.component)
│   ├── payroll/             (hr-payroll.component)
│   ├── performance-reviews/ (hr-performance-reviews.component)
│   ├── positions/           (hr-positions.component)
│   ├── reports/             (hr-reports.component - 6 types)
│   ├── salary-components/   (hr-salary-components.component)
│   ├── settings/            (hr-settings.component)
│   ├── shifts/              (hr-shifts.component)
│   └── training/            (hr-training.component - 3 tabs)
├── core/
│   ├── services/hr-*.service.ts  (23 services)
│   ├── models/hr-*.model.ts      (13 model files)
│   └── store/hr/                  (8 NgRx slices, 24 files)
└── assets/i18n/{ar,en}.json       (129+ HR keys)

Component Details

ComponentRoutePermissionFeatures
Dashboard/hr/dashboard(none)Workforce stats, charts, payroll summary, quick actions
Departments/hr/departmentshrm.departmentsCRUD, hierarchy tree, manager link, branch link
Positions/hr/positionshrm.positionsCRUD, salary ranges, department link
Employees/hr/employeeshrm.employeesCRUD, 4-tab form, status management
Shifts/hr/shiftshrm.shiftsCRUD, night shift toggle, grace period
Attendance/hr/attendancehrm.attendanceCRUD, check-in/out, filters, status tags
Leave Types/hr/leave-typeshrm.leave-typesCRUD, carry-forward, gender rules
Leave Requests/hr/leave-requestshrm.leave-requestsCRUD, approve/reject, multi-level
Salary Components/hr/salary-componentshrm.salary-componentsCRUD, earning/deduction, mandatory flag
Payroll/hr/payrollhrm.payrollCRUD, calculate, approve, post, pay lifecycle
Loans/hr/loanshrm.loansCRUD, approve, installment tracking
EOS/hr/eoshrm.eosCRUD, preview calc, approve, pay
Job Openings/hr/job-openingshrm.job-openingsCRUD, publish/close, vacancy tracking
Candidates/hr/candidateshrm.candidatesCRUD, nested applications sub-dialog
KPIs/hr/kpishrm.kpis2-tab: KPI definitions + Review Templates
Performance Reviews/hr/performance-reviewshrm.performance-reviewsCRUD, self/manager review, scoring
Training/hr/traininghrm.training3-tab: Programs + Sessions + Enrollments
Reports/hr/reportshrm.reports6 reports: workforce, attendance, leave, payroll, loans, turnover
Settings/hr/settingshrm.settingsKey-value HR configuration (~25 settings)

Services (23 total)

ServiceAPI BaseKey Methods
HrDepartmentService/api/hr/departmentsCRUD + listAll
HrPositionService/api/hr/positionsCRUD + listAll
HrEmployeeService/api/hr/employeesCRUD + terminate()
HrShiftService/api/hr/shiftsCRUD + listAll
HrAttendanceService/api/hr/attendanceCRUD + checkIn() + checkOut()
HrLeaveTypeService/api/hr/leave-typesCRUD + listAll
HrLeaveRequestService/api/hr/leave-requestsCRUD + approve() + reject() + cancel()
HrSalaryComponentService/api/hr/salary-componentsCRUD + listAll
HrPayrollService/api/hr/payrollCRUD + calculate() + approve() + post() + pay()
HrLoanService/api/hr/loansCRUD + approve() + reject() + cancel()
HrEosService/api/hr/eosCRUD + calculate() + approve() + pay()
HrJobOpeningService/api/hr/job-openingsCRUD + publish() + close()
HrCandidateService/api/hr/candidatesCRUD + listAll
HrApplicationService/api/hr/applicationsCRUD + updateStatus()
HrOfferService/api/hr/offersCRUD + send() + accept() + reject()
HrKpiService/api/hr/kpisCRUD + listAll
HrReviewTemplateService/api/hr/review-templatesCRUD + listAll
HrPerformanceReviewService/api/hr/performance-reviewsCRUD + submit() + approve() + complete()
HrTrainingProgramService/api/hr/training-programsCRUD + listAll
HrTrainingSessionService/api/hr/training-sessionsCRUD + listAll
HrTrainingEnrollmentService/api/hr/training-enrollmentsCRUD + listAll
HrReportService/api/hr/reportsworkforce, attendance, leave, payroll, loans, turnover
HrSettingsService/api/hr/settingsgetAll() + update()

4. API Endpoints Reference (138 total)

Departments (6)

MethodEndpointDescription
GET/api/hr/departmentsList (filters: search, branch_id, status, parent_id)
POST/api/hr/departmentsCreate (name_ar*, name_en*, code, parent_id, manager_id, branch_id)
GET/api/hr/departments/treeHierarchical tree view
GET/api/hr/departments/{id}Show single
PUT/api/hr/departments/{id}Update
DEL/api/hr/departments/{id}Delete (fails if has employees)

Positions (5)

MethodEndpointDescription
GET/api/hr/positionsList (filters: search, department_id, status)
POST/api/hr/positionsCreate (name_ar*, name_en*, code, department_id, grade, min/max_salary)
GET/api/hr/positions/{id}Show single
PUT/api/hr/positions/{id}Update
DEL/api/hr/positions/{id}Delete (fails if has employees)

Employees (8)

MethodEndpointDescription
GET/api/hr/employeesList (filters: search, department_id, position_id, branch_id, status, contract_type, manager_id)
POST/api/hr/employeesCreate (multipart/form-data: personal + employment + bank + documents[] + contacts[] + dependents[])
GET/api/hr/employees/{id}Show with relations
PUT/api/hr/employees/{id}Update
DEL/api/hr/employees/{id}Soft-delete (fails if has payroll/attendance)
PUT/api/hr/employees/{id}/statusChange status (active, on_leave, suspended, terminated, resigned)
POST/api/hr/employees/{id}/documentsUpload document (max 5MB)
DEL/api/hr/employees/{id}/documents/{doc}Delete document

Shifts (5)

MethodEndpointDescription
GET/api/hr/shiftsList (filter: status)
POST/api/hr/shiftsCreate (name_ar*, name_en*, start_time*, end_time*, break, grace, night_shift)
GET/api/hr/shifts/{id}Show
PUT/api/hr/shifts/{id}Update
DEL/api/hr/shifts/{id}Delete (fails if has future schedules)

Schedules (4)

MethodEndpointDescription
GET/api/hr/schedulesList (filters: employee_id, department_id, shift_id, date_from/to)
POST/api/hr/schedules/bulkBulk create (employee_ids*, shift_id*, date_from/to*, days_of_week*)
PUT/api/hr/schedules/{id}Update (shift_id, date, actual_start/end, status)
DEL/api/hr/schedules/{id}Delete

Attendance (5) + Corrections (2)

MethodEndpointDescription
GET/api/hr/attendanceList (filters: employee_id, date_from/to, status)
POST/api/hr/attendance/check-inCheck in (employee_id*, time, source)
POST/api/hr/attendance/check-outCheck out (attendance_id*, time, source)
POST/api/hr/attendance/bulkBulk check-in (employee_ids, date*, time*)
GET/api/hr/attendance/summarySummary (employee_id*, date_from*, date_to*)
POST/api/hr/attendance/correctionsSubmit correction (attendance_id*, corrected times, reason*)
PUT/api/hr/attendance/corrections/{id}/approveApprove/reject (action*: approve|reject)

Leave Types (5) + Balances (3) + Requests (7)

MethodEndpointDescription
GET/api/hr/leave-typesList (filters: search, is_active)
POST/api/hr/leave-typesCreate (name*, code*, max_days*, is_paid, carry_over, gender)
GET/api/hr/leave-types/{id}Show
PUT/api/hr/leave-types/{id}Update
DEL/api/hr/leave-types/{id}Delete
GET/api/hr/leave-balancesList (filters: employee_id, fiscal_year, leave_type_id)
POST/api/hr/leave-balances/initializeInitialize for all active employees (fiscal_year*)
PUT/api/hr/leave-balances/{id}/adjustAdjust balance (days*, reason*)
GET/api/hr/leave-requestsList (filters: employee_id, status, leave_type_id, date_from/to)
POST/api/hr/leave-requestsCreate & auto-submit (employee_id*, leave_type_id*, dates*, reason)
GET/api/hr/leave-requests/calendarCalendar view (date_from*, date_to*)
GET/api/hr/leave-requests/{id}Show
POST/api/hr/leave-requests/{id}/approveApprove (comments)
POST/api/hr/leave-requests/{id}/rejectReject (comments*)
POST/api/hr/leave-requests/{id}/cancelCancel (restores balance)

Salary Components (5) + Structures (3)

MethodEndpointDescription
GET/api/hr/salary-componentsList (filters: search, component_type, is_active)
POST/api/hr/salary-componentsCreate (name*, code*, type*: earning|deduction, calc_type, amount)
GET/api/hr/salary-components/{id}Show
PUT/api/hr/salary-components/{id}Update
DEL/api/hr/salary-components/{id}Delete
GET/api/hr/employees/{id}/salary-structureList employee salary structure
POST/api/hr/employees/{id}/salary-structureAssign component (component_id*, amount, effective_from*)
POST/api/hr/salary-structures/apply-mandatoryApply all mandatory components to active employees

Payroll (9)

MethodEndpointDescription
GET/api/hr/payrollList (filters: year, status)
POST/api/hr/payrollCreate (month*, year*, notes)
GET/api/hr/payroll/{id}Show with items
POST/api/hr/payroll/{id}/calculateCalculate salaries for all active employees
POST/api/hr/payroll/{id}/approveApprove payroll
POST/api/hr/payroll/{id}/postPost to accounting (creates journal entries)
POST/api/hr/payroll/{id}/mark-paidMark as paid
POST/api/hr/payroll/{id}/create-paymentCreate bank payment JE (bank_account_id*)
GET/api/hr/payroll/{id}/payslipGet payslip (employee_id*)

Loans (6)

MethodEndpointDescription
GET/api/hr/loansList (filters: employee_id, status, loan_type)
POST/api/hr/loansCreate (employee_id*, type*, amount*, monthly_installment*, total_installments*)
GET/api/hr/loans/active-installmentsPending installments (filters: month, year)
GET/api/hr/loans/{id}Show with installments
POST/api/hr/loans/{id}/approveApprove & generate installments
POST/api/hr/loans/{id}/cancelCancel loan & pending installments

Recruitment: Job Openings (6) + Candidates (5) + Applications (5) + Offers (5)

MethodEndpointDescription
GET/api/hr/job-openingsList (filters: status, department_id, employment_type)
POST/api/hr/job-openingsCreate (title*, department_id*, position_id*, employment_type*)
GET/api/hr/job-openings/{id}Show
PUT/api/hr/job-openings/{id}Update
DEL/api/hr/job-openings/{id}Delete
POST/api/hr/job-openings/{id}/statusStatus transition (draft→open→closed/filled)
GET/api/hr/candidatesList (filters: source, search)
POST/api/hr/candidatesCreate (name_en*, email*, phone, source)
GET/api/hr/candidates/{id}Show
PUT/api/hr/candidates/{id}Update
DEL/api/hr/candidates/{id}Delete
GET/api/hr/applicationsList (filters: job_opening_id, stage, candidate_id)
POST/api/hr/applicationsCreate (candidate_id*, job_opening_id*)
GET/api/hr/applications/pipelinePipeline counts by stage
GET/api/hr/applications/{id}Show
POST/api/hr/applications/{id}/stageAdvance stage (screening→interview→assessment→offer→hired)
GET/api/hr/offersList (filters: status, candidate_id)
POST/api/hr/offersCreate (application_id*, position_id*, department_id*, salary*)
GET/api/hr/offers/{id}Show
POST/api/hr/offers/{id}/sendSend offer
POST/api/hr/offers/{id}/hireAccept & auto-create employee

Performance: KPIs (5) + Templates (5) + Reviews (7)

MethodEndpointDescription
GET/api/hr/kpisList (filters: category, is_active)
POST/api/hr/kpisCreate (name*, category*, weight, is_active)
GET/api/hr/kpis/{id}Show
PUT/api/hr/kpis/{id}Update
DEL/api/hr/kpis/{id}Delete
GET/api/hr/review-templatesList (filters: is_active, review_type)
POST/api/hr/review-templatesCreate (name*, review_type, kpi_ids[])
GET/api/hr/review-templates/{id}Show
PUT/api/hr/review-templates/{id}Update
DEL/api/hr/review-templates/{id}Delete
GET/api/hr/performance-reviewsList (filters: employee_id, status, period)
POST/api/hr/performance-reviewsCreate (template_id*, period*, employee_ids[])
POST/api/hr/performance-reviews/bulkBulk create for multiple employees
GET/api/hr/performance-reviews/{id}Show
POST/api/hr/performance-reviews/{id}/submit-selfSelf-review scores (scores[]: kpi_id, score 0-10, comments)
POST/api/hr/performance-reviews/{id}/submit-managerManager review scores
POST/api/hr/performance-reviews/{id}/finalizeHR finalize + calc final score

Training: Programs (5) + Sessions (5) + Enrollments (3)

MethodEndpointDescription
GET/api/hr/training-programsList (filters: category, is_active)
POST/api/hr/training-programsCreate (name*, category*, duration_hours, is_mandatory)
GET/api/hr/training-programs/{id}Show
PUT/api/hr/training-programs/{id}Update
DEL/api/hr/training-programs/{id}Delete
GET/api/hr/training-sessionsList (filters: program_id, status)
POST/api/hr/training-sessionsCreate (program_id*, session_date*, location, trainer, max_participants)
GET/api/hr/training-sessions/{id}Show
PUT/api/hr/training-sessions/{id}Update
POST/api/hr/training-sessions/{id}/statusStatus transition (scheduled→in_progress→completed)
GET/api/hr/training-enrollmentsList (filters: session_id, employee_id, status)
POST/api/hr/training-enrollmentsEnroll (session_id*, employee_id*)
PUT/api/hr/training-enrollments/{id}Update (status, score, feedback)

EOS (6)

MethodEndpointDescription
GET/api/hr/eosList (filters: employee_id, status)
POST/api/hr/eosCreate & auto-calculate (employee_id*, settlement_type*, last_working_day*)
POST/api/hr/eos/calculate-previewPreview calculation without saving
GET/api/hr/eos/{id}Show
POST/api/hr/eos/{id}/approveApprove settlement
POST/api/hr/eos/{id}/payMark as paid

Reports (6) + Settings (2)

MethodEndpointDescription
GET/api/hr/reports/workforceHeadcount, status, departments, avg tenure
GET/api/hr/reports/attendancePresent/absent/late, attendance rate
GET/api/hr/reports/leaveBy type/status, approval rates
GET/api/hr/reports/payroll-summaryEarnings/deductions/net
GET/api/hr/reports/loansActive/completed, outstanding
GET/api/hr/reports/turnoverHires/separations/turnover rate
GET/api/hr/settingsGet all HR settings with definitions
PUT/api/hr/settingsBulk update (~25 settings)

5. Data Models (33 Backend Models)

Core Organization

ModelKey FieldsRelationships
Departmentname_ar, name_en, code, parent_id, manager_id, branch_id, statusparent, children, manager(Employee), branch, employees
Positionname_ar, name_en, code, department_id, grade, min_salary, max_salarydepartment, employees
Employeeemployee_number, names (ar/en), user_id, department_id, position_id, branch_id, manager_id, hire_date, contract_type/dates, status, basic_salary, bank info, personal infodepartment, position, branch, manager, subordinates, documents, emergencyContacts, dependents, schedules, attendances, salaryStructures
EmployeeDocumentemployee_id, document_type, title, file_path, issue_date, expiry_dateemployee
EmergencyContactemployee_id, name, relationship, phone, alternative_phone, addressemployee
EmployeeDependentemployee_id, name, relationship, date_of_birth, national_idemployee

Attendance & Shifts

ModelKey FieldsRelationships
Shiftname_ar, name_en, start_time, end_time, break_duration, working_hours, is_night_shift, grace_period, overtime_start_afterschedules
ShiftScheduleemployee_id, shift_id, dateemployee, shift
Attendanceemployee_id, date, check_in, check_out, status, worked_hours, overtime_hours, late_minutes, early_leave_minutes, sourceemployee, corrections
AttendanceCorrectionattendance_id, correction_type, reason, corrected_check_in/out, status, requested_by, approved_byattendance, employee

Leave Management

ModelKey FieldsRelationships
LeaveTypename_ar, name_en, code, max_days_per_year, is_paid, requires_attachment, carry_over, max_carry_over_days, gender, min_service_monthsbalances
LeaveBalanceemployee_id, leave_type_id, year, opening_balance, accrued_days, used_days, carry_over_days, closing_balanceemployee, leaveType
LeaveRequestemployee_id, leave_type_id, start_date, end_date, total_days, reason, status, attachment_pathemployee, leaveType, approvals
LeaveApprovalleave_request_id, level, approver_id, action, comments, acted_atleaveRequest, approver

Payroll & Salary

ModelKey FieldsRelationships
SalaryComponentname_ar, name_en, code, component_type (earning/deduction), calculation_type (fixed/percentage), default_amount, is_mandatory, is_taxablesalaryStructures
SalaryStructureemployee_id, salary_component_id, amount, calculation_type, percentage_value, effective_from, effective_toemployee, salaryComponent
Payrollpayroll_number, month, year, period, status, totals (earnings/deductions/net), employee_count, journal_entry_iditems, journalEntry
PayrollItempayroll_id, employee_id, basic_salary, working/absent days, overtime, totalspayroll, employee
PayrollItemDetailpayroll_item_id, salary_component_id, amount, calculation_basis, is_earningpayrollItem, salaryComponent

Loans & EOS

ModelKey FieldsRelationships
EmployeeLoanloan_number, employee_id, loan_type, amount, monthly_installment, total/paid installments, remaining_amount, statusemployee, installments
LoanInstallmentloan_id, installment_number, due_date, amount, paid_amount, statusloan
EosSettlementsettlement_number, employee_id, settlement_type, last_working_day, years_of_service, eos_amount, leave_balance_amount, loan_deduction, net_amount, calculation_details (JSON)employee, journalEntry

Recruitment

ModelKey FieldsRelationships
JobOpeningopening_number, title, department_id, position_id, number_of_positions, filled_positions, status, employment_type, salary_range, closing_datedepartment, position, branch
Candidatename_en, name_ar, email, phone, source, resume_pathapplications
JobApplicationcandidate_id, job_opening_id, stage (applied→hired), status, resume_pathcandidate, jobOpening
JobOfferapplication_id, offer_number, salary, start_date, contract_type, terms, status (draft→accepted)application

Performance & Training

ModelKey FieldsRelationships
Kpiname_en, name_ar, category, weight, is_active(none)
ReviewTemplatename_en, name_ar, kpi_ids (JSON array), is_active(none)
PerformanceReviewemployee_id, reviewer_id, template_id, period, status, self/manager/final_score, commentsemployee, reviewer, template, scores
ReviewScoreperformance_review_id, kpi_id, self/manager/final_score, commentsperformanceReview, kpi
TrainingProgramname, category, duration_hours, is_mandatory, is_activesessions
TrainingSessionprogram_id, session_date, location, trainer, max_participants, statusprogram, enrollments
TrainingEnrollmentsession_id, employee_id, status, score, feedbacksession, employee

6. Backend Services (11)

ServiceMethodsDescription
AttendanceServicecheckIn(), checkOut(), summary()Handles check-in/out with late detection, calculates worked/overtime hours
PayrollServicecalculate()Calculates payroll: daily_rate=basic/30, hourly=daily/8, overtime=hours*hourly*1.5
LeaveRequestServicesubmit(), approve(), reject(), cancel()Multi-level approval workflow, working days calculation
LeaveBalanceServiceadjustBalance(), deductBalance(), getAvailableBalance()Manages leave balance operations and deductions
EosServicecalculatePreview(), calculate()Saudi Labor Law EOS formula, resignation discount, leave balance payout
RecruitmentServiceadvanceStage(), getPipeline(), hire()Stage transitions, pipeline stats, auto-create employee from offer
SalaryStructureServiceassignToEmployee(), applyMandatory(), getCurrentStructure()Component assignment, mandatory application, salary change recalculation
PerformanceServicebulkCreateReviews(), submitSelf/Manager(), finalize()Multi-step review workflow with scoring
LoanServiceapprove(), calculateInstallments(), deductFromPayroll()Loan approval, installment generation, payroll deduction
PayrollAccountingServicepostToAccounting(), createPaymentEntry()Journal entry creation for salary expenses and payments
HrReportServiceworkforceStatistics(), attendance/leave/payroll/loan/turnover reportsAll 6 report types with filters

7. Enums Reference (27)

EnumValues
EmployeeStatusactive, on_leave, suspended, terminated, resigned
ContractTypepermanent, contract, part_time, probation
PaymentMethodbank_transfer, cash, check
Gendermale, female
MaritalStatussingle, married, divorced, widowed
AttendanceStatuspresent, absent, late, on_leave, excused
AttendanceSourcemanual, biometric, mobile, web
CorrectionStatuspending, approved, rejected
LeaveRequestStatuspending, manager_approved, approved, rejected, cancelled
PayrollStatusdraft, calculated, approved, posted, paid
PayrollCyclemonthly, biweekly, weekly
SalaryCalcDays28, 30, 365
ComponentTypeearning, deduction
CalculationTypefixed, percentage, formula
LoanTypeloan, advance
LoanStatuspending, approved, active, completed, cancelled
InstallmentStatuspending, paid, cancelled
JobOpeningStatusdraft, open, on_hold, closed, filled
EmploymentTypefull_time, part_time, contract
CandidateSourcewebsite, referral, agency, linkedin, other
ApplicationStageapplied, screening, interview, assessment, offer, hired, rejected
OfferStatusdraft, sent, accepted, rejected, withdrawn
KpiCategoryquality, productivity, attendance, teamwork, leadership, communication
ReviewTypeannual, probation, quarterly, monthly
ReviewStatusdraft, self_review, manager_review, manager_approved, finalized
TrainingCategorytechnical, soft_skills, compliance, leadership, safety, onboarding
SessionStatusscheduled, in_progress, completed, cancelled
EnrollmentStatusenrolled, attended, completed, cancelled, no_show
EosSettlementTyperesignation, termination, end_of_contract, retirement, death
EosCalcMethodsaudi_labor_law, kuwait_labor_law, custom

8. Database Schema (34 Tables)

Core Organization (8 tables)

  1. departments - hierarchy with parent_id, manager, branch, status
  2. positions - name, grade, min/max salary, department FK
  3. employees - comprehensive master data (40+ columns)
  4. employee_documents - file attachments per employee
  5. emergency_contacts - multiple contacts per employee
  6. employee_dependents - spouse, children, etc.
  7. shifts - shift definitions with hours and rules
  8. shift_schedules - employee-to-shift assignments by date

Attendance & Leave (6 tables)

  1. attendances - daily records, unique per (employee_id, date)
  2. attendance_corrections - correction requests with approval workflow
  3. leave_types - policy definitions (paid, carry-over, gender, service requirements)
  4. leave_balances - per employee, per type, per fiscal year
  5. leave_requests - applications with multi-level approval
  6. leave_approvals - approval chain tracking

Payroll & Salary (5 tables)

  1. salary_components - earnings/deductions definitions
  2. salary_structures - employee-component assignments with effective dates
  3. payrolls - monthly batch with totals, unique per (company, month, year)
  4. payroll_items - per-employee breakdown
  5. payroll_item_details - component-level amounts

Loans & EOS (3 tables)

  1. employee_loans - principal, installments, status
  2. loan_installments - monthly installment tracking
  3. eos_settlements - end-of-service with calculation breakdown (JSON)

Recruitment (4 tables)

  1. job_openings - vacancies with salary range and status transitions
  2. candidates - external applicants with source tracking
  3. job_applications - pipeline stages (applied → hired)
  4. job_offers - offer terms with send/accept/reject lifecycle

Performance & Training (7 tables)

  1. kpis - KPI definitions with categories and weights
  2. review_templates - template structures linking KPIs
  3. performance_reviews - multi-step scoring workflow
  4. review_scores - KPI-level scores per review
  5. training_programs - program definitions (mandatory/optional)
  6. training_sessions - scheduled sessions with capacity
  7. training_enrollments - employee enrollment with score/feedback

9. HR Settings Reference (~25 keys)

CategoryKeyTypeDefault
Work Schedulework_days_per_weekinteger (1-7)5
weekend_daysarray['friday', 'saturday']
default_shift_idFKnull
Attendanceovertime_rate_multiplierdecimal (1-5)1.5
late_threshold_minutesinteger (0-240)15
absent_threshold_minutesinteger (0-480)240
require_checkoutbooleantrue
Leaveleave_approval_levelsinteger (1-3)1
allow_negative_leave_balancebooleanfalse
max_carry_over_daysinteger (0-365)5
Payrollpayroll_cyclemonthly|biweekly|weeklymonthly
salary_calculation_days28|30|36530
working_hours_per_daydecimal (1-24)8
Accountingsalary_expense_account_idFKnull
salary_payable_account_idFKnull
social_insurance_account_idFKnull
medical_insurance_account_idFKnull
income_tax_account_idFKnull
loan_receivable_account_idFKnull
eos_provision_account_id / eos_expense_account_idFKnull
Self-Serviceemployee_self_servicebooleanfalse
allow_attendance_self_checkinbooleanfalse
EOSeos_calculation_methodsaudi_labor_law|kuwait_labor_law|customsaudi_labor_law
Probationprobation_period_monthsinteger (0-12)3

Next: View Gap Analysis & Missing Features →

Generated for Moon ERP HRM Module Analysis | 2026-04-08