Employee Transfer allow same company, update internal work history (#14430)

This commit is contained in:
Ranjith Kurungadam
2018-06-11 11:24:44 +05:30
committed by Nabin Hait
parent 88a90ff3b5
commit e46639f47c
3 changed files with 18 additions and 11 deletions

View File

@@ -88,7 +88,8 @@ def set_employee_name(doc):
if doc.employee and not doc.employee_name:
doc.employee_name = frappe.db.get_value("Employee", doc.employee, "employee_name")
def update_employee(employee, details, cancel=False):
def update_employee(employee, details, date=None, cancel=False):
internal_work_history = {}
for item in details:
fieldtype = frappe.get_meta("Employee").get_field(item.fieldname).fieldtype
new_data = item.new if not cancel else item.current
@@ -97,6 +98,11 @@ def update_employee(employee, details, cancel=False):
elif fieldtype =="Datetime" and new_data:
new_data = get_datetime(new_data)
setattr(employee, item.fieldname, new_data)
if item.fieldname in ["department", "designation", "branch"]:
internal_work_history[item.fieldname] = item.new
if internal_work_history and not cancel:
internal_work_history["from_date"] = date
employee.append("internal_work_history", internal_work_history)
return employee
@frappe.whitelist()
@@ -343,4 +349,4 @@ def get_annual_component_pay(frequency, amount):
elif frequency == "Monthly":
return amount * 12
elif frequency == "Bimonthly":
return amount * 6
return amount * 6