From aac404a155c5d0d3b2a7cfcc5b940ee2aa33248d Mon Sep 17 00:00:00 2001 From: navdeepghai1 Date: Mon, 28 Jan 2019 10:42:16 +0400 Subject: [PATCH 1/2] Fixed net_pay calculation issue --- erpnext/hr/doctype/salary_slip/salary_slip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 3ee98e6be0..901ede1197 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -360,7 +360,7 @@ class SalarySlip(TransactionBase): elif not d.amount: d.amount = d.default_amount if not d.do_not_include_in_total: - self.set(total_field, self.get(total_field) + flt(d.amount)) + self.set(total_field, self.get(total_field) + flt(d.amount, 2)) def calculate_net_pay(self): if self.salary_structure: @@ -473,4 +473,4 @@ def unlink_ref_doc_from_salary_slip(ref_no): if linked_ss: for ss in linked_ss: ss_doc = frappe.get_doc("Salary Slip", ss) - frappe.db.set_value("Salary Slip", ss_doc.name, "journal_entry", "") \ No newline at end of file + frappe.db.set_value("Salary Slip", ss_doc.name, "journal_entry", "") From 92bb84aa70270a8f6b278c040eff9dbd1097b1b5 Mon Sep 17 00:00:00 2001 From: navdeepghai1 Date: Mon, 28 Jan 2019 16:54:58 +0400 Subject: [PATCH 2/2] Changed static precision(2) value to system setting currency_precision value --- erpnext/hr/doctype/salary_slip/salary_slip.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 901ede1197..11538cc368 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -330,7 +330,7 @@ class SalarySlip(TransactionBase): if frappe.db.get_value('Timesheet', data.time_sheet, 'status') == 'Payrolled': frappe.throw(_("Salary Slip of employee {0} already created for time sheet {1}").format(self.employee, data.time_sheet)) - def sum_components(self, component_type, total_field): + def sum_components(self, component_type, total_field, precision): joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, ["date_of_joining", "relieving_date"]) @@ -350,7 +350,7 @@ class SalarySlip(TransactionBase): )): d.amount = rounded( - (flt(d.default_amount) * flt(self.payment_days) + (flt(d.default_amount, precision) * flt(self.payment_days) / cint(self.total_working_days)), self.precision("amount", component_type) ) @@ -360,19 +360,19 @@ class SalarySlip(TransactionBase): elif not d.amount: d.amount = d.default_amount if not d.do_not_include_in_total: - self.set(total_field, self.get(total_field) + flt(d.amount, 2)) + self.set(total_field, self.get(total_field) + flt(d.amount, precision)) def calculate_net_pay(self): if self.salary_structure: self.calculate_component_amounts() disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total")) - + precision = frappe.defaults.get_global_default("currency_precision") self.total_deduction = 0 self.gross_pay = 0 - self.sum_components('earnings', 'gross_pay') - self.sum_components('deductions', 'total_deduction') + self.sum_components('earnings', 'gross_pay', precision) + self.sum_components('deductions', 'total_deduction', precision) self.set_loan_repayment()