How get daily rate of monthly salary?

I need to calculate daily rate of monthly salary of employee and some component in salary structure Amount based on formula

Custom Field and Custom Script?

Total Earning or Net Earning / No. of Days in the Month

Salary Structure doesn’t have no. of months fetched, but Salary Slip has it.

I solve this by this code:

@frappe.whitelist()
def get_daily_rate(employee, start_date, end_date):
    doc = frappe.get_doc({"doctype": "Salary Slip", "employee": employee,
                          "start_date": start_date, "end_date": end_date, "payroll_frequency": "Monthly"})
    doc.get_emp_and_leave_details()
    return doc.gross_pay / 30
1 Like