Merge pull request #17809 from Alchez/develop-sales-analytics-total

fix(selling): Remove Totals row for Sales Analytics
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 01b935c..9a95e08 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -321,7 +321,7 @@
 def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None):
 	from erpnext.accounts.doctype.pricing_rule.utils import get_apply_on_and_items
 	for d in pricing_rules.split(','):
-		if not d: continue
+		if not d or not frappe.db.exists("Pricing Rule", d): continue
 		pricing_rule = frappe.get_doc('Pricing Rule', d)
 
 		if pricing_rule.price_or_product_discount == 'Price':
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index d3db130..8a8e329 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -480,10 +480,10 @@
 	rule_applied = {}
 
 	for item in doc.get("items"):
-		if not item.pricing_rules:
-			item.pricing_rules = item_row.pricing_rules
-
 		if item.get(apply_on) in items:
+			if not item.pricing_rules:
+				item.pricing_rules = item_row.pricing_rules
+
 			for field in ['discount_percentage', 'discount_amount', 'rate']:
 				if not pr_doc.get(field): continue
 
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index f277a8b..7127663 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -68,13 +68,13 @@
 
 		if self.filters.based_on_payment_terms:
 			columns.append({
-				"label": "Payment Term",
+				"label": _("Payment Term"),
 				"fieldname": "payment_term",
 				"fieldtype": "Data",
 				"width": 120
 			})
 			columns.append({
-				"label": "Invoice Grand Total",
+				"label": _("Invoice Grand Total"),
 				"fieldname": "invoice_grand_total",
 				"fieldtype": "Currency",
 				"options": "currency",
@@ -83,7 +83,7 @@
 
 		for label in ("Invoiced Amount", "Paid Amount", credit_or_debit_note, "Outstanding Amount"):
 			columns.append({
-				"label": label,
+				"label": _(label),
 				"fieldname": frappe.scrub(label),
 				"fieldtype": "Currency",
 				"options": "currency",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index e63ef60..1134b04 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -33,6 +33,14 @@
 				}
 			}
 		});
+
+		frm.set_query("expense_account", "items", function() {
+			return {
+				query: "erpnext.controllers.queries.get_expense_account",
+				filters: {'company': frm.doc.company}
+			}
+		});
+
 	},
 
 	refresh: function(frm) {
diff --git a/erpnext/config/getting_started.py b/erpnext/config/getting_started.py
index 19b71d2..fa84b1c 100644
--- a/erpnext/config/getting_started.py
+++ b/erpnext/config/getting_started.py
@@ -62,6 +62,13 @@
 				},
 				{
 					"type": "doctype",
+					"name": "Chart of Accounts Importer",
+					"labe": _("Chart Of Accounts Importer"),
+					"description": _("Import Chart Of Accounts from CSV / Excel files"),
+					"onboard": 1
+				},
+				{
+					"type": "doctype",
 					"name": "Letter Head",
 					"description": _("Letter Heads for print templates."),
 					"onboard": 1,
diff --git a/erpnext/public/js/payment/pos_payment.html b/erpnext/public/js/payment/pos_payment.html
index 185d748..cb6971b 100644
--- a/erpnext/public/js/payment/pos_payment.html
+++ b/erpnext/public/js/payment/pos_payment.html
@@ -21,7 +21,7 @@
 	<hr>
 	<div class="row">
 		<div class="col-sm-6 ">
-			<div class ="row multimode-payments">
+			<div class ="row multimode-payments" style = "margin-right:10px">
 			</div>
 		</div>
 		<div class="col-sm-6 payment-toolbar">
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 70c39ec..2151364 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -10,7 +10,7 @@
 		frm.custom_make_buttons = {
 			'Stock Entry': 'Return',
 			'Purchase Invoice': 'Invoice'
-		}
+		};
 
 		frm.set_query("asset", "items", function() {
 			return {
@@ -18,7 +18,15 @@
 					"purchase_receipt": frm.doc.name
 				}
 			}
-		})
+		});
+
+		frm.set_query("expense_account", "items", function() {
+			return {
+				query: "erpnext.controllers.queries.get_expense_account",
+				filters: {'company': frm.doc.company}
+			}
+		});
+
 	},
 	onload: function(frm) {
 		erpnext.queries.setup_queries(frm, "Warehouse", function() {
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index b3e75ac..7c6ed1a 100644
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -4,6 +4,7 @@
  "doctype": "DocType",
  "document_type": "Document",
  "editable_grid": 1,
+ "engine": "InnoDB",
  "field_order": [
   "barcode",
   "section_break_2",
@@ -80,6 +81,7 @@
   "rejected_serial_no",
   "section_break_50",
   "project",
+  "expense_account",
   "cost_center",
   "col_break5",
   "allow_zero_valuation_rate",
@@ -245,6 +247,7 @@
    "width": "100px"
   },
   {
+   "default": "0",
    "fetch_from": "item_code.retain_sample",
    "fieldname": "retain_sample",
    "fieldtype": "Check",
@@ -361,6 +364,7 @@
    "read_only": 1
   },
   {
+   "default": "0",
    "fieldname": "is_free_item",
    "fieldtype": "Check",
    "label": "Is Free Item",
@@ -482,6 +486,7 @@
    "fieldtype": "Column Break"
   },
   {
+   "default": "0",
    "fieldname": "is_fixed_asset",
    "fieldtype": "Check",
    "hidden": 1,
@@ -620,6 +625,7 @@
    "fieldtype": "Column Break"
   },
   {
+   "default": "0",
    "fieldname": "allow_zero_valuation_rate",
    "fieldtype": "Check",
    "label": "Allow Zero Valuation Rate",
@@ -635,6 +641,7 @@
    "print_hide": 1
   },
   {
+   "default": "0",
    "depends_on": "eval:parent.is_subcontracted == 'Yes'",
    "fieldname": "include_exploded_items",
    "fieldtype": "Check",
@@ -739,6 +746,7 @@
   },
   {
    "allow_on_submit": 1,
+   "default": "0",
    "fieldname": "page_break",
    "fieldtype": "Check",
    "label": "Page Break",
@@ -766,11 +774,19 @@
    "fieldname": "material_request_item",
    "fieldtype": "Data",
    "label": "Material Request Item"
+  },
+  {
+   "fieldname": "expense_account",
+   "fieldtype": "Link",
+   "hidden": 1,
+   "label": "Expense Account",
+   "options": "Account",
+   "read_only": 1
   }
  ],
  "idx": 1,
  "istable": 1,
- "modified": "2019-05-08 10:25:27.157675",
+ "modified": "2019-05-30 18:09:21.648599",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Purchase Receipt Item",