HR Salary need to double the discount of absent days

Hi everyone,
now i need when calculating the salary of an employee i need the day absent to be considered as double.
so on day absent to be as two days
two days to be four days
how may i do that?
thanks in advance.

@Badr You can do that by creating a Salary Component as a deduction and based on the conditions and calculation formula that you want, then add this component to the deduction section of the Salary Structure that you use for the employees.

For more information, read the following docs:

  1. Salary Component
  2. Salary Structure
  3. Salary Structure Assignment

Thank you for your replay,
already done the salary structure and components but cannot create the formula or conditions on my case because i can’t understand formula .
need a condition or formula to double the absent days and deduct them from the basic salary.

@Badr Based on the Salary Component documentation, here is what you can set as the condition and formula.

  • Condition:
    Check if absent days is greater than zero.
    absent_days > 0
  • Formula:
    (Assuming that you deduct 10 for each absent day)
    base - ((absent_days * 2) * 10)

You can also create another component for those with zero absent days and you can set the condition as absent_days == 0 and then set the amount.

@kid1194 Thank you
i’ll try it,
but how i can find the exact name like “absent_days” you used.

tried it now it give me this error: “Name error: name ‘absent_days’ is not defined”

@Badr Based on the documentation, fields from Salary Slip can be used in both, condition and formula. The Salary Slip form has a field called absent_days and that’s why I used it. You can check the Salary Slip form by yourself and confirm the existence of the field. Or you can use leave_without_pay field instead and check if it’s working in the way you want.

@kid1194 That’s my issue i’m using v12, it doesn’t have this field.
any help how to get it into Salary Slip DocType.

@Badr How about creating two custom fields in the Salary Slip doctype that you can fill manually.

  1. absent_days
  2. daily_rate

And then change the formula to

base - ((absent_days * 2) * daily_rate)

@kid1194 Yes I did that, I created custom field for absent days but I am not good in programming to add custom code script for it,so that it can retrieve the employee absent days and use it in the formula

@Badr Today I will try to provide you with the code you need and hopefully it will work with V12.

@Badr Sorry, I couldn’t find an easy way to calculate the absent days using JavaScript.

But, in the V12 Salary Slip documentation, it’s mentioned that

If Payroll is based on Attendance then, the Leave without pay will be considered as absent and half-day will be considered as half-day absent.

So, if payroll is based on attendance then what you need is:

leave_without_pay > 0


((base / payment_days) * leave_without_pay) * 2
  • payment_days = total working days
  • base / payment_days = daily salary rate

@kid1194 Thank you so for your help.