Introducing a new way to review your PRs.

Read the announcement

frappe / hrms

Open Source HR and Payroll Software

View on GitHub

20 documents · Updated Nov 23, 2026

docs / salary-processing

Salary processing and payroll runs

Salary processing turns an employee's assigned pay rules and period activity into a reviewed salary slip and a payable payroll result. It covers the path from salary setup through payroll runs, variable pay, corrections, benefit accruals, tax deductions, withholding, and payment records. See Payroll management for the wider payroll area and Compensation, benefits, and tax, Regional payroll, and Employee portal application for related concerns.

Salary setup

Salary setup defines the rules that payroll uses before it processes a person. A salary component gives a pay item its meaning. A salary structure groups those items. A salary structure assignment connects the structure to an employee from an effective date.

Salary components

The Salary Component is the reusable definition of a pay item. It classifies the item as an earning, deduction, or employer contribution, then sets the rules that control tax, payment-day use, totals, accounts, arrears, and benefits.

Components can use a fixed amount or a condition and formula. A component abbreviation lets another component refer to its value. Statistical items and items excluded from totals can still appear on a slip without changing employee pay. A component can also stay outside payroll accounting when its accounting exclusion is set.

Some component choices control other payroll paths. Flexible-benefit components use a yearly limit and payout method. Arrear components use payment-day logic. Tax-based deductions are calculated by the income-tax flow rather than by a fixed structure amount. When a shared condition or formula changes, payroll can sync it to selected salary structures so later slips use the same rule.

References: hrms/…/salary_component.json• L69-103 hrms/…/salary_component.json• L122-155 hrms/…/salary_component.json• L243-295 hrms/…/salary_component.json• L299-304 hrms/…/salary_component.js• L56-110 hrms/…/salary_component.py• L61-201

Salary structures and assignments

The Salary Structure is a company- and currency-specific pay plan. It holds the earning, deduction, employer-contribution, and benefit items that make up a pay package. It can also define a payroll frequency or a timesheet-based hourly wage path.

The Salary Structure Assignment makes a structure effective for one employee from a date. It carries employee-specific base and variable pay, tax-slab context, benefit choices, opening tax balances, payable account, and cost-center splits. Payroll selects the latest submitted assignment that applies to the employee's actual payroll start date, so a new assignment changes later processing without changing the meaning of past slips. The assignment must match the employee's company and employment dates, and its cost-center split must total 100 percent.

Before a slip applies its dates and payment days, the assignment evaluates the structure's earnings, deductions, and employer contributions in one shared full-cycle context. This lets dependent components use values from earlier component groups and supplies the full-cycle defaults that the slip later prorates. The evaluation also provides the period fields that formulas may need, while keeping the structure definition unchanged for other payroll work. The assignment derives annual gross earning and total cost to company from these results. Annual gross earning excludes statistical and non-payable earnings. Total cost to company includes employer contributions and earnings that are shown but not payable, while statistical earnings do not increase either payable gross or cost to company. Regional payroll can add statutory employer contributions to this cost without adding them to employee gross pay.

Timesheet wages stay period-specific. A timesheet-based slip adds them from approved timesheets and hourly settings rather than treating them as a fixed assignment component. The assignment still evaluates other base-driven components, but the variable hourly wage does not become part of the assignment's annual gross or cost to company.

For assignments that start before an available fiscal year, the assignment still evaluates its full payroll cycle from the assignment date. This keeps formulas that use cycle dates usable when payroll creates a later salary slip.

References: hrms/…/salary_structure.json• L68-128 hrms/…/salary_structure.json• L155-175 hrms/…/salary_structure.py• L53-129 hrms/…/salary_structure.py• L194-334 hrms/…/salary_structure_assignment.py• L88-220 hrms/…/salary_structure_assignment.py• L240-354 hrms/…/salary_structure_assignment.py• L400-445 hrms/…/salary_structure_assignment.py• L516-554 hrms/…/test_salary_structure_assignment.py• L37-119 hrms/…/test_salary_structure_assignment.py• L134-324 hrms/…/test_salary_structure_assignment.py• L326-437 hrms/…/test_salary_structure_assignment.py• L440-533

Payroll periods and runs

Payroll periods and payroll entries provide the time and control layer for salary processing. A period establishes the date range for a company's payroll cycle. A payroll entry selects that range, the employees, and the accounting context for one run.

Payroll periods

The Payroll Period defines a non-overlapping date range for a company. Its optional period-date rows can represent the smaller date units inside that range. Salary slips use the period to calculate cycle factors, year-to-date tax context, flexible-benefit limits, and withholding cycles.

The payroll frequency determines the processing window used by a slip or run. Supported patterns include monthly, bimonthly, fortnightly, weekly, and daily. Working days depend on the employee's holiday list and the payroll setting for whether holidays count.

References: hrms/…/payroll_period.json• L17-53 hrms/…/payroll_period.py• L31-67 hrms/…/payroll_period.py• L70-153

Payroll entries

The Payroll Entry is the control record for a payroll run. It selects a company, date range, frequency, currency, payable account, payment account, and employee group. It can check attendance before processing and can include timesheet-based pay. Employee selection also respects active status, joining and relieving dates, assignment dates, structure compatibility, and the selected payroll account.

The payroll entry form guides this run through employee selection, salary-slip creation, salary-slip submission, and bank-entry creation. It derives dates from the selected frequency, clears an employee selection when a scope-setting field changes, and exposes the next valid action as the run advances. It also refreshes the run when queued work completes and surfaces a retained error so the failed creation or submission step can be retried.

Attendance checks use holiday-list assignments that are effective during the employee's payroll dates. This allows the run to use the correct holiday calendar when an employee's holiday list changes inside the period rather than applying one static company list.

The run first gathers eligible employees with an applicable salary structure. It then creates salary slips and submits valid slips in a separate step. Submission creates the salary accrual journal and can email the submitted slips. A later bank or cash entry pays the slips that are ready for release. Large operations can move through a queued state, while creation or submission errors set a failed state and retain an error message. The entry also links overtime slip work to the same run when overtime processing is enabled.

Payroll accounting can group amounts by the run or tag payable amounts to each employee. Employee cost-center splits use the latest applicable assignment mapping, while currency conversion, advance deductions, and loan repayment can change the accounting and payment result without changing the salary slip's component detail. An advance-linked deduction posts recovery to the account used by the employee advance and keeps the advance as its reference, so the receivable is settled instead of using the salary component account. Employer contributions are accrued in a separate journal with their own expense and liability accounts. When employee-wise accounting is enabled, its liability rows carry the employee while expense rows remain split by cost center.

The main run flow is:

flowchart LR
    A[Select period and employees] --> B[Create salary slips]
    B --> C[Review pay and attendance]
    C --> D[Submit salary slips]
    D --> E[Accrue payroll]
    E --> F[Create bank or cash payment]
    F --> G[Employee salary record]

References: hrms/…/payroll_entry.json• L57-124 hrms/…/payroll_entry.json• L266-334 hrms/…/payroll_entry.js• L8-40 hrms/…/payroll_entry.js• L64-218 hrms/…/payroll_entry.js• L234-291 hrms/…/payroll_entry.js• L294-439 hrms/…/payroll_entry.js• L442-489 hrms/…/payroll_entry.py• L100-179 hrms/…/payroll_entry.py• L250-346 hrms/…/payroll_entry.py• L398-549 hrms/…/payroll_entry.py• L619-815 hrms/…/payroll_entry.py• L1068-1136 hrms/…/payroll_entry.py• L1297-1429 hrms/…/test_payroll_entry.py• L71-130 hrms/…/test_payroll_entry.py• L341-423 hrms/…/test_payroll_entry.py• L461-496 hrms/…/test_payroll_entry.py• L655-714 hrms/…/test_payroll_entry.py• L1118-1297

Salary slips and payroll detail

A salary slip is the employee-level result for one payroll window. It preserves the employee, assigned structure, dates, payment days, component values, tax view, totals, and links to payroll accounting. Its child salary-detail records explain how each earning or deduction contributes to the result.

Salary slips

The Salary Slip combines the applicable salary structure with employee data for its dates. It calculates working days and payment days from joining and relieving dates, holidays, attendance or leave data, and timesheets when the structure uses hourly pay. A holiday marked as half day counts as half a working day when holidays are excluded from the working-day total. Leave without pay, absence, and marked attendance on that date use the same half-day value.

The slip consumes the assignment's shared full-cycle component evaluation, then applies the actual payroll dates and payment days. It applies structured earnings and deductions, adds variable pay and tax components, and calculates gross pay, total deductions, net pay, rounded totals, company-currency values, and year-to-date or month-to-date values. Employer contributions can be shown on the slip without entering gross pay, deductions, or net pay. Regional payroll can add statutory deductions and employer contributions through the salary-slip calculation flow.

Its tax view carries taxable earnings, exemptions, tax already deducted, current tax, and future tax. For a tax deduction that depends on payment days, the slip treats the current cycle as the employee's payment-day share. A partial joining cycle spreads structured tax across the remaining full cycles plus that share, while a final relieving cycle deducts the remaining structured tax in full. A submitted slip can link to its payroll entry and journal entry, and it can be shown to the employee as the salary statement.

Salary slips use these states to show their processing position:

  • Draft: the slip is prepared but not submitted.
  • Submitted: the slip is accepted for payroll and payment.
  • Withheld: the slip belongs to a salary withholding cycle that is not released.
  • Cancelled: the slip is no longer active.

References: hrms/…/salary_slip.json• L177-251 hrms/…/salary_slip.json• L253-326 hrms/…/salary_slip.json• L335-419 hrms/…/salary_slip.json• L726-775 hrms/…/salary_slip.py• L218-295 hrms/…/salary_slip.py• L355-451 hrms/…/salary_slip.py• L545-649 hrms/…/salary_slip.py• L985-1038 hrms/…/salary_slip.py• L1323-1505 hrms/…/salary_slip.py• L1995-2071 hrms/…/test_salary_slip.py• L763-805 hrms/…/test_salary_slip.py• L899-1021 hrms/…/test_salary_slip.py• L2220-2276

Salary detail records

The Salary Detail child record is the line-level explanation inside a structure or slip. In a structure it describes the rule for a component. In a slip it stores the evaluated amount and links to any additional pay that supplied or changed the value.

Each row carries the flags needed to interpret its amount. These include tax use, payment-day dependence, flexible-benefit status, statistical status, accrual status, and whether the row belongs in totals or accounting. The row can also retain the default amount, additional amount, tax amounts, and component year-to-date value.

References: hrms/…/salary_detail.json• L39-201 hrms/…/salary_detail.json• L243-275 hrms/…/salary_slip.py• L1359-1444

Variable pay and benefits

Payroll keeps one-time pay, recurring pay, incentives, and flexible benefits separate from the base salary rules. The salary slip brings these sources together for the relevant period and records their effect in the slip or the benefit ledger.

Additional salary

The Additional Salary record adds an earning or deduction for an employee. A non-recurring record uses a payroll date. A recurring record uses a start and end date and is picked up when its active range covers the payroll window's end date while it remains enabled.

Additional salary can either add to a structure amount or overwrite that component for the selected period. It can link back to a source document such as an employee advance, referral, arrear, or correction. Its tax option controls whether tax is taken on the selected payroll date. Payroll rejects overlapping recurring entries and conflicting overwrite entries for the same component. An advance-linked deduction also cannot exceed the amount still available for return. A tax-based component can be overwritten only when the record explicitly permits that override, and an accrual component is recorded as a benefit payout rather than treated as ordinary cash pay.

The form derives the employee's company and currency and switches between a payroll date and a date range based on whether the record is recurring. It limits employee and component choices to valid records before payroll uses the entry. A recurring entry can be disabled after submission, while a non-recurring entry remains tied to its selected payroll date.

References: hrms/…/additional_salary.json• L43-95 hrms/…/additional_salary.json• L137-179 hrms/…/additional_salary.json• L196-202 hrms/…/test_additional_salary.py• L20-110 hrms/…/test_additional_salary.py• L112-261 hrms/…/test_additional_salary.py• L263-285

Employee incentives

The Employee Incentive record represents a dated incentive for an employee. It uses a salary component and amount, then creates a linked non-recurring additional salary when submitted. This keeps the incentive source visible while allowing the normal salary-slip process to include and account for it.

An incentive needs an active employee and a salary structure assignment. Its payroll date decides which run receives the amount. The linked additional salary also lets later payroll views trace the amount back to the incentive.

References: hrms/…/employee_incentive.json• L25-46 hrms/…/employee_incentive.json• L76-97

Flexible benefits and accruals

Flexible benefits are employee-selected benefit amounts that use earning components with a defined yearly limit and payout method. An accrual is an amount earned or set aside without immediate pay. A payout is an amount released into earnings.

The salary slip applies the benefit choice for the current cycle. Depending on the component's payout method, it can accrue the cycle amount, pay an eligible balance, or pay the benefit at the end of the period. The Employee Benefit Ledger records each accrual or payout against the employee and payroll period. This ledger is the source for later claim eligibility and for reversing records when a slip or source transaction is cancelled.

References: hrms/…/salary_component.json• L122-142 hrms/…/salary_component.json• L243-295 hrms/…/employee_benefit_ledger.json• L49-136 hrms/…/employee_benefit_ledger.py• L45-152 hrms/…/salary_slip.py• L1507-1511 hrms/…/test_salary_slip.py• L1299-1429

Arrears and corrections

Arrears and payroll corrections handle amounts that must be added after an earlier payroll result. They use salary components marked for arrears and preserve a link to the source period or slip so the later payment remains traceable.

Arrears

The Arrear record recalculates selected past salary slips with a new salary structure. It compares the old processed component totals with a preview under the new structure. Positive differences become earning, deduction, or accrual arrears for a chosen payroll period and date.

On submission, earning and deduction arrears become additional salary records. Accrual arrears become benefit-ledger accruals. The process requires a valid employee assignment and a start date inside the selected payroll period. It does not use tax-based variable components as ordinary arrear components.

References: hrms/…/arrear.json• L42-139 hrms/…/arrear.py• L49-61 hrms/…/arrear.py• L127-222 hrms/…/arrear.py• L297-368 hrms/…/arrear.py• L415-481

Payroll corrections

The Payroll Correction record corrects leave-without-pay treatment for a submitted salary slip. It selects a payroll period and affected slip, then states how many unpaid days to reverse. The system limits the correction to the unpaid days recorded on that slip and accounts for earlier corrections against the same slip.

The correction creates a component break-up from the selected slip. It uses only eligible, non-tax-variable components that were not already supplied by additional salary. Earning and deduction corrections become additional salary records for a later payroll date. Accrual corrections become employee benefit ledger entries. The original slip remains the reference, so the correction can be understood without rewriting the historical payroll result.

Accrual corrections use payment days as their daily basis. The process rejects a correction when the source slip has no payment days because it cannot derive a safe daily amount. Cancelling the correction removes the benefit-ledger entries that it created.

References: hrms/…/payroll_correction.py• L47-84 hrms/…/payroll_correction.py• L141-274 hrms/…/test_payroll_correction.py• L19-142

Salary withholding

Salary withholding separates salary calculation from salary release. The salary slip can be submitted and retained as a withheld result while the payment for one or more defined cycles waits for release.

Withholding records and cycles

The Salary Withholding record defines the employee, reason, start date, payroll frequency, and number of cycles to hold. It expands that request into Salary Withholding Cycle rows. Each cycle has dates, a release flag, and the journal entry used when its salary is paid. The withholding record moves through Draft, Withheld, Released, or Cancelled states.

During employee selection, payroll marks employees whose matching cycle is not released. Their salary slips carry the withholding record and cycle. A bank entry for withheld salaries links the payment back to those cycles. When the bank entry is submitted, the cycle becomes released and the related slips become submitted for payment. If that bank entry is cancelled, the slips and cycles return to the withheld state.

The withholding flow is:

sequenceDiagram
    participant H as HR
    participant W as Withholding record
    participant P as Payroll run
    participant S as Salary slip
    participant B as Bank entry
    H->>W: Define employee and holding cycles
    W->>P: Mark matching employee as withheld
    P->>S: Create and submit slip with withheld status
    H->>B: Create payment for withheld salaries
    B-->>W: Mark cycle released
    B-->>S: Change slip to submitted

References: hrms/…/salary_withholding.json• L67-103 hrms/…/salary_withholding.json• L135-163 hrms/…/salary_withholding.json• L175-179 hrms/…/salary_withholding.py• L43-126 hrms/…/salary_withholding.py• L157-228 hrms/…/salary_withholding_cycle.json• L14-48 hrms/…/payroll_entry.py• L297-307 hrms/…/payroll_entry.py• L1068-1136

Change checklist

When these files or sections are changed, remember to consider these:

  • When a salary component flag changes, check both salary-structure evaluation and salary-slip totals. The same flag also affects arrears, tax, benefit ledger entries, or accounting scope.
  • When salary frequency or payroll-period rules change, check slip date selection, payment-day factors, year-to-date tax projections, payment-day tax splits, recurring additional salary, and withholding-cycle dates.
  • When salary-detail fields change, check both structure rows and slip rows. A field may be a rule in one parent and an evaluated result in the other.
  • When additional salary or incentive links change, preserve the source reference on the generated salary line so payroll users can trace variable pay.
  • When arrear or correction logic changes, keep the generated additional salary and benefit-ledger records tied to the source document and original payroll period.
  • When withholding status changes, keep the salary slip status, payroll employee flag, withholding cycle, and bank-entry link in sync.
  • When shared component formulas or conditions change, check component-to-structure synchronization, structure cache invalidation, shared assignment evaluation, and later salary-slip results.
  • When employer-contribution accounting changes, check the separate expense-liability journal, employee party tags, cost-center splits, and balance after rounding.
  • When holiday-list assignment resolution changes, check both salary-slip payment days and payroll-entry attendance validation across assignment changes inside one period. Include the half-day holiday definition in the working-day, leave, and attendance checks.
  • When regional deduction or employer-contribution rules change, check assignment CTC values, salary-slip totals, and the related regional payroll accounting or reporting flow.
  • When timesheet processing changes, keep the assignment's period-independent component evaluation separate from salary-slip wage calculation and payroll-entry overtime work.
  • When payroll accounting changes, check the run-level accrual, employee-level payable tags, cost-center splits, currency conversion, advance deductions, employer-contribution journals, and payment amount.
  • When advance recovery accounting changes, keep the deduction linked to the employee advance, use that advance's account, and preserve the reference needed to settle the receivable.
  • When a run's async or error states change, keep the queued, failed, retry, and cancellation paths consistent with the salary-slip flags and retained error message.

Important failure modes

TriggerConsequenceGuard
No submitted salary structure assignment applies to the employee and datesThe salary slip cannot load its pay rulesCreate an assignment effective on or before the slip's actual start date
A payroll run uses a non-payable payroll payable accountPayroll submission stops before accounting is createdSet the selected account type to Payable
Attendance validation finds unmarked daysThe payroll entry cannot be submittedComplete attendance or disable the explicit attendance check when the business process allows it
An employee's holiday-list assignment does not cover the payroll dates or has the wrong effective rangeWorking days and attendance validation can count the wrong holidaysKeep employee and company holiday-list assignments valid for the full payroll date range
A half-day holiday is treated as a full holiday or a full working dayTotal working days, leave without pay, absence, and net pay can be wrong by half a dayKeep half-day holiday data available to salary-slip working-day and attendance calculations
Two salary slips cover the same employee and periodDuplicate pay can be created or the new slip is rejectedKeep one active slip for each employee and date range
A formula names a missing field or has invalid syntaxComponent evaluation fails and the payroll entry can move to FailedKeep formulas tied to valid employee, slip, or component context
A shared formula or condition is changed without updating its structures or cacheNew slips can use stale or mismatched component rulesSynchronize the affected structures and clear their cached definitions
A recurring or overwrite additional salary overlaps an existing recordThe additional pay record is rejected or produces an ambiguous amountKeep one active matching record for a component and date range
An additional salary overwrite names a component outside the employee's structureThe overwrite is disabled or cannot provide the intended pay changeUse an active component that belongs to the applicable salary structure
An advance-linked deduction exceeds the employee's available advance returnThe additional salary is rejectedLimit scheduled deductions to the remaining advance balance
An advance-linked deduction uses an unavailable or incorrect advance accountThe accrual entry can fail or leave the advance receivable openKeep the linked employee advance account valid and post the recovery against that account
A payroll slip has negative net payThe slip is not submitted by the payroll runResolve the deductions or review the pay inputs before submission
A component lacks the account needed for its salary typeAccrual or employer-contribution journal creation fails and the run records an errorSet the component's company account, and set both expense and liability accounts for employer contributions
A correction reverses more unpaid days than the source slip recordsThe correction is rejectedLimit the total reversed days across corrections to the slip's unpaid days
An accrual correction has zero payment days on its source slipThe correction cannot calculate a daily accrual amountUse a source slip with payment days greater than zero
A withholding bank entry is cancelledReleased cycles and related slips return to withheld statusReconcile the bank entry before treating the salary as released

Key files

FileWhy to read it
hrms/…/salary_component.jsonDefines the business meaning and payroll flags for each pay item.
hrms/…/salary_component.pyShows how shared component rules are validated and synchronized to structures.
hrms/…/salary_component.jsShows how component choices guide formulas, benefits, arrears, and structure creation.
hrms/…/salary_structure.jsonShows how earnings, deductions, employer contributions, and benefits form a pay plan.
hrms/…/salary_structure.pyShows how structures create assignments and salary-slip previews.
hrms/…/salary_structure_assignment.pyExplains how an employee-specific assignment validates dates and pay context, evaluates component values, and derives gross pay and CTC.
hrms/…/test_salary_structure_assignment.pyShows the guarantees for shared formula context, CTC scope, regional employer contributions, timesheet wages, old assignment dates, currency selection, and cache safety.
hrms/…/payroll_period.pyDefines payroll date ranges and the period factors used by salary processing.
hrms/…/payroll_entry.jsShows how the payroll run form guides employee selection, processing actions, asynchronous status refresh, retries, attendance checks, and payment actions.
hrms/…/payroll_entry.pyShows the lifecycle from employee selection to slips, overtime, accrual, accounting, payment, and cancellation.
hrms/…/payroll_entry.jsonDefines the run controls, processing states, payment links, and overtime step.
hrms/…/test_payroll_entry.pyShows the business guarantees for period dates, attendance, holiday assignments, accounting, payment, queued work, failure recovery, employer contributions, advance recovery, and cancellation.
hrms/…/salary_slip.pyShows how one employee's dates, attendance, holiday assignments, half-day holidays, components, regional deductions, tax, payment-day tax splits, and totals become a salary result.
hrms/…/test_salary_slip.pyShows the guarantees for payment days, half-day holidays, holiday-list changes, tax across partial joining and final relieving cycles, component evaluation, benefits, and salary-slip submission.
hrms/…/salary_detail.jsonDefines the line-level data shared by salary structures and salary slips.
hrms/…/additional_salary.jsonDefines one-time and recurring variable pay, overwrite behavior, and source links.
hrms/…/test_additional_salary.pyShows the guarantees for recurring pay, one-time pay, overwrites, tax components, accruals, and duplicate protection.
hrms/…/employee_incentive.jsonDefines dated employee incentives and their salary-component values.
hrms/…/employee_benefit_ledger.pyShows how benefit accrual and payout balances are recorded.
hrms/…/arrear.pyExplains recalculation of past slips and creation of arrear results.
hrms/…/payroll_correction.pyExplains unpaid-day reversal, component eligibility, and generated correction results.
hrms/…/test_payroll_correction.pyShows the guarantees for earning, accrual, source links, and zero-payment-day protection.
hrms/…/salary_withholding.jsonDefines withholding inputs, cycle rows, states, and links to salary slips.
hrms/…/salary_withholding.pyExplains holding cycles and their release through payment records.