amsrk
November 23, 2021, 8:58am
1
Create a Employee Advance
[Note: To be select the option Repay Unclaimed Amount from Salary]
Process “Deduction from Salary” for the amount to be repaid back through Additinal salary
Noticed the following:
Returned Amount value is properly updated after the Save and Submit of the Additional Salary
Pending Amount value is not udated after the Save and Submit of the Additional Salary
amsrk
November 23, 2021, 9:00am
2
Checking the code base:
https://github.com/frappe/erpnext/blob/develop/erpnext/payroll/doctype/additional_salary/additional_salary.py
def update_return_amount_in_employee_advance(self):
if self.ref_doctype == “Employee Advance” and self.ref_docname:
return_amount = frappe.db.get_value(“Employee Advance”, self.ref_docname, “return_amount”)
if self.docstatus == 2:
return_amount -= self.amount
else:
return_amount += self.amount
frappe.db.set_value("Employee Advance", self.ref_docname, "return_amount", return_amount)
return amount is handled but pending amount not handled
amsrk
November 23, 2021, 9:07am
3
def update_return_amount_in_employee_advance(self):
if self.ref_doctype == “Employee Advance” and self.ref_docname:
return_amount = frappe.db.get_value(“Employee Advance”, self.ref_docname, “return_amount”)
==> advance_amount = frappe.db.get_value(“Employee Advance”, self.ref_docname, “advance_amount”)
if self.docstatus == 2:
return_amount -= self.amount
else:
return_amount += self.amount
frappe.db.set_value("Employee Advance", self.ref_docname, "return_amount", return_amount)
==>frappe.db.set_value("Employee Advance", self.ref_docname, "pending_amount", (advance_amount - return_amount)
amsrk
November 23, 2021, 9:07am
4
The above change should help will publish PULL REQUEST shortly
amsrk
November 29, 2021, 8:45am
6
This server script solved the problem:
amsrk
November 29, 2021, 8:45am
7
if doc.ref_doctype == “Employee Advance” and doc.ref_docname:
advance_amount = frappe.db.get_value(“Employee Advance”, doc.ref_docname, “advance_amount”)
pending_amount = advance_amount - doc.amount
frappe.db.set_value(“Employee Advance”, doc.ref_docname, “pending_amount”, pending_amount)