Browse Source

fix: get fallback cost center from Employee/Department

develop
Nabin Hait 3 years ago
parent
commit
f867f1974a
  1. 2
      erpnext/hr/doctype/department/department.js
  2. 2
      erpnext/hr/doctype/employee/employee.js
  3. 8
      erpnext/payroll/doctype/payroll_entry/payroll_entry.py
  4. 6
      erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py
  5. 6
      erpnext/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js

2
erpnext/hr/doctype/department/department.js

@ -13,7 +13,7 @@ frappe.ui.form.on('Department', {
"company": frm.doc.company,
"is_group": 0
}
}
};
});
},
refresh: function(frm) {

2
erpnext/hr/doctype/employee/employee.js

@ -54,7 +54,7 @@ frappe.ui.form.on('Employee', {
"company": frm.doc.company,
"is_group": 0
}
}
};
});
},
onload: function (frm) {

8
erpnext/payroll/doctype/payroll_entry/payroll_entry.py

@ -239,8 +239,14 @@ class PayrollEntry(Document):
cost_centers = dict(frappe.get_all("Employee Cost Center", {"parent": ss_assignment_name},
["cost_center", "percentage"], as_list=1))
if not cost_centers:
default_cost_center, department = frappe.get_cached_value("Employee", employee, ["payroll_cost_center", "department"])
if not default_cost_center and department:
default_cost_center = frappe.get_cached_value("Department", department, "payroll_cost_center")
if not default_cost_center:
default_cost_center = self.cost_center
cost_centers = {
self.cost_center: 100
default_cost_center: 100
}
self.employee_cost_centers.setdefault(employee, cost_centers)

6
erpnext/payroll/doctype/payroll_entry/test_payroll_entry.py

@ -132,12 +132,12 @@ class TestPayrollEntry(unittest.TestCase):
"_Test Payroll Payable - _TC")
currency=frappe.db.get_value("Company", "_Test Company", "default_currency")
ss1 = make_salary_structure("_Test Salary Structure 1", "Monthly", employee1, company="_Test Company", currency=currency, test_tax=False)
ss2 = make_salary_structure("_Test Salary Structure 2", "Monthly", employee2, company="_Test Company", currency=currency, test_tax=False)
make_salary_structure("_Test Salary Structure 1", "Monthly", employee1, company="_Test Company", currency=currency, test_tax=False)
ss = make_salary_structure("_Test Salary Structure 2", "Monthly", employee2, company="_Test Company", currency=currency, test_tax=False)
# update cost centers in salary structure assignment for employee2
ssa = frappe.db.get_value("Salary Structure Assignment",
{"employee": employee2, "salary_structure": ss2.name, "docstatus": 1}, 'name')
{"employee": employee2, "salary_structure": ss.name, "docstatus": 1}, 'name')
ssa_doc = frappe.get_doc("Salary Structure Assignment", ssa)
ssa_doc.payroll_cost_centers = []

6
erpnext/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js

@ -47,12 +47,12 @@ frappe.ui.form.on('Salary Structure Assignment', {
"company": frm.doc.company,
"is_group": 0
}
}
};
});
},
employee: function(frm) {
if(frm.doc.employee){
if (frm.doc.employee) {
frappe.call({
method: "set_payroll_cost_centers",
doc: frm.doc,
@ -61,7 +61,7 @@ frappe.ui.form.on('Salary Structure Assignment', {
}
});
}
else{
else {
frm.set_value("payroll_cost_centers", []);
}
},

Loading…
Cancel
Save