mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-26 16:14:18 +00:00
fix: employee advance return through multiple additional salaries (#27438)
* fix: employee advance return through multiple additional salaries
* test: test repay unclaimed amount from salary
* fix: sorting in imports
(cherry picked from commit b98740b44a)
# Conflicts:
# erpnext/hr/doctype/employee_advance/employee_advance.json
# erpnext/hr/doctype/employee_advance/employee_advance.py
# erpnext/hr/doctype/employee_advance/test_employee_advance.py
This commit is contained in:
@@ -200,10 +200,15 @@
|
||||
],
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
<<<<<<< HEAD
|
||||
"modified": "2022-05-23 19:33:52.345823",
|
||||
=======
|
||||
"modified": "2021-09-11 18:38:38.617478",
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Advance",
|
||||
"naming_rule": "By \"Naming Series\" field",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
||||
@@ -232,7 +232,11 @@ def create_return_through_additional_salary(doc):
|
||||
if isinstance(doc, str):
|
||||
doc = frappe._dict(json.loads(doc))
|
||||
|
||||
<<<<<<< HEAD
|
||||
additional_salary = frappe.new_doc("Additional Salary")
|
||||
=======
|
||||
additional_salary = frappe.new_doc('Additional Salary')
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
additional_salary.employee = doc.employee
|
||||
additional_salary.currency = doc.currency
|
||||
additional_salary.amount = doc.paid_amount - doc.claimed_amount
|
||||
|
||||
@@ -14,11 +14,14 @@ from erpnext.hr.doctype.employee_advance.employee_advance import (
|
||||
make_bank_entry,
|
||||
make_return_entry,
|
||||
)
|
||||
<<<<<<< HEAD
|
||||
from erpnext.hr.doctype.expense_claim.expense_claim import get_advances
|
||||
from erpnext.hr.doctype.expense_claim.test_expense_claim import (
|
||||
get_payable_account,
|
||||
make_expense_claim,
|
||||
)
|
||||
=======
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
from erpnext.payroll.doctype.salary_component.test_salary_component import create_salary_component
|
||||
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure
|
||||
|
||||
@@ -43,6 +46,7 @@ class TestEmployeeAdvance(unittest.TestCase):
|
||||
journal_entry1 = make_payment_entry(advance)
|
||||
self.assertRaises(EmployeeAdvanceOverPayment, journal_entry1.submit)
|
||||
|
||||
<<<<<<< HEAD
|
||||
def test_paid_amount_on_pe_cancellation(self):
|
||||
employee_name = make_employee("_T@employe.advance")
|
||||
advance = make_employee_advance(employee_name)
|
||||
@@ -169,6 +173,15 @@ class TestEmployeeAdvance(unittest.TestCase):
|
||||
make_salary_structure(
|
||||
"Test Additional Salary for Advance Return", "Monthly", employee=employee_name
|
||||
)
|
||||
=======
|
||||
def test_repay_unclaimed_amount_from_salary(self):
|
||||
employee_name = make_employee("_T@employe.advance")
|
||||
advance = make_employee_advance(employee_name, {"repay_unclaimed_amount_from_salary": 1})
|
||||
|
||||
args = {"type": "Deduction"}
|
||||
create_salary_component("Advance Salary - Deduction", **args)
|
||||
make_salary_structure("Test Additional Salary for Advance Return", "Monthly", employee=employee_name)
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
|
||||
# additional salary for 700 first
|
||||
advance.reload()
|
||||
@@ -192,13 +205,19 @@ class TestEmployeeAdvance(unittest.TestCase):
|
||||
|
||||
advance.reload()
|
||||
self.assertEqual(advance.return_amount, 1000)
|
||||
<<<<<<< HEAD
|
||||
self.assertEqual(advance.status, "Returned")
|
||||
=======
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
|
||||
# update advance return amount on additional salary cancellation
|
||||
additional_salary.cancel()
|
||||
advance.reload()
|
||||
self.assertEqual(advance.return_amount, 700)
|
||||
<<<<<<< HEAD
|
||||
self.assertEqual(advance.status, "Paid")
|
||||
=======
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
|
||||
def tearDown(self):
|
||||
frappe.db.rollback()
|
||||
@@ -212,7 +231,10 @@ def make_payment_entry(advance):
|
||||
|
||||
return journal_entry
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> b98740b44a (fix: employee advance return through multiple additional salaries (#27438))
|
||||
def make_employee_advance(employee_name, args=None):
|
||||
doc = frappe.new_doc("Employee Advance")
|
||||
doc.employee = employee_name
|
||||
|
||||
@@ -127,6 +127,17 @@ class AdditionalSalary(Document):
|
||||
advance = frappe.get_doc("Employee Advance", self.ref_docname)
|
||||
advance.set_status(update=True)
|
||||
|
||||
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)
|
||||
|
||||
def update_employee_referral(self, cancel=False):
|
||||
if self.ref_doctype == "Employee Referral":
|
||||
status = "Unpaid" if cancel else "Paid"
|
||||
|
||||
Reference in New Issue
Block a user