Request: Allow Custom Formula for Salary Component Based Overtime Calculation

Description

I am using the Overtime Type → Salary Component Based calculation in Frappe HR.

Currently, Frappe HR calculates the overtime hourly rate using the standard formula:

OT Hourly Rate = Applicable Salary Components ÷ Payment Days ÷ Standard Working Hours

Then the configured overtime multiplier is applied.

This works for some payroll policies, but different companies may have different overtime calculation policies.

For example, our company may need an OT formula such as:

OT Hourly Rate = (Basic + HRA) ÷ Company-defined divisor ÷ Standard Working Hours

The divisor may be based on Working Days, Payment Days, Calendar Days, or another company-defined value.

Instead of hard-coding one calculation method, it would be useful to have a Custom Formula option under Overtime Type.

Current Example

In our case, the employee has:

  • Basic Office = ₹10,000
  • House Rent Allowance Office = ₹10,000
  • Total applicable salary components = ₹20,000
  • Working Days = 31
  • Payment Days = 25.5
  • Standard Working Hours = 10
  • Overtime Hours = 2.67
  • Standard Multiplier = 1.5

The current Frappe HR calculation is:

OT Hourly Rate
= ₹20,000 ÷ 25.5 ÷ 10
= ₹78.43/hour

Then:

OT Amount
= ₹78.43 × 2.67 × 1.5
= ₹314.12

However, our company policy may require the overtime calculation to use Working Days instead:

OT Hourly Rate
= ₹20,000 ÷ 31 ÷ 10
= ₹64.52/hour

Then:

OT Amount
= ₹64.52 × 2.67 × 1.5
≈ ₹258.00

Therefore, the requirement is not to remove or change the existing Payment Days calculation. Instead, we need the ability to configure which formula/basis should be used for overtime calculation.

Requested Feature

Could Frappe HR provide an option such as:

Overtime Amount Calculation:

  • Fixed Hourly Rate
  • Salary Component Based
  • Custom Formula

For Custom Formula, the administrator could define a formula using available salary/employee/payroll variables, for example:

(Basic Office + House Rent Allowance Office) / Working Days / Standard Working Hours

The configured overtime multiplier could then be applied to the resulting hourly rate.

Ideally, the Custom Formula should support variables such as:

  • Basic Salary
  • Selected Salary Components
  • Working Days
  • Payment Days
  • Calendar Days
  • Standard Working Hours
  • Overtime Hours
  • Overtime Multiplier

Why this is needed

Different organizations may calculate overtime using different policies. Some may use:

  • Payment Days
  • Working Days
  • Calendar Days
  • Company-defined fixed divisor
  • Basic salary only
  • Basic + allowances
  • Different standard working hours
  • Different overtime multipliers
  • A completely company-specific formula

Having a configurable formula would avoid requiring custom Server Scripts or modifying core HRMS code for every company’s OT policy.

The existing Salary Component Based calculation should continue to work as it does today. The requested feature would simply provide an additional configurable option for organizations that require a different overtime calculation policy.

Current Environment

  • Frappe Framework: v16
  • Frappe HR: v16
  • ERPNext: v16
  • Overtime Type: Salary Component Based
  • Overtime Salary Component: Overtime Office
  • Applicable Salary Components: Basic Office, House Rent Allowance Office
  • Standard Multiplier: 1.5
  • Shift: 09:00–19:00
  • Standard Working Hours: 10

Question

Would it be possible to add a Custom Formula option for Overtime Amount Calculation so that each company can define its own overtime calculation formula without modifying the Frappe HR core code?

Also, could the formula support payroll variables such as Working Days, Payment Days, Salary Components, Standard Working Hours, Overtime Hours, and Overtime Multiplier?

Hi there,

Formulas are convenient for simple things, but I strongly recommend that people use a Server Script for anything complicated. The before_save hook tends to be the right opportunity. Validate has already run, and you can process the output literally however you want. Literally anything in your system is available as an input, and you can avoid most circular dependencies.