Merge pull request #6202 from KanchanChauhan/component-type-added
'Type' field added to Salary Component
diff --git a/erpnext/hr/doctype/salary_component/salary_component.json b/erpnext/hr/doctype/salary_component/salary_component.json
index 5595fcc..ca7378b 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.json
+++ b/erpnext/hr/doctype/salary_component/salary_component.json
@@ -15,6 +15,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "salary_component",
"fieldtype": "Data",
"hidden": 0,
@@ -40,6 +41,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "salary_component_abbr",
"fieldtype": "Data",
"hidden": 0,
@@ -67,6 +69,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "description",
"fieldtype": "Small Text",
"hidden": 0,
@@ -92,6 +95,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "accounts",
"fieldtype": "Table",
"hidden": 0,
@@ -113,6 +117,33 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "type",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Earning\nDeduction",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
}
],
"hide_heading": 0,
@@ -126,7 +157,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-07-27 17:40:18.335540",
+ "modified": "2016-08-29 05:33:22.495594",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Component",
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js
index a108e38..0dce0a4 100755
--- a/erpnext/hr/doctype/salary_structure/salary_structure.js
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.js
@@ -13,6 +13,23 @@
}
frappe.ui.form.on('Salary Structure', {
+ onload: function(frm) {
+ frm.set_query("salary_component", "earnings", function() {
+ return {
+ filters: {
+ type: "earning"
+ }
+ }
+ })
+ frm.set_query("salary_component", "deductions", function() {
+ return {
+ filters: {
+ type: "deduction"
+ }
+ }
+ })
+ },
+
refresh: function(frm) {
frm.trigger("toggle_fields")
frm.fields_dict['earnings'].grid.set_column_disp("default_amount", false);
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ba82a23..436bbdb 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -316,3 +316,4 @@
erpnext.patches.v7_0.move_employee_parent_to_child_in_salary_structure
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
erpnext.patches.v7_1.update_total_billing_hours
+erpnext.patches.v7_1.update_component_type
diff --git a/erpnext/patches/v7_1/update_component_type.py b/erpnext/patches/v7_1/update_component_type.py
new file mode 100644
index 0000000..f57b1d1
--- /dev/null
+++ b/erpnext/patches/v7_1/update_component_type.py
@@ -0,0 +1,13 @@
+import frappe
+from frappe.utils import flt
+
+def execute():
+ sal_components = frappe.db.sql("""
+ select DISTINCT salary_component, parentfield from `tabSalary Detail`""", as_dict=True)
+
+ if sal_components:
+ for sal_component in sal_components:
+ if sal_component.parentfield == "earnings":
+ frappe.db.sql("""update `tabSalary Component` set type='Earning' where salary_component=%(sal_comp)s""",{"sal_comp": sal_component.salary_component})
+ else:
+ frappe.db.sql("""update `tabSalary Component` set type='Deduction' where salary_component=%(sal_comp)s""",{"sal_comp": sal_component.salary_component})
\ No newline at end of file