---
tags: [hr, service]
module: HR
---

# PayrollServices

## Connections
[[_HR]] · [[[Model]PayrollEntry]] · [[[Model]Employee]] · [[[Model]JournalEntry]] · [[[Model]Account]] · [[[Model]FiscalYear]] · [[[Service]JournalEntryServices]] · [[[Service]FiscalYearServices]] · [[[Repo]Repositories]] · [[[Controller]PayrollEntriesController]]

## Source
`Modules/HR/Services/` (payroll-related)

| Service | Responsibility |
|---|---|
| `StoringPayrollEntryService` | Creates [[[Model]PayrollEntry]] + details; builds debit/credit records; calls [[[Service]JournalEntryServices]] → `CreatingNewJournalEntryService` |
| `UpdatingPayrollEntryService` | Updates entry + details; deletes old JE via `DeletingJournalEntryService`; creates new JE |
| `DeletingPayrollEntryService` | Deletes entry + details + linked [[[Model]JournalEntry]] |
| `PayrollEntriesIndexService` | Lists payroll entries for current fiscal year |
| `PreparingDataForCreatingPayrollEntryService` | Loads employees, payment [[[Model]Account]] records, current [[[Model]FiscalYear]] |

## Journal Entry Creation (inside StoringPayrollEntryService)
```
For each employee in payroll:
  Debit  → employee.costAccount ([[[Model]Account]])
  Credit → payrollEntry.paymentAccount ([[[Model]Account]])

→ [[[Service]JournalEntryServices]] CreatingNewJournalEntryService
→ [[[Model]JournalEntry]].id stored on [[[Model]PayrollEntry]]
```

## Cross-Module Services Used

| Service | Module | Purpose |
|---|---|---|
| `CreatingNewJournalEntryService` | [[[Service]JournalEntryServices]] | Create payroll JE on store |
| `DeletingJournalEntryService` | [[[Service]JournalEntryServices]] | Delete old JE on update/delete |
| `RetrievingLastCodeService` | [[[Service]JournalEntryServices]] | JE code generation |
| `RetrievingCurrentFinancialYearService` | [[[Service]FiscalYearServices]] | Current fiscal year lookup |
