Calculate Absent days on salary slip doctype

I need to use total absence days in the salary slip like Working Days, Leave Without Pay, Payment Days fields

I have to create a field called Absent Days i need a custom script to fetch total absent days Depending on Employee Name, Start Date, End Date fields in Salary Slip doctype like the total absence in Monthly Attendance Sheet report

After that, I can use it in Salary Component formula

any ideas here?

you can create a hooks on before validate

"Salary Slip": {
      "before_validate": "custom_app.custom_script.before_validate"

then you can create method like this

def before_validate(doc, method):
    absent_days = your_custom_method_to_get_absent_days(doc.employee, doc.start_date, doc.end_date)
    doc.absent_days = absent_days
    return doc

then you can use absent_days in the formula

I need that method if you can

Thanks in advance

Hi @gmbelart, Kindly help us to understand it in a better way.


Basically, first you need to add custom field on Salary Slip doctype.
Then on your custom app, open, add event before_validate for Salary Slip doctype.
Then in your method in your you need to update your custom field.
After that, you can use your custom field in the formula

Guys, Did anyone achieved this technique? I also need to count late entries. :slightly_smiling_face: