brotherton-erpnext/erpnext/patches/v9_0/update_employee_loan_details.py
rohitwaghchaure 43edd5d03c Employee loan fixes ()
* Employee loan fixes

* Update update_employee_loan_details.py
2017-11-14 17:59:20 +05:30

25 lines
723 B
Python

# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('hr', 'doctype', 'salary_slip_loan')
frappe.reload_doc('hr', 'doctype', 'salary_slip')
for data in frappe.db.sql(""" select name,
start_date, end_date, total_loan_repayment
from
`tabSalary Slip`
where
docstatus < 2 and ifnull(total_loan_repayment, 0) > 0""", as_dict=1):
salary_slip = frappe.get_doc('Salary Slip', data.name)
salary_slip.set_loan_repayment()
if salary_slip.total_loan_repayment == data.total_loan_repayment:
for row in salary_slip.loans:
row.db_update()
salary_slip.db_update()