From 975d28307a389efa4bb9f3feefab22b039544e75 Mon Sep 17 00:00:00 2001 From: Utkarsh Goswami Date: Thu, 5 Oct 2017 15:59:51 +0530 Subject: [PATCH] Payroll feature (#10900) --- .../doctype/salary_detail/salary_detail.json | 47 ++++++++++++++++++- erpnext/hr/doctype/salary_slip/salary_slip.js | 10 +++- erpnext/hr/doctype/salary_slip/salary_slip.py | 7 ++- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/erpnext/hr/doctype/salary_detail/salary_detail.json b/erpnext/hr/doctype/salary_detail/salary_detail.json index d131295765..01d02779b7 100644 --- a/erpnext/hr/doctype/salary_detail/salary_detail.json +++ b/erpnext/hr/doctype/salary_detail/salary_detail.json @@ -12,6 +12,7 @@ "editable_grid": 1, "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -42,6 +43,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -73,6 +75,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -101,6 +104,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -131,6 +135,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -159,6 +164,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -189,6 +195,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -221,6 +228,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -253,6 +261,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -284,6 +293,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -314,6 +324,37 @@ "unique": 0 }, { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "do_not_include_in_total", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Do not include in total", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -345,6 +386,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -374,6 +416,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -415,8 +458,8 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-04-13 00:47:33.980646", - "modified_by": "chude.osiegbu@manqala.com", + "modified": "2017-10-02 13:57:22.769751", + "modified_by": "Administrator", "module": "HR", "name": "Salary Detail", "name_case": "", diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index de3276c8e3..24f2016bd6 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -158,14 +158,18 @@ var calculate_earning_total = function(doc, dt, dn, reset_amount) { var total_earn = 0; for(var i = 0; i < tbl.length; i++){ if(cint(tbl[i].depends_on_lwp) == 1) { + tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) / cint(doc.total_working_days)*100)/100; refresh_field('amount', tbl[i].name, 'earnings'); + } else if(reset_amount) { tbl[i].amount = tbl[i].default_amount; refresh_field('amount', tbl[i].name, 'earnings'); } - total_earn += flt(tbl[i].amount); + if(!tbl[i].do_not_include_in_total) { + total_earn += flt(tbl[i].amount); + } } doc.gross_pay = total_earn; refresh_many(['amount','gross_pay']); @@ -184,7 +188,9 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) { tbl[i].amount = tbl[i].default_amount; refresh_field('amount', tbl[i].name, 'deductions'); } - total_ded += flt(tbl[i].amount); + if(!tbl[i].do_not_include_in_total) { + total_ded += flt(tbl[i].amount); + } } doc.total_deduction = total_ded; refresh_field('total_deduction'); diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 356104e69c..f769d6f3db 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -69,7 +69,8 @@ class SalarySlip(TransactionBase): 'amount': amount, 'default_amount': amount, 'depends_on_lwp' : struct_row.depends_on_lwp, - 'salary_component' : struct_row.salary_component + 'salary_component' : struct_row.salary_component, + 'do_not_include_in_total' : struct_row.do_not_include_in_total }) else: component_row.amount = amount @@ -345,11 +346,13 @@ class SalarySlip(TransactionBase): (flt(d.default_amount) * flt(self.payment_days) / cint(self.total_working_days)), self.precision("amount", component_type) ) + elif not self.payment_days and not self.salary_slip_based_on_timesheet: d.amount = 0 elif not d.amount: d.amount = d.default_amount - self.set(total_field, self.get(total_field) + flt(d.amount)) + if not d.do_not_include_in_total: + self.set(total_field, self.get(total_field) + flt(d.amount)) def calculate_net_pay(self): if self.salary_structure: