Merge pull request #16961 from rohitwaghchaure/stock_ageing_warehouse_wise

feat: Stock ageing report warehouse wise
diff --git a/README.md b/README.md
index 8c13e1e..b1979d0 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,6 @@
     </p>
 
 [![Build Status](https://travis-ci.com/frappe/erpnext.png)](https://travis-ci.com/frappe/erpnext)
-[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 
 [![Open Source Helpers](https://www.codetriage.com/frappe/erpnext/badges/users.svg)](https://www.codetriage.com/frappe/erpnext)
 [![Coverage Status](https://coveralls.io/repos/github/frappe/erpnext/badge.svg?branch=develop)](https://coveralls.io/github/frappe/erpnext?branch=develop)
 
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index ea25fcf..2a375ae 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
 from erpnext.hooks import regional_overrides
 from frappe.utils import getdate
 
-__version__ = '11.1.14'
+__version__ = '11.1.16'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 5d504b9..427f3db 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -5,7 +5,7 @@
 import frappe
 from frappe.utils import cint, cstr
 from frappe import throw, _
-from frappe.utils.nestedset import NestedSet
+from frappe.utils.nestedset import NestedSet, get_ancestors_of, get_descendants_of
 
 class RootNotEditable(frappe.ValidationError): pass
 class BalanceMismatchError(frappe.ValidationError): pass
@@ -41,6 +41,7 @@
 		self.validate_frozen_accounts_modifier()
 		self.validate_balance_must_be_debit_or_credit()
 		self.validate_account_currency()
+		self.validate_root_company_and_sync_account_to_children()
 
 	def validate_parent(self):
 		"""Fetch Parent Details and validate parent account"""
@@ -90,6 +91,34 @@
 		if not self.parent_account and not self.is_group:
 			frappe.throw(_("Root Account must be a group"))
 
+	def validate_root_company_and_sync_account_to_children(self):
+		# ignore validation while creating new compnay or while syncing to child companies
+		if frappe.local.flags.ignore_root_company_validation or self.flags.ignore_root_company_validation:
+			return
+
+		ancestors = get_root_company(self.company)
+		if ancestors:
+			frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0]))
+		else:
+			descendants = get_descendants_of('Company', self.company)
+			if not descendants: return
+
+			acc_name_map = {}
+			acc_name = frappe.db.get_value('Account', self.parent_account, "account_name")
+			for d in frappe.db.get_values('Account',
+				{"company": ["in", descendants], "account_name": acc_name},
+				["company", "name"], as_dict=True):
+				acc_name_map[d["company"]] = d["name"]
+
+			for company in descendants:
+				doc = frappe.copy_doc(self)
+				doc.flags.ignore_root_company_validation = True
+				doc.update({"company": company, "account_currency": None,
+					"parent": acc_name_map[company], "parent_account": acc_name_map[company]})
+				doc.save()
+				frappe.msgprint(_("Account {0} is added in the child company {1}")
+					.format(doc.name, company))
+
 	def validate_group_or_ledger(self):
 		if self.get("__islocal"):
 			return
@@ -250,3 +279,9 @@
 	frappe.rename_doc("Account", old, new, merge=1, ignore_permissions=1)
 
 	return new
+
+@frappe.whitelist()
+def get_root_company(company):
+	# return the topmost company in the hierarchy
+	ancestors = get_ancestors_of('Company', company, "lft asc")
+	return [ancestors[0]] if ancestors else []
diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js
index 1047f51..03c98fa 100644
--- a/erpnext/accounts/doctype/account/account_tree.js
+++ b/erpnext/accounts/doctype/account/account_tree.js
@@ -4,13 +4,38 @@
 	breadcrumbs: "Accounts",
 	title: __("Chart Of Accounts"),
 	get_tree_root: false,
-	filters: [{
-		fieldname: "company",
-		fieldtype:"Select",
-		options: erpnext.utils.get_tree_options("company"),
-		label: __("Company"),
-		default: erpnext.utils.get_tree_default("company")
-	}],
+	filters: [
+		{
+			fieldname: "company",
+			fieldtype:"Select",
+			options: erpnext.utils.get_tree_options("company"),
+			label: __("Company"),
+			default: erpnext.utils.get_tree_default("company"),
+			on_change: function() {
+				var me = frappe.treeview_settings['Account'].treeview;
+				var company = me.page.fields_dict.company.get_value();
+				frappe.call({
+					method: "erpnext.accounts.doctype.account.account.get_root_company",
+					args: {
+						company: company,
+					},
+					callback: function(r) {
+						if(r.message) {
+							let root_company = r.message.length ? r.message[0] : "";
+							me.page.fields_dict.root_company.set_value(root_company);
+						}
+					}
+				});
+			}
+		},
+		{
+			fieldname: "root_company",
+			fieldtype:"Data",
+			label: __("Root Company"),
+			hidden: true,
+			disable_onchange: true
+		}
+	],
 	root_label: "Accounts",
 	get_tree_nodes: 'erpnext.accounts.utils.get_children',
 	add_tree_node: 'erpnext.accounts.utils.add_ac',
@@ -42,8 +67,8 @@
 	],
 	ignore_fields:["parent_account"],
 	onload: function(treeview) {
-		frappe.treeview_settings['Account'].page = {};
-		$.extend(frappe.treeview_settings['Account'].page, treeview.page);
+		frappe.treeview_settings['Account'].treeview = {};
+		$.extend(frappe.treeview_settings['Account'].treeview, treeview);
 		function get_company() {
 			return treeview.page.fields_dict.company.get_value();
 		}
@@ -78,6 +103,18 @@
 		}
 
 	},
+	post_render: function(treeview) {
+		frappe.treeview_settings['Account'].treeview["tree"] = treeview.tree;
+		treeview.page.set_primary_action(__("New"), function() {
+			let root_company = treeview.page.fields_dict.root_company.get_value();
+
+			if(root_company) {
+				frappe.throw(__("Please add the account to root level Company - ") + root_company);
+			} else {
+				treeview.new_node();
+			}
+		}, "octicon octicon-plus");
+	},
 	onrender: function(node) {
 		if(frappe.boot.user.can_read.indexOf("GL Entry") !== -1){
 			var dr_or_cr = node.data.balance < 0 ? "Cr" : "Dr";
@@ -94,6 +131,19 @@
 	},
 	toolbar: [
 		{
+			label:__("Add Child"),
+			condition: function(node) {
+				return frappe.boot.user.can_create.indexOf("Account") !== -1 &&
+				!frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value() &&
+					node.expandable && !node.hide_add;
+			},
+			click: function() {
+				var me = frappe.treeview_settings['Account'].treeview;
+				me.new_node();
+			},
+			btnClass: "hidden-xs"
+		},
+		{
 			condition: function(node) {
 				return !node.root && frappe.boot.user.can_read.indexOf("GL Entry") !== -1
 			},
@@ -103,7 +153,7 @@
 					"account": node.label,
 					"from_date": frappe.sys_defaults.year_start_date,
 					"to_date": frappe.sys_defaults.year_end_date,
-					"company": frappe.treeview_settings['Account'].page.fields_dict.company.get_value()
+					"company": frappe.treeview_settings['Account'].treeview.page.fields_dict.company.get_value()
 				};
 				frappe.set_route("query-report", "General Ledger");
 			},
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index bcb163f..1bf9196 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -9,8 +9,8 @@
 from six import iteritems
 from frappe.utils.nestedset import rebuild_tree
 
-def create_charts(company, chart_template=None, existing_company=None):
-	chart = get_chart(chart_template, existing_company)
+def create_charts(company, chart_template=None, existing_company=None, custom_chart=None):
+	chart = custom_chart or get_chart(chart_template, existing_company)
 	if chart:
 		accounts = []
 
@@ -40,7 +40,7 @@
 						"report_type": report_type,
 						"account_number": account_number,
 						"account_type": child.get("account_type"),
-						"account_currency": frappe.db.get_value('Company',  company,  "default_currency"),
+						"account_currency": child.get('account_currency') or frappe.db.get_value('Company',  company,  "default_currency"),
 						"tax_rate": child.get("tax_rate")
 					})
 
@@ -207,9 +207,9 @@
 	return (bank_account in accounts)
 
 @frappe.whitelist()
-def build_tree_from_json(chart_template):
+def build_tree_from_json(chart_template, chart_data=None):
 	''' get chart template from its folder and parse the json to be rendered as tree '''
-	chart = get_chart(chart_template)
+	chart = chart_data or get_chart(chart_template)
 
 	# if no template selected, return as it is
 	if not chart:
diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py
index acaa096..fc6f4e4 100644
--- a/erpnext/accounts/doctype/account/test_account.py
+++ b/erpnext/accounts/doctype/account/test_account.py
@@ -97,6 +97,19 @@
 		self.assertRaises(frappe.ValidationError, merge_account, "Capital Stock - _TC",\
 			"Softwares - _TC", doc.is_group, doc.root_type, doc.company)
 
+	def test_account_sync(self):
+		del frappe.local.flags["ignore_root_company_validation"]
+		acc = frappe.new_doc("Account")
+		acc.account_name = "Test Sync Account"
+		acc.parent_account = "Temporary Accounts - _TC3"
+		acc.company = "_Test Company 3"
+		acc.insert()
+
+		acc_tc_4 = frappe.db.get_value('Account', {'account_name': "Test Sync Account", "company": "_Test Company 4"})
+		acc_tc_5 = frappe.db.get_value('Account', {'account_name': "Test Sync Account", "company": "_Test Company 5"})
+		self.assertEqual(acc_tc_4, "Test Sync Account - _TC4")
+		self.assertEqual(acc_tc_5, "Test Sync Account - _TC5")
+
 def _make_test_records(verbose):
 	from frappe.test_runner import make_test_objects
 
@@ -129,6 +142,8 @@
 		["_Test Write Off", "Indirect Expenses", 0, None, None],
 		["_Test Exchange Gain/Loss", "Indirect Expenses", 0, None, None],
 
+		["_Test Account Sales", "Direct Income", 0, None, None],
+
 		# related to Account Inventory Integration
 		["_Test Account Stock In Hand", "Current Assets", 0, None, None],
 		
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.json b/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.json
deleted file mode 100644
index cc41f04..0000000
--- a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 0, 
- "creation": "2019-02-07 14:50:22.641575", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:parent.apply_on == 'Item Code'", 
-   "fieldname": "brand", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Brand", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Brand", 
-   "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": 1, 
-   "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": "uom", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "UOM", 
-   "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
-  }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2019-02-14 15:35:41.963974", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Apply Rule On Brand", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0, 
- "track_views": 0
-}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.py b/erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.py
deleted file mode 100644
index 3959e4a..0000000
--- a/erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.model.document import Document
-
-class ApplyRuleOnItemCode(Document):
-	pass
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.json b/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.json
deleted file mode 100644
index 24570ce..0000000
--- a/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 0, 
- "creation": "2019-02-07 14:50:01.599577", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:parent.apply_on == 'Item Code'", 
-   "fieldname": "item_group", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Item Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item Group", 
-   "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": 1, 
-   "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": "uom", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "UOM", 
-   "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
-  }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2019-02-14 15:35:32.311693", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Apply Rule On Item Group", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0, 
- "track_views": 0
-}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.py b/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.py
deleted file mode 100644
index 0fc1e63..0000000
--- a/erpnext/accounts/doctype/apply_rule_on_item_group/apply_rule_on_item_group.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.model.document import Document
-
-class ApplyRuleOnItemGroup(Document):
-	pass
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json
index 4897097..84a8e68 100644
--- a/erpnext/accounts/doctype/bank_account/bank_account.json
+++ b/erpnext/accounts/doctype/bank_account/bank_account.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
  "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 1, 
@@ -290,7 +291,7 @@
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "IBAN", 
-   "length": 25, 
+   "length": 30, 
    "no_copy": 0, 
    "permlevel": 0, 
    "precision": "", 
@@ -669,7 +670,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-07-20 13:55:36.996465", 
+ "modified": "2019-03-05 17:56:05.103238", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Bank Account", 
diff --git a/erpnext/accounts/doctype/budget/budget.json b/erpnext/accounts/doctype/budget/budget.json
index a803b65..50ad2e5 100644
--- a/erpnext/accounts/doctype/budget/budget.json
+++ b/erpnext/accounts/doctype/budget/budget.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
  "allow_guest_to_view": 0, 
  "allow_import": 1, 
  "allow_rename": 0, 
@@ -19,6 +20,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Cost Center", 
+   "fetch_if_empty": 0, 
    "fieldname": "budget_against", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -52,6 +54,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "company", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -86,6 +89,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.budget_against == 'Cost Center'", 
+   "fetch_if_empty": 0, 
    "fieldname": "cost_center", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -120,6 +124,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.budget_against == 'Project'", 
+   "fetch_if_empty": 0, 
    "fieldname": "project", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -153,6 +158,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "fiscal_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -186,6 +192,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -218,6 +225,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:in_list([\"Stop\", \"Warn\"], doc.action_if_accumulated_monthly_budget_exceeded_on_po || doc.action_if_accumulated_monthly_budget_exceeded_on_mr || doc.action_if_accumulated_monthly_budget_exceeded_on_actual)", 
+   "fetch_if_empty": 0, 
    "fieldname": "monthly_distribution", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -251,6 +259,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -283,6 +292,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_6", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -315,6 +325,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "applicable_on_material_request", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -343,12 +354,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Stop", 
    "depends_on": "eval:doc.applicable_on_material_request == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_annual_budget_exceeded_on_mr", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -378,12 +390,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Warn", 
    "depends_on": "eval:doc.applicable_on_material_request == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_accumulated_monthly_budget_exceeded_on_mr", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -417,6 +430,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_13", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -448,6 +462,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "applicable_on_purchase_order", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -476,12 +491,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Stop", 
    "depends_on": "eval:doc.applicable_on_purchase_order == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_annual_budget_exceeded_on_po", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -511,12 +527,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Warn", 
    "depends_on": "eval:doc.applicable_on_purchase_order == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_accumulated_monthly_budget_exceeded_on_po", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -550,6 +567,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_16", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -581,6 +599,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "applicable_on_booking_actual_expenses", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -609,12 +628,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Stop", 
    "depends_on": "eval:doc.applicable_on_booking_actual_expenses == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_annual_budget_exceeded", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -644,12 +664,13 @@
   {
    "allow_bulk_edit": 0, 
    "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
+   "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
    "default": "Warn", 
    "depends_on": "eval:doc.applicable_on_booking_actual_expenses == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "action_if_accumulated_monthly_budget_exceeded", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -683,6 +704,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_21", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -715,6 +737,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "accounts", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -735,7 +758,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 1,
+   "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
    "translatable": 0, 
@@ -752,7 +775,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-09-12 11:02:41.825923",
+ "modified": "2019-03-22 12:06:02.323099", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Budget", 
@@ -785,7 +808,7 @@
  "show_name_in_global_search": 0, 
  "sort_field": "modified", 
  "sort_order": "DESC", 
- "track_changes": 1,
- "track_seen": 0,
+ "track_changes": 1, 
+ "track_seen": 0, 
  "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/cashier_closing/cashier_closing.py b/erpnext/accounts/doctype/cashier_closing/cashier_closing.py
index f33b3e1..6de62ee 100644
--- a/erpnext/accounts/doctype/cashier_closing/cashier_closing.py
+++ b/erpnext/accounts/doctype/cashier_closing/cashier_closing.py
@@ -33,4 +33,4 @@
 
 	def validate_time(self):
 		if self.from_time >= self.time:
-			frappe.throw(_("From Time Should Be Less Than To Time"))	
+			frappe.throw(_("From Time Should Be Less Than To Time"))
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/__init__.py b/erpnext/accounts/doctype/chart_of_accounts_importer/__init__.py
similarity index 100%
copy from erpnext/accounts/doctype/apply_rule_on_brand/__init__.py
copy to erpnext/accounts/doctype/chart_of_accounts_importer/__init__.py
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js
new file mode 100644
index 0000000..aea6080
--- /dev/null
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js
@@ -0,0 +1,138 @@
+frappe.ui.form.on('Chart of Accounts Importer', {
+	onload: function (frm) {
+		frm.set_value("company", "");
+		frm.set_value("import_file", "");
+	},
+	refresh: function (frm) {
+		// disable default save
+		frm.disable_save();
+
+		// make company mandatory
+		frm.set_df_property('company', 'reqd', frm.doc.company ? 0 : 1);
+		frm.set_df_property('import_file_section', 'hidden', frm.doc.company ? 0 : 1);
+		frm.set_df_property('chart_preview', 'hidden',
+			$(frm.fields_dict['chart_tree'].wrapper).html()!="" ? 0 : 1);
+
+		// Show import button when file is successfully attached
+		if (frm.page && frm.page.show_import_button) {
+			create_import_button(frm);
+		}
+
+		// show download template button when company is properly selected
+		if(frm.doc.company) {
+			// download the csv template file
+			frm.add_custom_button(__("Download template"), function () {
+				let get_template_url = 'erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.download_template';
+				open_url_post(frappe.request.url, { cmd: get_template_url, doctype: frm.doc.doctype });
+			});
+		} else {
+			frm.set_value("import_file", "");
+		}
+	},
+
+	import_file: function (frm) {
+		if (!frm.doc.import_file) {
+			frm.page.set_indicator("");
+			$(frm.fields_dict['chart_tree'].wrapper).empty(); // empty wrapper on removing file
+		} else {
+			generate_tree_preview(frm);
+			validate_csv_data(frm);
+		}
+	},
+
+	company: function (frm) {
+		// validate that no Gl Entry record for the company exists.
+		frappe.call({
+			method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.validate_company",
+			args: {
+				company: frm.doc.company
+			},
+			callback: function(r) {
+				if(r.message===false) {
+					frm.set_value("company", "");
+					frappe.throw(__("Transactions against the company already exist! "));
+				} else {
+					frm.trigger("refresh");
+				}
+			}
+		});
+	}
+});
+
+var validate_csv_data = function(frm) {
+	frappe.call({
+		method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.validate_accounts",
+		args: {file_name: frm.doc.import_file},
+		callback: function(r) {
+			if(r.message && r.message[0]===true) {
+				frm.page["show_import_button"] = true;
+				frm.page["total_accounts"] = r.message[1];
+				frm.trigger("refresh");
+			} else {
+				frm.page.set_indicator(__('Resolve error and upload again.'), 'orange');
+				frappe.throw(__(r.message));
+			}
+		}
+	});
+};
+
+var create_import_button = function(frm) {
+	frm.page.set_primary_action(__("Start Import"), function () {
+		setup_progress_bar(frm);
+		frappe.call({
+			method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.import_coa",
+			args: {
+				file_name: frm.doc.import_file,
+				company: frm.doc.company
+			},
+			freeze: true,
+			callback: function(r) {
+				if(!r.exc) {
+					clearInterval(frm.page["interval"]);
+					frm.page.set_indicator(__('Import Successfull'), 'blue');
+					frappe.hide_progress();
+					create_reset_button(frm);
+				}
+			}
+		});
+	}).addClass('btn btn-primary');
+};
+
+var create_reset_button = function(frm) {
+	frm.page.set_primary_action(__("Reset"), function () {
+		frm.page.clear_primary_action();
+		delete frm.page["show_import_button"];
+		frm.reload_doc();
+	}).addClass('btn btn-primary');
+};
+
+var generate_tree_preview = function(frm) {
+	let parent = __('All Accounts');
+	$(frm.fields_dict['chart_tree'].wrapper).empty(); // empty wrapper to load new data
+
+	// generate tree structure based on the csv data
+	new frappe.ui.Tree({
+		parent: $(frm.fields_dict['chart_tree'].wrapper),
+		label: parent,
+		expandable: true,
+		method: 'erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.get_coa',
+		args: {
+			file_name: frm.doc.import_file,
+			parent: parent,
+			doctype: 'Chart of Accounts Importer'
+		},
+		onclick: function(node) {
+			parent = node.value;
+		}
+	});
+};
+
+var setup_progress_bar = function(frm) {
+	frm.page["seconds_elapsed"] = 0;
+	frm.page["execution_time"] = (frm.page["total_accounts"] > 100) ? 100 : frm.page["total_accounts"];
+
+	frm.page["interval"] = setInterval(function()  {
+		frm.page["seconds_elapsed"] += 1;
+		frappe.show_progress(__('Creating Accounts'), frm.page["seconds_elapsed"], frm.page["execution_time"]);
+	}, 250);
+};
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.json b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.json
new file mode 100644
index 0000000..d544e69
--- /dev/null
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.json
@@ -0,0 +1,226 @@
+{
+ "allow_copy": 1, 
+ "allow_events_in_timeline": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2019-02-01 12:24:34.761380", 
+ "custom": 0, 
+ "description": "Import Chart of Accounts from a csv file",
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Other", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Company", 
+   "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": "import_file_section",
+   "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, 
+   "depends_on": "",
+   "fieldname": "import_file",
+   "fieldtype": "Attach",
+   "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": "Attach custom Chart of Accounts file",
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "",
+   "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": 1,
+   "columns": 0,
+   "fieldname": "chart_preview",
+   "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": "Chart Preview",
+   "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": "chart_tree",
+   "fieldtype": "HTML",
+   "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": "Chart Tree",
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 1, 
+ "hide_toolbar": 1, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 1, 
+ "is_submittable": 0, 
+ "issingle": 1, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2019-02-04 23:10:30.136807",
+ "modified_by": "Administrator", 
+ "module": "Accounts", 
+ "name": "Chart of Accounts Importer", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 0, 
+   "email": 0, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 0, 
+   "read": 1, 
+   "report": 0, 
+   "role": "Accounts Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 1, 
+ "read_only": 1, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "", 
+ "sort_order": "DESC", 
+ "track_changes": 0, 
+ "track_seen": 0, 
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
new file mode 100644
index 0000000..948be64
--- /dev/null
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
@@ -0,0 +1,199 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe, csv
+from frappe import _
+from frappe.utils import cstr
+from frappe.model.document import Document
+from frappe.utils.csvutils import UnicodeWriter
+from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts, build_tree_from_json
+
+class ChartofAccountsImporter(Document):
+	pass
+
+@frappe.whitelist()
+def validate_company(company):
+	if frappe.db.get_all('GL Entry', {"company": company}, "name", limit=1):
+		return False
+
+@frappe.whitelist()
+def import_coa(file_name, company):
+	# delete existing data for accounts
+	unset_existing_data(company)
+
+	# create accounts
+	forest = build_forest(generate_data_from_csv(file_name))
+	create_charts(company, custom_chart=forest)
+
+	# trigger on_update for company to reset default accounts
+	set_default_accounts(company)
+
+def generate_data_from_csv(file_name, as_dict=False):
+	''' read csv file and return the generated nested tree '''
+	file_doc = frappe.get_doc('File', {"file_url": file_name})
+	file_path = file_doc.get_full_path()
+
+	data = []
+	with open(file_path, 'r') as in_file:
+		csv_reader = list(csv.reader(in_file))
+		headers = csv_reader[1][1:]
+		del csv_reader[0:2] # delete top row and headers row
+
+		for row in csv_reader:
+			if as_dict:
+				data.append({frappe.scrub(header): row[index+1] for index, header in enumerate(headers)})
+			else:
+				if not row[2]: row[2] = row[1]
+				data.append(row[1:])
+
+	# convert csv data
+	return data
+
+@frappe.whitelist()
+def get_coa(doctype, parent, is_root=False, file_name=None):
+	''' called by tree view (to fetch node's children) '''
+
+	parent = None if parent==_('All Accounts') else parent
+	forest = build_forest(generate_data_from_csv(file_name))
+	accounts = build_tree_from_json("", chart_data=forest) # returns alist of dict in a tree render-able form
+
+	# filter out to show data for the selected node only
+	accounts = [d for d in accounts if d['parent_account']==parent]
+
+	return accounts
+
+def build_forest(data):
+	'''
+		converts list of list into a nested tree
+		if a = [[1,1], [1,2], [3,2], [4,4], [5,4]]
+		tree = {
+			1: {
+				2: {
+					3: {}
+				}
+			},
+			4: {
+				5: {}
+			}
+		}
+	'''
+
+	# set the value of nested dictionary
+	def set_nested(d, path, value):
+		reduce(lambda d, k: d.setdefault(k, {}), path[:-1], d)[path[-1]] = value
+		return d
+
+	# returns the path of any node in list format
+	def return_parent(data, child):
+		for row in data:
+			account_name, parent_account = row[0:2]
+			if parent_account == account_name == child:
+				return [parent_account]
+			elif account_name == child:
+				return [child] + return_parent(data, parent_account)
+
+	charts_map, paths = {}, []
+	for i in data:
+		account_name, _, account_number, is_group, account_type, root_type = i
+		charts_map[account_name] = {}
+		if is_group: charts_map[account_name]["is_group"] = is_group
+		if account_type: charts_map[account_name]["account_type"] = account_type
+		if root_type: charts_map[account_name]["root_type"] = root_type
+		if account_number: charts_map[account_name]["account_number"] = account_number
+		path = return_parent(data, account_name)[::-1]
+		paths.append(path) # List of path is created
+
+	out = {}
+	for path in paths:
+		for n, account_name in enumerate(path):
+			set_nested(out, path[:n+1], charts_map[account_name]) # setting the value of nested dictionary.
+
+	return out
+
+@frappe.whitelist()
+def download_template():
+	data = frappe._dict(frappe.local.form_dict)
+	fields = ["Account Name", "Parent Account", "Account Number", "Is Group", "Account Type", "Root Type"]
+	writer = UnicodeWriter()
+
+	writer.writerow([_('Chart of Accounts Template')])
+	writer.writerow([_("Column Labels : ")] + fields)
+	writer.writerow([_("Start entering data from here : ")])
+
+	# download csv file
+	frappe.response['result'] = cstr(writer.getvalue())
+	frappe.response['type'] = 'csv'
+	frappe.response['doctype'] = data.get('doctype')
+
+@frappe.whitelist()
+def validate_accounts(file_name):
+	accounts = generate_data_from_csv(file_name, as_dict=True)
+
+	accounts_dict = {}
+	for account in accounts:
+		accounts_dict.setdefault(account["account_name"], account)
+		if account["parent_account"] and accounts_dict[account["parent_account"]]:
+			accounts_dict[account["parent_account"]]["is_group"] = 1
+
+	message = validate_root(accounts_dict)
+	if message: return message
+	message = validate_account_types(accounts_dict)
+	if message: return message
+
+	return [True, len(accounts)]
+
+def validate_root(accounts):
+	roots = [accounts[d] for d in accounts if not accounts[d].get('parent_account')]
+	if len(roots) < 4:
+		return _("Number of root accounts cannot be less than 4")
+
+	for account in roots:
+		if not account.get("root_type"):
+			return _("Please enter Root Type for - {0}").format(account.get("account_name"))
+		elif account.get("root_type") not in ("Asset", "Liability", "Expense", "Income", "Equity"):
+			return _('Root Type for "{0}" must be one of the Asset, Liability, Income, Expense and Equity').format(account.get("account_name"))
+
+def validate_account_types(accounts):
+	account_types_for_ledger = ["Cost of Goods Sold", "Depreciation", "Fixed Asset", "Payable", "Receivable", "Stock Adjustment"]
+	account_types = [accounts[d]["account_type"] for d in accounts if not accounts[d]['is_group']]
+
+	missing = list(set(account_types_for_ledger) - set(account_types))
+	if missing:
+		return _("Please identify/create Account (Ledger) for type - {0}").format(' , '.join(missing))
+
+	account_types_for_group = ["Bank", "Cash", "Stock"]
+	account_groups = [accounts[d]["account_type"] for d in accounts if accounts[d]['is_group']]
+
+	missing = list(set(account_types_for_group) - set(account_groups))
+	if missing:
+		return _("Please identify/create Account (Group) for type - {0}").format(' , '.join(missing))
+
+def unset_existing_data(company):
+	linked = frappe.db.sql('''select fieldname from tabDocField
+		where fieldtype="Link" and options="Account" and parent="Company"''', as_dict=True)
+
+	# remove accounts data from company
+	update_values = {d.fieldname: '' for d in linked}
+	frappe.db.set_value('Company', company, update_values, update_values)
+
+	# remove accounts data from various doctypes
+	for doctype in ["Account", "Party Account", "Mode of Payment Account", "Tax Withholding Account",
+		"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
+		frappe.db.sql('''delete from `tab{0}` where `company`="%s"''' # nosec
+			.format(doctype) % (company))
+
+def set_default_accounts(company):
+	from erpnext.setup.doctype.company.company import install_country_fixtures
+	company = frappe.get_doc('Company', company)
+	company.update({
+		"default_receivable_account": frappe.db.get_value("Account",
+			{"company": company.name, "account_type": "Receivable", "is_group": 0}),
+		"default_payable_account": frappe.db.get_value("Account",
+			{"company": company.name, "account_type": "Payable", "is_group": 0})
+	})
+
+	company.save()
+	install_country_fixtures(company.name)
+	company.create_default_tax_template()
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.js b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.js
new file mode 100644
index 0000000..b075a01
--- /dev/null
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Chart of Accounts Importer", function (assert) {
+	let done = assert.async();
+
+	// number of asserts
+	assert.expect(1);
+
+	frappe.run_serially([
+		// insert a new Chart of Accounts Importer
+		() => frappe.tests.make('Chart of Accounts Importer', [
+			// values to be set
+			{key: 'value'}
+		]),
+		() => {
+			assert.equal(cur_frm.doc.key, 'value');
+		},
+		() => done()
+	]);
+
+});
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py
new file mode 100644
index 0000000..6ab19b7
--- /dev/null
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestChartofAccountsImporter(unittest.TestCase):
+	pass
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 1fff11b..f566ec8 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -81,7 +81,8 @@
 
 	def check_pl_account(self):
 		if self.is_opening=='Yes' and \
-				frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss":
+				frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss" and \
+				self.voucher_type not in ['Purchase Invoice', 'Sales Invoice']:
 			frappe.throw(_("{0} {1}: 'Profit and Loss' type account {2} not allowed in Opening Entry")
 				.format(self.voucher_type, self.voucher_no, self.account))
 
diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
index 4fc4312..18f853c 100644
--- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
+++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
@@ -3,8 +3,8 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe.utils import flt
 from frappe import _
+from frappe.utils import (flt, add_months)
 from frappe.model.document import Document
 
 class MonthlyDistribution(Document):
@@ -25,3 +25,33 @@
 		if flt(total, 2) != 100.0:
 			frappe.throw(_("Percentage Allocation should be equal to 100%") + \
 				" ({0}%)".format(str(flt(total, 2))))
+
+def get_periodwise_distribution_data(distribution_id, period_list, periodicity):
+	doc = frappe.get_doc('Monthly Distribution', distribution_id)
+
+	months_to_add = {
+		"Yearly": 12,
+		"Half-Yearly": 6,
+		"Quarterly": 3,
+		"Monthly": 1
+	}[periodicity]
+
+	period_dict = {}
+
+	for d in period_list:
+		period_dict[d.key] = get_percentage(doc, d.from_date, months_to_add)
+
+	return period_dict
+
+def get_percentage(doc, start_date, period):
+	percentage = 0
+	months = [start_date.strftime("%B").title()]
+
+	for r in range(1, period):
+		months.append(add_months(start_date, r).strftime("%B").title())
+
+	for d in doc.percentages:
+		if d.month in months:
+			percentage += d.percentage_allocation
+
+	return percentage
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 014efd9..64c4124 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -214,9 +214,10 @@
 
 	def check_if_payment_entry_exists(self):
 		if self.status == "Paid":
-			payment_entry = frappe.db.sql_list("""select parent from `tabPayment Entry Reference`
-				where reference_name=%s""", self.reference_name)
-			if payment_entry:
+			if frappe.get_all("Payment Entry Reference",
+				filters={"reference_name": self.reference_name, "docstatus": ["<", 2]},
+				fields=["parent"],
+				limit=1):
 				frappe.throw(_("Payment Entry already exists"), title=_('Error'))
 
 	def make_communication_entry(self):
diff --git a/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.json b/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.json
deleted file mode 100644
index 3d49a63..0000000
--- a/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.json
+++ /dev/null
@@ -1,792 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 0, 
- "creation": "2019-01-22 14:59:16.794655", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "disable", 
-   "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": "Disable", 
-   "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_2", 
-   "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": "rule_description", 
-   "fieldtype": "Small Text", 
-   "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": "Rule Description", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "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": "section_break_2", 
-   "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": 1, 
-   "default": "0", 
-   "fieldname": "min_qty", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Min Qty", 
-   "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": 1, 
-   "default": "0", 
-   "fieldname": "max_qty", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Max Qty", 
-   "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_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, 
-   "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, 
-   "default": "0", 
-   "fieldname": "min_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Min 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, 
-   "default": "0", 
-   "depends_on": "", 
-   "fieldname": "max_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Max 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, 
-   "depends_on": "", 
-   "fieldname": "section_break_6", 
-   "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": "", 
-   "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, 
-   "default": "Discount Percentage", 
-   "depends_on": "", 
-   "fieldname": "rate_or_discount", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Discount Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nRate\nDiscount Percentage\nDiscount Amount", 
-   "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, 
-   "depends_on": "", 
-   "fieldname": "column_break_10", 
-   "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": 2, 
-   "depends_on": "eval:doc.rate_or_discount==\"Rate\"", 
-   "fieldname": "rate", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Rate", 
-   "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, 
-   "depends_on": "eval:doc.rate_or_discount==\"Discount Amount\"", 
-   "fieldname": "discount_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": "Discount 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, 
-   "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", 
-   "fieldname": "discount_percentage", 
-   "fieldtype": "Float", 
-   "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": "Discount Percentage", 
-   "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": "section_break_11", 
-   "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": "warehouse", 
-   "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": "Warehouse", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Warehouse", 
-   "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": "threshold_percentage", 
-   "fieldtype": "Percent", 
-   "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": "Threshold for Suggestion", 
-   "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, 
-   "default": "1", 
-   "fieldname": "validate_applied_rule", 
-   "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": "Validate Applied Rule", 
-   "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_14", 
-   "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": "priority", 
-   "fieldtype": "Select", 
-   "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": "Priority", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", 
-   "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, 
-   "depends_on": "priority", 
-   "fieldname": "apply_multiple_pricing_rules", 
-   "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": "Apply Multiple Pricing Rules", 
-   "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, 
-   "default": "0", 
-   "depends_on": "eval:in_list(['Discount Percentage', 'Discount Amount'], doc.rate_or_discount) && doc.apply_multiple_pricing_rules", 
-   "fieldname": "apply_discount_on_rate", 
-   "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": "Apply Discount on Rate", 
-   "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
-  }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2019-03-08 18:54:20.063950", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Price Discount Slab", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
-}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.py b/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.py
deleted file mode 100644
index 21abe33..0000000
--- a/erpnext/accounts/doctype/price_discount_slab/price_discount_slab.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.model.document import Document
-
-class PriceDiscountSlab(Document):
-	pass
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
index 299e634..0210212 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
@@ -21,6 +21,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "applicability_section", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -52,6 +53,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "title", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -84,6 +86,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "disable", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -116,6 +119,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Item Code", 
+   "fetch_if_empty": 0, 
    "fieldname": "apply_on", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -148,6 +152,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "price_or_product_discount", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -182,6 +187,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_on != 'Transaction'", 
+   "fetch_if_empty": 0, 
    "fieldname": "warehouse", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -215,6 +221,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_7", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -247,6 +254,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_on == 'Item Code'", 
+   "fetch_if_empty": 0, 
    "fieldname": "items", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -259,7 +267,7 @@
    "label": "Apply Rule On Item Code", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Apply Rule On Item Code", 
+   "options": "Pricing Rule Item Code", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -281,6 +289,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_on == 'Item Group'", 
+   "fetch_if_empty": 0, 
    "fieldname": "item_groups", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -293,7 +302,7 @@
    "label": "Apply Rule On Item Group", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Apply Rule On Item Group", 
+   "options": "Pricing Rule Item Group", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -315,6 +324,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_on == 'Brand'", 
+   "fetch_if_empty": 0, 
    "fieldname": "brands", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -327,7 +337,7 @@
    "label": "Apply Rule On Brand", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Apply Rule On Brand", 
+   "options": "Pricing Rule Brand", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -350,6 +360,7 @@
    "columns": 0, 
    "depends_on": "eval:doc.apply_on != 'Transaction'", 
    "description": "Conditions will be applied on all the selected items combined. ", 
+   "fetch_if_empty": 0, 
    "fieldname": "mixed_conditions", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -383,6 +394,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "is_cumulative", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -416,6 +428,7 @@
    "collapsible": 1, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_on != 'Transaction'", 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_18", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -448,6 +461,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "apply_rule_on_other", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -481,6 +495,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_17", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -513,6 +528,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_rule_on_other == 'Item Code'", 
+   "fetch_if_empty": 0, 
    "fieldname": "other_item_code", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -547,6 +563,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_rule_on_other == 'Item Group'", 
+   "fetch_if_empty": 0, 
    "fieldname": "other_item_group", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -581,6 +598,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.apply_rule_on_other == 'Brand'", 
+   "fetch_if_empty": 0, 
    "fieldname": "other_brand", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -614,6 +632,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -646,6 +665,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "selling", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -677,6 +697,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "buying", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -708,6 +729,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_11", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -740,6 +762,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval: doc.buying || doc.selling", 
+   "fetch_if_empty": 0, 
    "fieldname": "applicable_for", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -773,6 +796,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Customer\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "customer", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -806,6 +830,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Customer Group\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "customer_group", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -839,6 +864,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Territory\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "territory", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -872,6 +898,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "sales_partner", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -905,6 +932,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Campaign\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "campaign", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -938,6 +966,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Supplier\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "supplier", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -971,6 +1000,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.applicable_for==\"Supplier Group\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "supplier_group", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1004,6 +1034,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_19", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1036,6 +1067,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "min_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1067,6 +1099,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "max_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1098,6 +1131,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_21", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1130,6 +1164,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "0", 
+   "fetch_if_empty": 0, 
    "fieldname": "min_amt", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1164,6 +1199,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "0", 
+   "fetch_if_empty": 0, 
    "fieldname": "max_amt", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1197,6 +1233,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_23", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1230,6 +1267,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Today", 
+   "fetch_if_empty": 0, 
    "fieldname": "valid_from", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -1261,6 +1299,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "valid_upto", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -1292,6 +1331,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "col_break1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1322,6 +1362,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "company", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1355,6 +1396,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "currency", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1389,6 +1431,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval: doc.selling == 1", 
+   "fetch_if_empty": 0, 
    "fieldname": "margin", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1422,6 +1465,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Percentage", 
+   "fetch_if_empty": 0, 
    "fieldname": "margin_type", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -1455,6 +1499,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_33", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1488,6 +1533,7 @@
    "columns": 0, 
    "default": "0", 
    "depends_on": "eval:doc.margin_type", 
+   "fetch_if_empty": 0, 
    "fieldname": "margin_rate_or_amount", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1521,6 +1567,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.price_or_product_discount == 'Price'", 
+   "fetch_if_empty": 0, 
    "fieldname": "price_discount_scheme_section", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1553,6 +1600,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Discount Percentage", 
+   "fetch_if_empty": 0, 
    "fieldname": "rate_or_discount", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -1587,6 +1635,7 @@
    "columns": 0, 
    "default": "Grand Total", 
    "depends_on": "eval:doc.apply_on == 'Transaction' && doc.rate_or_discount != 'Rate'", 
+   "fetch_if_empty": 0, 
    "fieldname": "apply_discount_on", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -1621,6 +1670,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "col_break2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1652,6 +1702,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.rate_or_discount==\"Rate\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1685,6 +1736,7 @@
    "columns": 0, 
    "default": "0", 
    "depends_on": "eval:doc.rate_or_discount==\"Discount Amount\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "discount_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1719,6 +1771,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "discount_percentage", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1751,6 +1804,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", 
+   "fetch_if_empty": 0, 
    "fieldname": "for_price_list", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1784,6 +1838,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.price_or_product_discount == 'Product'", 
+   "fetch_if_empty": 0, 
    "fieldname": "product_discount_scheme_section", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1817,6 +1872,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:!doc.mixed_conditions", 
+   "fetch_if_empty": 0, 
    "fieldname": "same_item", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -1850,6 +1906,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:!doc.same_item || doc.mixed_conditions", 
+   "fetch_if_empty": 0, 
    "fieldname": "free_item", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1883,6 +1940,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "free_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1915,6 +1973,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_51", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1946,6 +2005,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "free_item_uom", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1979,6 +2039,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "free_item_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -2012,6 +2073,7 @@
    "collapsible": 1, 
    "columns": 0, 
    "depends_on": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_13", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -2045,6 +2107,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "System will notify to increase or decrease quantity or amount ", 
+   "fetch_if_empty": 0, 
    "fieldname": "threshold_percentage", 
    "fieldtype": "Percent", 
    "hidden": 0, 
@@ -2078,6 +2141,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "Higher the number, higher the priority", 
+   "fetch_if_empty": 0, 
    "fieldname": "priority", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -2110,6 +2174,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_66", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -2141,6 +2206,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "apply_multiple_pricing_rules", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -2174,6 +2240,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:in_list(['Discount Percentage', 'Discount Amount'], doc.rate_or_discount) && doc.apply_multiple_pricing_rules", 
+   "fetch_if_empty": 0, 
    "fieldname": "apply_discount_on_rate", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -2208,6 +2275,7 @@
    "columns": 0, 
    "depends_on": "eval:doc.price_or_product_discount == 'Price'", 
    "description": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "validate_applied_rule", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -2241,6 +2309,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "validate_applied_rule", 
+   "fetch_if_empty": 0, 
    "fieldname": "rule_description", 
    "fieldtype": "Small Text", 
    "hidden": 0, 
@@ -2273,6 +2342,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "help_section", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -2305,6 +2375,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "pricing_rule_help", 
    "fieldtype": "HTML", 
    "hidden": 0, 
@@ -2336,6 +2407,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "reference_section", 
    "fieldtype": "Section Break", 
    "hidden": 1, 
@@ -2368,6 +2440,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "promotional_scheme_id", 
    "fieldtype": "Data", 
    "hidden": 1, 
@@ -2400,6 +2473,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "promotional_scheme", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -2438,7 +2512,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2019-03-08 18:38:01.898869", 
+ "modified": "2019-03-25 13:20:11.773190", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Pricing Rule", 
diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
index 8d4af32..332a900 100644
--- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
@@ -315,7 +315,7 @@
 
 
 def delete_existing_pricing_rules():
-	for doctype in ["Pricing Rule", "Apply Rule On Item Code",
-		"Apply Rule On Item Group", "Apply Rule On Brand"]:
+	for doctype in ["Pricing Rule", "Pricing Rule Item Code",
+		"Pricing Rule Item Group", "Pricing Rule Brand"]:
 
 		frappe.db.sql("delete from `tab{0}`".format(doctype))
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index e384bbb..e12771b 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -42,7 +42,7 @@
 
     if not args.get(apply_on_field): return []
 
-    child_doc = '`tabApply Rule On {0}`'.format(apply_on)
+    child_doc = '`tabPricing Rule {0}`'.format(apply_on)
 
     conditions = item_variant_condition = item_conditions = ""
     values[apply_on_field] = args.get(apply_on_field)
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/__init__.py b/erpnext/accounts/doctype/pricing_rule_brand/__init__.py
similarity index 100%
rename from erpnext/accounts/doctype/apply_rule_on_brand/__init__.py
rename to erpnext/accounts/doctype/pricing_rule_brand/__init__.py
diff --git a/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.json b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.json
new file mode 100644
index 0000000..b631ba3
--- /dev/null
+++ b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.json
@@ -0,0 +1,110 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-24 14:48:59.649168",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:parent.apply_on == 'Item Code'",
+   "fieldname": "brand",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Brand",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Brand",
+   "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": 1,
+   "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": "uom",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "UOM",
+   "length": 0,
+   "no_copy": 0,
+   "options": "UOM",
+   "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
+  }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-24 14:48:59.649168",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Pricing Rule Brand",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py
similarity index 87%
rename from erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py
rename to erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py
index 2f7a29e..e2f70af 100644
--- a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py
+++ b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py
@@ -6,5 +6,5 @@
 import frappe
 from frappe.model.document import Document
 
-class ApplyRuleOnBrand(Document):
+class PricingRuleBrand(Document):
 	pass
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_code/__init__.py b/erpnext/accounts/doctype/pricing_rule_item_code/__init__.py
similarity index 100%
rename from erpnext/accounts/doctype/apply_rule_on_item_code/__init__.py
rename to erpnext/accounts/doctype/pricing_rule_item_code/__init__.py
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.json b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.json
similarity index 92%
rename from erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.json
rename to erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.json
index 6b6fd63..80b204d 100644
--- a/erpnext/accounts/doctype/apply_rule_on_item_code/apply_rule_on_item_code.json
+++ b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.json
@@ -5,7 +5,7 @@
  "allow_import": 0, 
  "allow_rename": 0, 
  "beta": 0, 
- "creation": "2019-02-07 14:48:59.649168", 
+ "creation": "2019-03-24 14:48:59.649168", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
@@ -21,6 +21,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:parent.apply_on == 'Item Code'", 
+   "fetch_if_empty": 0, 
    "fieldname": "item_code", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -54,6 +55,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "uom", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -91,10 +93,10 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2019-02-14 15:35:24.455316", 
+ "modified": "2019-03-25 14:05:41.504182", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
- "name": "Apply Rule On Item Code", 
+ "name": "Pricing Rule Item Code", 
  "name_case": "", 
  "owner": "Administrator", 
  "permissions": [], 
diff --git a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py
similarity index 86%
copy from erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
copy to erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py
index 940fce6..4468620 100644
--- a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
+++ b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py
@@ -6,5 +6,5 @@
 import frappe
 from frappe.model.document import Document
 
-class ProductDiscountSlab(Document):
+class PricingRuleItemCode(Document):
 	pass
diff --git a/erpnext/accounts/doctype/apply_rule_on_item_group/__init__.py b/erpnext/accounts/doctype/pricing_rule_item_group/__init__.py
similarity index 100%
rename from erpnext/accounts/doctype/apply_rule_on_item_group/__init__.py
rename to erpnext/accounts/doctype/pricing_rule_item_group/__init__.py
diff --git a/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.json b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.json
new file mode 100644
index 0000000..30027ba
--- /dev/null
+++ b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.json
@@ -0,0 +1,110 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-24 14:48:59.649168",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:parent.apply_on == 'Item Code'",
+   "fieldname": "item_group",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Item Group",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Item Group",
+   "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": 1,
+   "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": "uom",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "UOM",
+   "length": 0,
+   "no_copy": 0,
+   "options": "UOM",
+   "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
+  }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-24 14:48:59.649168",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Pricing Rule Item Group",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py
similarity index 86%
rename from erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
rename to erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py
index 940fce6..d3c3619 100644
--- a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
+++ b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py
@@ -6,5 +6,5 @@
 import frappe
 from frappe.model.document import Document
 
-class ProductDiscountSlab(Document):
+class PricingRuleItemGroup(Document):
 	pass
diff --git a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.json b/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.json
deleted file mode 100644
index 3c437b3..0000000
--- a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.json
+++ /dev/null
@@ -1,751 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 0, 
- "creation": "2019-01-22 15:16:17.920804", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "disable", 
-   "fieldtype": "Data", 
-   "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": "Disable", 
-   "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_2", 
-   "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": "rule_description", 
-   "fieldtype": "Small Text", 
-   "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": "Rule Description", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "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": "section_break_1", 
-   "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, 
-   "default": "0", 
-   "fieldname": "min_qty", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Min Qty", 
-   "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, 
-   "default": "0", 
-   "fieldname": "max_qty", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Max Qty", 
-   "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_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, 
-   "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, 
-   "default": "0", 
-   "fieldname": "min_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Min 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, 
-   "default": "0", 
-   "fieldname": "max_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Max 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": "section_break_6", 
-   "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": "Free Item", 
-   "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, 
-   "depends_on": "eval:!parent.mixed_conditions", 
-   "fieldname": "same_item", 
-   "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": "Same Item", 
-   "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, 
-   "depends_on": "eval:!doc.same_item || parent.mixed_conditions", 
-   "fieldname": "free_item", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Item Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item", 
-   "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": "free_qty", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Qty", 
-   "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_9", 
-   "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": "free_item_uom", 
-   "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": "UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "UOM", 
-   "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": "free_item_rate", 
-   "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": "Rate", 
-   "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": "section_break_12", 
-   "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": "warehouse", 
-   "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": "Warehouse", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Warehouse", 
-   "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": "threshold_percentage", 
-   "fieldtype": "Percent", 
-   "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": "Threshold for Suggestion", 
-   "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_15", 
-   "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": "priority", 
-   "fieldtype": "Select", 
-   "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": "Priority", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", 
-   "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": "apply_multiple_pricing_rules", 
-   "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": "Apply Multiple Pricing Rules", 
-   "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
-  }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2019-03-08 18:55:43.621860", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Product Discount Slab", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
-}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.json b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.json
index 5d0edcb..cc71324 100644
--- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.json
+++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.json
@@ -1,1344 +1,1381 @@
 {
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "Prompt", 
- "beta": 0, 
- "creation": "2019-02-08 17:10:36.077402", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "Prompt",
+ "beta": 0,
+ "creation": "2019-02-08 17:10:36.077402",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_1", 
-   "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": "", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "section_break_1",
+   "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": "",
+   "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, 
-   "default": "Item Code", 
-   "fieldname": "apply_on", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Apply On", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nItem Code\nItem Group\nBrand\nTransaction", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "default": "Item Code",
+   "fetch_if_empty": 0,
+   "fieldname": "apply_on",
+   "fieldtype": "Select",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Apply On",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\nItem Code\nItem Group\nBrand\nTransaction",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "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": "disable", 
-   "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": "Disable", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "disable",
+   "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": "Disable",
+   "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, 
-   "depends_on": "", 
-   "fieldname": "column_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, 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "column_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,
+   "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, 
-   "depends_on": "eval:doc.apply_on == 'Item Code'", 
-   "fieldname": "items", 
-   "fieldtype": "Table", 
-   "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": "Apply Rule On Item Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Apply Rule On Item Code", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_on == 'Item Code'",
+   "fetch_if_empty": 0,
+   "fieldname": "items",
+   "fieldtype": "Table",
+   "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": "Pricing Rule Item Code",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Pricing Rule Item Code",
+   "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, 
-   "depends_on": "eval:doc.apply_on == 'Item Group'", 
-   "fieldname": "item_groups", 
-   "fieldtype": "Table", 
-   "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": "Apply Rule On Item Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Apply Rule On Item Group", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_on == 'Item Group'",
+   "fetch_if_empty": 0,
+   "fieldname": "item_groups",
+   "fieldtype": "Table",
+   "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": "Pricing Rule Item Group",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Pricing Rule Item Group",
+   "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, 
-   "depends_on": "eval:doc.apply_on == 'Brand'", 
-   "fieldname": "brands", 
-   "fieldtype": "Table", 
-   "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": "Apply Rule On Brand", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Apply Rule On Brand", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_on == 'Brand'",
+   "fetch_if_empty": 0,
+   "fieldname": "brands",
+   "fieldtype": "Table",
+   "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": "Pricing Rule Brand",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Pricing Rule Brand",
+   "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": "mixed_conditions", 
-   "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": "Mixed Conditions", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "mixed_conditions",
+   "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": "Mixed Conditions",
+   "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": "is_cumulative", 
-   "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": "Is Cumulative", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "is_cumulative",
+   "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": "Is Cumulative",
+   "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": 1, 
-   "columns": 0, 
-   "fieldname": "section_break_10", 
-   "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": "Discount on Other Item", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 1,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "section_break_10",
+   "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": "Discount on Other Item",
+   "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, 
-   "depends_on": "", 
-   "fieldname": "apply_rule_on_other", 
-   "fieldtype": "Select", 
-   "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": "Apply Rule On Other", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nItem Code\nItem Group\nBrand", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "apply_rule_on_other",
+   "fieldtype": "Select",
+   "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": "Apply Rule On Other",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\nItem Code\nItem Group\nBrand",
+   "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, 
-   "depends_on": "", 
-   "fieldname": "column_break_11", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "column_break_11",
+   "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, 
-   "depends_on": "eval:doc.apply_rule_on_other == 'Item Code'", 
-   "fieldname": "other_item_code", 
-   "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": "Item Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_rule_on_other == 'Item Code'",
+   "fetch_if_empty": 0,
+   "fieldname": "other_item_code",
+   "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": "Item Code",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Item",
+   "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, 
-   "depends_on": "eval:doc.apply_rule_on_other == 'Item Group'", 
-   "fieldname": "other_item_group", 
-   "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": "Item Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item Group", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_rule_on_other == 'Item Group'",
+   "fetch_if_empty": 0,
+   "fieldname": "other_item_group",
+   "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": "Item Group",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Item Group",
+   "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, 
-   "depends_on": "eval:doc.apply_rule_on_other == 'Brand'", 
-   "fieldname": "other_brand", 
-   "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": "Brand", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Brand", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.apply_rule_on_other == 'Brand'",
+   "fetch_if_empty": 0,
+   "fieldname": "other_brand",
+   "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": "Brand",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Brand",
+   "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": 1, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "section_break_8", 
-   "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": "Party Information", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 1,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "section_break_8",
+   "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": "Party Information",
+   "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": "selling", 
-   "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": "Selling", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "selling",
+   "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": "Selling",
+   "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": "buying", 
-   "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": "Buying", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "buying",
+   "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": "Buying",
+   "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, 
-   "depends_on": "", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 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, 
-   "depends_on": "eval: doc.buying || doc.selling", 
-   "fieldname": "applicable_for", 
-   "fieldtype": "Select", 
-   "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": "Applicable For", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Group", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval: doc.buying || doc.selling",
+   "fetch_if_empty": 0,
+   "fieldname": "applicable_for",
+   "fieldtype": "Select",
+   "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": "Applicable For",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Group",
+   "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, 
-   "depends_on": "eval:doc.applicable_for=='Customer'", 
-   "fieldname": "customer", 
-   "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": "Customer", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Customer", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for=='Customer'",
+   "fetch_if_empty": 0,
+   "fieldname": "customer",
+   "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": "Customer",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Customer",
+   "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, 
-   "depends_on": "eval:doc.applicable_for==\"Customer Group\"", 
-   "fieldname": "customer_group", 
-   "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": "Customer Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Customer Group", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for==\"Customer Group\"",
+   "fetch_if_empty": 0,
+   "fieldname": "customer_group",
+   "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": "Customer Group",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Customer Group",
+   "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, 
-   "depends_on": "eval:doc.applicable_for==\"Territory\"", 
-   "fieldname": "territory", 
-   "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": "Territory", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Territory", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for==\"Territory\"",
+   "fetch_if_empty": 0,
+   "fieldname": "territory",
+   "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": "Territory",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Territory",
+   "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, 
-   "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", 
-   "fieldname": "sales_partner", 
-   "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": "Sales Partner", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Sales Partner", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for==\"Sales Partner\"",
+   "fetch_if_empty": 0,
+   "fieldname": "sales_partner",
+   "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": "Sales Partner",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Sales Partner",
+   "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, 
-   "depends_on": "eval:doc.applicable_for==\"Campaign\"", 
-   "fieldname": "campaign", 
-   "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": "Campaign", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Campaign", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for==\"Campaign\"",
+   "fetch_if_empty": 0,
+   "fieldname": "campaign",
+   "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": "Campaign",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Campaign",
+   "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, 
-   "depends_on": "eval:doc.applicable_for=='Supplier'", 
-   "fieldname": "supplier", 
-   "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": "Supplier", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Supplier", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for=='Supplier'",
+   "fetch_if_empty": 0,
+   "fieldname": "supplier",
+   "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": "Supplier",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Supplier",
+   "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, 
-   "depends_on": "eval:doc.applicable_for==\"Supplier Group\"", 
-   "fieldname": "supplier_group", 
-   "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": "Supplier Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Supplier Group", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "eval:doc.applicable_for==\"Supplier Group\"",
+   "fetch_if_empty": 0,
+   "fieldname": "supplier_group",
+   "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": "Supplier Group",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Supplier Group",
+   "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": "period_settings_section", 
-   "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": "Period 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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "period_settings_section",
+   "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": "Period 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, 
-   "default": "Today", 
-   "fieldname": "valid_from", 
-   "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": "Valid From", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "default": "Today",
+   "fetch_if_empty": 0,
+   "fieldname": "valid_from",
+   "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": "Valid From",
+   "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": "valid_upto", 
-   "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": "Valid Upto", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "valid_upto",
+   "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": "Valid Upto",
+   "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_26", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "column_break_26",
+   "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": "company", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Company", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Company", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Company",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Company",
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "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": "currency", 
-   "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": "Currency", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Currency", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "currency",
+   "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": "Currency",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Currency",
+   "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, 
-   "depends_on": "", 
-   "fieldname": "section_break_14", 
-   "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": "Price Discount Slabs", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "section_break_14",
+   "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": "Price Discount Slabs",
+   "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": 1, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "price_discount_slabs", 
-   "fieldtype": "Table", 
-   "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": "Price Discount Slabs", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Price Discount Slab", 
-   "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, 
+   "allow_bulk_edit": 1,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "price_discount_slabs",
+   "fieldtype": "Table",
+   "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": "Promotional Scheme Price Discount",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Promotional Scheme Price Discount",
+   "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, 
-   "depends_on": "", 
-   "fieldname": "section_break_15", 
-   "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": "Product Discount Slabs", 
-   "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, 
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "depends_on": "",
+   "fetch_if_empty": 0,
+   "fieldname": "section_break_15",
+   "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": "Product Discount Slabs",
+   "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": 1, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "product_discount_slabs", 
-   "fieldtype": "Table", 
-   "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": "Product Discount Slabs", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Product Discount Slab", 
-   "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, 
+   "allow_bulk_edit": 1,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fetch_if_empty": 0,
+   "fieldname": "product_discount_slabs",
+   "fieldtype": "Table",
+   "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": "Promotional Scheme Product Discount",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Promotional Scheme Product Discount",
+   "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
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2019-03-08 14:55:25.341607", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Promotional Scheme", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2019-03-25 12:14:27.486586",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Promotional Scheme",
+ "name_case": "",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "System Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "System Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Accounts Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Sales Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Sales Manager",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Accounts User", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "amend": 0,
+   "cancel": 0,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "if_owner": 0,
+   "import": 0,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "set_user_permissions": 0,
+   "share": 1,
+   "submit": 0,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0, 
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
  "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/product_discount_slab/__init__.py b/erpnext/accounts/doctype/promotional_scheme_price_discount/__init__.py
similarity index 100%
rename from erpnext/accounts/doctype/product_discount_slab/__init__.py
rename to erpnext/accounts/doctype/promotional_scheme_price_discount/__init__.py
diff --git a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json
new file mode 100644
index 0000000..224b8de
--- /dev/null
+++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json
@@ -0,0 +1,792 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-24 14:48:59.649168",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "disable",
+   "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": "Disable",
+   "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_2",
+   "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": "rule_description",
+   "fieldtype": "Small Text",
+   "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": "Rule Description",
+   "length": 0,
+   "no_copy": 1,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "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": "section_break_2",
+   "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": 1,
+   "default": "0",
+   "fieldname": "min_qty",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Min Qty",
+   "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": 1,
+   "default": "0",
+   "fieldname": "max_qty",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Max Qty",
+   "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_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,
+   "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,
+   "default": "0",
+   "fieldname": "min_amount",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Min 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,
+   "default": "0",
+   "depends_on": "",
+   "fieldname": "max_amount",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Max 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,
+   "depends_on": "",
+   "fieldname": "section_break_6",
+   "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": "",
+   "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,
+   "default": "Discount Percentage",
+   "depends_on": "",
+   "fieldname": "rate_or_discount",
+   "fieldtype": "Select",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Discount Type",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\nRate\nDiscount Percentage\nDiscount Amount",
+   "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,
+   "depends_on": "",
+   "fieldname": "column_break_10",
+   "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": 2,
+   "depends_on": "eval:doc.rate_or_discount==\"Rate\"",
+   "fieldname": "rate",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Rate",
+   "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,
+   "depends_on": "eval:doc.rate_or_discount==\"Discount Amount\"",
+   "fieldname": "discount_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": "Discount 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,
+   "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"",
+   "fieldname": "discount_percentage",
+   "fieldtype": "Float",
+   "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": "Discount Percentage",
+   "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": "section_break_11",
+   "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": "warehouse",
+   "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": "Warehouse",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Warehouse",
+   "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": "threshold_percentage",
+   "fieldtype": "Percent",
+   "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": "Threshold for Suggestion",
+   "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,
+   "default": "1",
+   "fieldname": "validate_applied_rule",
+   "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": "Validate Applied Rule",
+   "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_14",
+   "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": "priority",
+   "fieldtype": "Select",
+   "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": "Priority",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20",
+   "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,
+   "depends_on": "priority",
+   "fieldname": "apply_multiple_pricing_rules",
+   "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": "Apply Multiple Pricing Rules",
+   "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,
+   "default": "0",
+   "depends_on": "eval:in_list(['Discount Percentage', 'Discount Amount'], doc.rate_or_discount) && doc.apply_multiple_pricing_rules",
+   "fieldname": "apply_discount_on_rate",
+   "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": "Apply Discount on Rate",
+   "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
+  }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-24 14:48:59.649168",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Promotional Scheme Price Discount",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 0,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py
similarity index 83%
copy from erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
copy to erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py
index 940fce6..380ae32 100644
--- a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
+++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py
@@ -6,5 +6,5 @@
 import frappe
 from frappe.model.document import Document
 
-class ProductDiscountSlab(Document):
+class PromotionalSchemePriceDiscount(Document):
 	pass
diff --git a/erpnext/accounts/doctype/price_discount_slab/__init__.py b/erpnext/accounts/doctype/promotional_scheme_product_discount/__init__.py
similarity index 100%
rename from erpnext/accounts/doctype/price_discount_slab/__init__.py
rename to erpnext/accounts/doctype/promotional_scheme_product_discount/__init__.py
diff --git a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json
new file mode 100644
index 0000000..b87725f
--- /dev/null
+++ b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json
@@ -0,0 +1,751 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-24 14:48:59.649168",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+  {
+   "allow_bulk_edit": 0,
+   "allow_in_quick_entry": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "disable",
+   "fieldtype": "Data",
+   "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": "Disable",
+   "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_2",
+   "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": "rule_description",
+   "fieldtype": "Small Text",
+   "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": "Rule Description",
+   "length": 0,
+   "no_copy": 1,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 1,
+   "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": "section_break_1",
+   "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,
+   "default": "0",
+   "fieldname": "min_qty",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Min Qty",
+   "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,
+   "default": "0",
+   "fieldname": "max_qty",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Max Qty",
+   "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_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,
+   "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,
+   "default": "0",
+   "fieldname": "min_amount",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Min 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,
+   "default": "0",
+   "fieldname": "max_amount",
+   "fieldtype": "Currency",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Max 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": "section_break_6",
+   "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": "Free Item",
+   "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,
+   "depends_on": "eval:!parent.mixed_conditions",
+   "fieldname": "same_item",
+   "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": "Same Item",
+   "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,
+   "depends_on": "eval:!doc.same_item || parent.mixed_conditions",
+   "fieldname": "free_item",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Item Code",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Item",
+   "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": "free_qty",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 1,
+   "in_standard_filter": 0,
+   "label": "Qty",
+   "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_9",
+   "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": "free_item_uom",
+   "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": "UOM",
+   "length": 0,
+   "no_copy": 0,
+   "options": "UOM",
+   "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": "free_item_rate",
+   "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": "Rate",
+   "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": "section_break_12",
+   "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": "warehouse",
+   "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": "Warehouse",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Warehouse",
+   "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": "threshold_percentage",
+   "fieldtype": "Percent",
+   "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": "Threshold for Suggestion",
+   "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_15",
+   "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": "priority",
+   "fieldtype": "Select",
+   "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": "Priority",
+   "length": 0,
+   "no_copy": 0,
+   "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20",
+   "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": "apply_multiple_pricing_rules",
+   "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": "Apply Multiple Pricing Rules",
+   "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
+  }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-24 14:48:59.649168",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Promotional Scheme Product Discount",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 0,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py
similarity index 82%
copy from erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
copy to erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py
index 940fce6..2931106 100644
--- a/erpnext/accounts/doctype/product_discount_slab/product_discount_slab.py
+++ b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py
@@ -6,5 +6,5 @@
 import frappe
 from frappe.model.document import Document
 
-class ProductDiscountSlab(Document):
+class PromotionalSchemeProductDiscount(Document):
 	pass
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index c0d0d83..53eb731 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -8,6 +8,7 @@
 from frappe import _, throw
 import frappe.defaults
 
+from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
 from erpnext.controllers.buying_controller import BuyingController
 from erpnext.accounts.party import get_party_account, get_due_date
 from erpnext.accounts.utils import get_account_currency, get_fiscal_year
@@ -17,7 +18,7 @@
 from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
 from erpnext.buying.utils import check_for_closed_status
 from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center
-from erpnext.assets.doctype.asset.asset import get_asset_account
+from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_disabled
 from frappe.model.mapper import get_mapped_doc
 from six import iteritems
 from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_invoice,\
@@ -222,7 +223,7 @@
 			self.validate_item_code()
 			self.validate_warehouse()
 			if auto_accounting_for_stock:
-				warehouse_account = get_warehouse_account_map()
+				warehouse_account = get_warehouse_account_map(self.company)
 
 		for item in self.get("items"):
 			# in case of auto inventory accounting,
@@ -238,6 +239,13 @@
 					item.expense_account = warehouse_account[item.warehouse]["account"]
 				else:
 					item.expense_account = stock_not_billed_account
+			elif item.is_fixed_asset and is_cwip_accounting_disabled():
+				if not item.asset:
+					frappe.throw(_("Row {0}: asset is required for item {1}")
+						.format(item.idx, item.item_code))
+
+				item.expense_account = get_asset_category_account(item.asset, 'fixed_asset_account',
+					company = self.company)
 			elif item.is_fixed_asset and item.pr_detail:
 				item.expense_account = asset_received_but_not_billed
 			elif not item.expense_account and for_validate:
@@ -366,7 +374,8 @@
 			if repost_future_gle and cint(self.update_stock) and self.auto_accounting_for_stock:
 				from erpnext.controllers.stock_controller import update_gl_entries_after
 				items, warehouses = self.get_items_and_warehouses()
-				update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items)
+				update_gl_entries_after(self.posting_date, self.posting_time,
+					warehouses, items, company = self.company)
 
 		elif self.docstatus == 2 and cint(self.update_stock) and self.auto_accounting_for_stock:
 			delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
@@ -383,7 +392,9 @@
 
 		self.make_supplier_gl_entry(gl_entries)
 		self.make_item_gl_entries(gl_entries)
-		self.get_asset_gl_entry(gl_entries)
+		if not is_cwip_accounting_disabled():
+			self.get_asset_gl_entry(gl_entries)
+
 		self.make_tax_gl_entries(gl_entries)
 
 		gl_entries = merge_similar_entries(gl_entries)
@@ -423,7 +434,7 @@
 		stock_items = self.get_stock_items()
 		expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
 		if self.update_stock and self.auto_accounting_for_stock:
-			warehouse_account = get_warehouse_account_map()
+			warehouse_account = get_warehouse_account_map(self.company)
 
 		voucher_wise_stock_value = {}
 		if self.update_stock:
@@ -475,7 +486,7 @@
 							"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
 							"credit": flt(item.rm_supp_cost)
 						}, warehouse_account[self.supplier_warehouse]["account_currency"]))
-				elif not item.is_fixed_asset:
+				elif not item.is_fixed_asset or (item.is_fixed_asset and is_cwip_accounting_disabled()):
 					gl_entries.append(
 						self.get_gl_dict({
 							"account": item.expense_account if not item.enable_deferred_expense else item.deferred_expense_account,
@@ -520,7 +531,7 @@
 				base_asset_amount = flt(item.base_net_amount + item.item_tax_amount)
 
 				if (not item.expense_account or frappe.db.get_value('Account',
-					item.expense_account, 'account_type') != 'Asset Received But Not Billed'):
+					item.expense_account, 'account_type') not in ['Asset Received But Not Billed', 'Fixed Asset']):
 					arbnb_account = self.get_company_default("asset_received_but_not_billed")
 					item.expense_account = arbnb_account
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 62d8ffd..61e1224 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -405,7 +405,7 @@
 
 			for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name',
 				'company', 'select_print_heading', 'cash_bank_account', 'company_address',
-				'write_off_account', 'write_off_cost_center', 'apply_discount_on'):
+				'write_off_account', 'write_off_cost_center', 'apply_discount_on', 'cost_center'):
 					if (not for_validate) or (for_validate and not self.get(fieldname)):
 						self.set(fieldname, pos.get(fieldname))
 
@@ -695,7 +695,8 @@
 			if repost_future_gle and cint(self.update_stock) \
 				and cint(auto_accounting_for_stock):
 					items, warehouses = self.get_items_and_warehouses()
-					update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items)
+					update_gl_entries_after(self.posting_date, self.posting_time,
+						warehouses, items, company = self.company)
 		elif self.docstatus == 2 and cint(self.update_stock) \
 			and cint(auto_accounting_for_stock):
 				from erpnext.accounts.general_ledger import delete_gl_entries
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 90ac0d2..686579b 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -595,8 +595,10 @@
 def get_partywise_advanced_payment_amount(party_type="Customer"):
 	data = frappe.db.sql(""" SELECT party, sum({0}) as amount
 		FROM `tabGL Entry`
-		WHERE party_type = %s and against_voucher is null GROUP BY party"""
-		.format(("credit - debit") if party_type == "Customer" else "debit") , party_type)
+		WHERE
+			party_type = %s and against_voucher is null
+			GROUP BY party"""
+		.format(("credit") if party_type == "Customer" else "debit") , party_type)
 
 	if data:
 		return frappe._dict(data)
\ No newline at end of file
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 73ca8b4..8cb5ac1 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -144,9 +144,10 @@
 				row += [self.get_party_name(args.get("party_type"), party)]
 
 			row += [partywise_advance_amount.get(party, 0)]
+			paid_amt = flt(party_dict.paid_amt - partywise_advance_amount.get(party, 0))
 
 			row += [
-				party_dict.invoiced_amt, party_dict.paid_amt, party_dict.credit_amt, party_dict.outstanding_amt,
+				party_dict.invoiced_amt, paid_amt, party_dict.credit_amt, party_dict.outstanding_amt,
 				party_dict.range1, party_dict.range2, party_dict.range3, party_dict.range4,
 			]
 
@@ -205,7 +206,7 @@
 
 		cols += ["invoiced_amt", "paid_amt", "credit_amt",
 		"outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency", "pdc/lc_date", "pdc/lc_ref",
-		"pdc/lc_amount", "remaining_balance"]
+		"pdc/lc_amount"]
 
 		if args.get("party_type") == "Supplier":
 			cols += ["supplier_group", "remarks"]
diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
index e33bd61..eceabf5 100644
--- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
+++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
@@ -195,7 +195,7 @@
 		conditions = [""]
 
 		if self.filters.company:
-			conditions.append("company=%(company)s")
+			conditions.append("gle.company=%(company)s")
 
 		self.filters.company_finance_book = erpnext.get_default_finance_book(self.filters.company)
 
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index 4d26aa3..a5859e3 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -125,10 +125,11 @@
 
 			# get buying amount
 			if row.item_code in product_bundles:
-				row.buying_amount = self.get_buying_amount_from_product_bundle(row,
-					product_bundles[row.item_code])
+				row.buying_amount = flt(self.get_buying_amount_from_product_bundle(row,
+					product_bundles[row.item_code]), self.currency_precision)
 			else:
-				row.buying_amount = self.get_buying_amount(row, row.item_code)
+				row.buying_amount = flt(self.get_buying_amount(row, row.item_code),
+					self.currency_precision)
 
 			# get buying rate
 			if row.qty:
@@ -215,7 +216,7 @@
 			if packed_item.get("parent_detail_docname")==row.item_row:
 				buying_amount += self.get_buying_amount(row, packed_item.item_code)
 
-		return buying_amount
+		return flt(buying_amount, self.currency_precision)
 
 	def get_buying_amount(self, row, item_code):
 		# IMP NOTE
diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py
index e33b90d..3f8abb7 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.py
+++ b/erpnext/accounts/report/purchase_register/purchase_register.py
@@ -66,8 +66,8 @@
 				total_tax += tax_amount
 				row.append(tax_amount)
 
-		# total tax, grand total, outstanding amount & rounded total
-		row += [total_tax, inv.base_grand_total, flt(inv.base_grand_total, 2), inv.outstanding_amount]
+		# total tax, grand total, rounded total & outstanding amount 
+		row += [total_tax, inv.base_grand_total, flt(inv.base_grand_total, 0), inv.outstanding_amount]
 		data.append(row)
 
 	return columns, data
diff --git a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
index 6fd16f2..f812977 100644
--- a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
+++ b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
@@ -35,9 +35,9 @@
 		},
 		{
 			"fieldname":"party",
-			"label": __("Customer"),
+			"label": __("Supplier"),
 			"fieldtype": "Link",
-			"options": "Customer",
+			"options": "Supplier",
 			on_change: () => {
 				var party = frappe.query_report.get_filter_value('party');
 				if (party) {
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 1c9d977..00100ef 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -544,14 +544,14 @@
 				(dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr),
 				(d.diff, d.voucher_type, d.voucher_no))
 
-def get_stock_and_account_difference(account_list=None, posting_date=None):
+def get_stock_and_account_difference(account_list=None, posting_date=None, company=None):
 	from erpnext.stock.utils import get_stock_value_on
 	from erpnext.stock import get_warehouse_account_map
 
 	if not posting_date: posting_date = nowdate()
 
 	difference = {}
-	warehouse_account = get_warehouse_account_map()
+	warehouse_account = get_warehouse_account_map(company)
 
 	for warehouse, account_data in iteritems(warehouse_account):
 		if account_data.get('account') in account_list:
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index a38b40b..cfacb5a 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -33,7 +33,7 @@
 		self.validate_in_use_date()
 		self.set_status()
 		self.update_stock_movement()
-		if not self.booked_fixed_asset:
+		if not self.booked_fixed_asset and not is_cwip_accounting_disabled():
 			self.make_gl_entries()
 
 	def on_cancel(self):
@@ -71,14 +71,15 @@
 		if not flt(self.gross_purchase_amount):
 			frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError)
 
-		if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice):
-			frappe.throw(_("Please create purchase receipt or purchase invoice for the item {0}").
-				format(self.item_code))
+		if not is_cwip_accounting_disabled():
+			if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice):
+				frappe.throw(_("Please create purchase receipt or purchase invoice for the item {0}").
+					format(self.item_code))
 
-		if (not self.purchase_receipt and self.purchase_invoice
-			and not frappe.db.get_value('Purchase Invoice', self.purchase_invoice, 'update_stock')):
-			frappe.throw(_("Update stock must be enable for the purchase invoice {0}").
-				format(self.purchase_invoice))
+			if (not self.purchase_receipt and self.purchase_invoice
+				and not frappe.db.get_value('Purchase Invoice', self.purchase_invoice, 'update_stock')):
+				frappe.throw(_("Update stock must be enable for the purchase invoice {0}").
+					format(self.purchase_invoice))
 
 		if not self.calculate_depreciation:
 			return
@@ -255,7 +256,7 @@
 	def get_depreciation_amount(self, depreciable_value, total_number_of_depreciations, row):
 		percentage_value = 100.0 if row.depreciation_method == 'Written Down Value' else 200.0
 
-		factor = percentage_value /  total_number_of_depreciations
+		factor = percentage_value /  cint(total_number_of_depreciations)
 		depreciation_amount = flt(depreciable_value * factor / 100, 0)
 
 		value_after_depreciation = flt(depreciable_value) - depreciation_amount
@@ -275,7 +276,7 @@
 				flt(row.expected_value_after_useful_life)) / (cint(row.total_number_of_depreciations) -
 				cint(self.number_of_depreciations_booked)) * prorata_temporis
 		else:
-			depreciation_amount = self.get_depreciation_amount(depreciable_value, row)
+			depreciation_amount = self.get_depreciation_amount(depreciable_value, row.total_number_of_depreciations, row)
 
 		return depreciation_amount
 
@@ -404,6 +405,9 @@
 			asset.set_status('Out of Order')
 
 def make_post_gl_entry():
+	if is_cwip_accounting_disabled():
+		return
+
 	assets = frappe.db.sql_list(""" select name from `tabAsset`
 		where ifnull(booked_fixed_asset, 0) = 0 and available_for_use_date = %s""", nowdate())
 
@@ -551,3 +555,6 @@
 	})
 
 	return je
+
+def is_cwip_accounting_disabled():
+	return cint(frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting"))
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset_settings/asset_settings.json b/erpnext/assets/doctype/asset_settings/asset_settings.json
index d6ddd33..a3fee96 100644
--- a/erpnext/assets/doctype/asset_settings/asset_settings.json
+++ b/erpnext/assets/doctype/asset_settings/asset_settings.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
  "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
@@ -14,10 +15,12 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "depreciation_options", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -40,14 +43,17 @@
    "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, 
+   "fetch_if_empty": 0, 
    "fieldname": "schedule_based_on_fiscal_year", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -70,10 +76,12 @@
    "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, 
@@ -81,6 +89,7 @@
    "default": "360", 
    "depends_on": "eval:doc.schedule_based_on_fiscal_year", 
    "description": "This value is used for pro-rata temporis calculation", 
+   "fetch_if_empty": 0, 
    "fieldname": "number_of_days_in_fiscal_year", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -103,6 +112,40 @@
    "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "disable_cwip_accounting", 
+   "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": "Disable CWIP Accounting", 
+   "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
   }
  ], 
@@ -116,7 +159,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-01-05 10:10:39.803255", 
+ "modified": "2019-03-08 10:44:41.924547", 
  "modified_by": "Administrator", 
  "module": "Assets", 
  "name": "Asset Settings", 
@@ -125,7 +168,6 @@
  "permissions": [
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
    "cancel": 0, 
    "create": 1, 
    "delete": 1, 
@@ -145,7 +187,6 @@
   }, 
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
    "cancel": 0, 
    "create": 1, 
    "delete": 1, 
@@ -171,5 +212,6 @@
  "sort_field": "modified", 
  "sort_order": "DESC", 
  "track_changes": 1, 
- "track_seen": 0
+ "track_seen": 0, 
+ "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index e79a2ac..34bb803 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -391,9 +391,10 @@
 
 		item = get_item_defaults(target.item_code, source_parent.company)
 		item_group = get_item_group_defaults(target.item_code, source_parent.company)
-		target.cost_center = frappe.db.get_value("Project", obj.project, "cost_center") \
-			or item.get("buying_cost_center") \
-			or item_group.get("buying_cost_center")
+		target.cost_center = (obj.cost_center
+			or frappe.db.get_value("Project", obj.project, "cost_center")
+			or item.get("buying_cost_center")
+			or item_group.get("buying_cost_center"))
 
 	doc = get_mapped_doc("Purchase Order", source_name,	{
 		"Purchase Order": {
diff --git a/erpnext/config/accounting.py b/erpnext/config/accounting.py
index 9de5b36..afe35f8 100644
--- a/erpnext/config/accounting.py
+++ b/erpnext/config/accounting.py
@@ -564,6 +564,10 @@
 				"is_query_report": True
 			},
 			{
+				"type": "doctype",
+				"name": "GSTR 3B Report",
+			},
+			{
 				"type": "report",
 				"name": "GST Sales Register",
 				"is_query_report": True
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index 58f7952..4a65af3 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -298,7 +298,7 @@
 				{
 					"type": "help",
 					"label": _("Sales Order to Payment"),
-					"youtube_id": "7AMq4lqkN4A"
+					"youtube_id": "1eP90MWoDQM"
 				},
 				{
 					"type": "help",
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 9ca5219..d11c644 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -26,7 +26,7 @@
 			delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
 
 		if cint(erpnext.is_perpetual_inventory_enabled(self.company)):
-			warehouse_account = get_warehouse_account_map()
+			warehouse_account = get_warehouse_account_map(self.company)
 
 			if self.docstatus==1:
 				if not gl_entries:
@@ -36,7 +36,7 @@
 			if repost_future_gle:
 				items, warehouses = self.get_items_and_warehouses()
 				update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
-					warehouse_account)
+					warehouse_account, company=self.company)
 		elif self.doctype in ['Purchase Receipt', 'Purchase Invoice'] and self.docstatus == 1:
 			gl_entries = []
 			gl_entries = self.get_asset_gl_entry(gl_entries)
@@ -46,7 +46,7 @@
 			default_cost_center=None):
 
 		if not warehouse_account:
-			warehouse_account = get_warehouse_account_map()
+			warehouse_account = get_warehouse_account_map(self.company)
 
 		sle_map = self.get_stock_ledger_details()
 		voucher_details = self.get_voucher_details(default_expense_account, default_cost_center, sle_map)
@@ -199,7 +199,8 @@
 	def make_adjustment_entry(self, expected_gle, voucher_obj):
 		from erpnext.accounts.utils import get_stock_and_account_difference
 		account_list = [d.account for d in expected_gle]
-		acc_diff = get_stock_and_account_difference(account_list, expected_gle[0].posting_date)
+		acc_diff = get_stock_and_account_difference(account_list,
+			expected_gle[0].posting_date, self.company)
 
 		cost_center = self.get_company_default("cost_center")
 		stock_adjustment_account = self.get_company_default("stock_adjustment_account")
@@ -361,13 +362,13 @@
 			frappe.get_doc("Blanket Order", blanket_order).update_ordered_qty()
 
 def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None,
-		warehouse_account=None):
+		warehouse_account=None, company=None):
 	def _delete_gl_entries(voucher_type, voucher_no):
 		frappe.db.sql("""delete from `tabGL Entry`
 			where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
 
 	if not warehouse_account:
-		warehouse_account = get_warehouse_account_map()
+		warehouse_account = get_warehouse_account_map(company)
 
 	future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items)
 	gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date)
diff --git a/erpnext/healthcare/web_form/personal_details/personal_details.py b/erpnext/healthcare/web_form/personal_details/personal_details.py
index aa68c42..fe46d7b 100644
--- a/erpnext/healthcare/web_form/personal_details/personal_details.py
+++ b/erpnext/healthcare/web_form/personal_details/personal_details.py
@@ -4,7 +4,6 @@
 from frappe import _
 
 no_cache = 1
-no_sitemap = 1
 
 def get_context(context):
 	if frappe.session.user=='Guest':
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 942806e..c1ac407 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -322,3 +322,15 @@
 		'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.italy.utils.sales_invoice_validate',
 	}
 }
+user_privacy_documents = [
+	{
+		'doctype': 'Lead',
+		'match_field': 'email_id',
+		'personal_fields': ['phone', 'mobile_no', 'fax', 'website', 'lead_name'],
+	},
+	{
+		'doctype': 'Opportunity',
+		'match_field': 'contact_email',
+		'personal_fields': ['contact_mobile', 'contact_display', 'customer_name'],
+	}
+]
\ No newline at end of file
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
index e25e69e..968a1c4 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -19,8 +19,6 @@
 			["date_of_joining", "relieving_date"])
  		if date_of_joining and getdate(self.payroll_date) < getdate(date_of_joining):
  			frappe.throw(_("Payroll date can not be less than employee's joining date"))
- 		elif relieving_date and getdate(self.payroll_date) > getdate(relieving_date):
- 			frappe.throw(_("To date can not greater than employee's relieving date"))
 
 	def get_amount(self, sal_start_date, sal_end_date):
 		start_date = getdate(sal_start_date)
diff --git a/erpnext/hr/doctype/attendance/attendance.json b/erpnext/hr/doctype/attendance/attendance.json
index 97d28e7..2459b7a 100644
--- a/erpnext/hr/doctype/attendance/attendance.json
+++ b/erpnext/hr/doctype/attendance/attendance.json
@@ -225,6 +225,39 @@
    "bold": 0,
    "collapsible": 0,
    "columns": 0,
+   "fieldname": "leave_application",
+   "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": "Leave Application",
+   "length": 0,
+   "no_copy": 0,
+   "options": "Leave Application",
+   "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": "column_break0",
    "fieldtype": "Column Break",
    "hidden": 0,
@@ -428,7 +461,7 @@
  "issingle": 0,
  "istable": 0,
  "max_attachments": 0,
- "modified": "2019-01-30 11:28:13.075959",
+ "modified": "2019-03-08 12:00:14.043535",
  "modified_by": "Administrator",
  "module": "HR",
  "name": "Attendance",
diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py
index 74a5303..7dd9f0e 100644
--- a/erpnext/hr/doctype/attendance/attendance.py
+++ b/erpnext/hr/doctype/attendance/attendance.py
@@ -40,7 +40,8 @@
 	def validate_attendance_date(self):
 		date_of_joining = frappe.db.get_value("Employee", self.employee, "date_of_joining")
 
-		if getdate(self.attendance_date) > getdate(nowdate()):
+		# leaves can be marked for future dates
+		if self.status not in ('On Leave', 'Half Day') and getdate(self.attendance_date) > getdate(nowdate()):
 			frappe.throw(_("Attendance can not be marked for future dates"))
 		elif date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
 			frappe.throw(_("Attendance date can not be less than employee's joining date"))
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index b85f38b..b50b534 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -117,28 +117,29 @@
 
 	def update_attendance(self):
 		if self.status == "Approved":
-			attendance = frappe.db.sql("""select name from `tabAttendance` where employee = %s\
-				and (attendance_date between %s and %s) and docstatus < 2""",(self.employee, self.from_date, self.to_date), as_dict=1)
+			for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
+				date = dt.strftime("%Y-%m-%d")
+				status = "Half Day" if date == self.half_day_date else "On Leave"
 
-			if attendance:
-				for d in attendance:
-					doc = frappe.get_doc("Attendance", d.name)
-					if getdate(self.half_day_date) == doc.attendance_date:
-						status = "Half Day"
-					else:
-						status = "On Leave"
-					frappe.db.sql("""update `tabAttendance` set status = %s, leave_type = %s\
-						where name = %s""",(status, self.leave_type, d.name))
+				attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
+					attenance_date = date, docstatus = ('!=', 2)))
 
-			elif getdate(self.to_date) <= getdate(nowdate()):
-				for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
-					date = dt.strftime("%Y-%m-%d")
+				if attendance_name:
+					# update existing attendance, change absent to on leave
+					doc = frappe.get_doc('Attendance', attendance_name)
+					if doc.status != status:
+						doc.db_set('status', status)
+						doc.db_set('leave_type', self.leave_type)
+						doc.db_set('leave_application', self.name)
+				else:
+					# make new attendance and submit it
 					doc = frappe.new_doc("Attendance")
 					doc.employee = self.employee
 					doc.attendance_date = date
 					doc.company = self.company
 					doc.leave_type = self.leave_type
-					doc.status = "Half Day" if date == self.half_day_date else "On Leave"
+					doc.leave_application = self.name
+					doc.status = status
 					doc.flags.ignore_validate = True
 					doc.insert(ignore_permissions=True)
 					doc.submit()
@@ -505,8 +506,6 @@
 def add_leaves(events, start, end, filter_conditions=None):
 	conditions = []
 
-	if filter_conditions:
-		conditions.append(filter_conditions)
 
 	if not cint(frappe.db.get_value("HR Settings", None, "show_leaves_of_all_department_members_in_calendar")):
 		from frappe.desk.reportview import build_match_conditions
@@ -520,11 +519,14 @@
 		from `tabLeave Application` where
 		from_date <= %(end)s and to_date >= %(start)s <= to_date
 		and docstatus < 2
-		and status!="Rejected" """
+		and status!='Rejected' """
 
 	if conditions:
 		query += ' and ' + ' and '.join(conditions)
 
+	if filter_conditions:
+		query += filter_conditions
+
 	for d in frappe.db.sql(query, {"start":start, "end": end}, as_dict=True):
 		e = {
 			"name": d.name,
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index a682e8b..d3dcca1 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -7,7 +7,7 @@
 
 from erpnext.hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError, NotAnOptionalHoliday, get_leave_balance_on
 from frappe.permissions import clear_user_permissions_for_doctype
-from frappe.utils import add_days, nowdate, now_datetime
+from frappe.utils import add_days, nowdate, now_datetime, getdate
 
 test_dependencies = ["Leave Allocation", "Leave Block List"]
 
@@ -67,6 +67,43 @@
 		application.to_date = "2013-01-05"
 		return application
 
+	def test_attendance_creation(self):
+		'''check attendance is automatically created on leave approval'''
+		make_allocation_record()
+		application = self.get_application(_test_records[0])
+		application.status = 'Approved'
+		application.from_date = '2018-01-01'
+		application.to_date = '2018-01-03'
+		application.insert()
+		application.submit()
+
+		attendance = frappe.get_all('Attendance', ['name', 'status', 'attendance_date'], dict(leave_application = application.name))
+
+		# attendance created for all 3 days
+		self.assertEqual(len(attendance), 3)
+
+		# all on leave
+		self.assertTrue(all([d.status == 'On Leave' for d in attendance]))
+
+		# dates
+		dates = [d.attendance_date for d in attendance]
+		for d in ('2018-01-01', '2018-01-02', '2018-01-03'):
+			self.assertTrue(getdate(d) in dates)
+
+	def test_overwrite_attendance(self):
+		# employee marked as absent
+		doc = frappe.new_doc("Attendance")
+		doc.employee = '_T-Employee-00001'
+		doc.attendance_date = '2018-01-01'
+		doc.company = '_Test Company'
+		doc.status = 'Absent'
+		doc.flags.ignore_validate = True
+		doc.insert(ignore_permissions=True)
+		doc.submit()
+
+		# now check if the status has been updated
+		self.test_attendance_creation()
+
 	def test_block_list(self):
 		self._clear_roles()
 
@@ -428,7 +465,7 @@
 		"employee": employee or "_T-Employee-00001",
 		"leave_type": leave_type or "_Test Leave Type",
 		"from_date": "2013-01-01",
-		"to_date": "2015-12-31",
+		"to_date": "2019-12-31",
 		"new_leaves_allocated": 30
 	})
 
diff --git a/erpnext/hr/doctype/staffing_plan/staffing_plan.py b/erpnext/hr/doctype/staffing_plan/staffing_plan.py
index 70e185c..83e5313 100644
--- a/erpnext/hr/doctype/staffing_plan/staffing_plan.py
+++ b/erpnext/hr/doctype/staffing_plan/staffing_plan.py
@@ -20,6 +20,7 @@
 		self.total_estimated_budget = 0
 
 		for detail in self.get("staffing_details"):
+			self.set_vacancies(detail)
 			self.validate_overlap(detail)
 			self.validate_with_subsidiary_plans(detail)
 			self.validate_with_parent_plan(detail)
@@ -39,6 +40,15 @@
 			else: detail.vacancies = detail.number_of_positions = detail.total_estimated_cost = 0
 			self.total_estimated_budget += detail.total_estimated_cost
 
+	def set_vacancies(self, row):
+		if not row.vacancies:
+			current_openings = 0
+			for field in ['current_count', 'current_openings']:
+				if row.get(field):
+					current_openings += row.get(field)
+
+			row.vacancies = row.number_of_positions - current_openings
+
 	def validate_overlap(self, staffing_plan_detail):
 		# Validate if any submitted Staffing Plan exist for any Designations in this plan
 		# and spd.vacancies>0 ?
diff --git a/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py b/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py
index 66d9cdd..22dba99 100644
--- a/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py
+++ b/erpnext/hr/doctype/staffing_plan/test_staffing_plan.py
@@ -18,7 +18,7 @@
 		if frappe.db.exists("Staffing Plan", "Test"):
 			return
 		staffing_plan = frappe.new_doc("Staffing Plan")
-		staffing_plan.company = "_Test Company 3"
+		staffing_plan.company = "_Test Company 10"
 		staffing_plan.name = "Test"
 		staffing_plan.from_date = nowdate()
 		staffing_plan.to_date = add_days(nowdate(), 10)
@@ -67,7 +67,7 @@
 		if frappe.db.exists("Staffing Plan", "Test 1"):
 			return
 		staffing_plan = frappe.new_doc("Staffing Plan")
-		staffing_plan.company = "_Test Company 3"
+		staffing_plan.company = "_Test Company 10"
 		staffing_plan.name = "Test 1"
 		staffing_plan.from_date = nowdate()
 		staffing_plan.to_date = add_days(nowdate(), 10)
@@ -85,11 +85,11 @@
 	make_company()
 
 def make_company():
-	if frappe.db.exists("Company", "_Test Company 3"):
+	if frappe.db.exists("Company", "_Test Company 10"):
 		return
 	company = frappe.new_doc("Company")
-	company.company_name = "_Test Company 3"
-	company.abbr = "_TC3"
+	company.company_name = "_Test Company 10"
+	company.abbr = "_TC10"
 	company.parent_company = "_Test Company"
 	company.default_currency = "INR"
 	company.country = "India"
diff --git a/erpnext/hr/doctype/training_event/training_event.json b/erpnext/hr/doctype/training_event/training_event.json
index 527ac1b..fcf845a 100644
--- a/erpnext/hr/doctype/training_event/training_event.json
+++ b/erpnext/hr/doctype/training_event/training_event.json
@@ -809,7 +809,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-10-23 06:13:29.065781", 
+ "modified": "2019-03-12 10:56:29.065781", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Training Event", 
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 8d643a9..ffa3962 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -582,7 +582,7 @@
 	context.title = _("Bill of Materials")
 	# context.introduction = _('Boms')
 
-def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_items=0, include_non_stock_items=False):
+def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_items=0, include_non_stock_items=False, fetch_qty_in_stock_uom=True):
 	item_dict = {}
 
 	# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
@@ -590,7 +590,7 @@
 				bom_item.item_code,
 				bom_item.idx,
 				item.item_name,
-				sum(bom_item.stock_qty/ifnull(bom.quantity, 1)) * %(qty)s as qty,
+				sum(bom_item.{qty_field}/ifnull(bom.quantity, 1)) * %(qty)s as qty,
 				item.description,
 				item.image,
 				item.stock_uom,
@@ -618,16 +618,18 @@
 		query = query.format(table="BOM Explosion Item",
 			where_conditions="",
 			is_stock_item=is_stock_item,
+			qty_field="stock_qty",
 			select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.include_item_in_manufacturing,
 				(Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx""")
 
 		items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom, "company": company }, as_dict=True)
 	elif fetch_scrap_items:
-		query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx", is_stock_item=is_stock_item)
+		query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx", is_stock_item=is_stock_item, qty_field="stock_qty")
 		items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
 	else:
 		query = query.format(table="BOM Item", where_conditions="", is_stock_item=is_stock_item,
-			select_columns = ", bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing")
+			qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty",
+			select_columns = ", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing")
 		items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
 
 	for item in items:
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js
index 3fe9b8a..95549d5 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.js
+++ b/erpnext/manufacturing/doctype/job_card/job_card.js
@@ -18,20 +18,27 @@
 		}
 
 		if (frm.doc.docstatus == 0) {
-			if (!frm.doc.actual_start_date || !frm.doc.actual_end_date) {
-				frm.trigger("make_dashboard");
-			}
+			frm.trigger("make_dashboard");
 
-			if (!frm.doc.actual_start_date) {
+			if (!frm.doc.job_started) {
 				frm.add_custom_button(__("Start Job"), () => {
-					frm.set_value('actual_start_date', frappe.datetime.now_datetime());
+					let row = frappe.model.add_child(frm.doc, 'Job Card Time Log', 'time_logs');
+					row.from_time = frappe.datetime.now_datetime();
+					frm.set_value('job_started', 1);
+					frm.set_value('started_time' , row.from_time);
 					frm.save();
 				});
-			} else if (!frm.doc.actual_end_date) {
+			} else {
 				frm.add_custom_button(__("Complete Job"), () => {
-					frm.set_value('actual_end_date', frappe.datetime.now_datetime());
-					frm.save();
-					frm.savesubmit();
+					let completed_time = frappe.datetime.now_datetime();
+					frm.doc.time_logs.forEach(d => {
+						if (d.from_time && !d.to_time) {
+							d.to_time = completed_time;
+							frm.set_value('started_time' , '');
+							frm.set_value('job_started', 0);
+							frm.save();
+						}
+					})
 				});
 			}
 		}
@@ -53,8 +60,8 @@
 
 		var section = frm.dashboard.add_section(timer);
 
-		if (frm.doc.actual_start_date) {
-			let currentIncrement = moment(frappe.datetime.now_datetime()).diff(moment(frm.doc.actual_start_date),"seconds");
+		if (frm.doc.started_time) {
+			let currentIncrement = moment(frappe.datetime.now_datetime()).diff(moment(frm.doc.started_time),"seconds");
 			initialiseTimer();
 
 			function initialiseTimer() {
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json
index b020c89..39c5cce 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.json
+++ b/erpnext/manufacturing/doctype/job_card/job_card.json
@@ -21,6 +21,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "work_order", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -54,6 +55,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "bom_no", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -87,6 +89,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "workstation", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -120,6 +123,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "operation", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -153,6 +157,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_4", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -185,6 +190,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Today", 
+   "fetch_if_empty": 0, 
    "fieldname": "posting_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -217,6 +223,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "company", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -250,6 +257,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "for_quantity", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -282,6 +290,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "wip_warehouse", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -315,6 +324,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "timing_detail", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -347,6 +357,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "employee", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -380,7 +391,74 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "time_in_mins", 
+   "fetch_if_empty": 0, 
+   "fieldname": "time_logs", 
+   "fieldtype": "Table", 
+   "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": "Time Logs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Job Card Time Log", 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "section_break_13", 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "total_completed_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -389,7 +467,7 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Time In Mins", 
+   "label": "Total Completed Qty", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -412,7 +490,8 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "column_break_13", 
+   "fetch_if_empty": 0, 
+   "fieldname": "column_break_15", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -443,8 +522,9 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "actual_start_date", 
-   "fieldtype": "Datetime", 
+   "fetch_if_empty": 0, 
+   "fieldname": "total_time_in_mins", 
+   "fieldtype": "Float", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -452,14 +532,14 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Actual Start Date", 
+   "label": "Total Time in Mins", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
    "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, 
@@ -475,38 +555,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "actual_end_date", 
-   "fieldtype": "Datetime", 
-   "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": "Actual End 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, 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_8", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -539,6 +588,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "items", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -572,6 +622,7 @@
    "bold": 0, 
    "collapsible": 1, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "more_information", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -604,6 +655,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "operation_id", 
    "fieldtype": "Data", 
    "hidden": 1, 
@@ -637,6 +689,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "0", 
+   "fetch_if_empty": 0, 
    "fieldname": "transferred_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -670,6 +723,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "0", 
+   "fetch_if_empty": 0, 
    "fieldname": "requested_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -702,6 +756,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "project", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -735,6 +790,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "remarks", 
    "fieldtype": "Small Text", 
    "hidden": 0, 
@@ -767,6 +823,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_20", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -799,6 +856,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "Open", 
+   "fetch_if_empty": 0, 
    "fieldname": "status", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -832,6 +890,73 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "job_started", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Job Started", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "started_time", 
+   "fieldtype": "Datetime", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Started Time", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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, 
+   "fetch_if_empty": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -868,7 +993,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-12-13 17:23:57.986381", 
+ "modified": "2019-03-10 17:38:37.499871", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "Job Card", 
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index ea9f714..23a4e51 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -11,44 +11,56 @@
 
 class JobCard(Document):
 	def validate(self):
-		self.validate_actual_dates()
-		self.set_time_in_mins()
+		self.validate_time_logs()
 		self.set_status()
 
-	def validate_actual_dates(self):
-		if get_datetime(self.actual_start_date) > get_datetime(self.actual_end_date):
-			frappe.throw(_("Actual start date must be less than actual end date"))
+	def validate_time_logs(self):
+		self.total_completed_qty = 0.0
+		self.total_time_in_mins = 0.0
 
-		if not (self.employee and self.actual_start_date and self.actual_end_date):
-			return
+		for d in self.get('time_logs'):
+			if get_datetime(d.from_time) > get_datetime(d.to_time):
+				frappe.throw(_("Row {0}: From time must be less than to time").format(d.idx))
 
-		data = frappe.db.sql(""" select name from `tabJob Card`
-			where
-				((%(actual_start_date)s > actual_start_date and %(actual_start_date)s < actual_end_date) or
-				(%(actual_end_date)s > actual_start_date and %(actual_end_date)s < actual_end_date) or
-				(%(actual_start_date)s <= actual_start_date and %(actual_end_date)s >= actual_end_date)) and
-				name != %(name)s and employee = %(employee)s and docstatus =1
-		""", {
-			'actual_start_date': self.actual_start_date,
-			'actual_end_date': self.actual_end_date,
-			'employee': self.employee,
-			'name': self.name
-		}, as_dict=1)
+			data = self.get_overlap_for(d)
+			if data:
+				frappe.throw(_("Row {0}: From Time and To Time of {1} is overlapping with {2}")
+					.format(d.idx, self.name, data.name))
 
-		if data:
-			frappe.throw(_("Start date and end date is overlapping with the job card <a href='#Form/Job Card/{0}'>{1}</a>")
-				.format(data[0].name, data[0].name))
+			if d.from_time and d.to_time:
+				d.time_in_mins = time_diff_in_hours(d.to_time, d.from_time) * 60
+				self.total_time_in_mins += d.time_in_mins
 
-	def set_time_in_mins(self):
-		if self.actual_start_date and self.actual_end_date:
-			self.time_in_mins = time_diff_in_hours(self.actual_end_date, self.actual_start_date) * 60
+			if d.completed_qty:
+				self.total_completed_qty += d.completed_qty
+
+	def get_overlap_for(self, args):
+		existing = frappe.db.sql("""select jc.name as name from
+			`tabJob Card Time Log` jctl, `tabJob Card` jc where jctl.parent = jc.name and
+			(
+				(%(from_time)s > jctl.from_time and %(from_time)s < jctl.to_time) or
+				(%(to_time)s > jctl.from_time and %(to_time)s < jctl.to_time) or
+				(%(from_time)s <= jctl.from_time and %(to_time)s >= jctl.to_time))
+			and jctl.name!=%(name)s
+			and jc.name!=%(parent)s
+			and jc.docstatus < 2
+			and jc.employee = %(employee)s """,
+			{
+				"from_time": args.from_time,
+				"to_time": args.to_time,
+				"name": args.name or "No Name",
+				"parent": args.parent or "No Name",
+				"employee": self.employee
+			}, as_dict=True)
+
+		return existing[0] if existing else None
 
 	def get_required_items(self):
 		if not self.get('work_order'):
 			return
 
 		doc = frappe.get_doc('Work Order', self.get('work_order'))
-		if doc.transfer_material_against == 'Work Order' and doc.skip_transfer:
+		if doc.transfer_material_against == 'Work Order' or doc.skip_transfer:
 			return
 
 		for d in doc.required_items:
@@ -67,36 +79,51 @@
 				})
 
 	def on_submit(self):
-		self.validate_dates()
+		self.validate_job_card()
 		self.update_work_order()
 		self.set_transferred_qty()
 
-	def validate_dates(self):
-		if not self.actual_start_date and not self.actual_end_date:
-			frappe.throw(_("Actual start date and actual end date is mandatory"))
-
 	def on_cancel(self):
 		self.update_work_order()
 		self.set_transferred_qty()
 
+	def validate_job_card(self):
+		if not self.time_logs:
+			frappe.throw(_("Time logs are required for job card {0}").format(self.name))
+
+		if self.total_completed_qty <= 0.0:
+			frappe.throw(_("Total completed qty must be greater than zero"))
+
+		if self.total_completed_qty > self.for_quantity:
+			frappe.throw(_("Total completed qty can not be greater than for quantity"))
+
 	def update_work_order(self):
 		if not self.work_order:
 			return
 
-		data = frappe.db.get_value("Job Card", {'docstatus': 1, 'operation_id': self.operation_id},
-			['sum(time_in_mins)', 'min(actual_start_date)', 'max(actual_end_date)', 'sum(for_quantity)'])
+		for_quantity, time_in_mins = 0, 0
+		from_time_list, to_time_list = [], []
 
-		if data:
-			time_in_mins, actual_start_date, actual_end_date, for_quantity = data
 
+		for d in frappe.get_all('Job Card',
+			filters = {'docstatus': 1, 'operation_id': self.operation_id}):
+			doc = frappe.get_doc('Job Card', d.name)
+
+			for_quantity += doc.total_completed_qty
+			time_in_mins += doc.total_time_in_mins
+			for time_log in doc.time_logs:
+				from_time_list.append(time_log.from_time)
+				to_time_list.append(time_log.to_time)
+
+		if for_quantity:
 			wo = frappe.get_doc('Work Order', self.work_order)
 
 			for data in wo.operations:
 				if data.name == self.operation_id:
 					data.completed_qty = for_quantity
 					data.actual_operation_time = time_in_mins
-					data.actual_start_time = actual_start_date
-					data.actual_end_time = actual_end_date
+					data.actual_start_time = min(from_time_list)
+					data.actual_end_time = max(to_time_list)
 
 			wo.flags.ignore_validate_update_after_submit = True
 			wo.update_operation_status()
@@ -132,9 +159,11 @@
 						break
 
 				if completed:
-					job_cards = frappe.get_all('Job Card', filters = {'work_order': self.work_order, 
+					job_cards = frappe.get_all('Job Card', filters = {'work_order': self.work_order,
 						'docstatus': ('!=', 2)}, fields = 'sum(transferred_qty) as qty', group_by='operation_id')
-					qty = min([d.qty for d in job_cards])
+
+					if job_cards:
+						qty = min([d.qty for d in job_cards])
 
 			doc.db_set('material_transferred_for_manufacturing', qty)
 
@@ -147,7 +176,7 @@
 			2: "Cancelled"
 		}[self.docstatus or 0]
 
-		if self.actual_start_date:
+		if self.time_logs:
 			self.status = 'Work In Progress'
 
 		if (self.docstatus == 1 and
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/__init__.py b/erpnext/manufacturing/doctype/job_card_time_log/__init__.py
similarity index 100%
copy from erpnext/accounts/doctype/apply_rule_on_brand/__init__.py
copy to erpnext/manufacturing/doctype/job_card_time_log/__init__.py
diff --git a/erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.json b/erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.json
new file mode 100644
index 0000000..2aab71d
--- /dev/null
+++ b/erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.json
@@ -0,0 +1,208 @@
+{
+ "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2019-03-08 23:56:43.187569", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "from_time", 
+   "fieldtype": "Datetime", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "From Time", 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "to_time", 
+   "fieldtype": "Datetime", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "To Time", 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "column_break_2", 
+   "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "time_in_mins", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Time In Mins", 
+   "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, 
+   "default": "0", 
+   "fetch_if_empty": 0, 
+   "fieldname": "completed_qty", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Completed Qty", 
+   "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": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2019-03-10 17:08:46.504910", 
+ "modified_by": "Administrator", 
+ "module": "Manufacturing", 
+ "name": "Job Card Time Log", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "ASC", 
+ "track_changes": 1, 
+ "track_seen": 0, 
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py b/erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.py
similarity index 82%
copy from erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py
copy to erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.py
index 2f7a29e..3dc6689 100644
--- a/erpnext/accounts/doctype/apply_rule_on_brand/apply_rule_on_brand.py
+++ b/erpnext/manufacturing/doctype/job_card_time_log/job_card_time_log.py
@@ -3,8 +3,7 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
 from frappe.model.document import Document
 
-class ApplyRuleOnBrand(Document):
+class JobCardTimeLog(Document):
 	pass
diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py
index 69381c5..d710e57 100644
--- a/erpnext/manufacturing/doctype/work_order/test_work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py
@@ -302,6 +302,19 @@
 		self.assertEqual(len(ste.additional_costs), 1)
 		self.assertEqual(ste.total_additional_costs, 1000)
 
+	def test_job_card(self):
+		data = frappe.get_cached_value('BOM',
+			{'docstatus': 1, 'with_operations': 1, 'company': '_Test Company'}, ['name', 'item'])
+
+		if data:
+			bom, bom_item = data
+
+			bom_doc = frappe.get_doc('BOM', bom)
+			work_order = make_wo_order_test_record(item=bom_item, qty=1, bom_no=bom)
+
+			job_cards = frappe.get_all('Job Card', filters = {'work_order': work_order.name})
+			self.assertEqual(len(job_cards), len(bom_doc.operations))
+
 	def test_work_order_with_non_transfer_item(self):
 		items = {'Finished Good Transfer Item': 1, '_Test FG Item': 1, '_Test FG Item 1': 0}
 		for item, allow_transfer in items.items():
@@ -346,7 +359,7 @@
 
 	wo_order = frappe.new_doc("Work Order")
 	wo_order.production_item = args.production_item or args.item or args.item_code or "_Test FG Item"
-	wo_order.bom_no = frappe.db.get_value("BOM", {"item": wo_order.production_item,
+	wo_order.bom_no = args.bom_no or frappe.db.get_value("BOM", {"item": wo_order.production_item,
 		"is_active": 1, "is_default": 1})
 	wo_order.qty = args.qty or 10
 	wo_order.wip_warehouse = args.wip_warehouse or "_Test Warehouse - _TC"
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index 8a8a6c9..8ce6154 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -303,8 +303,9 @@
 						frm.set_value('sales_order', "");
 						frm.trigger('set_sales_order');
 						erpnext.in_production_item_onchange = true;
-						$.each(["description", "stock_uom", "project", "bom_no",
-							"allow_alternative_item", "transfer_material_against"], function(i, field) {
+
+						$.each(["description", "stock_uom", "project", "bom_no", "allow_alternative_item",
+							"transfer_material_against", "item_name"], function(i, field) {
 							frm.set_value(field, r.message[field]);
 						});
 
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.json b/erpnext/manufacturing/doctype/work_order/work_order.json
index a65d04f..f22697f 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.json
+++ b/erpnext/manufacturing/doctype/work_order/work_order.json
@@ -1,1732 +1,1765 @@
 {
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 1,
- "allow_rename": 0,
- "autoname": "naming_series:",
- "beta": 0,
- "creation": "2013-01-10 16:34:16",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Setup",
- "editable_grid": 0,
+ "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 1, 
+ "allow_rename": 0, 
+ "autoname": "naming_series:", 
+ "beta": 0, 
+ "creation": "2013-01-10 16:34:16", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Setup", 
+ "editable_grid": 0, 
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "item",
-   "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": "",
-   "length": 0,
-   "no_copy": 0,
-   "options": "fa fa-gift",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "item", 
+   "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": "", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "fa fa-gift", 
+   "permlevel": 0, 
+   "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,
-   "default": "",
-   "fieldname": "naming_series",
-   "fieldtype": "Select",
-   "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": "Series",
-   "length": 0,
-   "no_copy": 0,
-   "options": "MFG-WO-.YYYY.-",
-   "permlevel": 0,
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "fieldname": "naming_series", 
+   "fieldtype": "Select", 
+   "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": "Series", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "MFG-WO-.YYYY.-", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 1, 
+   "translatable": 0, 
    "unique": 0
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "Draft",
-   "depends_on": "eval:!doc.__islocal",
-   "fieldname": "status",
-   "fieldtype": "Select",
-   "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": "Status",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "status",
-   "oldfieldtype": "Select",
-   "options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nStopped\nCancelled",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Draft", 
+   "depends_on": "eval:!doc.__islocal", 
+   "fieldname": "status", 
+   "fieldtype": "Select", 
+   "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": "Status", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "status", 
+   "oldfieldtype": "Select", 
+   "options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nStopped\nCancelled", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 1, 
+   "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": "production_item",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 1,
-   "in_list_view": 1,
-   "in_standard_filter": 1,
-   "label": "Item To Manufacture",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "production_item",
-   "oldfieldtype": "Link",
-   "options": "Item",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "production_item", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 1, 
+   "in_list_view": 1, 
+   "in_standard_filter": 1, 
+   "label": "Item To Manufacture", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "production_item", 
+   "oldfieldtype": "Link", 
+   "options": "Item", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "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,
-   "depends_on": "",
-   "description": "",
-   "fieldname": "bom_no",
-   "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": "BOM No",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "bom_no",
-   "oldfieldtype": "Link",
-   "options": "BOM",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:doc.production_item", 
+   "fieldname": "item_name", 
+   "fieldtype": "Data", 
+   "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": "Item Name", 
+   "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": "allow_alternative_item",
-   "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": "Allow Alternative Item",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "description": "", 
+   "fieldname": "bom_no", 
+   "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": "BOM No", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "bom_no", 
+   "oldfieldtype": "Link", 
+   "options": "BOM", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "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,
-   "default": "1",
-   "description": "Plan material for sub-assemblies",
-   "fieldname": "use_multi_level_bom",
-   "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": "Use Multi-Level BOM",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "print_hide": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "allow_alternative_item", 
+   "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": "Allow Alternative Item", 
+   "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,
-   "description": "Check if material transfer entry is not required",
-   "fieldname": "skip_transfer",
-   "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": "Skip Material Transfer",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "1", 
+   "description": "Plan material for sub-assemblies", 
+   "fieldname": "use_multi_level_bom", 
+   "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": "Use Multi-Level BOM", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "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_break1",
-   "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,
-   "oldfieldtype": "Column Break",
-   "permlevel": 0,
-   "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, 
+   "description": "Check if material transfer entry is not required", 
+   "fieldname": "skip_transfer", 
+   "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": "Skip Material Transfer", 
+   "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_break1", 
+   "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, 
+   "oldfieldtype": "Column Break", 
+   "permlevel": 0, 
+   "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, 
    "width": "50%"
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "company",
-   "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": "Company",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "company",
-   "oldfieldtype": "Link",
-   "options": "Company",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 1,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "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": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "company", 
+   "oldfieldtype": "Link", 
+   "options": "Company", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 1, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "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,
-   "depends_on": "",
-   "fieldname": "qty",
-   "fieldtype": "Float",
-   "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": "Qty To Manufacture",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "qty",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "qty", 
+   "fieldtype": "Float", 
+   "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": "Qty To Manufacture", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "qty", 
+   "oldfieldtype": "Currency", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "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,
-   "default": "0",
-   "depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0",
-   "description": "",
-   "fieldname": "material_transferred_for_manufacturing",
-   "fieldtype": "Float",
-   "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": "Material Transferred for Manufacturing",
-   "length": 0,
-   "no_copy": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0", 
+   "description": "", 
+   "fieldname": "material_transferred_for_manufacturing", 
+   "fieldtype": "Float", 
+   "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": "Material Transferred for Manufacturing", 
+   "length": 0, 
+   "no_copy": 1, 
+   "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,
-   "default": "0",
-   "depends_on": "eval:doc.docstatus==1",
-   "description": "",
-   "fieldname": "produced_qty",
-   "fieldtype": "Float",
-   "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": "Manufactured Qty",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "produced_qty",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "depends_on": "eval:doc.docstatus==1", 
+   "description": "", 
+   "fieldname": "produced_qty", 
+   "fieldtype": "Float", 
+   "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": "Manufactured Qty", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "produced_qty", 
+   "oldfieldtype": "Currency", 
+   "permlevel": 0, 
+   "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": 1,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "",
-   "fieldname": "sales_order",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 1,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Sales Order",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Sales Order",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "", 
+   "fieldname": "sales_order", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 1, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Sales Order", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Sales Order", 
+   "permlevel": 0, 
+   "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": "project",
-   "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": "Project",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "project",
-   "oldfieldtype": "Link",
-   "options": "Project",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "project", 
+   "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": "Project", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "project", 
+   "oldfieldtype": "Link", 
+   "options": "Project", 
+   "permlevel": 0, 
+   "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,
-   "depends_on": "skip_transfer",
-   "fieldname": "from_wip_warehouse",
-   "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": "Backflush raw materials from work-in-progress warehouse",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "skip_transfer", 
+   "fieldname": "from_wip_warehouse", 
+   "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": "Backflush raw materials from work-in-progress warehouse", 
+   "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": "warehouses",
-   "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": "Warehouses",
-   "length": 0,
-   "no_copy": 0,
-   "options": "fa fa-building",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warehouses", 
+   "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": "Warehouses", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "fa fa-building", 
+   "permlevel": 0, 
+   "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": "wip_warehouse",
-   "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": "Work-in-Progress Warehouse",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Warehouse",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "wip_warehouse", 
+   "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": "Work-in-Progress Warehouse", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Warehouse", 
+   "permlevel": 0, 
+   "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,
-   "depends_on": "",
-   "description": "",
-   "fieldname": "fg_warehouse",
-   "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": "Target Warehouse",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Warehouse",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "description": "", 
+   "fieldname": "fg_warehouse", 
+   "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": "Target Warehouse", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Warehouse", 
+   "permlevel": 0, 
+   "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,
-   "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,
+   "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, 
+   "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": "scrap_warehouse",
-   "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": "Scrap Warehouse",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Warehouse",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "scrap_warehouse", 
+   "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": "Scrap Warehouse", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Warehouse", 
+   "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": "required_items_section",
-   "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": "Required Items",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "required_items_section", 
+   "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": "Required Items", 
+   "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": "required_items",
-   "fieldtype": "Table",
-   "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": "Required Items",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Work Order Item",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "required_items", 
+   "fieldtype": "Table", 
+   "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": "Required Items", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Work Order Item", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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": "time",
-   "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": "Time",
-   "length": 0,
-   "no_copy": 0,
-   "options": "fa fa-time",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "time", 
+   "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": "Time", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "fa fa-time", 
+   "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": 1,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "now",
-   "fieldname": "planned_start_date",
-   "fieldtype": "Datetime",
-   "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": "Planned Start 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": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "now", 
+   "fieldname": "planned_start_date", 
+   "fieldtype": "Datetime", 
+   "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": "Planned Start 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": 1, 
+   "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": "actual_start_date",
-   "fieldtype": "Datetime",
-   "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": "Actual Start Date",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "actual_start_date", 
+   "fieldtype": "Datetime", 
+   "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": "Actual Start Date", 
+   "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": "column_break_13",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_13", 
+   "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": "planned_end_date",
-   "fieldtype": "Datetime",
-   "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": "Planned End Date",
-   "length": 0,
-   "no_copy": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "planned_end_date", 
+   "fieldtype": "Datetime", 
+   "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": "Planned End Date", 
+   "length": 0, 
+   "no_copy": 1, 
+   "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": "actual_end_date",
-   "fieldtype": "Datetime",
-   "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": "Actual End Date",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "actual_end_date", 
+   "fieldtype": "Datetime", 
+   "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": "Actual End Date", 
+   "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": 1,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "",
-   "fieldname": "expected_delivery_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": "Expected Delivery Date",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "expected_delivery_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": "Expected Delivery Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "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,
-   "depends_on": "",
-   "fieldname": "operations_section",
-   "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": "Operations",
-   "length": 0,
-   "no_copy": 0,
-   "options": "fa fa-wrench",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "operations_section", 
+   "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": "Operations", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "fa fa-wrench", 
+   "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,
-   "default": "Work Order",
-   "depends_on": "operations",
-   "fieldname": "transfer_material_against",
-   "fieldtype": "Select",
-   "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": "Transfer Material Against",
-   "length": 0,
-   "no_copy": 0,
-   "options": "\nWork Order\nJob Card",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Work Order", 
+   "depends_on": "operations", 
+   "fieldname": "transfer_material_against", 
+   "fieldtype": "Select", 
+   "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": "Transfer Material Against", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nWork Order\nJob Card", 
+   "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,
-   "depends_on": "",
-   "fieldname": "operations",
-   "fieldtype": "Table",
-   "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": "Operations",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Work Order Operation",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "operations", 
+   "fieldtype": "Table", 
+   "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": "Operations", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Work Order Operation", 
+   "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,
-   "depends_on": "operations",
-   "fieldname": "section_break_22",
-   "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": "Operation Cost",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "operations", 
+   "fieldname": "section_break_22", 
+   "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": "Operation Cost", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "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": "planned_operating_cost",
-   "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": "Planned Operating Cost",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Company:company:default_currency",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "planned_operating_cost", 
+   "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": "Planned Operating Cost", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
+   "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": "actual_operating_cost",
-   "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": "Actual Operating Cost",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Company:company:default_currency",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "actual_operating_cost", 
+   "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": "Actual Operating Cost", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Company:company:default_currency", 
+   "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": "additional_operating_cost",
-   "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": "Additional Operating Cost",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Company:company:default_currency",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "additional_operating_cost", 
+   "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": "Additional Operating Cost", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Company:company:default_currency", 
+   "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_24",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_24", 
+   "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": "total_operating_cost",
-   "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 Operating Cost",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Company:company:default_currency",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "total_operating_cost", 
+   "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 Operating Cost", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Company:company:default_currency", 
+   "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": 1,
-   "columns": 0,
-   "fieldname": "more_info",
-   "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": "More Information",
-   "length": 0,
-   "no_copy": 0,
-   "options": "fa fa-file-text",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "more_info", 
+   "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": "More Information", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "fa fa-file-text", 
+   "permlevel": 0, 
+   "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": "description",
-   "fieldtype": "Small Text",
-   "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": "Item Description",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Small Text", 
+   "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": "Item Description", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "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,
-   "depends_on": "",
-   "fieldname": "stock_uom",
-   "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": "Stock UOM",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "stock_uom",
-   "oldfieldtype": "Data",
-   "options": "UOM",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "stock_uom", 
+   "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": "Stock UOM", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "stock_uom", 
+   "oldfieldtype": "Data", 
+   "options": "UOM", 
+   "permlevel": 0, 
+   "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": "column_break2",
-   "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,
-   "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_break2", 
+   "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, 
+   "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, 
    "width": "50%"
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "Manufacture against Material Request",
-   "fieldname": "material_request",
-   "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": "Material Request",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Material Request",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Manufacture against Material Request", 
+   "fieldname": "material_request", 
+   "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": "Material Request", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Material Request", 
+   "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": "material_request_item",
-   "fieldtype": "Data",
-   "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Material Request Item",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "material_request_item", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Material Request Item", 
+   "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": "sales_order_item",
-   "fieldtype": "Data",
-   "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Sales Order Item",
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "sales_order_item", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Sales Order Item", 
+   "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": "production_plan",
-   "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": "Production Plan",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Production Plan",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "production_plan", 
+   "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": "Production Plan", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Production Plan", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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": "production_plan_item",
-   "fieldtype": "Data",
-   "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": "Production Plan Item",
-   "length": 0,
-   "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "production_plan_item", 
+   "fieldtype": "Data", 
+   "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": "Production Plan Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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": "product_bundle_item",
-   "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": "Product Bundle Item",
-   "length": 0,
-   "no_copy": 1,
-   "options": "Item",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "product_bundle_item", 
+   "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": "Product Bundle Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Item", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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": "amended_from",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Amended From",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "amended_from",
-   "oldfieldtype": "Data",
-   "options": "Work Order",
-   "permlevel": 0,
-   "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,
+   "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, 
+   "ignore_user_permissions": 1, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Amended From", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "amended_from", 
+   "oldfieldtype": "Data", 
+   "options": "Work Order", 
+   "permlevel": 0, 
+   "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
   }
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "fa fa-cogs",
- "idx": 1,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 1,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-12-13 15:33:12.490710",
- "modified_by": "Administrator",
- "module": "Manufacturing",
- "name": "Work Order",
- "owner": "Administrator",
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "icon": "fa fa-cogs", 
+ "idx": 1, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 1, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2019-02-05 03:02:39.126868", 
+ "modified_by": "Administrator", 
+ "module": "Manufacturing", 
+ "name": "Work Order", 
+ "owner": "Administrator", 
  "permissions": [
   {
-   "amend": 1,
-   "cancel": 1,
-   "create": 1,
-   "delete": 1,
-   "email": 1,
-   "export": 1,
-   "if_owner": 0,
-   "import": 1,
-   "permlevel": 0,
-   "print": 1,
-   "read": 1,
-   "report": 1,
-   "role": "Manufacturing User",
-   "set_user_permissions": 1,
-   "share": 1,
-   "submit": 1,
+   "amend": 1, 
+   "cancel": 1, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 1, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Manufacturing User", 
+   "set_user_permissions": 1, 
+   "share": 1, 
+   "submit": 1, 
    "write": 1
-  },
+  }, 
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
-   "email": 0,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 0,
-   "read": 1,
-   "report": 1,
-   "role": "Stock User",
-   "set_user_permissions": 0,
-   "share": 0,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 0, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 0, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Stock User", 
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
    "write": 0
   }
- ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_order": "ASC",
- "title_field": "production_item",
- "track_changes": 1,
- "track_seen": 1,
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_order": "ASC", 
+ "title_field": "production_item", 
+ "track_changes": 1, 
+ "track_seen": 1, 
  "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 947d693..59a88d4 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -568,11 +568,10 @@
 			frappe.throw(_("Default BOM for {0} not found").format(item))
 
 	bom_data = frappe.db.get_value('BOM', res['bom_no'],
-		['project', 'allow_alternative_item', 'transfer_material_against'], as_dict=1)
+		['project', 'allow_alternative_item', 'transfer_material_against', 'item_name'], as_dict=1)
 
-	res['project'] = project or bom_data.project
-	res['allow_alternative_item'] = bom_data.allow_alternative_item
-	res['transfer_material_against'] = bom_data.transfer_material_against
+	res['project'] = project or bom_data.pop("project")
+	res.update(bom_data)
 	res.update(check_if_scrap_warehouse_mandatory(res["bom_no"]))
 
 	return res
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 9017fe8..f082dd1 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -583,7 +583,12 @@
 erpnext.patches.v11_0.add_permissions_in_gst_settings
 erpnext.patches.v11_1.setup_guardian_role
 execute:frappe.delete_doc('DocType', 'Notification Control')
+erpnext.patches.v12_0.set_gst_category
 erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants
 erpnext.patches.v12_0.set_task_status
 erpnext.patches.v11_0.make_italian_localization_fields # 01-03-2019
-erpnext.patches.v12_0.update_pricing_rule_fields
\ No newline at end of file
+erpnext.patches.v12_0.add_item_name_in_work_orders
+erpnext.patches.v12_0.update_pricing_rule_fields
+erpnext.patches.v11_1.make_job_card_time_logs
+erpnext.patches.v12_0.rename_pricing_rule_child_doctypes
+erpnext.patches.v12_0.move_target_distribution_from_parent_to_child #wmnfb
diff --git a/erpnext/patches/v11_1/make_job_card_time_logs.py b/erpnext/patches/v11_1/make_job_card_time_logs.py
new file mode 100644
index 0000000..6e708df
--- /dev/null
+++ b/erpnext/patches/v11_1/make_job_card_time_logs.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+    frappe.reload_doc('manufacturing', 'doctype', 'job_card_time_log')
+
+    if (frappe.db.table_exists("Job Card")
+        and frappe.get_meta("Job Card").has_field("actual_start_date")):
+        time_logs = []
+        for d in frappe.get_all('Job Card',
+            fields = ["actual_start_date", "actual_end_date", "time_in_mins", "name", "for_quantity"],
+            filters = {'docstatus': ("<", 2)}):
+            if d.actual_start_date:
+                time_logs.append([d.actual_start_date, d.actual_end_date, d.time_in_mins,
+                    d.for_quantity, d.name, 'Job Card', 'time_logs', frappe.generate_hash("", 10)])
+
+        if time_logs:
+            frappe.db.sql(""" INSERT INTO
+                `tabJob Card Time Log`
+                    (from_time, to_time, time_in_mins, completed_qty, parent, parenttype, parentfield, name)
+                values {values}
+            """.format(values = ','.join(['%s'] * len(time_logs))), tuple(time_logs))
+
+        frappe.reload_doc('manufacturing', 'doctype', 'job_card')
+        frappe.db.sql(""" update `tabJob Card` set total_completed_qty = for_quantity,
+            total_time_in_mins = time_in_mins where docstatus < 2 """)
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/add_item_name_in_work_orders.py b/erpnext/patches/v12_0/add_item_name_in_work_orders.py
new file mode 100644
index 0000000..485dd31
--- /dev/null
+++ b/erpnext/patches/v12_0/add_item_name_in_work_orders.py
@@ -0,0 +1,14 @@
+import frappe
+
+
+def execute():
+	frappe.reload_doc("manufacturing", "doctype", "work_order")
+
+	frappe.db.sql("""
+		UPDATE
+			`tabWork Order` wo
+				JOIN `tabItem` item ON wo.production_item = item.item_code
+		SET
+			wo.item_name = item.item_name
+	""")
+	frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/move_target_distribution_from_parent_to_child.py b/erpnext/patches/v12_0/move_target_distribution_from_parent_to_child.py
new file mode 100644
index 0000000..548c1a4
--- /dev/null
+++ b/erpnext/patches/v12_0/move_target_distribution_from_parent_to_child.py
@@ -0,0 +1,22 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+    frappe.reload_doc("setup", "doctype", "target_detail")
+
+    for d in ['Sales Person', 'Sales Partner', 'Territory']:
+        frappe.db.sql("""
+            UPDATE `tab{child_doc}`, `tab{parent_doc}`
+            SET
+                `tab{child_doc}`.distribution_id = `tab{parent_doc}`.distribution_id
+            WHERE
+                `tab{child_doc}`.parent = `tab{parent_doc}`.name
+                and `tab{parent_doc}`.distribution_id is not null and `tab{parent_doc}`.distribution_id != ''
+        """.format(parent_doc = d, child_doc = "Target Detail"))
+
+    frappe.delete_doc("Report", "Sales Partner-wise Transaction Summary")
+    frappe.delete_doc("Report", "Sales Person Target Variance Item Group-Wise")
+    frappe.delete_doc("Report", "Territory Target Variance Item Group-Wise")
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/rename_pricing_rule_child_doctypes.py b/erpnext/patches/v12_0/rename_pricing_rule_child_doctypes.py
new file mode 100644
index 0000000..41ac8cf
--- /dev/null
+++ b/erpnext/patches/v12_0/rename_pricing_rule_child_doctypes.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.rename_doc import rename_doc
+
+doctypes = {
+    'Price Discount Slab': 'Promotional Scheme Price Discount',
+    'Product Discount Slab': 'Promotional Scheme Product Discount',
+    'Apply Rule On Item Code': 'Pricing Rule Item Code',
+    'Apply Rule On Item Group': 'Pricing Rule Item Group',
+    'Apply Rule On Brand': 'Pricing Rule Brand'
+}
+
+def execute():
+    for old_doc, new_doc in doctypes.items():
+        if not frappe.db.table_exists(new_doc) and frappe.db.table_exists(old_doc):
+            rename_doc('DocType', old_doc, new_doc)
+            frappe.reload_doc("accounts", "doctype", frappe.scrub(new_doc))
+            frappe.delete_doc("DocType", old_doc)
diff --git a/erpnext/patches/v12_0/set_gst_category.py b/erpnext/patches/v12_0/set_gst_category.py
new file mode 100644
index 0000000..54bc5b3
--- /dev/null
+++ b/erpnext/patches/v12_0/set_gst_category.py
@@ -0,0 +1,50 @@
+import frappe
+from erpnext.regional.india.setup import make_custom_fields
+
+def execute():
+
+	company = frappe.get_all('Company', filters = {'country': 'India'})
+	if not company:
+		return
+
+	make_custom_fields()
+
+	for doctype in ['Sales Invoice', 'Purchase Invoice']:
+		has_column = frappe.db.has_column(doctype,'invoice_type')
+
+		if has_column:
+			update_map = {
+				'Regular': 'Registered Regular',
+				'Export': 'Overseas',
+				'SEZ': 'SEZ',
+				'Deemed Export': 'Deemed Export',
+			}
+
+			for old, new in update_map.items():
+				frappe.db.sql("UPDATE `tab{doctype}` SET gst_category = %s where invoice_type = %s".format(doctype=doctype), (new, old)) #nosec
+
+	frappe.delete_doc('Custom Field', 'Sales Invoice-invoice_type')
+	frappe.delete_doc('Custom Field', 'Purchase Invoice-invoice_type')
+
+	itc_update_map = {
+		"ineligible": "Ineligible",
+		"input service": "Input Service Distributor",
+		"capital goods": "Import Of Capital Goods",
+		"input": "All Other ITC"
+	}
+
+	has_gst_fields = frappe.db.has_column('Purchase Invoice','eligibility_for_itc')
+
+	if has_gst_fields:
+		for old, new in itc_update_map.items():
+			frappe.db.sql("UPDATE `tabPurchase Invoice` SET eligibility_for_itc = %s where eligibility_for_itc = %s ", (new, old))
+
+	for doctype in ["Customer", "Supplier"]:
+
+		frappe.db.sql(""" UPDATE `tab{doctype}` t1, `tabAddress` t2, `tabDynamic Link` t3 SET t1.gst_category = "Registered Regular"
+			where t3.link_name = t1.name and t3.parent = t2.name and t2.gstin IS NOT NULL and t2.gstin != '' """.format(doctype=doctype)) #nosec
+
+		frappe.db.sql(""" UPDATE `tab{doctype}` t1, `tabAddress` t2, `tabDynamic Link` t3 SET t1.gst_category = "Overseas"
+			where t3.link_name = t1.name and t3.parent = t2.name and t2.country != 'India' """.format(doctype=doctype)) #nosec
+
+
diff --git a/erpnext/patches/v12_0/update_pricing_rule_fields.py b/erpnext/patches/v12_0/update_pricing_rule_fields.py
index 26bb693..8f8349e 100644
--- a/erpnext/patches/v12_0/update_pricing_rule_fields.py
+++ b/erpnext/patches/v12_0/update_pricing_rule_fields.py
@@ -29,7 +29,7 @@
         child_doctype = doctype + ' Item'
 
         frappe.db.sql(""" UPDATE `tab{child_doctype}` SET pricing_rules = pricing_rule
-            WHERE docstatus < 2 and pricing_rule is not null and pricing_rule != '' 
+            WHERE docstatus < 2 and pricing_rule is not null and pricing_rule != ''
         """.format(child_doctype= child_doctype))
 
         data = frappe.db.sql(""" SELECT pricing_rule, name, parent,
@@ -43,15 +43,15 @@
                 d.creation, d.modified, d.docstatus, d.modified_by, d.owner, frappe.generate_hash("", 10)))
 
         if values:
-            frappe.db.sql(""" INSERT INTO 
-                `tabPricing Rule Detail` (`pricing_rule`, `child_docname`, `parent`, `parentfield`, `parenttype`, 
+            frappe.db.sql(""" INSERT INTO
+                `tabPricing Rule Detail` (`pricing_rule`, `child_docname`, `parent`, `parentfield`, `parenttype`,
                 `creation`, `modified`, `docstatus`, `modified_by`, `owner`, `name`)
             VALUES {values} """.format(values=', '.join(['%s'] * len(values))), tuple(values))
 
     frappe.reload_doc('accounts', 'doctype', 'pricing_rule')
 
-    for doctype, apply_on in {'Apply Rule On Item Code': 'Item Code',
-        'Apply Rule On Item Group': 'Item Group', 'Apply Rule On Brand': 'Brand'}.items():
+    for doctype, apply_on in {'Pricing Rule Item Code': 'Item Code',
+        'Pricing Rule Item Group': 'Item Group', 'Pricing Rule Brand': 'Brand'}.items():
         frappe.reload_doc('accounts', 'doctype', frappe.scrub(doctype))
 
         field = frappe.scrub(apply_on)
@@ -64,8 +64,8 @@
                 d.creation, d.modified, d.owner, d.modified_by, frappe.generate_hash("", 10)))
 
         if values:
-            frappe.db.sql(""" INSERT INTO 
+            frappe.db.sql(""" INSERT INTO
                 `tab{doctype}` ({field}, parent, parentfield, parenttype, creation, modified,
                     owner, modified_by, name)
-            VALUES {values} """.format(doctype=doctype, 
-                field=field, values=', '.join(['%s'] * len(values))), tuple(values), debug=1)
\ No newline at end of file
+            VALUES {values} """.format(doctype=doctype,
+                field=field, values=', '.join(['%s'] * len(values))), tuple(values))
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/repost_future_gle_for_purchase_invoice.py b/erpnext/patches/v7_0/repost_future_gle_for_purchase_invoice.py
index 22f9db6..9e21fb6 100644
--- a/erpnext/patches/v7_0/repost_future_gle_for_purchase_invoice.py
+++ b/erpnext/patches/v7_0/repost_future_gle_for_purchase_invoice.py
@@ -10,14 +10,15 @@
 def execute():
 	company_list = frappe.db.sql_list("""Select name from tabCompany where enable_perpetual_inventory = 1""")
 	frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
-	
-	frappe.reload_doctype("Purchase Invoice")	
+
+	frappe.reload_doctype("Purchase Invoice")
 	wh_account = get_warehouse_account_map()
-	
+
 	for pi in frappe.get_all("Purchase Invoice", fields=["name", "company"], filters={"docstatus": 1, "update_stock": 1}):
 		if pi.company in company_list:
 			pi_doc = frappe.get_doc("Purchase Invoice", pi.name)
 			items, warehouses = pi_doc.get_items_and_warehouses()
-			update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account)
-		
+			update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time,
+				warehouses, items, wh_account, company = pi.company)
+
 			frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json
index 5ad2ab3..c29c11b 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.json
+++ b/erpnext/projects/doctype/timesheet/timesheet.json
@@ -739,7 +739,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "total_costing_amount", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -805,7 +805,7 @@
    "depends_on": "", 
    "description": "", 
    "fieldname": "total_billable_amount", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -837,7 +837,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "total_billed_amount", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -1000,7 +1000,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2019-01-30 11:28:18.518590", 
+ "modified": "2019-03-05 21:54:02.654690", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Timesheet", 
diff --git a/erpnext/public/js/conf.js b/erpnext/public/js/conf.js
index 56e6bdb..477781b 100644
--- a/erpnext/public/js/conf.js
+++ b/erpnext/public/js/conf.js
@@ -27,8 +27,6 @@
 		target="_blank">'+__('Documentation')+'</a></li>').insertBefore($help_menu);
 	$('<li><a data-link-type="forum" href="https://discuss.erpnext.com" \
 		target="_blank">'+__('User Forum')+'</a></li>').insertBefore($help_menu);
-	$('<li class="gitter-chat-link"><a href="https://gitter.im/frappe/erpnext" \
-		target="_blank">'+__('Gitter Chat')+'</a></li>').insertBefore($help_menu);
 	$('<li><a href="https://github.com/frappe/erpnext/issues" \
 		target="_blank">'+__('Report an Issue')+'</a></li>').insertBefore($help_menu);
 
diff --git a/erpnext/accounts/doctype/apply_rule_on_brand/__init__.py b/erpnext/regional/doctype/gstr_3b_report/__init__.py
similarity index 100%
copy from erpnext/accounts/doctype/apply_rule_on_brand/__init__.py
copy to erpnext/regional/doctype/gstr_3b_report/__init__.py
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html
new file mode 100644
index 0000000..4bf0de1
--- /dev/null
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html
@@ -0,0 +1,297 @@
+<style>
+	.print-format {
+		padding: 15mm;
+		font-size: 8.0pt !important;
+		font-family: Tahoma, sans-serif;
+	}
+	.disabled {
+		background-color: #d9d9d9;
+	}
+
+</style>
+<div>
+	<h3 class="text-center">{{ __("GSTR3B-Form")}}</h3>
+	<h5>{{__("GSTIN")}}: &nbsp {{ data.gstin }}</h5>
+	<h5>{{__("Period")}}: &nbsp {{ data.ret_period }}</h5>
+</div>
+
+<h5>3.1&nbsp&nbsp{{__("Details of Outward Supplies and inward supplies liable to reverse charge")}}</h5>
+<table class="table table-bordered">
+	<thead>
+		<tr>
+			<th>{{__("Nature Of Supplies")}}</th>
+			<th>{{__("Total Taxable value")}}</th>
+			<th>{{__("Integrated Tax")}}</th>
+			<th>{{__("Central Tax")}}</th>
+			<th>{{__("State/UT Tax")}}</th>
+			<th>{{__("Cess")}}</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr>
+			<td>(a) {{__("Outward taxable supplies(other than zero rated, nil rated and exempted")}}</td>
+			<td class="right">{{ flt(data.sup_details.osup_det.txval, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.osup_det.iamt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.osup_det.camt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.osup_det.samt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.osup_det.csamt, 2) }}</td>
+		</tr>
+		<tr>
+			<td>(b) {{__("Outward taxable supplies(zero rated)")}}</td>
+			<td class="right">{{ flt(data.sup_details.osup_zero.txval, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.osup_zero.iamt, 2) }}</td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+			<td class="right">{{ flt(data.sup_details.osup_zero.csamt, 2) }}</td>
+		</tr>
+		<tr>
+			<td>(b) {{__("Other outward supplies(Nil rated,Exempted)")}}</td>
+			<td class="right">{{ data.sup_details.osup_nil_exmp.txval }}</td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+		<tr>
+			<td>(d) {{__("Inward Supplies(liable to reverse charge")}}</td>
+			<td class="right">{{ flt(data.sup_details.isup_rev.txval, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.isup_rev.iamt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.isup_rev.camt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.isup_rev.samt, 2) }}</td>
+			<td class="right">{{ flt(data.sup_details.isup_rev.csamt,2) }}</td>
+		</tr>
+		<tr>
+			<td>(e) {{__("Non-GST outward supplies")}}</td>
+			<td class="right">{{ data.sup_details.osup_nongst.txval }}</td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+			<td class="disabled"></td>
+		</tr>
+	</tbody>
+</table>
+
+<h5>
+	3.2&nbsp&nbsp{{__("Of the supplies shown in 3.1 (a) above, details of inter-State supplies made to unregisterd
+	persons, composition taxable persons and UIN holders")}}
+</h5>
+<table class="table table-bordered">
+	<thead>
+		<tr>
+			<th></th>
+			<th>{{__("Place Of Supply (State/UT)")}}</th>
+			<th>{{__("Total Taxable Value")}}</th>
+			<th>{{__("Amount of Integrated Tax")}}</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr>
+			<td>{{__("Supplies made to Unregistered Persons")}}</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ row.pos }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.txval, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.iamt, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+		</tr>
+		<tr>
+			<td>{{__("Suppliies made to Composition Taxable Persons")}}</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ row.pos }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.txval, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.iamt, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+		</tr>
+		<tr>
+			<td>{{__("Supplies made to UIN holders")}}</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ row.pos }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.txval, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+			<td class="right">
+				{% for row in data.inter_sup.unreg_details %}
+					{% if row %}
+						{{ flt(row.iamt, 2) }}<br>
+					{% endif %}
+				{% endfor %}
+			</td>
+		</tr>
+	</tbody>
+</table>
+
+<h5>4. &nbsp {{__("Eligible ITC")}}</h5>
+<table class="table table-bordered">
+		<thead>
+			<tr>
+				<th>Details</th>
+				<th>Integrated Tax</th>
+				<th>Central Tax</th>
+				<th>State/UT tax</th>
+				<th>Cess</th>
+			</tr>
+		</thead>
+		<tbody>
+			<tr>
+				<td><b>(A) {{__("ITC Available (whether in full op part)")}}</b></td>
+				<td></td>
+				<td></td>
+				<td></td>
+				<td></td>
+			</tr>
+			<tr>
+				<td>&nbsp (1) {{__("Import of goods")}} </td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[0].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[0].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[0].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[0].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td>&nbsp (2) {{__("Import of services")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[1].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[1].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[1].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[1].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td>&nbsp (3) {{__("Inward supplies liable to reverse charge (other than 1 & 2 above)")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[2].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[2].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[2].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[2].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td>&nbsp (4) {{__("Inward supplies from ISD")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[3].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[3].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[3].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[3].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td>&nbsp (5) {{__("All other ITC")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[4].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[4].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[4].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_avl[4].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td><b>(B) {{__("ITC Reversed")}}</b></td>
+				<td></td>
+				<td></td>
+				<td></td>
+				<td></td>
+			</tr>
+			<tr>
+				<td>&nbsp (1) {{__("As per rules 42 & 43 of CGST Rules")}}</td>
+				<td></td>
+				<td></td>
+				<td></td>
+				<td></td>
+			</tr>
+			<tr>
+				<td>&nbsp (2) {{__("Others")}}</td>
+				<td></td>
+				<td></td>
+				<td></td>
+				<td></td>
+			</tr>
+			<tr>
+				<td><b>(C) {{__("Net ITC Available(A) - (B)")}}</b></td>
+				<td class="right">{{ flt(data.itc_elg.itc_net.iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_net.camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_net.samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_net.csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td><b>(D) {{__("Ineligible ITC")}}</b></td>
+				<td></td>
+				<td></td>
+				<td></td>
+				<td></td>
+			</tr>
+			<tr>
+				<td>&nbsp (1) {{__("As per section 17(5)")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[0].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[0].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[0].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[0].csamt, 2) }}</td>
+			</tr>
+			<tr>
+				<td>&nbsp (2) {{__("Others")}}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[1].iamt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[1].camt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[1].samt, 2) }}</td>
+				<td class="right">{{ flt(data.itc_elg.itc_inelg[1].csamt, 2) }}</td>
+			</tr>
+		</tbody>
+	</table>
+
+<h5>5. &nbsp&nbsp {{__("Values of exempt, nil rated and non-GST inward supplies")}}</h5>
+<table class="table table-bordered">
+	<thead>
+		<tr>
+			<th>{{__("Nature of Supplies")}}</th>
+			<th>{{__("Inter-State Supplies")}}</th>
+			<th>{{__("Intra-State Supplies")}}</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr>
+			<td>{{__("From a supplier under composition scheme, Exempt and Nil rated")}}</td>
+			<td class="right">{{ flt(data.inward_sup.isup_details[0].inter, 2) }}</td>
+			<td class="right">{{ flt(data.inward_sup.isup_details[0].intra, 2) }}</td>
+		</tr>
+		<tr>
+			<td>{{__("Non GST Inward Supplies")}}</td>
+			<td class="right">{{ flt(data.inward_sup.isup_details[1].inter, 2) }}</td>
+			<td class="right">{{ flt(data.inward_sup.isup_details[1].intra, 2) }}</td>
+		</tr>
+	</tbody>
+</table>
+
+<style>
+
+.right{
+	text-align: right;
+}
+
+</style>
\ No newline at end of file
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
new file mode 100644
index 0000000..0d6cef0
--- /dev/null
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
@@ -0,0 +1,59 @@
+// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('GSTR 3B Report', {
+	refresh : function(frm){
+		if(!frm.is_new()) {
+			frm.set_intro(__("Please save the report again to rebuild or update"));
+			frm.add_custom_button(__('Download JSON'), function() {
+				var w = window.open(
+					frappe.urllib.get_full_url(
+						"/api/method/erpnext.regional.doctype.gstr_3b_report.gstr_3b_report.make_json?"
+						+"name="+encodeURIComponent(frm.doc.name)));
+
+				if(!w) {
+					frappe.msgprint(__("Please enable pop-ups")); return;
+				}
+			});
+			frm.add_custom_button(__('View Form'), function() {
+				frappe.call({
+					"method" : "erpnext.regional.doctype.gstr_3b_report.gstr_3b_report.view_report",
+					"args" : {
+						name : frm.doc.name,
+					},
+					"callback" : function(r){
+
+						let data = r.message;
+
+						frappe.ui.get_print_settings(false, print_settings => {
+
+							frappe.render_grid({
+								template: 'gstr_3b_report',
+								title: __(this.doctype),
+								print_settings: print_settings,
+								data: data,
+								columns:[]
+							});
+						});
+					}
+				});
+			});
+		}
+	},
+
+	setup: function(frm){
+		frm.set_query('company_address', function(doc) {
+			if(!doc.company) {
+				frappe.throw(__('Please set Company'));
+			}
+
+			return {
+				query: 'frappe.contacts.doctype.address.address.address_query',
+				filters: {
+					link_doctype: 'Company',
+					link_name: doc.company
+				}
+			};
+		});
+	},
+});
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.json b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.json
new file mode 100644
index 0000000..7b0462f
--- /dev/null
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.json
@@ -0,0 +1,259 @@
+{
+ "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "format:GSTR3B-{month}-{year}-{company_address}", 
+ "beta": 0, 
+ "creation": "2019-02-04 11:35:55.964639", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "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": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Company", 
+   "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": "company_address", 
+   "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": "Company Address", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Address", 
+   "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": "year", 
+   "fieldtype": "Data", 
+   "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": "Year", 
+   "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": "month", 
+   "fieldtype": "Select", 
+   "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": "Month", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "January\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember", 
+   "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": "json_output", 
+   "fieldtype": "Code", 
+   "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": "JSON Output", 
+   "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": "missing_field_invoices", 
+   "fieldtype": "Small Text", 
+   "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": "Invoices with no Place Of Supply", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2019-03-04 10:04:44.767655", 
+ "modified_by": "Administrator", 
+ "module": "Regional", 
+ "name": "GSTR 3B Report", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0, 
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
new file mode 100644
index 0000000..a9aa1d5
--- /dev/null
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
@@ -0,0 +1,459 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+import json
+from six import iteritems
+from frappe.utils import flt, getdate
+from erpnext.regional.india import state_numbers
+
+class GSTR3BReport(Document):
+	def before_save(self):
+
+		self.get_data()
+
+	def get_data(self):
+
+		self.report_dict = {
+			"gstin": "",
+			"ret_period": "",
+			"inward_sup": {
+				"isup_details": [
+					{
+						"ty": "GST",
+						"intra": 0,
+						"inter": 0
+					},
+					{
+						"ty": "NONGST",
+						"inter": 0,
+						"intra": 0
+					}
+				]
+			},
+			"sup_details": {
+				"osup_zero": {
+					"csamt": 0,
+					"txval": 0,
+					"iamt": 0
+				},
+				"osup_nil_exmp": {
+					"txval": 0
+				},
+				"osup_det": {
+					"samt": 0,
+					"csamt": 0,
+					"txval": 0,
+					"camt": 0,
+					"iamt": 0
+				},
+				"isup_rev": {
+					"samt": 0,
+					"csamt": 0,
+					"txval": 0,
+					"camt": 0,
+					"iamt": 0
+				},
+				"osup_nongst": {
+					"txval": 0,
+				}
+			},
+			"inter_sup": {
+				"unreg_details": [],
+				"comp_details": [],
+				"uin_details": []
+			},
+			"itc_elg": {
+				"itc_avl": [
+					{
+						"csamt": 0,
+						"samt": 0,
+						"ty": "IMPG",
+						"camt": 0,
+						"iamt": 0
+					},
+					{
+						"csamt": 0,
+						"samt": 0,
+						"ty": "IMPS",
+						"camt": 0,
+						"iamt": 0
+					},
+					{
+						"samt": 0,
+						"csamt": 0,
+						"ty": "ISRC",
+						"camt": 0,
+						"iamt": 0
+					},
+					{
+						"ty": "ISD",
+						"iamt": 1,
+						"camt": 1,
+						"samt": 1,
+						"csamt": 1
+					},
+					{
+						"samt": 0,
+						"csamt": 0,
+						"ty": "OTH",
+						"camt": 0,
+						"iamt": 0
+					}
+				],
+				"itc_net": {
+					"samt": 0,
+					"csamt": 0,
+					"camt": 0,
+					"iamt": 0
+				},
+				"itc_inelg": [
+					{
+						"ty": "RUL",
+						"iamt": 0,
+						"camt": 0,
+						"samt": 0,
+						"csamt": 0
+					},
+					{
+						"ty": "OTH",
+						"iamt": 0,
+						"camt": 0,
+						"samt": 0,
+						"csamt": 0
+					}
+				]
+			}
+		}
+
+		self.gst_details = self.get_company_gst_details()
+		self.report_dict["gstin"] = self.gst_details.get("gstin")
+		self.report_dict["ret_period"] = get_period(self.month, self.year)
+		self.month_no = get_period(self.month)
+		self.account_heads = self.get_account_heads()
+
+		outward_supply_tax_amounts = self.get_tax_amounts("Sales Invoice")
+		inward_supply_tax_amounts = self.get_tax_amounts("Purchase Invoice", reverse_charge="Y")
+		itc_details = self.get_itc_details()
+		inter_state_supplies = self.get_inter_state_supplies(self.gst_details.get("gst_state"))
+		inward_nil_exempt = self.get_inward_nil_exempt(self.gst_details.get("gst_state"))
+
+		self.prepare_data("Sales Invoice", outward_supply_tax_amounts, "sup_details", "osup_det", ["Registered Regular"])
+		self.prepare_data("Sales Invoice", outward_supply_tax_amounts, "sup_details", "osup_zero", ["SEZ", "Deemed Export", "Overseas"])
+		self.prepare_data("Purchase Invoice", inward_supply_tax_amounts, "sup_details", "isup_rev", ["Registered Regular"], reverse_charge="Y")
+		self.report_dict["sup_details"]["osup_nil_exmp"]["txval"] = flt(self.get_nil_rated_supply_value(), 2)
+		self.set_itc_details(itc_details)
+		self.set_inter_state_supply(inter_state_supplies)
+		self.set_inward_nil_exempt(inward_nil_exempt)
+
+		self.missing_field_invoices = self.get_missing_field_invoices()
+
+		self.json_output = frappe.as_json(self.report_dict)
+
+	def set_inward_nil_exempt(self, inward_nil_exempt):
+
+		self.report_dict["inward_sup"]["isup_details"][0]["inter"] = flt(inward_nil_exempt.get("gst").get("inter"), 2)
+		self.report_dict["inward_sup"]["isup_details"][0]["intra"] = flt(inward_nil_exempt.get("gst").get("intra"), 2)
+		self.report_dict["inward_sup"]["isup_details"][1]["inter"] = flt(inward_nil_exempt.get("non_gst").get("inter"), 2)
+		self.report_dict["inward_sup"]["isup_details"][1]["intra"] = flt(inward_nil_exempt.get("non_gst").get("intra"), 2)
+
+	def set_itc_details(self, itc_details):
+
+		itc_type_map = {
+			'IMPG': 'Import Of Capital Goods',
+			'IMPS': 'Import Of Service',
+			'ISD': 'Input Service Distributor',
+			'OTH': 'All Other ITC'
+		}
+
+		net_itc = self.report_dict["itc_elg"]["itc_net"]
+
+		for d in self.report_dict["itc_elg"]["itc_avl"]:
+			if d["ty"] == 'ISRC':
+				reverse_charge = "Y"
+			else:
+				reverse_charge = "N"
+
+			for account_head in self.account_heads:
+
+				d["iamt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('igst_account')), {}).get("amount"), 2)
+				net_itc["iamt"] += flt(d["iamt"], 2)
+
+				d["camt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('cgst_account')), {}).get("amount"), 2)
+				net_itc["camt"] += flt(d["camt"], 2)
+
+				d["samt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('sgst_account')), {}).get("amount"), 2)
+				net_itc["samt"] += flt(d["samt"], 2)
+
+				d["csamt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('cess_account')), {}).get("amount"), 2)
+				net_itc["csamt"] += flt(d["csamt"], 2)
+
+		for account_head in self.account_heads:
+
+			self.report_dict["itc_elg"]["itc_inelg"][1]["iamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("igst_account")), {}).get("amount"), 2)
+			self.report_dict["itc_elg"]["itc_inelg"][1]["camt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cgst_account")), {}).get("amount"), 2)
+			self.report_dict["itc_elg"]["itc_inelg"][1]["samt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("sgst_account")), {}).get("amount"), 2)
+			self.report_dict["itc_elg"]["itc_inelg"][1]["csamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cess_account")), {}).get("amount"), 2)
+
+	def prepare_data(self, doctype, tax_details, supply_type, supply_category, gst_category_list, reverse_charge="N"):
+
+		account_map = {
+			'sgst_account': 'samt',
+			'cess_account': 'csamt',
+			'cgst_account': 'camt',
+			'igst_account': 'iamt'
+		}
+
+		txval = 0
+		total_taxable_value = self.get_total_taxable_value(doctype, reverse_charge)
+
+		for gst_category in gst_category_list:
+			txval += total_taxable_value.get(gst_category,0)
+			for account_head in self.account_heads:
+				for account_type, account_name in iteritems(account_head):
+					if account_map.get(account_type) in self.report_dict.get(supply_type).get(supply_category):
+						self.report_dict[supply_type][supply_category][account_map.get(account_type)] += \
+							flt(tax_details.get((account_name, gst_category), {}).get("amount"), 2)
+
+		for k, v in iteritems(account_map):
+			txval -= self.report_dict.get(supply_type, {}).get(supply_category, {}).get(v, 0)
+
+		self.report_dict[supply_type][supply_category]["txval"] = flt(txval, 2)
+
+	def set_inter_state_supply(self, inter_state_supply):
+
+		for d in inter_state_supply.get("Unregistered", []):
+			self.report_dict["inter_sup"]["unreg_details"].append(d)
+
+		for d in inter_state_supply.get("Registered Composition", []):
+			self.report_dict["inter_sup"]["comp_details"].append(d)
+
+		for d in inter_state_supply.get("UIN Holders", []):
+			self.report_dict["inter_sup"]["uin_details"].append(d)
+
+	def get_total_taxable_value(self, doctype, reverse_charge):
+
+		return frappe._dict(frappe.db.sql("""
+			select gst_category, sum(base_grand_total) as total
+			from `tab{doctype}`
+			where docstatus = 1 and month(posting_date) = %s
+			and year(posting_date) = %s and reverse_charge = %s
+			and company = %s and company_gstin = %s
+			group by gst_category
+			""" #nosec
+			.format(doctype = doctype), (self.month_no, self.year, reverse_charge, self.company, self.gst_details.get("gstin"))))
+
+	def get_itc_details(self, reverse_charge='N'):
+
+		itc_amount = frappe.db.sql("""
+			select s.gst_category, sum(t.tax_amount) as tax_amount, t.account_head, s.eligibility_for_itc, s.reverse_charge
+			from `tabPurchase Invoice` s , `tabPurchase Taxes and Charges` t
+			where s.docstatus = 1 and t.parent = s.name and s.reverse_charge = %s
+			and month(s.posting_date) = %s and year(s.posting_date) = %s and s.company = %s
+			and s.company_gstin = %s
+			group by t.account_head, s.gst_category, s.eligibility_for_itc
+			""",
+			(reverse_charge, self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
+
+		itc_details = {}
+
+		for d in itc_amount:
+			itc_details.setdefault((d.eligibility_for_itc, d.reverse_charge, d.account_head),{
+				"amount": d.tax_amount
+			})
+
+		return itc_details
+
+	def get_nil_rated_supply_value(self):
+
+		return frappe.db.sql("""
+			select sum(i.base_amount) as total from
+			`tabSales Invoice Item` i, `tabSales Invoice` s
+			where s.docstatus = 1 and i.parent = s.name and i.is_nil_exempt = 1
+			and month(s.posting_date) = %s and year(s.posting_date) = %s
+			and s.company = %s and s.company_gstin = %s""",
+			(self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)[0].total
+
+	def get_inter_state_supplies(self, state):
+
+		inter_state_supply = frappe.db.sql(""" select sum(s.grand_total) as total, t.tax_amount, a.gst_state, s.gst_category
+			from `tabSales Invoice` s, `tabSales Taxes and Charges` t, `tabAddress` a
+			where t.parent = s.name and s.customer_address = a.name and
+			s.docstatus = 1 and month(s.posting_date) = %s and year(s.posting_date) = %s and
+			a.gst_state <> %s and s.company = %s and s.company_gstin = %s and
+			s.gst_category in ('Unregistered', 'Registered Composition', 'UIN Holders')
+			group by s.gst_category, a.state""", (self.month_no, self.year, state, self.company, self.gst_details.get("gstin")), as_dict=1)
+
+		inter_state_supply_details = {}
+
+		for d in inter_state_supply:
+			inter_state_supply_details.setdefault(
+				d.gst_category, []
+			)
+
+			inter_state_supply_details[d.gst_category].append({
+				"pos": get_state_code(d.gst_state),
+				"txval": d.total,
+				"iamt": d.tax_amount
+			})
+
+		return inter_state_supply_details
+
+	def get_inward_nil_exempt(self, state):
+
+		inward_nil_exempt = frappe.db.sql(""" select a.gst_state, sum(i.base_amount) as base_amount,
+			i.is_nil_exempt, i.is_non_gst from `tabPurchase Invoice` p , `tabPurchase Invoice Item` i, `tabAddress` a
+			where p.docstatus = 1 and p.name = i.parent and p.supplier_address = a.name
+			and i.is_nil_exempt = 1 or i.is_non_gst = 1 and
+			month(p.posting_date) = %s and year(p.posting_date) = %s and p.company = %s and p.company_gstin = %s
+			group by a.gst_state """, (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
+
+		inward_nil_exempt_details = {
+			"gst": {
+				"intra": 0.0,
+				"inter": 0.0
+			},
+			"non_gst": {
+				"intra": 0.0,
+				"inter": 0.0
+			}
+		}
+
+		for d in inward_nil_exempt:
+			if d.is_nil_exempt == 1 and state == d.gst_state:
+				inward_nil_exempt_details["gst"]["intra"] += d.base_amount
+			elif d.is_nil_exempt == 1 and state != d.gst_state:
+				inward_nil_exempt_details["gst"]["inter"] += d.base_amount
+			elif d.is_non_gst == 1 and state == d.gst_state:
+				inward_nil_exempt_details["non_gst"]["inter"] += d.base_amount
+			elif d.is_non_gst == 1 and state != d.gst_state:
+				inward_nil_exempt_details["non_gst"]["intra"] += d.base_amount
+
+		return inward_nil_exempt_details
+
+	def get_tax_amounts(self, doctype, reverse_charge="N"):
+
+		if doctype == "Sales Invoice":
+			tax_template = 'Sales Taxes and Charges'
+		elif doctype == "Purchase Invoice":
+			tax_template = 'Purchase Taxes and Charges'
+
+		tax_amounts = frappe.db.sql("""
+			select s.gst_category, sum(t.tax_amount) as tax_amount, t.account_head
+			from `tab{doctype}` s , `tab{template}` t
+			where s.docstatus = 1 and t.parent = s.name and s.reverse_charge = %s
+			and month(s.posting_date) = %s and year(s.posting_date) = %s and s.company = %s
+			and s.company_gstin = %s
+			group by t.account_head, s.gst_category
+			""" #nosec
+			.format(doctype=doctype, template=tax_template),
+			(reverse_charge, self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
+
+		tax_details = {}
+
+		for d in tax_amounts:
+			tax_details.setdefault(
+				(d.account_head,d.gst_category),{
+					"amount": d.get("tax_amount"),
+				}
+			)
+
+		return tax_details
+
+	def get_company_gst_details(self):
+
+		gst_details =  frappe.get_all("Address",
+			fields=["gstin", "gst_state", "gst_state_number"],
+			filters={
+				"name":self.company_address
+			})
+
+		if gst_details:
+			return gst_details[0]
+		else:
+			frappe.throw("Please enter GSTIN and state for the Company Address {0}".format(self.company_address))
+
+	def get_account_heads(self):
+
+		account_heads =  frappe.get_all("GST Account",
+			fields=["cgst_account", "sgst_account", "igst_account", "cess_account"],
+			filters={
+				"company":self.company
+			})
+
+		if account_heads:
+			return account_heads
+		else:
+			frappe.throw("Please set account heads in GST Settings for Compnay {0}".format(self.company))
+
+	def get_missing_field_invoices(self):
+
+		missing_field_invoices = []
+
+		for doctype in ["Sales Invoice", "Purchase Invoice"]:
+
+			if doctype == "Sales Invoice":
+				party_type = 'Customer'
+				party = 'customer'
+			else:
+				party_type = 'Supplier'
+				party = 'supplier'
+
+			docnames = frappe.db.sql("""
+				select t1.name from `tab{doctype}` t1, `tab{party_type}` t2
+				where t1.docstatus = 1 and month(t1.posting_date) = %s and year(t1.posting_date) = %s
+				and t1.company = %s and t1.place_of_supply IS NULL and t1.{party} = t2.name and
+				t2.gst_category != 'Overseas'
+			""".format(doctype = doctype, party_type = party_type, party=party), (self.month_no, self.year, self.company), as_dict=1) #nosec
+
+			for d in docnames:
+				missing_field_invoices.append(d.name)
+
+		return ",".join(missing_field_invoices)
+
+def get_state_code(state):
+
+	state_code = state_numbers.get(state)
+
+	return state_code
+
+def get_period(month, year=None):
+
+	month_no = {
+		"January": 1,
+		"February": 2,
+		"March": 3,
+		"April": 4,
+		"May": 5,
+		"June": 6,
+		"July": 7,
+		"August": 8,
+		"September": 9,
+		"October": 10,
+		"November": 11,
+		"December": 12
+	}.get(month)
+
+	if year:
+		return str(month_no).zfill(2) + str(year)
+	else:
+		return month_no
+
+
+@frappe.whitelist()
+def view_report(name):
+
+	json_data = frappe.get_value("GSTR 3B Report", name, 'json_output')
+	return json.loads(json_data)
+
+@frappe.whitelist()
+def make_json(name):
+
+	json_data = frappe.get_value("GSTR 3B Report", name, 'json_output')
+	file_name = "GST3B.json"
+	frappe.local.response.filename = file_name
+	frappe.local.response.filecontent = json_data
+	frappe.local.response.type = "download"
diff --git a/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
new file mode 100644
index 0000000..2e9f536
--- /dev/null
+++ b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
@@ -0,0 +1,380 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
+from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
+from erpnext.stock.doctype.item.test_item import make_item
+import json
+
+class TestGSTR3BReport(unittest.TestCase):
+	def test_gstr_3b_report(self):
+		frappe.set_user("Administrator")
+
+		frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company GST'")
+		frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company GST'")
+
+		make_company()
+		make_item("Milk", properties = {"is_nil_exempt": 1, "standard_rate": 0.000000})
+		set_account_heads()
+		make_customers()
+		make_suppliers()
+		make_sales_invoice()
+		create_purchase_invoices()
+
+		if frappe.db.exists("GSTR 3B Report", "GSTR3B-March-2019-_Test Address-Billing"):
+			report = frappe.get_doc("GSTR 3B Report", "GSTR3B-March-2019-_Test Address-Billing")
+			report.save()
+		else:
+			report = frappe.get_doc({
+				"doctype": "GSTR 3B Report",
+				"company": "_Test Company GST",
+				"company_address": "_Test Address-Billing",
+				"year": "2019",
+				"month": "March"
+			}).insert()
+
+		output = json.loads(report.json_output)
+
+		self.assertEqual(output["sup_details"]["osup_det"]["iamt"], 18),
+		self.assertEqual(output["sup_details"]["osup_zero"]["iamt"], 18),
+		self.assertEqual(output["inter_sup"]["unreg_details"][0]["iamt"], 18),
+		self.assertEqual(output["sup_details"]["osup_nil_exmp"]["txval"], 100),
+		self.assertEqual(output["inward_sup"]["isup_details"][0]["inter"], 250)
+		self.assertEqual(output["itc_elg"]["itc_avl"][4]["iamt"], 45)
+
+def make_sales_invoice():
+	si = create_sales_invoice(company="_Test Company GST",
+			customer = '_Test GST Customer',
+			currency = 'INR',
+			warehouse = 'Finished Goods - _GST',
+			debit_to = 'Debtors - _GST',
+			income_account = 'Sales - _GST',
+			expense_account = 'Cost of Goods Sold - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			do_not_save=1
+		)
+
+	si.append("taxes", {
+			"charge_type": "On Net Total",
+			"account_head": "IGST - _GST",
+			"cost_center": "Main - _GST",
+			"description": "IGST @ 18.0",
+			"rate": 18
+		})
+
+	si.submit()
+
+	si1 = create_sales_invoice(company="_Test Company GST",
+			customer = '_Test GST SEZ Customer',
+			currency = 'INR',
+			warehouse = 'Finished Goods - _GST',
+			debit_to = 'Debtors - _GST',
+			income_account = 'Sales - _GST',
+			expense_account = 'Cost of Goods Sold - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			do_not_save=1
+		)
+
+	si1.append("taxes", {
+			"charge_type": "On Net Total",
+			"account_head": "IGST - _GST",
+			"cost_center": "Main - _GST",
+			"description": "IGST @ 18.0",
+			"rate": 18
+		})
+
+	si1.submit()
+
+	si2 = create_sales_invoice(company="_Test Company GST",
+			customer = '_Test Unregistered Customer',
+			currency = 'INR',
+			warehouse = 'Finished Goods - _GST',
+			debit_to = 'Debtors - _GST',
+			income_account = 'Sales - _GST',
+			expense_account = 'Cost of Goods Sold - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			do_not_save=1
+		)
+
+	si2.append("taxes", {
+			"charge_type": "On Net Total",
+			"account_head": "IGST - _GST",
+			"cost_center": "Main - _GST",
+			"description": "IGST @ 18.0",
+			"rate": 18
+		})
+
+	si2.submit()
+
+	si3 = create_sales_invoice(company="_Test Company GST",
+			customer = '_Test GST Customer',
+			currency = 'INR',
+			item = 'Milk',
+			warehouse = 'Finished Goods - _GST',
+			debit_to = 'Debtors - _GST',
+			income_account = 'Sales - _GST',
+			expense_account = 'Cost of Goods Sold - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			do_not_save=1
+		)
+	si3.submit()
+
+def create_purchase_invoices():
+
+	pi = make_purchase_invoice(
+			company="_Test Company GST",
+			supplier = '_Test Registered Supplier',
+			currency = 'INR',
+			warehouse = 'Finished Goods - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			do_not_save=1,
+		)
+
+	pi.eligibility_for_itc = "All Other ITC"
+
+	pi.append("taxes", {
+			"charge_type": "On Net Total",
+			"account_head": "IGST - _GST",
+			"cost_center": "Main - _GST",
+			"description": "IGST @ 18.0",
+			"rate": 18
+		})
+
+	pi.submit()
+
+	pi1 = make_purchase_invoice(
+			company="_Test Company GST",
+			supplier = '_Test Registered Supplier',
+			currency = 'INR',
+			warehouse = 'Finished Goods - _GST',
+			cost_center = 'Main - _GST',
+			posting_date = '2019-03-10',
+			item = "Milk",
+			do_not_save=1
+		)
+
+	pi1.submit()
+
+def make_suppliers():
+
+	if not frappe.db.exists("Supplier", "_Test Registered Supplier"):
+		frappe.get_doc({
+			"supplier_group": "_Test Supplier Group",
+			"supplier_name": "_Test Registered Supplier",
+			"gst_category": "Registered Regular",
+			"supplier_type": "Individual",
+			"doctype": "Supplier",
+		}).insert()
+
+	if not frappe.db.exists("Supplier", "_Test Unregistered Supplier"):
+		frappe.get_doc({
+			"supplier_group": "_Test Supplier Group",
+			"supplier_name": "_Test Unregistered Supplier",
+			"gst_category": "Unregistered",
+			"supplier_type": "Individual",
+			"doctype": "Supplier",
+		}).insert()
+
+	if not frappe.db.exists('Address', '_Test Supplier GST-1-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test Supplier GST-1",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gstin": "29AACCV0498C1Z9",
+			"gst_state": "Karnataka",
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Supplier",
+			"link_name": "_Test Registered Supplier"
+		})
+
+		address.save()
+
+	if not frappe.db.exists('Address', '_Test Supplier GST-2-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test Supplier GST-2",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gst_state": "Karnataka",
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Supplier",
+			"link_name": "_Test Unregistered Supplier"
+		})
+
+		address.save()
+
+def make_customers():
+
+	if not frappe.db.exists("Customer", "_Test GST Customer"):
+		frappe.get_doc({
+			"customer_group": "_Test Customer Group",
+			"customer_name": "_Test GST Customer",
+			"gst_category": "Registered Regular",
+			"customer_type": "Individual",
+			"doctype": "Customer",
+			"territory": "_Test Territory"
+		}).insert()
+
+	if not frappe.db.exists("Customer", "_Test GST SEZ Customer"):
+		frappe.get_doc({
+			"customer_group": "_Test Customer Group",
+			"customer_name": "_Test GST SEZ Customer",
+			"gst_category": "SEZ",
+			"customer_type": "Individual",
+			"doctype": "Customer",
+			"territory": "_Test Territory"
+		}).insert()
+
+	if not frappe.db.exists("Customer", "_Test Unregistered Customer"):
+		frappe.get_doc({
+			"customer_group": "_Test Customer Group",
+			"customer_name": "_Test Unregistered Customer",
+			"gst_category": "Unregistered",
+			"customer_type": "Individual",
+			"doctype": "Customer",
+			"territory": "_Test Territory"
+		}).insert()
+
+	if not frappe.db.exists('Address', '_Test GST-1-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test GST-1",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gstin": "29AZWPS7135H1ZG",
+			"gst_state": "Karnataka",
+			"gst_state_number": "29"
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Customer",
+			"link_name": "_Test GST Customer"
+		})
+
+		address.save()
+
+	if not frappe.db.exists('Address', '_Test GST-2-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test GST-2",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gst_state": "Haryana",
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Customer",
+			"link_name": "_Test Unregistered Customer"
+		})
+
+		address.save()
+
+	if not frappe.db.exists('Address', '_Test GST-3-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test GST-3",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gst_state": "Gujarat",
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Customer",
+			"link_name": "_Test GST SEZ Customer"
+		})
+
+		address.save()
+
+def make_company():
+
+	if frappe.db.exists("Company", "_Test Company GST"):
+		return
+	company = frappe.new_doc("Company")
+	company.company_name = "_Test Company GST"
+	company.abbr = "_GST"
+	company.default_currency = "INR"
+	company.country = "India"
+	company.insert()
+
+	if not frappe.db.exists('Address', '_Test Address-Billing'):
+		address = frappe.get_doc({
+			"address_line1": "_Test Address Line 1",
+			"address_title": "_Test Address",
+			"address_type": "Billing",
+			"city": "_Test City",
+			"state": "Test State",
+			"country": "India",
+			"doctype": "Address",
+			"is_primary_address": 1,
+			"phone": "+91 0000000000",
+			"gstin": "27AAECE4835E1ZR",
+			"gst_state": "Maharashtra",
+			"gst_state_number": "27"
+		}).insert()
+
+		address.append("links", {
+			"link_doctype": "Company",
+			"link_name": "_Test Company GST"
+		})
+
+		address.save()
+
+def set_account_heads():
+
+	gst_settings = frappe.get_doc("GST Settings")
+
+	gst_account = frappe.get_all(
+		"GST Account",
+		fields=["cgst_account", "sgst_account", "igst_account"],
+		filters = {"company": "_Test Company GST"})
+
+	if not gst_account:
+		gst_settings.append("gst_accounts", {
+			"company": "_Test Company GST",
+			"cgst_account": "CGST - _GST",
+			"sgst_account": "SGST - _GST",
+			"igst_account": "IGST - _GST",
+		})
+
+		gst_settings.save()
+
+
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index c5498c7..f7057aa 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -94,21 +94,39 @@
 	hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
 		fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
 		allow_on_submit=1, print_hide=1)
-	invoice_gst_fields = [
+	nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is nil rated or exempted',
+		fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
+		print_hide=1)
+	is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
+		fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
+		print_hide=1)
+
+	purchase_invoice_gst_category = [
 		dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
 			insert_after='language', print_hide=1, collapsible=1),
+		dict(fieldname='gst_category', label='GST Category',
+			fieldtype='Data', insert_after='gst_section', print_hide=1,
+			fetch_from='supplier.gst_category')
+	]
+
+	sales_invoice_gst_category = [
+		dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
+			insert_after='language', print_hide=1, collapsible=1),
+		dict(fieldname='gst_category', label='GST Category',
+			fieldtype='Data', insert_after='gst_section', print_hide=1,
+			fetch_from='customer.gst_category')
+	]
+
+	invoice_gst_fields = [
 		dict(fieldname='invoice_copy', label='Invoice Copy',
-			fieldtype='Select', insert_after='gst_section', print_hide=1, allow_on_submit=1,
+			fieldtype='Select', insert_after='gst_category', print_hide=1, allow_on_submit=1,
 			options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
 		dict(fieldname='reverse_charge', label='Reverse Charge',
 			fieldtype='Select', insert_after='invoice_copy', print_hide=1,
 			options='Y\nN', default='N'),
-		dict(fieldname='invoice_type', label='Invoice Type',
-			fieldtype='Select', insert_after='invoice_copy', print_hide=1,
-			options='Regular\nSEZ\nExport\nDeemed Export', default='Regular'),
 		dict(fieldname='export_type', label='Export Type',
-			fieldtype='Select', insert_after='invoice_type', print_hide=1,
-			depends_on='eval:in_list(["SEZ", "Export", "Deemed Export"], doc.invoice_type)',
+			fieldtype='Select', insert_after='reverse_charge', print_hide=1,
+			depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
 			options='\nWith Payment of Tax\nWithout Payment of Tax'),
 		dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
 			fieldtype='Data', insert_after='export_type', print_hide=1),
@@ -134,7 +152,7 @@
 	purchase_invoice_itc_fields = [
 			dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
 				fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
-				options='input\ninput service\ncapital goods\nineligible', default="ineligible"),
+				options='Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nIneligible\nAll Other ITC', default="All Other ITC"),
 			dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
 				fieldtype='Data', insert_after='eligibility_for_itc', print_hide=1),
 			dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
@@ -163,13 +181,13 @@
 	sales_invoice_shipping_fields = [
 			dict(fieldname='port_code', label='Port Code',
 				fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
-				depends_on="eval:doc.invoice_type=='Export' "),
+				depends_on="eval:doc.gst_category=='Overseas' "),
 			dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
 				fieldtype='Data', insert_after='port_code', print_hide=1,
-				depends_on="eval:doc.invoice_type=='Export' "),
+				depends_on="eval:doc.gst_category=='Overseas' "),
 			dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
 				fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
-				depends_on="eval:doc.invoice_type=='Export' ")
+				depends_on="eval:doc.gst_category=='Overseas' "),
 		]
 
 	inter_state_gst_field = [
@@ -223,26 +241,30 @@
 			dict(fieldname='gst_state_number', label='GST State Number',
 				fieldtype='Data', insert_after='gst_state', read_only=1),
 		],
-		'Purchase Invoice': invoice_gst_fields + purchase_invoice_gst_fields + purchase_invoice_itc_fields,
+		'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
 		'Purchase Order': purchase_invoice_gst_fields,
 		'Purchase Receipt': purchase_invoice_gst_fields,
-		'Sales Invoice': invoice_gst_fields + sales_invoice_gst_fields + sales_invoice_shipping_fields,
-		'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields,
+		'Sales Invoice': sales_invoice_gst_category + invoice_gst_fields + sales_invoice_shipping_fields + sales_invoice_gst_fields,
+		'Delivery Note': sales_invoice_gst_fields + ewaybill_fields,
 		'Sales Order': sales_invoice_gst_fields,
 		'Sales Taxes and Charges Template': inter_state_gst_field,
 		'Purchase Taxes and Charges Template': inter_state_gst_field,
 		'Item': [
 			dict(fieldname='gst_hsn_code', label='HSN/SAC',
 				fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
+			dict(fieldname='is_nil_exempt', label='Is nil rated or exempted',
+				fieldtype='Check', insert_after='gst_hsn_code'),
+			dict(fieldname='is_non_gst', label='Is Non GST ',
+				fieldtype='Check', insert_after='is_nil_exempt')
 		],
-		'Quotation Item': [hsn_sac_field],
-		'Supplier Quotation Item': [hsn_sac_field],
-		'Sales Order Item': [hsn_sac_field],
-		'Delivery Note Item': [hsn_sac_field],
-		'Sales Invoice Item': [hsn_sac_field],
-		'Purchase Order Item': [hsn_sac_field],
-		'Purchase Receipt Item': [hsn_sac_field],
-		'Purchase Invoice Item': [hsn_sac_field],
+		'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
+		'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
 		'Employee': [
 			dict(fieldname='ifsc_code', label='IFSC Code',
 				fieldtype='Data', insert_after='bank_ac_no', print_hide=1,
@@ -301,11 +323,28 @@
 				'fieldtype': 'Data',
 				'insert_after': 'supplier_type',
 				'depends_on': 'eval:doc.is_transporter'
+			},
+			{
+				'fieldname': 'gst_category',
+				'label': 'GST Category',
+				'fieldtype': 'Select',
+				'insert_after': 'gst_transporter_id',
+				'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
+				'default': 'Unregistered'
+			}
+		],
+		'Customer': [
+			{
+				'fieldname': 'gst_category',
+				'label': 'GST Category',
+				'fieldtype': 'Select',
+				'insert_after': 'customer_type',
+				'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
+				'default': 'Unregistered'
 			}
 		]
 	}
-
-	create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=update)
+	create_custom_fields(custom_fields, update=update)
 
 def make_fixtures(company=None):
 	docs = []
@@ -356,7 +395,9 @@
 			doc.insert()
 		except frappe.DuplicateEntryError:
 			doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
-			doc.append("accounts", accounts[0])
+
+			if accounts:
+				doc.append("accounts", accounts[0])
 
 			# if fiscal year don't match with any of the already entered data, append rate row
 			fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 4e94e5b..e379ed8 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -9,6 +9,8 @@
 from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
 
 def validate_gstin_for_india(doc, method):
+	if hasattr(doc, 'gst_state') and doc.gst_state:
+		doc.gst_state_number = state_numbers[doc.gst_state]
 	if not hasattr(doc, 'gstin') or not doc.gstin:
 		return
 
diff --git "a/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.py" "b/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.py"
index 5fbf700..6b8d3f0 100644
--- "a/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.py"
+++ "b/erpnext/regional/report/fichier_des_ecritures_comptables_\133fec\135/fichier_des_ecritures_comptables_\133fec\135.py"
@@ -87,8 +87,8 @@
 			left join `tabPurchase Invoice` pur on gl.voucher_no = pur.name
 			left join `tabJournal Entry` jnl on gl.voucher_no = jnl.name
 			left join `tabPayment Entry` pay on gl.voucher_no = pay.name
-			left join `tabCustomer` cus on gl.party = cus.customer_name
-			left join `tabSupplier` sup on gl.party = sup.supplier_name
+			left join `tabCustomer` cus on gl.party = cus.name
+			left join `tabSupplier` sup on gl.party = sup.name
 		where gl.company=%(company)s and gl.fiscal_year=%(fiscal_year)s
 		{group_by_condition}
 		order by GlPostDate, voucher_no"""\
diff --git a/erpnext/regional/report/gst_itemised_purchase_register/gst_itemised_purchase_register.py b/erpnext/regional/report/gst_itemised_purchase_register/gst_itemised_purchase_register.py
index 34ebb72..3ce2547 100644
--- a/erpnext/regional/report/gst_itemised_purchase_register/gst_itemised_purchase_register.py
+++ b/erpnext/regional/report/gst_itemised_purchase_register/gst_itemised_purchase_register.py
@@ -10,7 +10,7 @@
 		dict(fieldtype='Data', label='Supplier GSTIN', fieldname="supplier_gstin", width=120),
 		dict(fieldtype='Data', label='Company GSTIN', fieldname="company_gstin", width=120),
 		dict(fieldtype='Data', label='Reverse Charge', fieldname="reverse_charge", width=120),
-		dict(fieldtype='Data', label='Invoice Type', fieldname="invoice_type", width=120),
+		dict(fieldtype='Data', label='GST Category', fieldname="gst_category", width=120),
 		dict(fieldtype='Data', label='Export Type', fieldname="export_type", width=120),
 		dict(fieldtype='Data', label='E-Commerce GSTIN', fieldname="ecommerce_gstin", width=130),
 		dict(fieldtype='Data', label='HSN Code', fieldname="hsn_code", width=120),
@@ -20,7 +20,7 @@
 		'supplier_gstin',
 		'company_gstin',
 		'reverse_charge',
-		'invoice_type',
+		'gst_category',
 		'export_type',
 		'ecommerce_gstin',
 		'gst_hsn_code',
diff --git a/erpnext/regional/report/gst_itemised_sales_register/gst_itemised_sales_register.py b/erpnext/regional/report/gst_itemised_sales_register/gst_itemised_sales_register.py
index d0b1163..ab523e7 100644
--- a/erpnext/regional/report/gst_itemised_sales_register/gst_itemised_sales_register.py
+++ b/erpnext/regional/report/gst_itemised_sales_register/gst_itemised_sales_register.py
@@ -12,7 +12,7 @@
 		dict(fieldtype='Data', label='Company GSTIN', fieldname="company_gstin", width=120),
 		dict(fieldtype='Data', label='Place of Supply', fieldname="place_of_supply", width=120),
 		dict(fieldtype='Data', label='Reverse Charge', fieldname="reverse_charge", width=120),
-		dict(fieldtype='Data', label='Invoice Type', fieldname="invoice_type", width=120),
+		dict(fieldtype='Data', label='GST Category', fieldname="gst_category", width=120),
 		dict(fieldtype='Data', label='Export Type', fieldname="export_type", width=120),
 		dict(fieldtype='Data', label='E-Commerce GSTIN', fieldname="ecommerce_gstin", width=130),
 		dict(fieldtype='Data', label='HSN Code', fieldname="hsn_code", width=120)
@@ -22,7 +22,7 @@
 		'company_gstin',
 		'place_of_supply',
 		'reverse_charge',
-		'invoice_type',
+		'gst_category',
 		'export_type',
 		'ecommerce_gstin',
 		'gst_hsn_code'
diff --git a/erpnext/regional/report/gst_purchase_register/gst_purchase_register.py b/erpnext/regional/report/gst_purchase_register/gst_purchase_register.py
index 59df553..7274e0a 100644
--- a/erpnext/regional/report/gst_purchase_register/gst_purchase_register.py
+++ b/erpnext/regional/report/gst_purchase_register/gst_purchase_register.py
@@ -10,14 +10,14 @@
 		dict(fieldtype='Data', label='Supplier GSTIN', fieldname="supplier_gstin", width=120),
 		dict(fieldtype='Data', label='Company GSTIN', fieldname="company_gstin", width=120),
 		dict(fieldtype='Data', label='Reverse Charge', fieldname="reverse_charge", width=120),
-		dict(fieldtype='Data', label='Invoice Type', fieldname="invoice_type", width=120),
+		dict(fieldtype='Data', label='GST Category', fieldname="gst_category", width=120),
 		dict(fieldtype='Data', label='Export Type', fieldname="export_type", width=120),
 		dict(fieldtype='Data', label='E-Commerce GSTIN', fieldname="ecommerce_gstin", width=130)
 	], additional_query_columns=[
 		'supplier_gstin',
 		'company_gstin',
 		'reverse_charge',
-		'invoice_type',
+		'gst_category',
 		'export_type',
 		'ecommerce_gstin'
 	])
diff --git a/erpnext/regional/report/gst_sales_register/gst_sales_register.py b/erpnext/regional/report/gst_sales_register/gst_sales_register.py
index 4b32081..075bd48 100644
--- a/erpnext/regional/report/gst_sales_register/gst_sales_register.py
+++ b/erpnext/regional/report/gst_sales_register/gst_sales_register.py
@@ -12,7 +12,7 @@
 		dict(fieldtype='Data', label='Company GSTIN', fieldname="company_gstin", width=120),
 		dict(fieldtype='Data', label='Place of Supply', fieldname="place_of_supply", width=120),
 		dict(fieldtype='Data', label='Reverse Charge', fieldname="reverse_charge", width=120),
-		dict(fieldtype='Data', label='Invoice Type', fieldname="invoice_type", width=120),
+		dict(fieldtype='Data', label='GST Category', fieldname="gst_category", width=120),
 		dict(fieldtype='Data', label='Export Type', fieldname="export_type", width=120),
 		dict(fieldtype='Data', label='E-Commerce GSTIN', fieldname="ecommerce_gstin", width=130)
 	], additional_query_columns=[
@@ -21,7 +21,7 @@
 		'company_gstin',
 		'place_of_supply',
 		'reverse_charge',
-		'invoice_type',
+		'gst_category',
 		'export_type',
 		'ecommerce_gstin'
 	])
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index 906e90d..b01abce 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -28,10 +28,10 @@
 			place_of_supply,
 			ecommerce_gstin,
 			reverse_charge,
-			invoice_type,
+			gst_category,
 			return_against,
 			is_return,
-			invoice_type,
+			gst_category,
 			export_type,
 			port_code,
 			shipping_bill_number,
@@ -116,7 +116,7 @@
 		customers = frappe.get_all("Customer", filters={"customer_type": self.customer_type})
 
 		if self.filters.get("type_of_business") ==  "B2B":
-			conditions += """ and ifnull(invoice_type, '') != 'Export' and is_return != 1
+			conditions += """ and ifnull(gst_category, '') != 'Overseas' and is_return != 1
 				and customer in ({0})""".format(", ".join([frappe.db.escape(c.name) for c in customers]))
 
 		if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"):
@@ -138,7 +138,7 @@
 			conditions += """ and is_return = 1 """
 
 		elif self.filters.get("type_of_business") ==  "EXPORT":
-			conditions += """ and is_return !=1 and invoice_type = 'Export' """
+			conditions += """ and is_return !=1 and gst_category = 'Overseas' """
 		return conditions
 
 	def get_invoice_items(self):
@@ -283,8 +283,8 @@
 					"fieldtype": "Data"
 				},
 				{
-					"fieldname": "invoice_type",
-					"label": "Invoice Type",
+					"fieldname": "gst_category",
+					"label": "GST Category",
 					"fieldtype": "Data"
 				},
 				{
diff --git a/erpnext/regional/report/gstr_2/gstr_2.py b/erpnext/regional/report/gstr_2/gstr_2.py
index 0605695..a362269 100644
--- a/erpnext/regional/report/gstr_2/gstr_2.py
+++ b/erpnext/regional/report/gstr_2/gstr_2.py
@@ -26,10 +26,10 @@
 			place_of_supply,
 			ecommerce_gstin,
 			reverse_charge,
-			invoice_type,
+			gst_category,
 			return_against,
 			is_return,
-			invoice_type,
+			gst_category,
 			export_type,
 			reason_for_issuing_document,
 			eligibility_for_itc,
@@ -82,7 +82,7 @@
 					conditions += opts[1]
 
 		if self.filters.get("type_of_business") ==  "B2B":
-			conditions += "and ifnull(invoice_type, '') != 'Export' and is_return != 1 "
+			conditions += "and ifnull(gst_category, '') != 'Overseas' and is_return != 1 "
 
 		elif self.filters.get("type_of_business") ==  "CDNR":
 			conditions += """ and is_return = 1 """
@@ -200,7 +200,7 @@
 					"width": 80
 				},
 				{
-					"fieldname": "invoice_type",
+					"fieldname": "gst_category",
 					"label": "Invoice Type",
 					"fieldtype": "Data",
 					"width": 80
diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py
index 3c8328b..250659e 100644
--- a/erpnext/regional/united_arab_emirates/setup.py
+++ b/erpnext/regional/united_arab_emirates/setup.py
@@ -28,24 +28,24 @@
 	purchase_invoice_fields = [
 			dict(fieldname='company_trn', label='Company TRN',
 				fieldtype='Read Only', insert_after='shipping_address',
-				options='company.tax_id', print_hide=1),
+				fetch_from='company.tax_id', print_hide=1),
 			dict(fieldname='supplier_name_in_arabic', label='Supplier Name in Arabic',
 				fieldtype='Read Only', insert_after='supplier_name',
-				options='supplier.supplier_name_in_arabic', print_hide=1)
+				fetch_from='supplier.supplier_name_in_arabic', print_hide=1)
 		]
 
 	sales_invoice_fields = [
 			dict(fieldname='company_trn', label='Company TRN',
 				fieldtype='Read Only', insert_after='company_address',
-				options='company.tax_id', print_hide=1),
+				fetch_from='company.tax_id', print_hide=1),
 			dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic',
 				fieldtype='Read Only', insert_after='customer_name',
-				options='customer.customer_name_in_arabic', print_hide=1),
+				fetch_from='customer.customer_name_in_arabic', print_hide=1),
 		]
 
 	invoice_item_fields = [
 		dict(fieldname='tax_code', label='Tax Code',
-			fieldtype='Read Only', options='item_code.tax_code', insert_after='description',
+			fieldtype='Read Only', fetch_from='item_code.tax_code', insert_after='description',
 			allow_on_submit=1, print_hide=1),
 		dict(fieldname='tax_rate', label='Tax Rate',
 			fieldtype='Float', insert_after='tax_code',
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 10aab16..1ad4e9b 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -385,6 +385,7 @@
 						items.append(dict(
 							name= i.name,
 							item_code= i.item_code,
+							description= i.description,
 							bom = bom,
 							warehouse = i.warehouse,
 							pending_qty = pending_qty,
@@ -395,6 +396,7 @@
 						items.append(dict(
 							name= i.name,
 							item_code= i.item_code,
+							description= i.description,
 							bom = '',
 							warehouse = i.warehouse,
 							pending_qty = pending_qty,
@@ -898,7 +900,8 @@
 			sales_order=sales_order,
 			sales_order_item=i['sales_order_item'],
 			project=project,
-			fg_warehouse=i['warehouse']
+			fg_warehouse=i['warehouse'],
+			description=i['description']
 		)).insert()
 		work_order.set_work_order_operations()
 		work_order.save()
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index f62ea00..766e4e6 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -591,7 +591,8 @@
 				"item_code": item.get("item_code"),
 				"pending_qty": item.get("pending_qty"),
 				"sales_order_item": item.get("sales_order_item"),
-				"bom": item.get("bom")
+				"bom": item.get("bom"),
+				"description": item.get("description")
 			})
 			so_item_name[item.get("sales_order_item")]= item.get("pending_qty")
 		make_work_orders(json.dumps({"items":po_items}), so.name, so.company)
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py b/erpnext/selling/report/sales_partner_commission_summary/__init__.py
similarity index 100%
copy from erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py
copy to erpnext/selling/report/sales_partner_commission_summary/__init__.py
diff --git a/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js
new file mode 100644
index 0000000..63d930c
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js
@@ -0,0 +1,54 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Sales Partner Commission Summary"] = {
+	"filters": [
+
+		{
+			fieldname: "sales_partner",
+			label: __("Sales Partner"),
+			fieldtype: "Link",
+			options: "Sales Partner"
+		},
+		{
+			fieldname: "doctype",
+			label: __("Document Type"),
+			fieldtype: "Select",
+			options: "Sales Order\nDelivery Note\nSales Invoice",
+			default: "Sales Order"
+		},
+		{
+			fieldname: "from_date",
+			label: __("From Date"),
+			fieldtype: "Date",
+			default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+		},
+		{
+			fieldname:"to_date",
+			label: __("To Date"),
+			fieldtype: "Date",
+			default: frappe.datetime.get_today()
+		},
+		{
+			fieldname:"company",
+			label: __("Company"),
+			fieldtype: "Link",
+			options: "Company",
+			default: frappe.defaults.get_user_default("Company")
+		},
+		{
+			fieldname:"customer",
+			label: __("Customer"),
+			fieldtype: "Link",
+			options: "Customer",
+		},
+		{
+			fieldname:"territory",
+			label: __("Territory"),
+			fieldtype: "Link",
+			options: "Territory",
+		},
+
+	]
+}
diff --git a/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.json b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.json
new file mode 100644
index 0000000..79b82b9
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.json
@@ -0,0 +1,28 @@
+{
+ "add_total_row": 1, 
+ "creation": "2019-03-15 15:22:15.012318", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2019-03-15 15:22:15.012318", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Sales Partner Commission Summary", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Sales Order", 
+ "report_name": "Sales Partner Commission Summary", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Sales Manager"
+  }, 
+  {
+   "role": "Maintenance User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.py b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.py
new file mode 100644
index 0000000..66f9aae
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.py
@@ -0,0 +1,113 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import msgprint, _
+from frappe.utils import flt
+
+
+def execute(filters=None):
+	if not filters: filters = {}
+
+	columns = get_columns(filters)
+	data = get_entries(filters)
+
+	return columns, data
+
+def get_columns(filters):
+	if not filters.get("doctype"):
+		msgprint(_("Please select the document type first"), raise_exception=1)
+
+	columns =[
+		{
+			"label": _(filters["doctype"]),
+			"options": filters["doctype"],
+			"fieldname": "name",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Customer"),
+			"options": "Customer",
+			"fieldname": "customer",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Territory"),
+			"options": "Territory",
+			"fieldname": "territory",
+			"fieldtype": "Link",
+			"width": 100
+		},
+		{
+			"label": _("Posting Date"),
+			"fieldname": "posting_date",
+			"fieldtype": "Date",
+			"width": 100
+		},
+		{
+			"label": _("Amount"),
+			"fieldname": "amount",
+			"fieldtype": "Currency",
+			"width": 120
+		},
+		{
+			"label": _("Sales Partner"),
+			"options": "Sales Partner",
+			"fieldname": "sales_partner",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Commission Rate %"),
+			"fieldname": "commission_rate",
+			"fieldtype": "Data",
+			"width": 100
+		},
+		{
+			"label": _("Total Commission"),
+			"fieldname": "total_commission",
+			"fieldtype": "Currency",
+			"width": 120
+		}
+	]
+
+	return columns
+
+def get_entries(filters):
+	date_field = ("transaction_date" if filters.get('doctype') == "Sales Order"
+		else "posting_date")
+
+	conditions = get_conditions(filters, date_field)
+	entries = frappe.db.sql("""
+		SELECT
+			name, customer, territory, {0} as posting_date, base_net_total as amount,
+			sales_partner, commission_rate, total_commission
+		FROM
+			`tab{1}`
+		WHERE
+			{2} and docstatus = 1 and sales_partner is not null
+			and sales_partner != '' order by name desc, sales_partner
+		""".format(date_field, filters.get('doctype'), conditions), filters, as_dict=1)
+
+	return entries
+
+def get_conditions(filters, date_field):
+	conditions = "1=1"
+
+	for field in ["company", "customer", "territory"]:
+		if filters.get(field):
+			conditions += " and {0} = %({1})s".format(field, field)
+
+	if filters.get("sales_partner"):
+		conditions += " and sales_partner = %(sales_partner)s"
+
+	if filters.get("from_date"):
+		conditions += " and {0} >= %(from_date)s".format(date_field)
+
+	if filters.get("to_date"):
+		conditions += " and {0} <= %(to_date)s".format(date_field)
+
+	return conditions
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/__init__.py
similarity index 100%
copy from erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py
copy to erpnext/selling/report/sales_partner_target_variance_based_on_item_group/__init__.py
diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py
new file mode 100644
index 0000000..d7ebafc
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py
@@ -0,0 +1,211 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+from frappe.utils import flt
+from erpnext.accounts.utils import get_fiscal_year
+from erpnext.accounts.report.financial_statements import get_period_list
+from erpnext.accounts.doctype.monthly_distribution.monthly_distribution import get_periodwise_distribution_data
+
+def get_data_column(filters, partner_doctype):
+	data = []
+	period_list = get_period_list(filters.fiscal_year, filters.fiscal_year,
+		filters.period, company=filters.company)
+
+	rows = get_data(filters, period_list, partner_doctype)
+	columns = get_columns(filters, period_list, partner_doctype)
+
+	if not rows:
+		return columns, data
+
+	for key, value in rows.items():
+		value.update({
+			frappe.scrub(partner_doctype): key[0],
+			'item_group': key[1]
+		})
+
+		data.append(value)
+
+	return columns, data
+
+def get_data(filters, period_list, partner_doctype):
+	sales_field = frappe.scrub(partner_doctype)
+	sales_users_data = get_parents_data(filters, partner_doctype)
+
+	if not sales_users_data: return
+	sales_users, item_groups = [], []
+
+	for d in sales_users_data:
+		if d.parent not in sales_users:
+			sales_users.append(d.parent)
+
+		if d.item_group not in item_groups:
+			item_groups.append(d.item_group)
+
+	date_field = ("transaction_date"
+		if filters.get('doctype') == "Sales Order" else "posting_date")
+
+	actual_data = get_actual_data(filters, item_groups, sales_users, date_field, sales_field)
+
+	return prepare_data(filters, sales_users_data,
+		actual_data, date_field, period_list, sales_field)
+
+def get_columns(filters, period_list, partner_doctype):
+	fieldtype, options = "Currency", "currency"
+
+	if filters.get("target_on") == 'Quantity':
+		fieldtype, options = "Float", ""
+
+	columns = [{
+		"fieldname": frappe.scrub(partner_doctype),
+		"label": _(partner_doctype),
+		"fieldtype": "Link",
+		"options": partner_doctype,
+		"width": 100
+	}, {
+		"fieldname": "item_group",
+		"label": _("Item Group"),
+		"fieldtype": "Link",
+		"options": "Item Group",
+		"width": 100
+	}]
+
+	for period in period_list:
+		target_key = 'target_{}'.format(period.key)
+		variance_key = 'variance_{}'.format(period.key)
+
+		columns.extend([{
+			"fieldname": target_key,
+			"label": _("Target ({})".format(period.label)),
+			"fieldtype": fieldtype,
+			"options": options,
+			"width": 100
+		}, {
+			"fieldname": period.key,
+			"label": _("Achieved ({})".format(period.label)),
+			"fieldtype": fieldtype,
+			"options": options,
+			"width": 100
+		}, {
+			"fieldname": variance_key,
+			"label": _("Variance ({})".format(period.label)),
+			"fieldtype": fieldtype,
+			"options": options,
+			"width": 100
+		}])
+
+	columns.extend([{
+		"fieldname": "total_target",
+		"label": _("Total Target"),
+		"fieldtype": fieldtype,
+		"options": options,
+		"width": 100
+	}, {
+		"fieldname": "total_achieved",
+		"label": _("Total Achieved"),
+		"fieldtype": fieldtype,
+		"options": options,
+		"width": 100
+	}, {
+		"fieldname": "total_variance",
+		"label": _("Total Variance"),
+		"fieldtype": fieldtype,
+		"options": options,
+		"width": 100
+	}])
+
+	return columns
+
+def prepare_data(filters, sales_users_data, actual_data, date_field, period_list, sales_field):
+	rows = {}
+
+	target_qty_amt_field = ("target_qty"
+		if filters.get("target_on") == 'Quantity' else "target_amount")
+
+	qty_or_amount_field = ("stock_qty"
+		if filters.get("target_on") == 'Quantity' else "base_net_amount")
+
+	for d in sales_users_data:
+		key = (d.parent, d.item_group)
+		dist_data = get_periodwise_distribution_data(d.distribution_id, period_list, filters.get("period"))
+
+		if key not in rows:
+			rows.setdefault(key,{
+				'total_target': 0,
+				'total_achieved': 0,
+				'total_variance': 0
+			})
+
+		details = rows[key]
+		for period in period_list:
+			p_key = period.key
+			if p_key not in details:
+				details[p_key] = 0
+
+			target_key = 'target_{}'.format(p_key)
+			variance_key = 'variance_{}'.format(p_key)
+			details[target_key] = (d.get(target_qty_amt_field) * dist_data.get(p_key)) / 100
+			details[variance_key] = 0
+			details["total_target"] += details[target_key]
+
+			for r in actual_data:
+				if (r.get(sales_field) == d.parent and r.item_group == d.item_group and
+					period.from_date <= r.get(date_field) and r.get(date_field) <= period.to_date):
+					details[p_key] += r.get(qty_or_amount_field, 0)
+					details[variance_key] = details.get(target_key) - details.get(p_key)
+
+			details["total_achieved"] += details.get(p_key)
+			details["total_variance"] = details.get("total_target") - details.get("total_achieved")
+
+	return rows
+
+def get_actual_data(filters, item_groups, sales_users_or_territory_data, date_field, sales_field):
+	fiscal_year = get_fiscal_year(fiscal_year=filters.get("fiscal_year"), as_dict=1)
+	dates = [fiscal_year.year_start_date, fiscal_year.year_end_date]
+
+	select_field = "`tab{0}`.{1}".format(filters.get("doctype"), sales_field)
+	child_table = "`tab{0}`".format(filters.get("doctype") + ' Item')
+
+	if sales_field == 'sales_person':
+		select_field = "`tabSales Team`.sales_person"
+		child_table = "`tab{0}`, `tabSales Team`".format(filters.get("doctype") + ' Item')
+		cond = """`tabSales Team`.parent = `tab{0}`.name and
+			`tabSales Team`.sales_person in ({1}) """.format(filters.get("doctype"),
+			','.join(['%s'] * len(sales_users_or_territory_data)))
+	else:
+		cond = "`tab{0}`.{1} in ({2})".format(filters.get("doctype"), sales_field,
+			','.join(['%s'] * len(sales_users_or_territory_data)))
+
+	return frappe.db.sql(""" SELECT `tab{child_doc}`.item_group,
+			`tab{child_doc}`.stock_qty, `tab{child_doc}`.base_net_amount,
+			{select_field}, `tab{parent_doc}`.{date_field}
+		FROM `tab{parent_doc}`, {child_table}
+		WHERE
+			`tab{child_doc}`.parent = `tab{parent_doc}`.name
+			and `tab{parent_doc}`.docstatus = 1 and {cond}
+			and `tab{child_doc}`.item_group in ({item_groups})
+			and `tab{parent_doc}`.{date_field} between %s and %s"""
+			.format(
+				cond = cond,
+				date_field = date_field,
+				select_field = select_field,
+				child_table = child_table,
+				parent_doc = filters.get("doctype"),
+				child_doc = filters.get("doctype") + ' Item',
+				item_groups = ','.join(['%s'] * len(item_groups))
+			), tuple(sales_users_or_territory_data + item_groups + dates), as_dict=1)
+
+def get_parents_data(filters, partner_doctype):
+	filters_dict = {'parenttype': partner_doctype}
+
+	target_qty_amt_field = ("target_qty"
+		if filters.get("target_on") == 'Quantity' else "target_amount")
+
+	if filters.get("fiscal_year"):
+		filters_dict["fiscal_year"] = filters.get("fiscal_year")
+
+	return frappe.get_all('Target Detail',
+		filters = filters_dict,
+		fields = ["parent", "item_group", target_qty_amt_field, "fiscal_year", "distribution_id"])
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js
new file mode 100644
index 0000000..f99f68c
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Sales Partner Target Variance based on Item Group"] = {
+	"filters": [
+		{
+			fieldname:"company",
+			label: __("Company"),
+			fieldtype: "Link",
+			options: "Company",
+			default: frappe.defaults.get_user_default("Company")
+		},
+		{
+			fieldname: "fiscal_year",
+			label: __("Fiscal Year"),
+			fieldtype: "Link",
+			options: "Fiscal Year",
+			default: frappe.sys_defaults.fiscal_year
+		},
+		{
+			fieldname: "doctype",
+			label: __("Document Type"),
+			fieldtype: "Select",
+			options: "Sales Order\nDelivery Note\nSales Invoice",
+			default: "Sales Order"
+		},
+		{
+			fieldname: "period",
+			label: __("Period"),
+			fieldtype: "Select",
+			options: [
+				{ "value": "Monthly", "label": __("Monthly") },
+				{ "value": "Quarterly", "label": __("Quarterly") },
+				{ "value": "Half-Yearly", "label": __("Half-Yearly") },
+				{ "value": "Yearly", "label": __("Yearly") }
+			],
+			default: "Monthly"
+		},
+		{
+			fieldname: "target_on",
+			label: __("Target On"),
+			fieldtype: "Select",
+			options: "Quantity\nAmount",
+			default: "Quantity"
+		},
+	]
+}
diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.json b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.json
new file mode 100644
index 0000000..1cc7e96
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.json
@@ -0,0 +1,37 @@
+{
+ "add_total_row": 0, 
+ "creation": "2019-03-25 18:22:37.323995", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2019-03-25 18:22:37.323995", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Sales Partner Target Variance based on Item Group", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Sales Order", 
+ "report_name": "Sales Partner Target Variance based on Item Group", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Sales User"
+  }, 
+  {
+   "role": "Sales Manager"
+  }, 
+  {
+   "role": "Maintenance User"
+  }, 
+  {
+   "role": "Accounts User"
+  }, 
+  {
+   "role": "Stock User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.py
new file mode 100644
index 0000000..e41011f
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.py
@@ -0,0 +1,12 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.selling.report.sales_partner_target_variance_based_on_item_group.item_group_wise_sales_target_variance import get_data_column
+
+def execute(filters=None):
+	data = []
+
+	return get_data_column(filters, "Sales Partner")
+
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py b/erpnext/selling/report/sales_partner_transaction_summary/__init__.py
similarity index 100%
copy from erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py
copy to erpnext/selling/report/sales_partner_transaction_summary/__init__.py
diff --git a/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js
new file mode 100644
index 0000000..e404233
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js
@@ -0,0 +1,71 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Sales Partner Transaction Summary"] = {
+	"filters": [
+		{
+			fieldname: "sales_partner",
+			label: __("Sales Partner"),
+			fieldtype: "Link",
+			options: "Sales Partner"
+		},
+		{
+			fieldname: "doctype",
+			label: __("Document Type"),
+			fieldtype: "Select",
+			options: "Sales Order\nDelivery Note\nSales Invoice",
+			default: "Sales Order"
+		},
+		{
+			fieldname: "from_date",
+			label: __("From Date"),
+			fieldtype: "Date",
+			default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+		},
+		{
+			fieldname:"to_date",
+			label: __("To Date"),
+			fieldtype: "Date",
+			default: frappe.datetime.get_today()
+		},
+		{
+			fieldname:"company",
+			label: __("Company"),
+			fieldtype: "Link",
+			options: "Company",
+			default: frappe.defaults.get_user_default("Company"),
+			reqd: 1
+		},
+		{
+			fieldname:"item_group",
+			label: __("Item Group"),
+			fieldtype: "Link",
+			options: "Item Group",
+		},
+		{
+			fieldname:"brand",
+			label: __("Brand"),
+			fieldtype: "Link",
+			options: "Brand",
+		},
+		{
+			fieldname:"customer",
+			label: __("Customer"),
+			fieldtype: "Link",
+			options: "Customer",
+		},
+		{
+			fieldname:"territory",
+			label: __("Territory"),
+			fieldtype: "Link",
+			options: "Territory",
+		},
+		{
+			fieldname:"show_return_entries",
+			label: __("Show Return Entries"),
+			fieldtype: "Check",
+			default: 0,
+		},
+	]
+}
diff --git a/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.json b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.json
new file mode 100644
index 0000000..b518b42
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.json
@@ -0,0 +1,37 @@
+{
+ "add_total_row": 1, 
+ "creation": "2019-03-25 18:15:09.920739", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2019-03-25 18:15:09.920739", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Sales Partner Transaction Summary", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Sales Order", 
+ "report_name": "Sales Partner Transaction Summary", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Sales User"
+  }, 
+  {
+   "role": "Sales Manager"
+  }, 
+  {
+   "role": "Maintenance User"
+  }, 
+  {
+   "role": "Accounts User"
+  }, 
+  {
+   "role": "Stock User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.py b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.py
new file mode 100644
index 0000000..5356028
--- /dev/null
+++ b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.py
@@ -0,0 +1,168 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import msgprint, _
+from frappe.utils import flt
+
+
+def execute(filters=None):
+	if not filters: filters = {}
+
+	columns = get_columns(filters)
+	data = get_entries(filters)
+
+	return columns, data
+
+def get_columns(filters):
+	if not filters.get("doctype"):
+		msgprint(_("Please select the document type first"), raise_exception=1)
+
+	columns =[
+		{
+			"label": _(filters["doctype"]),
+			"options": filters["doctype"],
+			"fieldname": "name",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Customer"),
+			"options": "Customer",
+			"fieldname": "customer",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Territory"),
+			"options": "Territory",
+			"fieldname": "territory",
+			"fieldtype": "Link",
+			"width": 100
+		},
+		{
+			"label": _("Posting Date"),
+			"fieldname": "posting_date",
+			"fieldtype": "Date",
+			"width": 100
+		},
+		{
+			"label": _("Item Code"),
+			"fieldname": "item_code",
+			"fieldtype": "Link",
+			"options": "Item",
+			"width": 100
+		},
+		{
+			"label": _("Item Group"),
+			"fieldname": "item_group",
+			"fieldtype": "Link",
+			"options": "Item Group",
+			"width": 100
+		},
+		{
+			"label": _("Brand"),
+			"fieldname": "brand",
+			"fieldtype": "Link",
+			"options": "Brand",
+			"width": 100
+		},
+		{
+			"label": _("Quantity"),
+			"fieldname": "qty",
+			"fieldtype": "Float",
+			"width": 120
+		},
+		{
+			"label": _("Rate"),
+			"fieldname": "rate",
+			"fieldtype": "Currency",
+			"width": 120
+		},
+		{
+			"label": _("Amount"),
+			"fieldname": "amount",
+			"fieldtype": "Currency",
+			"width": 120
+		},
+		{
+			"label": _("Sales Partner"),
+			"options": "Sales Partner",
+			"fieldname": "sales_partner",
+			"fieldtype": "Link",
+			"width": 140
+		},
+		{
+			"label": _("Commission Rate %"),
+			"fieldname": "commission_rate",
+			"fieldtype": "Data",
+			"width": 100
+		},
+		{
+			"label": _("Commission"),
+			"fieldname": "commission",
+			"fieldtype": "Currency",
+			"width": 120
+		},
+		{
+			"label": _("Currency"),
+			"fieldname": "currency",
+			"fieldtype": "Link",
+			"options": "Currency",
+			"width": 120
+		}
+	]
+
+	return columns
+
+def get_entries(filters):
+	date_field = ("transaction_date" if filters.get('doctype') == "Sales Order"
+		else "posting_date")
+
+	conditions = get_conditions(filters, date_field)
+	entries = frappe.db.sql("""
+		SELECT
+			dt.name, dt.customer, dt.territory, dt.{date_field} as posting_date, dt.currency,
+			dt_item.base_net_rate as rate, dt_item.qty, dt_item.base_net_amount as amount,
+			((dt_item.base_net_amount * dt.commission_rate) / 100) as commission,
+			dt_item.brand, dt.sales_partner, dt.commission_rate, dt_item.item_group, dt_item.item_code
+		FROM
+			`tab{doctype}` dt, `tab{doctype} Item` dt_item
+		WHERE
+			{cond} and dt.name = dt_item.parent and dt.docstatus = 1
+			and dt.sales_partner is not null and dt.sales_partner != ''
+			order by dt.name desc, dt.sales_partner
+		""".format(date_field=date_field, doctype=filters.get('doctype'),
+			cond=conditions), filters, as_dict=1)
+
+	return entries
+
+def get_conditions(filters, date_field):
+	conditions = "1=1"
+
+	for field in ["company", "customer", "territory", "sales_partner"]:
+		if filters.get(field):
+			conditions += " and dt.{0} = %({1})s".format(field, field)
+
+	if filters.get("from_date"):
+		conditions += " and dt.{0} >= %(from_date)s".format(date_field)
+
+	if filters.get("to_date"):
+		conditions += " and dt.{0} <= %(to_date)s".format(date_field)
+
+	if not filters.get('show_return_entries'):
+		conditions += " and dt_item.qty > 0.0"
+
+	if filters.get('brand'):
+		conditions += " and dt_item.brand = %(brand)s"
+
+	if filters.get('item_group'):
+		lft, rgt = frappe.get_cached_value('Item Group',
+			filters.get('item_group'), ['lft', 'rgt'])
+
+		conditions += """ and dt_item.item_group in (select name from
+			`tabItem Group` where lft >= %s and rgt <= %s)""" % (lft, rgt)
+
+
+	return conditions
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/__init__.py
similarity index 100%
rename from erpnext/selling/report/sales_person_target_variance_item_group_wise/__init__.py
rename to erpnext/selling/report/sales_person_target_variance_based_on_item_group/__init__.py
diff --git a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js
new file mode 100644
index 0000000..9f6bfc4
--- /dev/null
+++ b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Sales Person Target Variance Based On Item Group"] = {
+	"filters": [
+		{
+			fieldname:"company",
+			label: __("Company"),
+			fieldtype: "Link",
+			options: "Company",
+			default: frappe.defaults.get_user_default("Company")
+		},
+		{
+			fieldname: "fiscal_year",
+			label: __("Fiscal Year"),
+			fieldtype: "Link",
+			options: "Fiscal Year",
+			default: frappe.sys_defaults.fiscal_year
+		},
+		{
+			fieldname: "doctype",
+			label: __("Document Type"),
+			fieldtype: "Select",
+			options: "Sales Order\nDelivery Note\nSales Invoice",
+			default: "Sales Order"
+		},
+		{
+			fieldname: "period",
+			label: __("Period"),
+			fieldtype: "Select",
+			options: [
+				{ "value": "Monthly", "label": __("Monthly") },
+				{ "value": "Quarterly", "label": __("Quarterly") },
+				{ "value": "Half-Yearly", "label": __("Half-Yearly") },
+				{ "value": "Yearly", "label": __("Yearly") }
+			],
+			default: "Monthly"
+		},
+		{
+			fieldname: "target_on",
+			label: __("Target On"),
+			fieldtype: "Select",
+			options: "Quantity\nAmount",
+			default: "Quantity"
+		},
+	]
+}
diff --git a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.json b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.json
new file mode 100644
index 0000000..84cd27e
--- /dev/null
+++ b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.json
@@ -0,0 +1,37 @@
+{
+ "add_total_row": 0, 
+ "creation": "2019-03-25 22:16:49.040998", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2019-03-25 22:16:49.040998", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Sales Person Target Variance Based On Item Group", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Sales Order", 
+ "report_name": "Sales Person Target Variance Based On Item Group", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Sales User"
+  }, 
+  {
+   "role": "Sales Manager"
+  }, 
+  {
+   "role": "Maintenance User"
+  }, 
+  {
+   "role": "Accounts User"
+  }, 
+  {
+   "role": "Stock User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.py b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.py
new file mode 100644
index 0000000..5166cc8
--- /dev/null
+++ b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.selling.report.sales_partner_target_variance_based_on_item_group.item_group_wise_sales_target_variance import get_data_column
+
+def execute(filters=None):
+	data = []
+
+	return get_data_column(filters, "Sales Person")
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js
deleted file mode 100644
index 8987a74..0000000
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
-frappe.query_reports["Sales Person Target Variance Item Group-Wise"] = {
-	"filters": [
-		{
-			fieldname: "fiscal_year",
-			label: __("Fiscal Year"),
-			fieldtype: "Link",
-			options: "Fiscal Year",
-			default: frappe.sys_defaults.fiscal_year
-		},
-		{
-			fieldname: "period",
-			label: __("Period"),
-			fieldtype: "Select",
-			options: [
-				{ "value": "Monthly", "label": __("Monthly") },
-				{ "value": "Quarterly", "label": __("Quarterly") },
-				{ "value": "Half-Yearly", "label": __("Half-Yearly") },
-				{ "value": "Yearly", "label": __("Yearly") }
-			],
-			default: "Monthly"
-		},
-		{
-			fieldname: "target_on",
-			label: __("Target On"),
-			fieldtype: "Select",
-			options: "Quantity\nAmount",
-			default: "Quantity"
-		},
-	]
-}
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json
deleted file mode 100644
index 452caf9..0000000
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2013-06-21 12:14:15", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 3, 
- "is_standard": "Yes", 
- "modified": "2017-02-24 20:14:50.589149", 
- "modified_by": "Administrator", 
- "module": "Selling", 
- "name": "Sales Person Target Variance Item Group-Wise", 
- "owner": "Administrator", 
- "ref_doctype": "Sales Order", 
- "report_name": "Sales Person Target Variance Item Group-Wise", 
- "report_type": "Script Report", 
- "roles": [
-  {
-   "role": "Sales User"
-  }, 
-  {
-   "role": "Sales Manager"
-  }, 
-  {
-   "role": "Maintenance User"
-  }, 
-  {
-   "role": "Accounts User"
-  }, 
-  {
-   "role": "Stock User"
-  }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
deleted file mode 100644
index fd5bc4e..0000000
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _, msgprint
-from frappe.utils import flt
-from erpnext.accounts.utils import get_fiscal_year
-from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
-
-def execute(filters=None):
-	if not filters: filters = {}
-
-	columns = get_columns(filters)
-	period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
-	sim_map = get_salesperson_item_month_map(filters)
-
-	data = []
-	for salesperson, salesperson_items in sim_map.items():
-		for item_group, monthwise_data in salesperson_items.items():
-			row = [salesperson, item_group]
-			totals = [0, 0, 0]
-			for relevant_months in period_month_ranges:
-				period_data = [0, 0, 0]
-				for month in relevant_months:
-					month_data = monthwise_data.get(month, {})
-					for i, fieldname in enumerate(["target", "achieved", "variance"]):
-						value = flt(month_data.get(fieldname))
-						period_data[i] += value
-						totals[i] += value
-				period_data[2] = period_data[0] - period_data[1]
-				row += period_data
-			totals[2] = totals[0] - totals[1]
-			row += totals
-			data.append(row)
-
-	return columns, sorted(data, key=lambda x: (x[0], x[1]))
-
-def get_columns(filters):
-	for fieldname in ["fiscal_year", "period", "target_on"]:
-		if not filters.get(fieldname):
-			label = (" ".join(fieldname.split("_"))).title()
-			msgprint(_("Please specify") + ": " + label,
-				raise_exception=True)
-
-	columns = [_("Sales Person") + ":Link/Sales Person:120", _("Item Group") + ":Link/Item Group:120"]
-
-	group_months = False if filters["period"] == "Monthly" else True
-
-	for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
-		for label in [_("Target") + " (%s)", _("Achieved") + " (%s)", _("Variance") + " (%s)"]:
-			if group_months:
-				label = label % (_(from_date.strftime("%b")) + " - " + _(to_date.strftime("%b")))
-			else:
-				label = label % _(from_date.strftime("%b"))
-
-			columns.append(label+":Float:120")
-
-	return columns + [_("Total Target") + ":Float:120", _("Total Achieved") + ":Float:120",
-		_("Total Variance") + ":Float:120"]
-
-#Get sales person & item group details
-def get_salesperson_details(filters):
-	return frappe.db.sql("""
-		select
-			sp.name, td.item_group, td.target_qty, td.target_amount, sp.distribution_id
-		from
-			`tabSales Person` sp, `tabTarget Detail` td
-		where
-			td.parent=sp.name and td.fiscal_year=%s order by sp.name
-		""", (filters["fiscal_year"]), as_dict=1)
-
-#Get target distribution details of item group
-def get_target_distribution_details(filters):
-	target_details = {}
-
-	for d in frappe.db.sql("""
-		select
-			md.name, mdp.month, mdp.percentage_allocation
-		from
-			`tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
-		where
-			mdp.parent=md.name and md.fiscal_year=%s
-		""", (filters["fiscal_year"]), as_dict=1):
-			target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
-
-	return target_details
-
-#Get achieved details from sales order
-def get_achieved_details(filters, sales_person, all_sales_persons, target_item_group, item_groups):
-	start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
-
-	item_details = frappe.db.sql("""
-		SELECT st.sales_person, MONTHNAME(so.transaction_date) as month_name,
-		CASE
-			WHEN so.status = "Closed" THEN sum(soi.delivered_qty * soi.conversion_factor * (st.allocated_percentage/100))
-			ELSE sum(soi.stock_qty * (st.allocated_percentage/100))
-		END as qty,
-		CASE
-			WHEN so.status = "Closed" THEN sum(soi.delivered_qty * soi.conversion_factor * soi.base_net_rate * (st.allocated_percentage/100))
-			ELSE sum(soi.base_net_amount * (st.allocated_percentage/100))
-		END as amount
-		from
-			`tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
-		where
-			soi.parent=so.name and so.docstatus=1 and st.parent=so.name
-			and so.transaction_date>=%s and so.transaction_date<=%s
-			and exists(SELECT name from `tabSales Person` where lft >= %s and rgt <= %s and name=st.sales_person)
-			and exists(SELECT name from `tabItem Group` where lft >= %s and rgt <= %s and name=soi.item_group)
-		group by
-			sales_person, month_name
-			""",
-		(start_date, end_date, all_sales_persons[sales_person].lft, all_sales_persons[sales_person].rgt, 
-			item_groups[target_item_group].lft, item_groups[target_item_group].rgt), as_dict=1)
-
-	actual_details = {}
-	for d in item_details:
-		actual_details.setdefault(d.month_name, frappe._dict({
-			"quantity" : 0,
-			"amount" : 0
-		}))
-
-		value_dict = actual_details[d.month_name]
-		value_dict.quantity += flt(d.qty)
-		value_dict.amount += flt(d.amount)
-
-	return actual_details
-
-def get_salesperson_item_month_map(filters):
-	import datetime
-	salesperson_details = get_salesperson_details(filters)
-	tdd = get_target_distribution_details(filters)
-	item_groups = get_item_groups()
-	sales_persons = get_sales_persons()
-
-	sales_person_achievement_dict = {}
-	for sd in salesperson_details:
-		achieved_details = get_achieved_details(filters, sd.name, sales_persons, sd.item_group, item_groups)
-
-		for month_id in range(1, 13):
-			month = datetime.date(2013, month_id, 1).strftime('%B')
-			sales_person_achievement_dict.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
-					.setdefault(month, frappe._dict({
-							"target": 0.0, "achieved": 0.0
-						}))
-
-			sales_target_achieved = sales_person_achievement_dict[sd.name][sd.item_group][month]
-			month_percentage = tdd.get(sd.distribution_id, {}).get(month, 0) \
-				if sd.distribution_id else 100.0/12
-
-			if (filters["target_on"] == "Quantity"):
-				sales_target_achieved.target = flt(sd.target_qty) * month_percentage / 100
-			else:
-				sales_target_achieved.target = flt(sd.target_amount) * month_percentage / 100
-
-			sales_target_achieved.achieved = achieved_details.get(month, frappe._dict())\
-				.get(filters["target_on"].lower())
-
-	return sales_person_achievement_dict
-
-def get_item_groups():
-	item_groups = frappe._dict()
-	for d in frappe.get_all("Item Group", fields=["name", "lft", "rgt"]):
-		item_groups.setdefault(d.name, frappe._dict({
-			"lft": d.lft,
-			"rgt": d.rgt
-		}))
-	return item_groups
-
-def get_sales_persons():
-	sales_persons = frappe._dict()
-	for d in frappe.get_all("Sales Person", fields=["name", "lft", "rgt"]):
-		sales_persons.setdefault(d.name, frappe._dict({
-			"lft": d.lft,
-			"rgt": d.rgt
-		}))
-	return sales_persons	
-	
\ No newline at end of file
diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/__init__.py b/erpnext/selling/report/territory_target_variance_based_on_item_group/__init__.py
similarity index 100%
rename from erpnext/selling/report/territory_target_variance_item_group_wise/__init__.py
rename to erpnext/selling/report/territory_target_variance_based_on_item_group/__init__.py
diff --git a/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js
new file mode 100644
index 0000000..dd9607f
--- /dev/null
+++ b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Territory Target Variance Based On Item Group"] = {
+	"filters": [
+		{
+			fieldname:"company",
+			label: __("Company"),
+			fieldtype: "Link",
+			options: "Company",
+			default: frappe.defaults.get_user_default("Company")
+		},
+		{
+			fieldname: "fiscal_year",
+			label: __("Fiscal Year"),
+			fieldtype: "Link",
+			options: "Fiscal Year",
+			default: frappe.sys_defaults.fiscal_year
+		},
+		{
+			fieldname: "doctype",
+			label: __("Document Type"),
+			fieldtype: "Select",
+			options: "Sales Order\nDelivery Note\nSales Invoice",
+			default: "Sales Order"
+		},
+		{
+			fieldname: "period",
+			label: __("Period"),
+			fieldtype: "Select",
+			options: [
+				{ "value": "Monthly", "label": __("Monthly") },
+				{ "value": "Quarterly", "label": __("Quarterly") },
+				{ "value": "Half-Yearly", "label": __("Half-Yearly") },
+				{ "value": "Yearly", "label": __("Yearly") }
+			],
+			default: "Monthly"
+		},
+		{
+			fieldname: "target_on",
+			label: __("Target On"),
+			fieldtype: "Select",
+			options: "Quantity\nAmount",
+			default: "Quantity"
+		},
+	]
+}
diff --git a/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.json b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.json
new file mode 100644
index 0000000..d3b05ba
--- /dev/null
+++ b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.json
@@ -0,0 +1,37 @@
+{
+ "add_total_row": 0, 
+ "creation": "2019-03-25 22:20:59.033199", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "Gadgets International", 
+ "modified": "2019-03-25 22:20:59.033199", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Territory Target Variance Based On Item Group", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Sales Order", 
+ "report_name": "Territory Target Variance Based On Item Group", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "Sales User"
+  }, 
+  {
+   "role": "Sales Manager"
+  }, 
+  {
+   "role": "Maintenance User"
+  }, 
+  {
+   "role": "Accounts User"
+  }, 
+  {
+   "role": "Stock User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.py b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.py
new file mode 100644
index 0000000..b1d89cc
--- /dev/null
+++ b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.selling.report.sales_partner_target_variance_based_on_item_group.item_group_wise_sales_target_variance import get_data_column
+
+def execute(filters=None):
+	data = []
+
+	return get_data_column(filters, "Territory")
diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js
deleted file mode 100644
index 55a13d9..0000000
--- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
-frappe.query_reports["Territory Target Variance Item Group-Wise"] = {
-	"filters": [
-		{
-			fieldname: "fiscal_year",
-			label: __("Fiscal Year"),
-			fieldtype: "Link",
-			options: "Fiscal Year",
-			default: frappe.sys_defaults.fiscal_year
-		},
-		{
-			fieldname: "period",
-			label: __("Period"),
-			fieldtype: "Select",
-			options: [
-				{ "value": "Monthly", "label": __("Monthly") },
-				{ "value": "Quarterly", "label": __("Quarterly") },
-				{ "value": "Half-Yearly", "label": __("Half-Yearly") },
-				{ "value": "Yearly", "label": __("Yearly") }
-			],
-			default: "Monthly"
-		},
-		{
-			fieldname: "target_on",
-			label: __("Target On"),
-			fieldtype: "Select",
-			options: "Quantity\nAmount",
-			default: "Quantity"
-		},
-	]
-}
diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json
deleted file mode 100644
index 2cb548f..0000000
--- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2013-06-21 12:15:00", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 3, 
- "is_standard": "Yes", 
- "modified": "2017-02-24 20:13:29.705321", 
- "modified_by": "Administrator", 
- "module": "Selling", 
- "name": "Territory Target Variance Item Group-Wise", 
- "owner": "Administrator", 
- "ref_doctype": "Sales Order", 
- "report_name": "Territory Target Variance Item Group-Wise", 
- "report_type": "Script Report", 
- "roles": [
-  {
-   "role": "Sales User"
-  }, 
-  {
-   "role": "Sales Manager"
-  }, 
-  {
-   "role": "Maintenance User"
-  }, 
-  {
-   "role": "Accounts User"
-  }, 
-  {
-   "role": "Stock User"
-  }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
deleted file mode 100644
index 7caed9b..0000000
--- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _, msgprint
-from frappe.utils import flt
-from erpnext.accounts.utils import get_fiscal_year
-from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
-
-def execute(filters=None):
-	if not filters: filters = {}
-
-	columns = get_columns(filters)
-	period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
-	territory_item_group_dict = get_territory_item_month_map(filters)
-
-	data = []
-	for territory, territory_items in territory_item_group_dict.items():
-		for item_group, monthwise_data in territory_items.items():
-			row = [territory, item_group]
-			totals = [0, 0, 0]
-			for relevant_months in period_month_ranges:
-				period_data = [0, 0, 0]
-				for month in relevant_months:
-					month_data = monthwise_data.get(month, {})
-					for i, fieldname in enumerate(["target", "achieved", "variance"]):
-						value = flt(month_data.get(fieldname))
-						period_data[i] += value
-						totals[i] += value
-				period_data[2] = period_data[0] - period_data[1]
-				row += period_data
-			totals[2] = totals[0] - totals[1]
-			row += totals
-			data.append(row)
-
-	return columns, sorted(data, key=lambda x: (x[0], x[1]))
-
-def get_columns(filters):
-	for fieldname in ["fiscal_year", "period", "target_on"]:
-		if not filters.get(fieldname):
-			label = (" ".join(fieldname.split("_"))).title()
-			msgprint(_("Please specify") + ": " + label, raise_exception=True)
-
-	columns = [_("Territory") + ":Link/Territory:120", _("Item Group") + ":Link/Item Group:120"]
-
-	group_months = False if filters["period"] == "Monthly" else True
-
-	for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
-		for label in [_("Target") +" (%s)", _("Achieved") + " (%s)", _("Variance") + " (%s)"]:
-			if group_months:
-				label = label % (_(from_date.strftime("%b")) + " - " + _(to_date.strftime("%b")))
-			else:
-				label = label % _(from_date.strftime("%b"))
-			columns.append(label+":Float:120")
-
-	return columns + [_("Total Target") + ":Float:120", _("Total Achieved") + ":Float:120",
-		_("Total Variance") + ":Float:120"]
-
-#Get territory & item group details
-def get_territory_details(filters):
-	return frappe.db.sql("""
-		select
-			t.name, td.item_group, td.target_qty, td.target_amount, t.distribution_id
-		from
-			`tabTerritory` t, `tabTarget Detail` td
-		where
-			td.parent=t.name and td.fiscal_year=%s order by t.name
-		""", (filters["fiscal_year"]), as_dict=1)
-
-#Get target distribution details of item group
-def get_target_distribution_details(filters):
-	target_details = {}
-
-	for d in frappe.db.sql("""
-		select
-			md.name, mdp.month, mdp.percentage_allocation
-		from
-			`tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
-		where
-			mdp.parent=md.name and md.fiscal_year=%s
-		""", (filters["fiscal_year"]), as_dict=1):
-			target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
-
-	return target_details
-
-#Get achieved details from sales order
-def get_achieved_details(filters, territory, item_groups):
-	start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
-
-	lft, rgt = frappe.db.get_value("Territory", territory, ["lft", "rgt"])
-
-	item_details = frappe.db.sql("""
-		select
-			soi.item_code, sum(soi.stock_qty) as qty, sum(soi.base_net_amount) as amount,
-			MONTHNAME(so.transaction_date) as month_name
-		from
-			`tabSales Order Item` soi, `tabSales Order` so
-		where
-			soi.parent=so.name and so.docstatus=1
-			and so.transaction_date>=%s and so.transaction_date<=%s
-			and exists(select name from `tabTerritory` where lft >=%s and rgt <= %s and name=so.territory)
-		group by
-			month_name, item_code
-		""", (start_date, end_date, lft, rgt), as_dict=1)
-
-	item_actual_details = {}
-	for d in item_details:
-		item_group = item_groups[d.item_code]
-		item_actual_details.setdefault(item_group, frappe._dict())\
-			.setdefault(d.month_name, frappe._dict({
-				"quantity": 0,
-				"amount": 0
-			}))
-
-		value_dict = item_actual_details[item_group][d.month_name]
-		value_dict.quantity += flt(d.qty)
-		value_dict.amount += flt(d.amount)
-
-	return item_actual_details
-
-def get_territory_item_month_map(filters):
-	import datetime
-	territory_details = get_territory_details(filters)
-	tdd = get_target_distribution_details(filters)
-	item_groups = get_item_groups()
-
-	territory_item_group_dict = {}
-
-	for td in territory_details:
-		achieved_details = get_achieved_details(filters, td.name, item_groups)
-
-		for month_id in range(1, 13):
-			month = datetime.date(2013, month_id, 1).strftime('%B')
-
-			territory_item_group_dict.setdefault(td.name, {}).setdefault(td.item_group, {})\
-				.setdefault(month, frappe._dict({
-					"target": 0.0, "achieved": 0.0
-				}))
-
-			target_achieved = territory_item_group_dict[td.name][td.item_group][month]
-			month_percentage = tdd.get(td.distribution_id, {}).get(month, 0) \
-				if td.distribution_id else 100.0/12
-
-
-			if (filters["target_on"] == "Quantity"):
-				target_achieved.target = flt(td.target_qty) * month_percentage / 100
-			else:
-				target_achieved.target = flt(td.target_amount) * month_percentage / 100
-
-			target_achieved.achieved = achieved_details.get(td.item_group, {}).get(month, {})\
-				.get(filters["target_on"].lower())
-
-	return territory_item_group_dict
-
-def get_item_groups():
-	return dict(frappe.get_all("Item", fields=["name", "item_group"], as_list=1))
diff --git a/erpnext/setup/doctype/brand/brand.json b/erpnext/setup/doctype/brand/brand.json
index 920c9cf..a8f0674 100644
--- a/erpnext/setup/doctype/brand/brand.json
+++ b/erpnext/setup/doctype/brand/brand.json
@@ -15,7 +15,7 @@
  "fields": [
   {
    "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
+   "allow_in_quick_entry": 1, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -79,6 +79,71 @@
    "translatable": 0, 
    "unique": 0, 
    "width": "300px"
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "defaults", 
+   "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": "Defaults", 
+   "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": "brand_defaults", 
+   "fieldtype": "Table", 
+   "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": "Brand Defaults", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Item Default", 
+   "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
   }
  ], 
  "has_web_view": 0, 
@@ -92,7 +157,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2019-01-07 16:52:05.945810", 
+ "modified": "2018-10-23 23:18:06.067612", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Brand", 
@@ -202,4 +267,4 @@
  "track_changes": 0, 
  "track_seen": 0, 
  "track_views": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/setup/doctype/brand/brand.py b/erpnext/setup/doctype/brand/brand.py
index d90aa5a..12839d1 100644
--- a/erpnext/setup/doctype/brand/brand.py
+++ b/erpnext/setup/doctype/brand/brand.py
@@ -3,8 +3,22 @@
 
 from __future__ import unicode_literals
 import frappe
+import copy
 
 from frappe.model.document import Document
 
 class Brand(Document):
-	pass
\ No newline at end of file
+	pass
+
+def get_brand_defaults(item, company):
+	item = frappe.get_cached_doc("Item", item)
+	if item.brand:
+		brand = frappe.get_cached_doc("Brand", item.brand)
+
+		for d in brand.brand_defaults or []:
+			if d.company == company:
+				row = copy.deepcopy(d.as_dict())
+				row.pop("name")
+				return row
+
+	return frappe._dict()
\ No newline at end of file
diff --git a/erpnext/setup/doctype/brand/test_records.json b/erpnext/setup/doctype/brand/test_records.json
index d2a4ad4..17b5a6b 100644
--- a/erpnext/setup/doctype/brand/test_records.json
+++ b/erpnext/setup/doctype/brand/test_records.json
@@ -2,5 +2,16 @@
  {
   "brand": "_Test Brand", 
   "doctype": "Brand"
+ },
+ {
+  "brand": "_Test Brand With Item Defaults",
+  "doctype": "Brand",
+  "brand_defaults": [{
+    "company": "_Test Company",
+    "expense_account": "_Test Account Cost for Goods Sold - _TC",
+    "income_account": "_Test Account Sales - _TC",
+    "buying_cost_center": "_Test Cost Center - _TC",
+    "selling_cost_center": "_Test Cost Center - _TC"
+  }]
  }
 ]
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index bff8988..4ac11c0 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -16,6 +16,12 @@
 				filters: {"is_additional_component": 1}
 			}
 		});
+
+		frm.set_query("parent_company", function() {
+			return {
+				filters: {"is_group": 1}
+			}
+		});
 	},
 
 	company_name: function(frm) {
@@ -28,6 +34,13 @@
 		}
 	},
 
+	parent_company: function(frm) {
+		var bool = frm.doc.parent_company ? true : false;
+		frm.set_value('create_chart_of_accounts_based_on', bool ? "Existing Company" : "");
+		frm.set_value('existing_company', bool ? frm.doc.parent_company : "");
+		disbale_coa_fields(frm, bool);
+	},
+
 	date_of_commencement: function(frm) {
 		if(frm.doc.date_of_commencement<frm.doc.date_of_incorporation)
 		{
@@ -39,8 +52,10 @@
 	},
 
 	refresh: function(frm) {
-		if(frm.doc.abbr && !frm.doc.__islocal) {
-			frm.set_df_property("abbr", "read_only", 1);
+		if(!frm.doc.__islocal) {
+			frm.doc.abbr && frm.set_df_property("abbr", "read_only", 1);
+			frm.set_df_property("parent_company", "read_only", 1);
+			disbale_coa_fields(frm);
 		}
 
 		frm.toggle_display('address_html', !frm.doc.__islocal);
@@ -256,3 +271,10 @@
 		}
 	});
 }
+
+var disbale_coa_fields = function(frm, bool=true) {
+	frm.set_df_property("create_chart_of_accounts_based_on", "read_only", bool);
+	frm.set_df_property("chart_of_accounts", "read_only", bool);
+	frm.set_df_property("existing_company", "read_only", bool);
+}
+
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 9949ae4..52c9c5a 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -39,6 +39,7 @@
 		self.validate_coa_input()
 		self.validate_perpetual_inventory()
 		self.check_country_change()
+		self.set_chart_of_accounts()
 
 	def validate_abbr(self):
 		if not self.abbr:
@@ -96,8 +97,6 @@
 			install_country_fixtures(self.name)
 			self.create_default_tax_template()
 
-
-
 		if not frappe.db.get_value("Department", {"company": self.name}):
 			from erpnext.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures
 			install_post_company_fixtures(frappe._dict({'company_name': self.name}))
@@ -141,6 +140,7 @@
 
 	def create_default_accounts(self):
 		from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
+		frappe.local.flags.ignore_root_company_validation = True
 		create_charts(self.name, self.chart_of_accounts, self.existing_company)
 
 		frappe.db.set(self, "default_receivable_account", frappe.db.get_value("Account",
@@ -173,6 +173,12 @@
 			self.country != frappe.get_cached_value('Company',  self.name,  'country'):
 			frappe.flags.country_change = True
 
+	def set_chart_of_accounts(self):
+		''' If parent company is set, chart of accounts will be based on that company '''
+		if self.parent_company:
+			self.create_chart_of_accounts_based_on = "Existing Company"
+			self.existing_company = self.parent_company
+
 	def set_default_accounts(self):
 		self._set_default_account("default_cash_account", "Cash")
 		self._set_default_account("default_bank_account", "Bank")
@@ -327,6 +333,11 @@
 			where doctype='Global Defaults' and field='default_company'
 			and value=%s""", self.name)
 
+		# reset default company
+		frappe.db.sql("""update `tabSingles` set value=""
+			where doctype='Chart of Accounts Importer' and field='company'
+			and value=%s""", self.name)
+
 		# delete BOMs
 		boms = frappe.db.sql_list("select name from tabBOM where company=%s", self.name)
 		if boms:
diff --git a/erpnext/setup/doctype/company/test_records.json b/erpnext/setup/doctype/company/test_records.json
index 7e26ca3..58d8b5c 100644
--- a/erpnext/setup/doctype/company/test_records.json
+++ b/erpnext/setup/doctype/company/test_records.json
@@ -1,32 +1,66 @@
 [
- {
-  "abbr": "_TC",
-  "company_name": "_Test Company",
-  "country": "India",
-  "default_currency": "INR",
-  "doctype": "Company",
-  "domain": "Manufacturing",
-  "chart_of_accounts": "Standard",
-  "default_holiday_list": "_Test Holiday List"
- },
- {
-  "abbr": "_TC1",
-  "company_name": "_Test Company 1",
-  "country": "United States",
-  "default_currency": "USD",
-  "doctype": "Company",
-  "domain": "Retail",
-  "chart_of_accounts": "Standard",
-  "default_holiday_list": "_Test Holiday List"
- },
- {
-  "abbr": "_TC2",
-  "company_name": "_Test Company 2",
-  "default_currency": "EUR",
-  "country": "Germany",
-  "doctype": "Company",
-  "domain": "Retail",
-  "chart_of_accounts": "Standard",
-  "default_holiday_list": "_Test Holiday List"
- }
+	{
+		"abbr": "_TC",
+		"company_name": "_Test Company",
+		"country": "India",
+		"default_currency": "INR",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC1",
+		"company_name": "_Test Company 1",
+		"country": "United States",
+		"default_currency": "USD",
+		"doctype": "Company",
+		"domain": "Retail",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC2",
+		"company_name": "_Test Company 2",
+		"default_currency": "EUR",
+		"country": "Germany",
+		"doctype": "Company",
+		"domain": "Retail",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC3",
+		"company_name": "_Test Company 3",
+		"is_group": 1,
+		"country": "India",
+		"default_currency": "INR",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC4",
+		"company_name": "_Test Company 4",
+		"parent_company": "_Test Company 3",
+		"is_group": 1,
+		"country": "India",
+		"default_currency": "INR",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC5",
+		"company_name": "_Test Company 5",
+		"parent_company": "_Test Company 4",
+		"country": "India",
+		"default_currency": "INR",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List"
+	}
 ]
diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js
index 30c2c91..7164add 100644
--- a/erpnext/setup/doctype/sales_partner/sales_partner.js
+++ b/erpnext/setup/doctype/sales_partner/sales_partner.js
@@ -13,5 +13,16 @@
 			unhide_field(['address_html', 'contact_html', 'address_contacts']);
 			frappe.contacts.render_address_and_contact(frm);
 		}
+	},
+
+	setup: function(frm) {
+		frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
+			var row = locals[cdt][cdn];
+			return {
+				filters: {
+					'fiscal_year': row.fiscal_year
+				}
+			}
+		};
 	}
 });
diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.json b/erpnext/setup/doctype/sales_partner/sales_partner.json
index 351aba2..28cdd3e 100644
--- a/erpnext/setup/doctype/sales_partner/sales_partner.json
+++ b/erpnext/setup/doctype/sales_partner/sales_partner.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
  "allow_guest_to_view": 0, 
  "allow_import": 1, 
  "allow_rename": 1, 
@@ -21,6 +22,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "partner_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -45,7 +47,7 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "translatable": 0, 
-   "unique": 0
+   "unique": 1
   }, 
   {
    "allow_bulk_edit": 0, 
@@ -54,6 +56,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "partner_type", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -89,6 +92,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "territory", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -121,6 +125,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break0", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -153,6 +158,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "commission_rate", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -186,6 +192,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "address_contacts", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -218,6 +225,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.__islocal", 
+   "fetch_if_empty": 0, 
    "fieldname": "address_desc", 
    "fieldtype": "HTML", 
    "hidden": 0, 
@@ -249,6 +257,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "address_html", 
    "fieldtype": "HTML", 
    "hidden": 0, 
@@ -280,6 +289,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -311,6 +321,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "eval:doc.__islocal", 
+   "fetch_if_empty": 0, 
    "fieldname": "contact_desc", 
    "fieldtype": "HTML", 
    "hidden": 0, 
@@ -342,6 +353,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "contact_html", 
    "fieldtype": "HTML", 
    "hidden": 0, 
@@ -373,6 +385,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "partner_target_details_section_break", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -405,6 +418,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "targets", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -439,41 +453,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "description": "Select Monthly Distribution to unevenly distribute targets across months.", 
-   "fieldname": "distribution_id", 
-   "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": "Target Distribution", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "distribution_id", 
-   "oldfieldtype": "Link", 
-   "options": "Monthly Distribution", 
-   "permlevel": 0, 
-   "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, 
+   "fetch_if_empty": 0, 
    "fieldname": "website", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -505,6 +485,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "show_in_website", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -537,6 +518,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "show_in_website", 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_17", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -567,6 +549,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "route", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -599,6 +582,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "column_break_20", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -629,6 +613,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "logo", 
    "fieldtype": "Attach", 
    "hidden": 0, 
@@ -661,6 +646,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "partner_website", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -693,6 +679,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "depends_on": "show_in_website", 
+   "fetch_if_empty": 0, 
    "fieldname": "section_break_22", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -723,6 +710,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "introduction", 
    "fieldtype": "Text", 
    "hidden": 0, 
@@ -754,6 +742,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "description", 
    "fieldtype": "Text Editor", 
    "hidden": 0, 
@@ -790,7 +779,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-06-11 13:47:04.182339", 
+ "modified": "2019-03-21 16:26:45.447265", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Sales Partner", 
@@ -860,5 +849,6 @@
  "show_name_in_global_search": 1, 
  "sort_order": "ASC", 
  "track_changes": 0, 
- "track_seen": 0
+ "track_seen": 0, 
+ "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_person/sales_person.js b/erpnext/setup/doctype/sales_person/sales_person.js
index 584f879..9ff37fa 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.js
+++ b/erpnext/setup/doctype/sales_person/sales_person.js
@@ -8,6 +8,17 @@
 			frm.dashboard.add_indicator(__('Total Contribution Amount: {0}',
 				[format_currency(info.allocated_amount, info.currency)]), 'blue');
 		}
+	},
+
+	setup: function(frm) {
+		frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
+			var row = locals[cdt][cdn];
+			return {
+				filters: {
+					'fiscal_year': row.fiscal_year
+				}
+			}
+		};
 	}
 });
 
diff --git a/erpnext/setup/doctype/sales_person/sales_person.json b/erpnext/setup/doctype/sales_person/sales_person.json
index 73f7623..5a32028 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.json
+++ b/erpnext/setup/doctype/sales_person/sales_person.json
@@ -22,6 +22,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "name_and_employee_id", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -54,6 +55,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "sales_person_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -88,6 +90,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "Select company name first.", 
+   "fetch_if_empty": 0, 
    "fieldname": "parent_sales_person", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -122,6 +125,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "commission_rate", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -154,6 +158,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "is_group", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -189,6 +194,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "default": "1", 
+   "fetch_if_empty": 0, 
    "fieldname": "enabled", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -221,6 +227,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "cb0", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -251,6 +258,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "employee", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -284,6 +292,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "fetch_from": "employee.department", 
+   "fetch_if_empty": 0, 
    "fieldname": "department", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -317,6 +326,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "lft", 
    "fieldtype": "Int", 
    "hidden": 1, 
@@ -350,6 +360,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "rgt", 
    "fieldtype": "Int", 
    "hidden": 1, 
@@ -383,6 +394,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "old_parent", 
    "fieldtype": "Data", 
    "hidden": 1, 
@@ -417,6 +429,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "Set targets Item Group-wise for this Sales Person.", 
+   "fetch_if_empty": 0, 
    "fieldname": "target_details_section_break", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -450,6 +463,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "targets", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -476,41 +490,6 @@
    "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, 
-   "description": "Select Monthly Distribution to unevenly distribute targets across months.", 
-   "fieldname": "distribution_id", 
-   "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": "Target Distribution", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "distribution_id", 
-   "oldfieldtype": "Link", 
-   "options": "Monthly Distribution", 
-   "permlevel": 0, 
-   "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
   }
  ], 
  "has_web_view": 0, 
@@ -524,7 +503,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2019-01-30 11:28:16.966735", 
+ "modified": "2019-03-21 16:26:01.706129", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Sales Person", 
diff --git a/erpnext/setup/doctype/target_detail/target_detail.json b/erpnext/setup/doctype/target_detail/target_detail.json
index 55d437c..768cf9f 100644
--- a/erpnext/setup/doctype/target_detail/target_detail.json
+++ b/erpnext/setup/doctype/target_detail/target_detail.json
@@ -19,6 +19,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "description": "", 
+   "fetch_if_empty": 0, 
    "fieldname": "item_group", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -53,6 +54,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "fiscal_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -87,6 +89,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "target_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -120,6 +123,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fetch_if_empty": 0, 
    "fieldname": "target_amount", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -145,6 +149,40 @@
    "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, 
+   "fetch_if_empty": 0, 
+   "fieldname": "distribution_id", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Target Distribution", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Monthly Distribution", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
+   "unique": 0
   }
  ], 
  "has_web_view": 0, 
@@ -157,7 +195,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2019-01-07 16:56:48.179709", 
+ "modified": "2019-03-20 16:59:03.578274", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Target Detail", 
diff --git a/erpnext/setup/doctype/territory/territory.js b/erpnext/setup/doctype/territory/territory.js
index 69f761a..1eb9958 100644
--- a/erpnext/setup/doctype/territory/territory.js
+++ b/erpnext/setup/doctype/territory/territory.js
@@ -1,6 +1,18 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
+frappe.ui.form.on("Territory", {
+	setup: function(frm) {
+		frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
+			var row = locals[cdt][cdn];
+			return {
+				filters: {
+					'fiscal_year': row.fiscal_year
+				}
+			}
+		};
+	}
+});
 
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 	cur_frm.cscript.set_root_readonly(doc);
diff --git a/erpnext/setup/doctype/territory/territory.json b/erpnext/setup/doctype/territory/territory.json
index 38d0e0f..beadb48 100644
--- a/erpnext/setup/doctype/territory/territory.json
+++ b/erpnext/setup/doctype/territory/territory.json
@@ -1,511 +1,487 @@
 {
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 1,
- "allow_rename": 1,
- "autoname": "field:territory_name",
- "beta": 0,
- "creation": "2013-01-10 16:34:24",
- "custom": 0,
- "description": "Classification of Customers by region",
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Setup",
- "editable_grid": 0,
+ "allow_copy": 0, 
+ "allow_events_in_timeline": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 1, 
+ "allow_rename": 1, 
+ "autoname": "field:territory_name", 
+ "beta": 0, 
+ "creation": "2013-01-10 16:34:24", 
+ "custom": 0, 
+ "description": "Classification of Customers by region", 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Setup", 
+ "editable_grid": 0, 
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "territory_name",
-   "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Territory Name",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "territory_name",
-   "oldfieldtype": "Data",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "territory_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Territory Name", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "territory_name", 
+   "oldfieldtype": "Data", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 1
-  },
+  }, 
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "",
-   "fieldname": "parent_territory",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Parent Territory",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "parent_territory",
-   "oldfieldtype": "Link",
-   "options": "Territory",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 1, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "", 
+   "fetch_if_empty": 0, 
+   "fieldname": "parent_territory", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 1, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Parent Territory", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "parent_territory", 
+   "oldfieldtype": "Link", 
+   "options": "Territory", 
+   "permlevel": 0, 
+   "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": 1,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "",
-   "fieldname": "is_group",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Is Group",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "is_group",
-   "oldfieldtype": "Select",
-   "options": "",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 1, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "", 
+   "fetch_if_empty": 0, 
+   "fieldname": "is_group", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Is Group", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "is_group", 
+   "oldfieldtype": "Select", 
+   "options": "", 
+   "permlevel": 0, 
+   "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": "cb0",
-   "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,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "cb0", 
+   "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, 
+   "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,
-   "description": "For reference",
-   "fieldname": "territory_manager",
-   "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Territory Manager",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "territory_manager",
-   "oldfieldtype": "Link",
-   "options": "Sales Person",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "For reference", 
+   "fetch_if_empty": 0, 
+   "fieldname": "territory_manager", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Territory Manager", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "territory_manager", 
+   "oldfieldtype": "Link", 
+   "options": "Sales Person", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 1, 
+   "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": "lft",
-   "fieldtype": "Int",
-   "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "lft",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "lft",
-   "oldfieldtype": "Int",
-   "permlevel": 0,
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "lft", 
+   "fieldtype": "Int", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "lft", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "lft", 
+   "oldfieldtype": "Int", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 1, 
+   "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": "rgt",
-   "fieldtype": "Int",
-   "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "rgt",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "rgt",
-   "oldfieldtype": "Int",
-   "permlevel": 0,
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "rgt", 
+   "fieldtype": "Int", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "rgt", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "rgt", 
+   "oldfieldtype": "Int", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 1, 
+   "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,
-   "description": "",
-   "fieldname": "old_parent",
-   "fieldtype": "Link",
-   "hidden": 1,
-   "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "old_parent",
-   "length": 0,
-   "no_copy": 1,
-   "oldfieldname": "old_parent",
-   "oldfieldtype": "Data",
-   "options": "Territory",
-   "permlevel": 0,
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "", 
+   "fetch_if_empty": 0, 
+   "fieldname": "old_parent", 
+   "fieldtype": "Link", 
+   "hidden": 1, 
+   "ignore_user_permissions": 1, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "old_parent", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "old_parent", 
+   "oldfieldtype": "Data", 
+   "options": "Territory", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 1, 
+   "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,
-   "description": "Set Item Group-wise budgets on this Territory. You can also include seasonality by setting the Distribution.",
-   "fieldname": "target_details_section_break",
-   "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": "Territory Targets",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldtype": "Section Break",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Set Item Group-wise budgets on this Territory. You can also include seasonality by setting the Distribution.", 
+   "fetch_if_empty": 0, 
+   "fieldname": "target_details_section_break", 
+   "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": "Territory Targets", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldtype": "Section Break", 
+   "permlevel": 0, 
+   "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": "targets",
-   "fieldtype": "Table",
-   "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": "Targets",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "target_details",
-   "oldfieldtype": "Table",
-   "options": "Target Detail",
-   "permlevel": 0,
-   "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,
-   "description": "Select Monthly Distribution to unevenly distribute targets across months.",
-   "fieldname": "distribution_id",
-   "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": "Target Distribution",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldname": "distribution_id",
-   "oldfieldtype": "Link",
-   "options": "Monthly Distribution",
-   "permlevel": 0,
-   "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,
+   "allow_bulk_edit": 0, 
+   "allow_in_quick_entry": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fetch_if_empty": 0, 
+   "fieldname": "targets", 
+   "fieldtype": "Table", 
+   "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": "Targets", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "target_details", 
+   "oldfieldtype": "Table", 
+   "options": "Target Detail", 
+   "permlevel": 0, 
+   "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
   }
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "fa fa-map-marker",
- "idx": 1,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-08-29 06:26:38.918259",
- "modified_by": "Administrator",
- "module": "Setup",
- "name": "Territory",
- "name_case": "Title Case",
- "owner": "Administrator",
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "icon": "fa fa-map-marker", 
+ "idx": 1, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2019-03-21 16:26:58.581431", 
+ "modified_by": "Administrator", 
+ "module": "Setup", 
+ "name": "Territory", 
+ "name_case": "Title Case", 
+ "owner": "Administrator", 
  "permissions": [
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 1,
-   "delete": 1,
-   "email": 1,
-   "export": 1,
-   "if_owner": 0,
-   "import": 1,
-   "permlevel": 0,
-   "print": 1,
-   "read": 1,
-   "report": 1,
-   "role": "Sales Master Manager",
-   "set_user_permissions": 1,
-   "share": 1,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 1, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Sales Master Manager", 
+   "set_user_permissions": 1, 
+   "share": 1, 
+   "submit": 0, 
    "write": 1
-  },
+  }, 
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
-   "email": 1,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 1,
-   "read": 1,
-   "report": 1,
-   "role": "Sales Manager",
-   "set_user_permissions": 0,
-   "share": 0,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Sales Manager", 
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
    "write": 0
-  },
+  }, 
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
-   "email": 1,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 1,
-   "read": 1,
-   "report": 1,
-   "role": "Sales User",
-   "set_user_permissions": 0,
-   "share": 0,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Sales User", 
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
    "write": 0
-  },
+  }, 
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
-   "email": 0,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 0,
-   "read": 1,
-   "report": 0,
-   "role": "Stock User",
-   "set_user_permissions": 0,
-   "share": 0,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 0, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 0, 
+   "read": 1, 
+   "report": 0, 
+   "role": "Stock User", 
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
    "write": 0
-  },
+  }, 
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
-   "email": 0,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
-   "print": 0,
-   "read": 1,
-   "report": 0,
-   "role": "Maintenance User",
-   "set_user_permissions": 0,
-   "share": 0,
-   "submit": 0,
+   "amend": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 0, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 0, 
+   "read": 1, 
+   "report": 0, 
+   "role": "Maintenance User", 
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
    "write": 0
   }
- ],
- "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
- "search_fields": "parent_territory,territory_manager",
- "show_name_in_global_search": 1,
- "sort_order": "DESC",
- "track_changes": 0,
- "track_seen": 0,
+ ], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "search_fields": "parent_territory,territory_manager", 
+ "show_name_in_global_search": 1, 
+ "sort_order": "DESC", 
+ "track_changes": 0, 
+ "track_seen": 0, 
  "track_views": 0
 }
\ No newline at end of file
diff --git a/erpnext/stock/__init__.py b/erpnext/stock/__init__.py
index ea3d103..32a03e7 100644
--- a/erpnext/stock/__init__.py
+++ b/erpnext/stock/__init__.py
@@ -8,16 +8,21 @@
 	{"doctype":"Role", "role_name":"Stock User", "name":"Stock User"},
 	{"doctype":"Role", "role_name":"Quality Manager", "name":"Quality Manager"},
 	{"doctype":"Item Group", "item_group_name":"All Item Groups", "is_group": 1},
-	{"doctype":"Item Group", "item_group_name":"Default", 
+	{"doctype":"Item Group", "item_group_name":"Default",
 		"parent_item_group":"All Item Groups", "is_group": 0},
 ]
 
-def get_warehouse_account_map():
+def get_warehouse_account_map(company=None):
 	if not frappe.flags.warehouse_account_map or frappe.flags.in_test:
 		warehouse_account = frappe._dict()
 
+		filters = {}
+		if company:
+			filters['company'] = company
+
 		for d in frappe.get_all('Warehouse',
 			fields = ["name", "account", "parent_warehouse", "company"],
+			filters = filters,
 			order_by="lft, rgt"):
 			if not d.account:
 				d.account = get_warehouse_account(d, warehouse_account)
@@ -57,6 +62,6 @@
 		frappe.throw(_("Please set Account in Warehouse {0} or Default Inventory Account in Company {1}")
 			.format(warehouse.name, warehouse.company))
 	return account
-	
+
 def get_company_default_inventory_account(company):
 	return frappe.get_cached_value('Company',  company,  'default_inventory_account')
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 2dcecb9..73c009c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -86,7 +86,7 @@
 	def after_insert(self):
 		'''set opening stock and item price'''
 		if self.standard_rate:
-			for default in self.item_defaults:
+			for default in self.item_defaults or [frappe._dict()]:
 				self.add_price(default.default_price_list)
 
 		if self.opening_stock:
@@ -127,7 +127,6 @@
 		self.validate_retain_sample()
 		self.validate_uom_conversion_factor()
 		self.validate_item_defaults()
-		self.update_defaults_from_item_group()
 		self.validate_customer_provided_part()
 
 		if not self.get("__islocal"):
@@ -185,7 +184,7 @@
 		from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
 
 		# default warehouse, or Stores
-		for default in self.item_defaults:
+		for default in self.item_defaults or [frappe._dict({'company': frappe.defaults.get_defaults().company})]:
 			default_warehouse = (default.default_warehouse
 					or frappe.db.get_single_value('Stock Settings', 'default_warehouse')
 					or frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')}))
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index de702ff..1a94d5a 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -164,6 +164,61 @@
 			self.assertEqual(details.item_tax_template, data['item_tax_template'])
 			self.assertEqual(json.loads(details.item_tax_rate), expected_item_tax_map[details.item_tax_template])
 
+	def test_item_defaults(self):
+		frappe.delete_doc_if_exists("Item", "Test Item With Defaults", force=1)
+		make_item("Test Item With Defaults", {
+			"item_group": "_Test Item Group",
+			"brand": "_Test Brand With Item Defaults",
+			"item_defaults": [{
+				"company": "_Test Company",
+				"default_warehouse": "_Test Warehouse 2 - _TC",  # no override
+				"expense_account": "_Test Account Stock Expenses - _TC",  # override brand default
+				"buying_cost_center": "_Test Write Off Cost Center - _TC",  # override item group default
+			}]
+		})
+
+		sales_item_check = {
+			"item_code": "Test Item With Defaults",
+			"warehouse": "_Test Warehouse 2 - _TC",  # from item
+			"income_account": "_Test Account Sales - _TC",  # from brand
+			"expense_account": "_Test Account Stock Expenses - _TC",  # from item
+			"cost_center": "_Test Cost Center 2 - _TC",  # from item group
+		}
+		sales_item_details = get_item_details({
+			"item_code": "Test Item With Defaults",
+			"company": "_Test Company",
+			"price_list": "_Test Price List",
+			"currency": "_Test Currency",
+			"doctype": "Sales Invoice",
+			"conversion_rate": 1,
+			"price_list_currency": "_Test Currency",
+			"plc_conversion_rate": 1,
+			"customer": "_Test Customer",
+		})
+		for key, value in iteritems(sales_item_check):
+			self.assertEqual(value, sales_item_details.get(key))
+
+		purchase_item_check = {
+			"item_code": "Test Item With Defaults",
+			"warehouse": "_Test Warehouse 2 - _TC",  # from item
+			"expense_account": "_Test Account Stock Expenses - _TC",  # from item
+			"income_account": "_Test Account Sales - _TC",  # from brand
+			"cost_center": "_Test Write Off Cost Center - _TC"  # from item
+		}
+		purchase_item_details = get_item_details({
+			"item_code": "Test Item With Defaults",
+			"company": "_Test Company",
+			"price_list": "_Test Price List",
+			"currency": "_Test Currency",
+			"doctype": "Purchase Invoice",
+			"conversion_rate": 1,
+			"price_list_currency": "_Test Currency",
+			"plc_conversion_rate": 1,
+			"supplier": "_Test Supplier",
+		})
+		for key, value in iteritems(purchase_item_check):
+			self.assertEqual(value, purchase_item_details.get(key))
+
 	def test_item_attribute_change_after_variant(self):
 		frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)
 
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index a3c1e27..2ea121c 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -13,7 +13,7 @@
 from erpnext.accounts.utils import get_account_currency
 from frappe.desk.notifications import clear_doctype_notifications
 from erpnext.buying.utils import check_for_closed_status
-from erpnext.assets.doctype.asset.asset import get_asset_account
+from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_disabled
 from six import iteritems
 
 form_grid_templates = {
@@ -258,7 +258,8 @@
 					d.rejected_warehouse not in warehouse_with_no_account:
 						warehouse_with_no_account.append(d.warehouse)
 
-		self.get_asset_gl_entry(gl_entries)
+		if not is_cwip_accounting_disabled():
+			self.get_asset_gl_entry(gl_entries)
 		# Cost center-wise amount breakup for other charges included for valuation
 		valuation_tax = {}
 		for tax in self.get("taxes"):
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 3012d0b..1149c3d 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -10,6 +10,7 @@
 from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError, get_valuation_rate
 from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor, get_reserved_qty_for_so
 from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
+from erpnext.setup.doctype.brand.brand import get_brand_defaults
 from erpnext.stock.doctype.batch.batch import get_batch_no, set_batch_nos, get_batch_qty
 from erpnext.stock.doctype.item.item import get_item_defaults
 from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, add_additional_cost
@@ -636,6 +637,7 @@
 
 		item = item[0]
 		item_group_defaults = get_item_group_defaults(item.name, self.company)
+		brand_defaults = get_brand_defaults(item.name, self.company)
 
 		ret = frappe._dict({
 			'uom'			      	: item.stock_uom,
@@ -644,7 +646,7 @@
 			'image'				: item.image,
 			'item_name' 		  	: item.item_name,
 			'expense_account'		: args.get("expense_account"),
-			'cost_center'			: get_default_cost_center(args, item, item_group_defaults),
+			'cost_center'			: get_default_cost_center(args, item, item_group_defaults, brand_defaults),
 			'qty'				: args.get("qty"),
 			'transfer_qty'			: args.get('qty'),
 			'conversion_factor'		: 1,
@@ -806,7 +808,7 @@
 
 		# item dict = { item_code: {qty, description, stock_uom} }
 		item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty,
-			fetch_exploded = self.use_multi_level_bom)
+			fetch_exploded = self.use_multi_level_bom, fetch_qty_in_stock_uom=False)
 
 		used_alternative_items = get_used_alternative_items(work_order = self.work_order)
 		for item in itervalues(item_dict):
@@ -1035,7 +1037,7 @@
 			se_child.item_code = item_dict[d].get('item_code') or cstr(d)
 			se_child.item_name = item_dict[d]["item_name"]
 			se_child.description = item_dict[d]["description"]
-			se_child.uom = stock_uom
+			se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom
 			se_child.stock_uom = stock_uom
 			se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
 			se_child.expense_account = item_dict[d].get("expense_account") or expense_account
@@ -1053,8 +1055,9 @@
 				se_child.t_warehouse = self.to_warehouse
 
 			# in stock uom
-			se_child.transfer_qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
-			se_child.conversion_factor = 1.00
+			se_child.conversion_factor = flt(item_dict[d].get("conversion_factor")) or 1
+			se_child.transfer_qty = flt(item_dict[d]["qty"]*se_child.conversion_factor, se_child.precision("qty"))
+
 
 			# to be assigned for finished item
 			se_child.bom_no = bom_no
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index d8e78c8..6d75314 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -13,6 +13,7 @@
 from erpnext import get_company_currency
 from erpnext.stock.doctype.item.item import get_item_defaults, get_uom_conv_factor
 from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
+from erpnext.setup.doctype.brand.brand import get_brand_defaults
 
 from six import string_types, iteritems
 
@@ -226,9 +227,10 @@
 
 	item_defaults = get_item_defaults(item.name, args.company)
 	item_group_defaults = get_item_group_defaults(item.name, args.company)
+	brand_defaults = get_brand_defaults(item.name, args.company)
 
 	warehouse = args.get("set_warehouse") or user_default_warehouse or item_defaults.get("default_warehouse") or\
-		item_group_defaults.get("default_warehouse") or args.warehouse
+		item_group_defaults.get("default_warehouse") or brand_defaults.get("default_warehouse") or args.warehouse
 
 	if args.get('doctype') == "Material Request" and not args.get('material_request_type'):
 		args['material_request_type'] = frappe.db.get_value('Material Request',
@@ -250,9 +252,9 @@
 		"description": cstr(item.description).strip(),
 		"image": cstr(item.image).strip(),
 		"warehouse": warehouse,
-		"income_account": get_default_income_account(args, item_defaults, item_group_defaults),
-		"expense_account": get_default_expense_account(args, item_defaults, item_group_defaults),
-		"cost_center": get_default_cost_center(args, item_defaults, item_group_defaults),
+		"income_account": get_default_income_account(args, item_defaults, item_group_defaults, brand_defaults),
+		"expense_account": get_default_expense_account(args, item_defaults, item_group_defaults, brand_defaults),
+		"cost_center": get_default_cost_center(args, item_defaults, item_group_defaults, brand_defaults),
 		'has_serial_no': item.has_serial_no,
 		'has_batch_no': item.has_batch_no,
 		"batch_no": None,
@@ -269,7 +271,7 @@
 		"net_rate": 0.0,
 		"net_amount": 0.0,
 		"discount_percentage": 0.0,
-		"supplier": get_default_supplier(args, item_defaults, item_group_defaults),
+		"supplier": get_default_supplier(args, item_defaults, item_group_defaults, brand_defaults),
 		"update_stock": args.get("update_stock") if args.get('doctype') in ['Sales Invoice', 'Purchase Invoice'] else 0,
 		"delivered_by_supplier": item.delivered_by_supplier if args.get("doctype") in ["Sales Order", "Sales Invoice"] else 0,
 		"is_fixed_asset": item.is_fixed_asset,
@@ -391,14 +393,16 @@
 
 	return deferred_detail
 
-def get_default_income_account(args, item, item_group):
+def get_default_income_account(args, item, item_group, brand):
 	return (item.get("income_account")
 		or item_group.get("income_account")
+		or brand.get("income_account")
 		or args.income_account)
 
-def get_default_expense_account(args, item, item_group):
+def get_default_expense_account(args, item, item_group, brand):
 	return (item.get("expense_account")
 		or item_group.get("expense_account")
+		or brand.get("expense_account")
 		or args.expense_account)
 
 def get_default_deferred_account(args, item, fieldname=None):
@@ -409,22 +413,23 @@
 	else:
 		return None
 
-def get_default_cost_center(args, item, item_group):
+def get_default_cost_center(args, item, item_group, brand):
 	cost_center = None
 	if args.get('project'):
 		cost_center = frappe.db.get_value("Project", args.get("project"), "cost_center", cache=True)
 
 	if not cost_center:
 		if args.get('customer'):
-			cost_center = item.get('selling_cost_center') or item_group.get('selling_cost_center')
+			cost_center = item.get('selling_cost_center') or item_group.get('selling_cost_center') or brand.get('selling_cost_center')
 		else:
-			cost_center = item.get('buying_cost_center') or item_group.get('buying_cost_center')
+			cost_center = item.get('buying_cost_center') or item_group.get('buying_cost_center') or brand.get('buying_cost_center')
 
 	return cost_center or args.get("cost_center")
 
-def get_default_supplier(args, item, item_group):
+def get_default_supplier(args, item, item_group, brand):
 	return (item.get("default_supplier")
-		or item_group.get("default_supplier"))
+		or item_group.get("default_supplier")
+		or brand.get("default_supplier"))
 
 def get_price_list_rate(args, item_doc, out):
 	meta = frappe.get_meta(args.parenttype or args.doctype)
@@ -899,10 +904,11 @@
 def get_valuation_rate(item_code, company, warehouse=None):
 	item = get_item_defaults(item_code, company)
 	item_group = get_item_group_defaults(item_code, company)
+	brand = get_brand_defaults(item_code, company)
 	# item = frappe.get_doc("Item", item_code)
 	if item.get("is_stock_item"):
 		if not warehouse:
-			warehouse = item.get("default_warehouse") or item_group.get("default_warehouse")
+			warehouse = item.get("default_warehouse") or item_group.get("default_warehouse") or brand.get("default_warehouse")
 
 		return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
 			["valuation_rate"], as_dict=True) or {"valuation_rate": 0}
diff --git a/erpnext/stock/report/total_stock_summary/total_stock_summary.js b/erpnext/stock/report/total_stock_summary/total_stock_summary.js
index 223a603..b7461c4 100644
--- a/erpnext/stock/report/total_stock_summary/total_stock_summary.js
+++ b/erpnext/stock/report/total_stock_summary/total_stock_summary.js
@@ -18,7 +18,9 @@
 			"label": __("Company"),
 			"fieldtype": "Link",
 			"width": "80",
-			"options": "Company"
+			"options": "Company",
+			"default": frappe.defaults.get_user_default("Company"),
+			"reqd": 1
 		},
 	]
 }
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index c89fc10..76631fa 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -56,7 +56,7 @@
 
 	if item_code:
 		values.append(item_code)
-		condition.append(" AND item_code = %s")
+		condition += " AND item_code = %s"
 
 	stock_ledger_entries = frappe.db.sql("""
 		SELECT item_code, stock_value, name, warehouse
diff --git a/erpnext/templates/pages/cart.py b/erpnext/templates/pages/cart.py
index c57d826..30b0357 100644
--- a/erpnext/templates/pages/cart.py
+++ b/erpnext/templates/pages/cart.py
@@ -3,7 +3,6 @@
 from __future__ import unicode_literals
 
 no_cache = 1
-no_sitemap = 1
 
 import frappe
 from erpnext.shopping_cart.cart import get_cart_quotation
diff --git a/erpnext/templates/pages/home.py b/erpnext/templates/pages/home.py
index 4b688b1..1c14450 100644
--- a/erpnext/templates/pages/home.py
+++ b/erpnext/templates/pages/home.py
@@ -5,7 +5,6 @@
 import frappe
 
 no_cache = 1
-no_sitemap = 1
 
 def get_context(context):
 	homepage = frappe.get_doc('Homepage')
diff --git a/erpnext/templates/pages/integrations/gocardless_checkout.py b/erpnext/templates/pages/integrations/gocardless_checkout.py
index 8d77245..e604b94 100644
--- a/erpnext/templates/pages/integrations/gocardless_checkout.py
+++ b/erpnext/templates/pages/integrations/gocardless_checkout.py
@@ -9,7 +9,6 @@
 from frappe.utils import get_url
 
 no_cache = 1
-no_sitemap = 1
 
 expected_keys = ('amount', 'title', 'description', 'reference_doctype', 'reference_docname',
 	'payer_name', 'payer_email', 'order_id', 'currency')
diff --git a/erpnext/templates/pages/integrations/gocardless_confirmation.py b/erpnext/templates/pages/integrations/gocardless_confirmation.py
index 697ed3c..cfaa1a1 100644
--- a/erpnext/templates/pages/integrations/gocardless_confirmation.py
+++ b/erpnext/templates/pages/integrations/gocardless_confirmation.py
@@ -6,7 +6,6 @@
 from erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings import gocardless_initialization, get_gateway_controller
 
 no_cache = 1
-no_sitemap = 1
 
 expected_keys = ('redirect_flow_id', 'reference_doctype', 'reference_docname')
 
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py
index c34001b..d0d72f0 100644
--- a/erpnext/templates/pages/product_search.py
+++ b/erpnext/templates/pages/product_search.py
@@ -8,7 +8,6 @@
 from erpnext.shopping_cart.product_info import set_product_info_for_website
 
 no_cache = 1
-no_sitemap = 1
 
 def get_context(context):
 	context.show_search = True
diff --git a/erpnext/www/all-products/index.py b/erpnext/www/all-products/index.py
index 8e2d268..0394e4b 100644
--- a/erpnext/www/all-products/index.py
+++ b/erpnext/www/all-products/index.py
@@ -2,6 +2,8 @@
 from erpnext.portal.product_configurator.utils import (get_products_for_website, get_product_settings,
 	get_field_filter_data, get_attribute_filter_data)
 
+sitemap = 1
+
 def get_context(context):
 
 	if frappe.form_dict: