From fb257ba19cba3f53eeaee12ff3a6f06c96980760 Mon Sep 17 00:00:00 2001 From: Ranjith Date: Tue, 29 May 2018 13:57:27 +0530 Subject: [PATCH 1/6] Company - Payroll Settings- fields --- erpnext/setup/doctype/company/company.js | 10 ++ erpnext/setup/doctype/company/company.json | 102 ++++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 5ca28855474..16676ac78af 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -6,6 +6,16 @@ frappe.provide("erpnext.company"); frappe.ui.form.on("Company", { setup: function(frm) { erpnext.company.setup_queries(frm); + frm.set_query("hra_component", function(){ + return { + filters: {"type": "Earning"} + } + }); + frm.set_query("arrear_component", function(){ + return { + filters: {"is_additional_component": 1} + } + }); }, company_name: function(frm) { diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 694a840fc7e..32f0ec4820e 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -2069,6 +2069,104 @@ "set_only_once": 0, "translatable": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_66", + "fieldtype": "Section Break", + "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": "Payroll Settings", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "hra_component", + "fieldtype": "Link", + "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": "HRA Component", + "length": 0, + "no_copy": 0, + "options": "Salary Component", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "arrear_component", + "fieldtype": "Link", + "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": "Arrear Component", + "length": 0, + "no_copy": 0, + "options": "Salary Component", + "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, + "translatable": 0, + "unique": 0 }, { "allow_bulk_edit": 0, @@ -2591,7 +2689,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-05-23 03:25:15.872138", + "modified": "2018-05-29 13:25:15.872138", "modified_by": "Administrator", "module": "Setup", "name": "Company", @@ -2738,4 +2836,4 @@ "sort_order": "ASC", "track_changes": 1, "track_seen": 0 -} \ No newline at end of file +} From 7bb621d2bf1f8d669681d92864964c8236ce6137 Mon Sep 17 00:00:00 2001 From: Ranjith Date: Tue, 29 May 2018 13:58:31 +0530 Subject: [PATCH 2/6] Tax Exemption Declaration, Proof Submission HRA fields --- .../employee_tax_exemption_declaration.json | 312 +++++++++++++++--- ...ployee_tax_exemption_proof_submission.json | 285 +++++++++++++--- 2 files changed, 516 insertions(+), 81 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json index 1975c1c8657..f107b06f613 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json @@ -15,6 +15,7 @@ "fields": [ { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -42,15 +43,17 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "employee.company", "fieldname": "company", "fieldtype": "Link", "hidden": 0, @@ -74,11 +77,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -104,11 +108,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -136,11 +141,12 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -172,43 +178,45 @@ }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "employee.department", - "fieldname": "department", - "fieldtype": "Link", - "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": "Department", - "length": 0, - "no_copy": 0, - "options": "Department", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "fetch_from": "employee.department", + "fieldname": "department", + "fieldtype": "Link", + "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": "Department", + "length": 0, + "no_copy": 0, + "options": "Department", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, "fieldname": "amended_from", "fieldtype": "Link", "hidden": 0, @@ -231,11 +239,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -261,11 +270,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -293,7 +303,231 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "hra_declaration", + "fieldtype": "Section Break", + "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": "HRA Declaration", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "salary_structure_hra", + "fieldtype": "Currency", + "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": "HRA as per Salary Structure", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "monthly_house_rent", + "fieldtype": "Currency", + "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": "Monthly House Rent", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "rented_in_metro_city", + "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": "Rented in Metro City", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "coloum_break_3", + "fieldtype": "Column Break", + "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": " ", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "annual_hra", + "fieldtype": "Currency", + "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": "Annual HRA", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "monthly_hra", + "fieldtype": "Currency", + "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": "Monthly HRA", + "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, + "translatable": 0, "unique": 0 } ], @@ -307,7 +541,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-17 12:20:24.433775", + "modified": "2018-05-29 12:41:27.446550", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Declaration", diff --git a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json index ead62c6cdb6..9e53a972476 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json +++ b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json @@ -15,6 +15,7 @@ "fields": [ { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -42,11 +43,12 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -74,11 +76,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -104,11 +107,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -136,48 +140,50 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "employee.department", - "fieldname": "department", - "fieldtype": "Link", - "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": "Department", - "length": 0, - "no_copy": 0, - "options": "Department", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "fetch_from": "employee.department", + "fieldname": "department", + "fieldtype": "Link", + "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": "Department", + "length": 0, + "no_copy": 0, + "options": "Department", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, "fieldname": "processed_in_payroll", "fieldtype": "Check", "hidden": 0, @@ -200,11 +206,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -230,11 +237,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -262,11 +270,202 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_9", + "fieldtype": "Section Break", + "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, + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "house_rent_payment_amount", + "fieldtype": "Currency", + "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": " House Rent Payment Amount", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "rented_in_metro_city", + "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": "Rented in Metro City", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_12", + "fieldtype": "Column Break", + "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, + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "rented_from_date", + "fieldtype": "Date", + "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": "Rented From Date", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "rented_to_date", + "fieldtype": "Date", + "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": "Rented To Date", + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -293,11 +492,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -324,11 +524,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -355,7 +556,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 } ], @@ -369,7 +570,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-17 10:01:12.346201", + "modified": "2018-05-29 13:54:55.004847", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Proof Submission", From 155ecc1b4a5cd3cbe37ef75bfde27bf599f33433 Mon Sep 17 00:00:00 2001 From: Ranjith Date: Wed, 30 May 2018 13:37:15 +0530 Subject: [PATCH 3/6] Tax Exemption Declaration - HRA Calculation --- .../employee_tax_exemption_declaration.js | 48 ++++++++++++-- .../employee_tax_exemption_declaration.json | 13 ++-- .../employee_tax_exemption_declaration.py | 63 +++++++++++++++++-- ...ee_tax_exemption_declaration_category.json | 17 ++--- erpnext/hr/utils.py | 13 ++++ 5 files changed, 133 insertions(+), 21 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js index 23d158c7f0c..fb8c81ac762 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js @@ -2,6 +2,11 @@ // For license information, please see license.txt frappe.ui.form.on('Employee Tax Exemption Declaration', { + refresh: function(frm){ + if(frm.doc.__islocal){ + frm.set_df_property('hra_declaration_section', 'hidden', 1); + } + }, setup: function(frm) { frm.set_query('employee', function() { return { @@ -36,10 +41,45 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', { }); }, employee: function(frm){ - if(frm.doc.employee){ - frm.add_fetch('employee', 'company', 'company'); - }else{ - frm.set_value('company', ''); + frm.trigger('set_null_value'); + }, + company: function(frm) { + if(frm.doc.company){ + frappe.call({ + method: "frappe.client.get_value", + args: { + doctype: "Company", + filters: {"name": frm.doc.company}, + fieldname: "hra_component" + }, + callback: function(r){ + if(r.message.hra_component){ + frm.set_df_property('hra_declaration_section', 'hidden', 0); + } + } + }); } + }, + monthly_house_rent: function(frm) { + frm.trigger("calculate_hra_component"); + }, + rented_in_metro_city: function(frm) { + frm.trigger("calculate_hra_component"); + }, + calculate_hra_component: function(frm) { + frappe.call({ + method: "calculate_hra_component", + doc: frm.doc, + callback: function(r) { + frm.refresh_fields(); + } + }); + }, + set_null_value(frm){ + let fields = ['salary_structure_hra', 'monthly_house_rent','annual_hra', 'monthly_hra', + 'total_exemption_amount', 'payroll_period']; + fields.forEach(function(field) { + frm.set_value(field, ''); + }); } }); diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json index f107b06f613..b984873e4df 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json @@ -249,7 +249,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "section_break_4", + "fieldname": "section_break_8", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, @@ -313,7 +313,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "hra_declaration", + "depends_on": "", + "fieldname": "hra_declaration_section", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, @@ -361,7 +362,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -489,7 +490,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -521,7 +522,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -541,7 +542,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-29 12:41:27.446550", + "modified": "2018-05-30 13:35:08.941961", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Declaration", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py index 22e1638751e..b2d87bc32d9 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py @@ -6,11 +6,19 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from erpnext.hr.utils import validate_tax_declaration +from frappe.utils import getdate, flt +from erpnext.hr.utils import validate_tax_declaration, get_salary_assignment +from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip class EmployeeTaxExemptionDeclaration(Document): def validate(self): validate_tax_declaration(self.declarations) + self.calculate_hra_component() + self.total_exemption_amount = 0 + for item in self.declarations: + self.total_exemption_amount += item.amount + if self.annual_hra: + self.total_exemption_amount += self.annual_hra def before_submit(self): if frappe.db.exists({"doctype": "Employee Tax Exemption Declaration", @@ -19,6 +27,53 @@ class EmployeeTaxExemptionDeclaration(Document): "docstatus": 1}): frappe.throw(_("Tax Declaration of {0} for period {1} already submitted.")\ .format(self.employee, self.payroll_period), frappe.DocstatusTransitionError) - self.total_exemption_amount = 0 - for item in self.declarations: - self.total_exemption_amount += item.amount + + def calculate_hra_component(self): + hra_component = frappe.db.get_value("Company", self.company, "hra_component") + if hra_component: + assignment = get_salary_assignment(self.employee, getdate()) + if assignment and frappe.db.exists("Salary Detail", { + "parent": assignment.salary_structure, + "salary_component": hra_component, "parentfield": "earnings"}): + hra_amount = self.get_hra_from_salary_slip(assignment.salary_structure, hra_component) + if hra_amount: + self.salary_structure_hra = hra_amount + if self.monthly_house_rent: + self.annual_hra, self.monthly_hra = 0, 0 + annual_hra = self.calculate_eligible_hra_amount(assignment.salary_structure, assignment.base) + if annual_hra > 0: + self.annual_hra = annual_hra + self.monthly_hra = annual_hra / 12 + + def calculate_eligible_hra_amount(self, salary_structure, base): + # TODO make this configurable + exemptions = [] + frequency = frappe.get_value("Salary Structure", salary_structure, "payroll_frequency") + # case 1: The actual amount allotted by the employer as the HRA. + exemptions.append(self.get_annual_component_pay(frequency, self.salary_structure_hra)) + actual_annual_rent = self.monthly_house_rent * 12 + annual_base = self.get_annual_component_pay(frequency, base) + # case 2: Actual rent paid less 10% of the basic salary. + exemptions.append(flt(actual_annual_rent) - flt(annual_base * 0.1)) + # case 3: 50% of the basic salary, if the employee is staying in a metro city (40% for a non-metro city). + exemptions.append(annual_base * 0.5 if self.rented_in_metro_city else annual_base * 0.4) + # return minimum of 3 cases + return min(exemptions) + + def get_annual_component_pay(self, frequency, amount): + if frequency == "Daily": + return amount * 365 + elif frequency == "Weekly": + return amount * 52 + elif frequency == "Fortnightly": + return amount * 26 + elif frequency == "Monthly": + return amount * 12 + elif frequency == "Bimonthly": + return amount * 6 + + def get_hra_from_salary_slip(self, salary_structure, hra_component): + salary_slip = make_salary_slip(salary_structure, employee=self.employee) + for earning in salary_slip.earnings: + if earning.salary_component == hra_component: + return earning.amount diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json b/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json index 29df0646c35..ebde4c9c717 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json @@ -14,6 +14,7 @@ "fields": [ { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -41,18 +42,19 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "exemption_sub_category.exemption_category", + "fetch_from": "exemption_sub_category.exemption_category", "fieldname": "exemption_category", - "fieldtype": "Read Only", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -63,7 +65,7 @@ "label": "Exemption Category", "length": 0, "no_copy": 0, - "options": "", + "options": "Employee Tax Exemption Category", "permlevel": 0, "precision": "", "print_hide": 0, @@ -74,11 +76,12 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -105,7 +108,7 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 } ], @@ -119,7 +122,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-16 22:42:42.980630", + "modified": "2018-05-29 15:58:05.779031", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Declaration Category", diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index 20fe666d2b1..71a763c1aa1 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -241,3 +241,16 @@ def get_payroll_period(from_date, to_date, company): pd.parent=pp.name where pd.start_date<=%s and pd.end_date>= %s and pp.company=%s""", (from_date, to_date, company), as_dict=1) return payroll_period[0] if payroll_period else None + +def get_salary_assignment(employee, date): + assignment = frappe.db.sql(""" + select * from `tabSalary Structure Assignment` + where employee=%(employee)s + and docstatus = 1 + and ( + (%(on_date)s between from_date and ifnull(to_date, '2199-12-31')) + )""", { + 'employee': employee, + 'on_date': date, + }, as_dict=1) + return assignment[0] if assignment else None From 793f8e8caa8cb3bf6c0566a1d4f3eab500be2c9d Mon Sep 17 00:00:00 2001 From: Ranjith Date: Wed, 30 May 2018 20:50:48 +0530 Subject: [PATCH 4/6] Tax Exemption Declaration - update fields, move generic methods to utils --- .../employee_tax_exemption_declaration.js | 8 +-- .../employee_tax_exemption_declaration.json | 10 +-- .../employee_tax_exemption_declaration.py | 66 ++++--------------- erpnext/hr/utils.py | 56 +++++++++++++++- 4 files changed, 75 insertions(+), 65 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js index fb8c81ac762..130d202c4f1 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js @@ -61,14 +61,14 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', { } }, monthly_house_rent: function(frm) { - frm.trigger("calculate_hra_component"); + frm.trigger("calculate_hra_exemption"); }, rented_in_metro_city: function(frm) { - frm.trigger("calculate_hra_component"); + frm.trigger("calculate_hra_exemption"); }, - calculate_hra_component: function(frm) { + calculate_hra_exemption: function(frm) { frappe.call({ - method: "calculate_hra_component", + method: "calculate_hra_exemption", doc: frm.doc, callback: function(r) { frm.refresh_fields(); diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json index b984873e4df..473150b825a 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json @@ -474,7 +474,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "annual_hra", + "fieldname": "annual_hra_exemption", "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, @@ -483,7 +483,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Annual HRA", + "label": "Annual HRA Exemption", "length": 0, "no_copy": 0, "permlevel": 0, @@ -506,7 +506,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "monthly_hra", + "fieldname": "monthly_hra_exemption", "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, @@ -515,7 +515,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Monthly HRA", + "label": "Monthly HRA Exemption", "length": 0, "no_copy": 0, "permlevel": 0, @@ -542,7 +542,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-30 13:35:08.941961", + "modified": "2018-05-30 18:09:50.662362", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Declaration", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py index b2d87bc32d9..9bdba4a6d51 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py @@ -6,19 +6,18 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from frappe.utils import getdate, flt -from erpnext.hr.utils import validate_tax_declaration, get_salary_assignment -from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip +from frappe.utils import getdate +from erpnext.hr.utils import validate_tax_declaration, calculate_eligible_hra_exemption class EmployeeTaxExemptionDeclaration(Document): def validate(self): validate_tax_declaration(self.declarations) - self.calculate_hra_component() + self.calculate_hra_exemption() self.total_exemption_amount = 0 for item in self.declarations: self.total_exemption_amount += item.amount - if self.annual_hra: - self.total_exemption_amount += self.annual_hra + if self.annual_hra_exemption: + self.total_exemption_amount += self.annual_hra_exemption def before_submit(self): if frappe.db.exists({"doctype": "Employee Tax Exemption Declaration", @@ -28,52 +27,9 @@ class EmployeeTaxExemptionDeclaration(Document): frappe.throw(_("Tax Declaration of {0} for period {1} already submitted.")\ .format(self.employee, self.payroll_period), frappe.DocstatusTransitionError) - def calculate_hra_component(self): - hra_component = frappe.db.get_value("Company", self.company, "hra_component") - if hra_component: - assignment = get_salary_assignment(self.employee, getdate()) - if assignment and frappe.db.exists("Salary Detail", { - "parent": assignment.salary_structure, - "salary_component": hra_component, "parentfield": "earnings"}): - hra_amount = self.get_hra_from_salary_slip(assignment.salary_structure, hra_component) - if hra_amount: - self.salary_structure_hra = hra_amount - if self.monthly_house_rent: - self.annual_hra, self.monthly_hra = 0, 0 - annual_hra = self.calculate_eligible_hra_amount(assignment.salary_structure, assignment.base) - if annual_hra > 0: - self.annual_hra = annual_hra - self.monthly_hra = annual_hra / 12 - - def calculate_eligible_hra_amount(self, salary_structure, base): - # TODO make this configurable - exemptions = [] - frequency = frappe.get_value("Salary Structure", salary_structure, "payroll_frequency") - # case 1: The actual amount allotted by the employer as the HRA. - exemptions.append(self.get_annual_component_pay(frequency, self.salary_structure_hra)) - actual_annual_rent = self.monthly_house_rent * 12 - annual_base = self.get_annual_component_pay(frequency, base) - # case 2: Actual rent paid less 10% of the basic salary. - exemptions.append(flt(actual_annual_rent) - flt(annual_base * 0.1)) - # case 3: 50% of the basic salary, if the employee is staying in a metro city (40% for a non-metro city). - exemptions.append(annual_base * 0.5 if self.rented_in_metro_city else annual_base * 0.4) - # return minimum of 3 cases - return min(exemptions) - - def get_annual_component_pay(self, frequency, amount): - if frequency == "Daily": - return amount * 365 - elif frequency == "Weekly": - return amount * 52 - elif frequency == "Fortnightly": - return amount * 26 - elif frequency == "Monthly": - return amount * 12 - elif frequency == "Bimonthly": - return amount * 6 - - def get_hra_from_salary_slip(self, salary_structure, hra_component): - salary_slip = make_salary_slip(salary_structure, employee=self.employee) - for earning in salary_slip.earnings: - if earning.salary_component == hra_component: - return earning.amount + def calculate_hra_exemption(self): + exemptions = calculate_eligible_hra_exemption(self.company, self.employee, \ + self.monthly_house_rent, self.rented_in_metro_city) + self.salary_structure_hra = exemptions["hra_amount"] + self.annual_hra_exemption = exemptions["annual_exemption"] + self.monthly_hra_exemption = exemptions["monthly_exemption"] diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index 71a763c1aa1..cbc373841ef 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -4,9 +4,10 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import formatdate, format_datetime, getdate, get_datetime, nowdate +from frappe.utils import formatdate, format_datetime, getdate, get_datetime, nowdate, flt from frappe.model.document import Document from frappe.desk.form import assign_to +from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip class EmployeeBoardingController(Document): ''' @@ -254,3 +255,56 @@ def get_salary_assignment(employee, date): 'on_date': date, }, as_dict=1) return assignment[0] if assignment else None + +def calculate_eligible_hra_exemption(company, employee, monthly_house_rent, rented_in_metro_city): + hra_component = frappe.db.get_value("Company", company, "hra_component") + annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 + if hra_component: + assignment = get_salary_assignment(employee, getdate()) + if assignment and frappe.db.exists("Salary Detail", { + "parent": assignment.salary_structure, + "salary_component": hra_component, "parentfield": "earnings"}): + hra_amount = get_hra_from_salary_slip(employee, assignment.salary_structure, hra_component) + if hra_amount: + if monthly_house_rent: + annual_exemption = calculate_hra_exemption(assignment.salary_structure, + assignment.base, hra_amount, monthly_house_rent, + rented_in_metro_city) + if annual_exemption > 0: + monthly_exemption = annual_exemption / 12 + else: + annual_exemption = 0 + return {"hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption} + +def get_hra_from_salary_slip(employee, salary_structure, hra_component): + salary_slip = make_salary_slip(salary_structure, employee=employee) + for earning in salary_slip.earnings: + if earning.salary_component == hra_component: + return earning.amount + +def calculate_hra_exemption(salary_structure, base, monthly_hra, monthly_house_rent, rented_in_metro_city): + # TODO make this configurable + exemptions = [] + frequency = frappe.get_value("Salary Structure", salary_structure, "payroll_frequency") + # case 1: The actual amount allotted by the employer as the HRA. + exemptions.append(get_annual_component_pay(frequency, monthly_hra)) + actual_annual_rent = monthly_house_rent * 12 + annual_base = get_annual_component_pay(frequency, base) + # case 2: Actual rent paid less 10% of the basic salary. + exemptions.append(flt(actual_annual_rent) - flt(annual_base * 0.1)) + # case 3: 50% of the basic salary, if the employee is staying in a metro city (40% for a non-metro city). + exemptions.append(annual_base * 0.5 if rented_in_metro_city else annual_base * 0.4) + # return minimum of 3 cases + return min(exemptions) + +def get_annual_component_pay(frequency, amount): + if frequency == "Daily": + return amount * 365 + elif frequency == "Weekly": + return amount * 52 + elif frequency == "Fortnightly": + return amount * 26 + elif frequency == "Monthly": + return amount * 12 + elif frequency == "Bimonthly": + return amount * 6 From 0cb268413008eb1828d4f8904ffb41e2317bc834 Mon Sep 17 00:00:00 2001 From: Ranjith Date: Wed, 30 May 2018 20:51:37 +0530 Subject: [PATCH 5/6] Tax Exemption Proof Submission - validations, eligible hra calc --- ...ployee_tax_exemption_proof_submission.json | 192 +++++++++++++++--- ...employee_tax_exemption_proof_submission.py | 54 ++++- 2 files changed, 205 insertions(+), 41 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json index 9e53a972476..32203d8604e 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json +++ b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.json @@ -209,6 +209,38 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "total_amount", + "fieldtype": "Currency", + "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": "Total Exemption Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -368,37 +400,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_12", - "fieldtype": "Column Break", - "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, - "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, - "translatable": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -463,6 +464,133 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_12", + "fieldtype": "Column Break", + "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, + "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, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "monthly_house_rent", + "fieldtype": "Currency", + "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": "Monthly House Rent", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "monthly_hra_exemption", + "fieldtype": "Currency", + "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": "Monthly Eligible Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "total_eligible_hra_exemption", + "fieldtype": "Currency", + "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": "Total Eligible HRA Exemption", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -570,7 +698,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-29 13:54:55.004847", + "modified": "2018-05-30 20:26:05.714414", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Proof Submission", diff --git a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py index a0c003cdc60..2be09ae9b9d 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py +++ b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py @@ -6,16 +6,52 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from erpnext.hr.utils import validate_tax_declaration +from frappe.utils import date_diff, flt, getdate, get_first_day, get_last_day +from erpnext.hr.utils import validate_tax_declaration, calculate_eligible_hra_exemption class EmployeeTaxExemptionProofSubmission(Document): def validate(self): validate_tax_declaration(self.tax_exemption_proofs) - #TODO: allow multiple? - # def before_submit(self): - # if frappe.db.exists({"doctype": "Employee Tax Exemption Proof Submission", - # "employee": self.employee, - # "payroll_period": self.payroll_period, - # "docstatus": 1}): - # frappe.throw(_("Proof Submission of {0} for period {1} already submitted.")\ - # .format(self.employee, self.payroll_period), frappe.DocstatusTransitionError) + if self.house_rent_payment_amount: + self.validate_house_rent_dates() + self.get_monthly_hra() + self.calculate_hra_exemption() + self.calculate_total_exemption() + + def get_monthly_hra(self): + factor = self.get_rented_days_factor() + self.monthly_house_rent = self.house_rent_payment_amount / factor + + def validate_house_rent_dates(self): + if date_diff(self.rented_to_date, self.rented_from_date) < 14: + frappe.throw(_("House Rented dates should be atleast 15 days apart")) + + proofs = frappe.db.sql("""select name from `tabEmployee Tax Exemption Proof Submission` + where docstatus=1 and employee='{0}' and payroll_period='{1}' and + (rented_from_date between '{2}' and '{3}' or rented_to_date between + '{2}' and '{2}')""".format(self.employee, self.payroll_period, + self.rented_from_date, self.rented_to_date)) + if proofs: + frappe.throw(_("House rent paid days overlap with {0}").format(proofs[0][0])) + + def calculate_hra_exemption(self): + exemptions = calculate_eligible_hra_exemption(self.company, self.employee, \ + self.monthly_house_rent, self.rented_in_metro_city) + self.monthly_hra_exemption = exemptions["monthly_exemption"] + if self.monthly_hra_exemption: + factor = self.get_rented_days_factor(rounded=False) + self.total_eligible_hra_exemption = self.monthly_hra_exemption * factor + else: + self.monthly_hra_exemption, self.total_eligible_hra_exemption = 0, 0 + + def get_rented_days_factor(self, rounded=True): + factor = flt(date_diff(self.rented_to_date, self.rented_from_date) + 1)/30 + factor = round(factor * 2)/2 + return factor if factor else 0.5 + + def calculate_total_exemption(self): + self.total_amount = 0 + for proof in self.tax_exemption_proofs: + self.total_amount += proof.amount + if self.monthly_house_rent and self.total_eligible_hra_exemption: + self.total_amount += self.total_eligible_hra_exemption From 590bf4ce3a999a9533a07b485e55c9a16f06dc51 Mon Sep 17 00:00:00 2001 From: Ranjith Date: Thu, 31 May 2018 12:08:14 +0530 Subject: [PATCH 6/6] codacy fixes --- .../employee_tax_exemption_declaration.js | 6 ++++-- .../employee_tax_exemption_declaration.py | 1 - .../employee_tax_exemption_proof_submission.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js index 130d202c4f1..72ce7a5b807 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js @@ -71,13 +71,15 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', { method: "calculate_hra_exemption", doc: frm.doc, callback: function(r) { - frm.refresh_fields(); + if (!r.exc){ + frm.refresh_fields(); + } } }); }, set_null_value(frm){ let fields = ['salary_structure_hra', 'monthly_house_rent','annual_hra', 'monthly_hra', - 'total_exemption_amount', 'payroll_period']; + 'total_exemption_amount', 'payroll_period']; fields.forEach(function(field) { frm.set_value(field, ''); }); diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py index 9bdba4a6d51..a9b1e33af51 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py @@ -6,7 +6,6 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from frappe.utils import getdate from erpnext.hr.utils import validate_tax_declaration, calculate_eligible_hra_exemption class EmployeeTaxExemptionDeclaration(Document): diff --git a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py index 2be09ae9b9d..503cfe051eb 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py +++ b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from frappe.utils import date_diff, flt, getdate, get_first_day, get_last_day +from frappe.utils import date_diff, flt from erpnext.hr.utils import validate_tax_declaration, calculate_eligible_hra_exemption class EmployeeTaxExemptionProofSubmission(Document):