From 4a888b4c912d97dbd13f35b3dd109204c42c9687 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Fri, 2 Dec 2016 17:04:53 +0530 Subject: [PATCH] [Fix] lwp issue fixed for salary slip without salary structure --- .../doctype/process_payroll/process_payroll.js | 10 ++++++++++ erpnext/hr/doctype/salary_slip/salary_slip.js | 17 +++++------------ erpnext/hr/doctype/salary_slip/salary_slip.py | 5 ++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js index 2ab6aef7b5..35c097ac0d 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.js +++ b/erpnext/hr/doctype/process_payroll/process_payroll.js @@ -43,6 +43,16 @@ frappe.ui.form.on("Process Payroll", { } }) } + }, + account: function(frm) { + var account_types = ["Bank", "Cash"]; + return { + filters: { + "account_type": ["in", account_types], + "is_group": 0, + "company": frm.doc.company + } + } } }) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index bb27a4212a..e1120e8826 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -114,22 +114,15 @@ var calculate_all = function(doc, dt, dn) { } cur_frm.cscript.amount = function(doc,dt,dn){ - calculate_earning_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); + var child = locals[dt][dn]; + if(!doc.salary_structure){ + frappe.model.set_value(dt,dn, "default_amount", child.amount) + } + calculate_all(doc, dt, dn); } cur_frm.cscript.depends_on_lwp = function(doc,dt,dn){ calculate_earning_total(doc, dt, dn, true); - calculate_net_pay(doc, dt, dn); -} -// Trigger on earning modified amount and depends on lwp -// ------------------------------------------------------------------------ -cur_frm.cscript.amount = function(doc,dt,dn){ - calculate_ded_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); -} - -cur_frm.cscript.depends_on_lwp = function(doc, dt, dn) { calculate_ded_total(doc, dt, dn, true); calculate_net_pay(doc, dt, dn); }; diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 3ffa4dd184..65a8dd3c6c 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -10,7 +10,6 @@ from frappe.model.naming import make_autoname from frappe import msgprint, _ from erpnext.accounts.utils import get_fiscal_year from erpnext.setup.utils import get_company_currency -from erpnext.hr.utils import set_employee_name from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee from erpnext.utilities.transaction_base import TransactionBase @@ -84,7 +83,7 @@ class SalarySlip(TransactionBase): if d.amount_based_on_formula: if d.formula: amount = eval(d.formula, None, data) - if amount: + if amount: data[d.abbr] = amount return amount @@ -316,7 +315,7 @@ class SalarySlip(TransactionBase): def sum_components(self, component_type, total_field): for d in self.get(component_type): if cint(d.depends_on_lwp) == 1 and not self.salary_slip_based_on_timesheet: - d.amount = rounded((flt(d.amount) * flt(self.payment_days) + d.amount = rounded((flt(d.default_amount) * flt(self.payment_days) / cint(self.total_days_in_month)), self.precision("amount", component_type)) elif not self.payment_days and not self.salary_slip_based_on_timesheet: d.amount = 0