fix: reset old CTC on promotion cancellation

This commit is contained in:
Rucha Mahabal 2022-04-22 20:20:04 +05:30
parent 9b93c63830
commit cfa4dfe7a8
4 changed files with 13 additions and 3 deletions

View File

@ -106,6 +106,7 @@
"fieldname": "current_ctc",
"fieldtype": "Currency",
"label": "Current CTC",
"mandatory_depends_on": "revised_ctc",
"options": "salary_currency"
},
{
@ -118,7 +119,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2022-04-22 16:26:46.933791",
"modified": "2022-04-22 18:47:10.168744",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Promotion",

View File

@ -35,4 +35,8 @@ class EmployeePromotion(Document):
def on_cancel(self):
employee = frappe.get_doc("Employee", self.employee)
employee = update_employee_work_history(employee, self.promotion_details, cancel=True)
if self.revised_ctc:
employee.ctc = self.current_ctc
employee.save()

View File

@ -49,7 +49,7 @@ class TestEmployeePromotion(FrappeTestCase):
designation="Software Developer",
grade="L1",
salary_currency="INR",
annual_ctc="500000",
ctc="500000",
)
promotion = frappe.get_doc(
@ -86,6 +86,11 @@ class TestEmployeePromotion(FrappeTestCase):
promotion.cancel()
employee.reload()
# fields restored
self.assertEqual(employee.grade, "L1")
self.assertEqual(employee.designation, "Software Developer")
self.assertEqual(employee.ctc, 500000)
# internal work history updated on cancellation
self.assertEqual(len(employee.internal_work_history), 1)
self.assertEqual(employee.internal_work_history[0].designation, "Software Developer")

View File

@ -42,7 +42,7 @@ frappe.ui.form.on(cur_frm.doctype, {
}
const allowed_fields = [];
const exclude_fields = ["naming_series", "employee", "first_name", "middle_name", "last_name", "marital_status",
const exclude_fields = ["naming_series", "employee", "first_name", "middle_name", "last_name", "marital_status", "ctc",
"employee_name", "status", "image", "gender", "date_of_birth", "date_of_joining", "lft", "rgt", "old_parent"];
const exclude_field_types = ["HTML", "Section Break", "Column Break", "Button", "Read Only", "Tab Break", "Table"];