fix: get fallback cost center from Employee/Department
This commit is contained in:
parent
f152a40b28
commit
f867f1974a
@ -13,7 +13,7 @@ frappe.ui.form.on('Department', {
|
||||
"company": frm.doc.company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
refresh: function(frm) {
|
||||
|
@ -54,7 +54,7 @@ frappe.ui.form.on('Employee', {
|
||||
"company": frm.doc.company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
onload: function (frm) {
|
||||
|
@ -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)
|
||||
|
@ -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 = []
|
||||
|
@ -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…
x
Reference in New Issue
Block a user