Try ERPNext Buy Support Partners Foundation Foundation Members

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