Merge pull request #27863 from rohitwaghchaure/multi-currency-issue-for-consolidated-report

fix: consolidated report not consider company currency
diff --git a/.github/helper/.flake8_strict b/.github/helper/.flake8_strict
index c8337a9..a79137d 100644
--- a/.github/helper/.flake8_strict
+++ b/.github/helper/.flake8_strict
@@ -1,6 +1,8 @@
 [flake8]
 ignore =
     B007,
+    B009,
+    B010,
     B950,
     E101,
     E111,
@@ -65,11 +67,6 @@
     E713,
     E712,
 
-enable-extensions =
-    M90
-
-select =
-    M511
 
 max-line-length = 200
 exclude=.github/helper/semgrep_rules,test_*.py
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e411f11..b74d9a6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,9 +21,9 @@
     hooks:
       - id: flake8
         additional_dependencies: [
-          'flake8-mutable',
+          'flake8-bugbear',
         ]
-        args: ['--select=M511', '--config', '.github/helper/.flake8_strict']
+        args: ['--config', '.github/helper/.flake8_strict']
         exclude: ".*setup.py$"
 
   - repo: https://github.com/timothycrosley/isort
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
index b1f3e6f..412833b 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
@@ -52,21 +52,35 @@
 
 	refresh() {
 		this.frm.disable_save();
+		this.frm.set_df_property('invoices', 'cannot_delete_rows', true);
+		this.frm.set_df_property('payments', 'cannot_delete_rows', true);
+		this.frm.set_df_property('allocation', 'cannot_delete_rows', true);
+
+		this.frm.set_df_property('invoices', 'cannot_add_rows', true);
+		this.frm.set_df_property('payments', 'cannot_add_rows', true);
+		this.frm.set_df_property('allocation', 'cannot_add_rows', true);
+
 
 		if (this.frm.doc.receivable_payable_account) {
 			this.frm.add_custom_button(__('Get Unreconciled Entries'), () =>
 				this.frm.trigger("get_unreconciled_entries")
 			);
+			this.frm.change_custom_button_type('Get Unreconciled Entries', null, 'primary');
 		}
 		if (this.frm.doc.invoices.length && this.frm.doc.payments.length) {
 			this.frm.add_custom_button(__('Allocate'), () =>
 				this.frm.trigger("allocate")
 			);
+			this.frm.change_custom_button_type('Allocate', null, 'primary');
+			this.frm.change_custom_button_type('Get Unreconciled Entries', null, 'default');
 		}
 		if (this.frm.doc.allocation.length) {
 			this.frm.add_custom_button(__('Reconcile'), () =>
 				this.frm.trigger("reconcile")
 			);
+			this.frm.change_custom_button_type('Reconcile', null, 'primary');
+			this.frm.change_custom_button_type('Get Unreconciled Entries', null, 'default');
+			this.frm.change_custom_button_type('Allocate', null, 'default');
 		}
 	}
 
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json
index 9023b36..eb0c20f 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json
@@ -12,15 +12,16 @@
   "receivable_payable_account",
   "col_break1",
   "from_invoice_date",
-  "to_invoice_date",
-  "minimum_invoice_amount",
-  "maximum_invoice_amount",
-  "invoice_limit",
-  "column_break_13",
   "from_payment_date",
-  "to_payment_date",
+  "minimum_invoice_amount",
   "minimum_payment_amount",
+  "column_break_11",
+  "to_invoice_date",
+  "to_payment_date",
+  "maximum_invoice_amount",
   "maximum_payment_amount",
+  "column_break_13",
+  "invoice_limit",
   "payment_limit",
   "bank_cash_account",
   "sec_break1",
@@ -79,6 +80,7 @@
   },
   {
    "depends_on": "eval:(doc.payments).length || (doc.invoices).length",
+   "description": "If you need to reconcile particular transactions against each other, then please select accordingly. If not, all the transactions will be allocated in FIFO order.",
    "fieldname": "sec_break1",
    "fieldtype": "Section Break",
    "label": "Unreconciled Entries"
@@ -163,6 +165,7 @@
    "label": "Maximum Payment Amount"
   },
   {
+   "description": "System will fetch all the entries if limit value is zero.",
    "fieldname": "payment_limit",
    "fieldtype": "Int",
    "label": "Payment Limit"
@@ -171,13 +174,17 @@
    "fieldname": "maximum_invoice_amount",
    "fieldtype": "Currency",
    "label": "Maximum Invoice Amount"
+  },
+  {
+   "fieldname": "column_break_11",
+   "fieldtype": "Column Break"
   }
  ],
  "hide_toolbar": 1,
  "icon": "icon-resize-horizontal",
  "issingle": 1,
  "links": [],
- "modified": "2021-08-30 13:05:51.977861",
+ "modified": "2021-10-04 20:27:11.114194",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Reconciliation",
diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
index b8c65ee..6a21692 100644
--- a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
+++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
@@ -14,8 +14,8 @@
   "section_break_6",
   "allocated_amount",
   "unreconciled_amount",
-  "amount",
   "column_break_8",
+  "amount",
   "is_advance",
   "section_break_5",
   "difference_amount",
@@ -127,12 +127,13 @@
    "fieldname": "reference_row",
    "fieldtype": "Data",
    "hidden": 1,
-   "label": "Reference Row"
+   "label": "Reference Row",
+   "read_only": 1
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2021-09-20 17:23:09.455803",
+ "modified": "2021-10-06 11:48:59.616562",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Reconciliation Allocation",
diff --git a/erpnext/accounts/workspace/accounting/accounting.json b/erpnext/accounts/workspace/accounting/accounting.json
index 2b26ac5..30ed58b 100644
--- a/erpnext/accounts/workspace/accounting/accounting.json
+++ b/erpnext/accounts/workspace/accounting/accounting.json
@@ -534,6 +534,17 @@
    "type": "Link"
   },
   {
+    "dependencies": "GL Entry",
+    "hidden": 0,
+    "is_query_report": 1,
+    "label": "KSA VAT Report",
+    "link_to": "KSA VAT",
+    "link_type": "Report",
+    "onboard": 0,
+    "only_for": "Saudi Arabia",
+    "type": "Link"
+   },
+  {
    "hidden": 0,
    "is_query_report": 0,
    "label": "Financial Statements",
@@ -1154,6 +1165,16 @@
    "type": "Link"
   },
   {
+    "hidden": 0,
+    "is_query_report": 0,
+    "label": "KSA VAT Setting",
+    "link_to": "KSA VAT Setting",
+    "link_type": "DocType",
+    "onboard": 0,
+    "only_for": "Saudi Arabia",
+    "type": "Link"
+   },
+  {
    "hidden": 0,
    "is_query_report": 0,
    "label": "Profitability",
@@ -1206,7 +1227,7 @@
    "type": "Link"
   }
  ],
- "modified": "2021-08-27 12:15:52.872470",
+ "modified": "2021-08-26 13:15:52.872470",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Accounting",
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index d708f92..05f07f5 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -250,6 +250,7 @@
 		"validate": "erpnext.regional.india.utils.validate_tax_category"
 	},
 	"Sales Invoice": {
+		"after_insert": "erpnext.regional.saudi_arabia.utils.create_qr_code",
 		"on_submit": [
 			"erpnext.regional.create_transaction_log",
 			"erpnext.regional.italy.utils.sales_invoice_on_submit",
@@ -259,7 +260,10 @@
 			"erpnext.regional.italy.utils.sales_invoice_on_cancel",
 			"erpnext.erpnext_integrations.taxjar_integration.delete_transaction"
 		],
-		"on_trash": "erpnext.regional.check_deletion_permission",
+		"on_trash": [
+			"erpnext.regional.check_deletion_permission",
+			"erpnext.regional.saudi_arabia.utils.delete_qr_code_file"
+		],
 		"validate": [
 			"erpnext.regional.india.utils.validate_document_name",
 			"erpnext.regional.india.utils.update_taxable_values"
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index 3c4c672..218e97d 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -10,6 +10,26 @@
 	},
 	company: function(frm) {
 		erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
+		var expenses = frm.doc.expenses;
+		for (var i = 0; i < expenses.length; i++) {
+			var expense = expenses[i];
+			if (!expense.expense_type) {
+				continue;
+			}
+			frappe.call({
+				method: "erpnext.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center",
+				args: {
+					"expense_claim_type": expense.expense_type,
+					"company": frm.doc.company
+				},
+				callback: function(r) {
+					if (r.message) {
+						expense.default_account = r.message.account;
+						expense.cost_center = r.message.cost_center;
+					}
+				}
+			});
+		}
 	},
 });
 
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 7cfec97..232e3a0 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -1133,8 +1133,7 @@
 			query_filters["has_variants"] = 0
 
 	if filters and filters.get("is_stock_item"):
-		or_cond_filters["is_stock_item"] = 1
-		or_cond_filters["has_variants"] = 1
+		query_filters["is_stock_item"] = 1
 
 	return frappe.get_list("Item",
 		fields = fields, filters=query_filters,
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index 706ea26..4c03230 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -4,13 +4,14 @@
 
 import unittest
 from collections import deque
+from functools import partial
 
 import frappe
 from frappe.test_runner import make_test_records
 from frappe.utils import cstr, flt
 
 from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
-from erpnext.manufacturing.doctype.bom.bom import make_variant_bom
+from erpnext.manufacturing.doctype.bom.bom import item_query, make_variant_bom
 from erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool import update_cost
 from erpnext.stock.doctype.item.test_item import make_item
 from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import (
@@ -375,6 +376,16 @@
 		# FG Items in Scrap/Loss Table should have Is Process Loss set
 		self.assertRaises(frappe.ValidationError, bom_doc.submit)
 
+	def test_bom_item_query(self):
+		query = partial(item_query, doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters={"is_stock_item": 1})
+
+		test_items = query(txt="_Test")
+		filtered = query(txt="_Test Item 2")
+
+		self.assertNotEqual(len(test_items), len(filtered), msg="Item filtering showing excessive results")
+		self.assertTrue(0 < len(filtered) <= 3, msg="Item filtering showing excessive results")
+
+
 def get_default_bom(item_code="_Test FG Item 2"):
 	return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1})
 
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.json b/erpnext/payroll/doctype/salary_slip/salary_slip.json
index 1974403..7a80e69 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.json
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.json
@@ -329,7 +329,7 @@
   {
    "fieldname": "earning_deduction",
    "fieldtype": "Section Break",
-   "label": "Earning & Deduction",
+   "label": "Earnings & Deductions",
    "oldfieldtype": "Section Break"
   },
   {
@@ -380,7 +380,7 @@
    "depends_on": "total_loan_repayment",
    "fieldname": "loan_repayment",
    "fieldtype": "Section Break",
-   "label": "Loan repayment"
+   "label": "Loan Repayment"
   },
   {
    "fieldname": "loans",
@@ -425,7 +425,7 @@
   {
    "fieldname": "net_pay_info",
    "fieldtype": "Section Break",
-   "label": "net pay info"
+   "label": "Net Pay Info"
   },
   {
    "fieldname": "net_pay",
@@ -647,7 +647,7 @@
  "idx": 9,
  "is_submittable": 1,
  "links": [],
- "modified": "2021-09-01 10:35:52.374549",
+ "modified": "2021-10-08 11:47:47.098248",
  "modified_by": "Administrator",
  "module": "Payroll",
  "name": "Salary Slip",
diff --git a/erpnext/public/js/help_links.js b/erpnext/public/js/help_links.js
index d0c935f..b643cca 100644
--- a/erpnext/public/js/help_links.js
+++ b/erpnext/public/js/help_links.js
@@ -5,7 +5,7 @@
 frappe.help.help_links["Form/Rename Tool"] = [
 	{
 		label: "Bulk Rename",
-		url: docsUrl + "user/manual/en/setting-up/data/bulk-rename",
+		url: docsUrl + "user/manual/en/using-erpnext/articles/bulk-rename",
 	},
 ];
 
@@ -59,10 +59,23 @@
 	},
 ];
 
-frappe.help.help_links["data-import-tool"] = [
+frappe.help.help_links["Form/Data Import"] = [
 	{
 		label: "Importing and Exporting Data",
-		url: docsUrl + "user/manual/en/setting-up/data/data-import-tool",
+		url: docsUrl + "user/manual/en/setting-up/data/data-import",
+	},
+	{
+		label: "Overwriting Data from Data Import Tool",
+		url:
+			docsUrl +
+			"user/manual/en/setting-up/articles/overwriting-data-from-data-import-tool",
+	},
+];
+
+frappe.help.help_links["List/Data Import"] = [
+	{
+		label: "Importing and Exporting Data",
+		url: docsUrl + "user/manual/en/setting-up/data/data-import",
 	},
 	{
 		label: "Overwriting Data from Data Import Tool",
@@ -101,14 +114,14 @@
 	},
 ];
 
-frappe.help.help_links["Form/Email Digest"] = [
+frappe.help.help_links["List/Print Heading"] = [
 	{
-		label: "Email Digest",
-		url: docsUrl + "user/manual/en/setting-up/email/email-digest",
+		label: "Print Heading",
+		url: docsUrl + "user/manual/en/setting-up/print/print-headings",
 	},
 ];
 
-frappe.help.help_links["List/Print Heading"] = [
+frappe.help.help_links["Form/Print Heading"] = [
 	{
 		label: "Print Heading",
 		url: docsUrl + "user/manual/en/setting-up/print/print-headings",
@@ -153,18 +166,25 @@
 frappe.help.help_links["List/Notification"] = [
 	{
 		label: "Notification",
-		url: docsUrl + "user/manual/en/setting-up/email/notifications",
+		url: docsUrl + "user/manual/en/setting-up/notifications",
 	},
 ];
 
 frappe.help.help_links["Form/Notification"] = [
 	{
 		label: "Notification",
-		url: docsUrl + "user/manual/en/setting-up/email/notifications",
+		url: docsUrl + "user/manual/en/setting-up/notifications",
 	},
 ];
 
-frappe.help.help_links["List/Email Digest"] = [
+frappe.help.help_links["Form/Email Digest"] = [
+	{
+		label: "Email Digest",
+		url: docsUrl + "user/manual/en/setting-up/email/email-digest",
+	},
+];
+
+frappe.help.help_links["Form/Email Digest"] = [
 	{
 		label: "Email Digest",
 		url: docsUrl + "user/manual/en/setting-up/email/email-digest",
@@ -174,7 +194,7 @@
 frappe.help.help_links["List/Auto Email Report"] = [
 	{
 		label: "Auto Email Reports",
-		url: docsUrl + "user/manual/en/setting-up/email/email-reports",
+		url: docsUrl + "user/manual/en/setting-up/email/auto-email-reports",
 	},
 ];
 
@@ -188,14 +208,7 @@
 frappe.help.help_links["print-format-builder"] = [
 	{
 		label: "Print Format Builder",
-		url: docsUrl + "user/manual/en/setting-up/print/print-settings",
-	},
-];
-
-frappe.help.help_links["List/Print Heading"] = [
-	{
-		label: "Print Heading",
-		url: docsUrl + "user/manual/en/setting-up/print/print-headings",
+		url: docsUrl + "user/manual/en/setting-up/print/print-format-builder",
 	},
 ];
 
@@ -300,7 +313,7 @@
 	},
 	{
 		label: "Recurring Sales Order",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 	{
 		label: "Applying Discount",
@@ -315,7 +328,7 @@
 	},
 	{
 		label: "Recurring Sales Order",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 	{
 		label: "Applying Discount",
@@ -344,14 +357,14 @@
 frappe.help.help_links["Form/Product Bundle"] = [
 	{
 		label: "Product Bundle",
-		url: docsUrl + "user/manual/en/selling/setup/product-bundle",
+		url: docsUrl + "user/manual/en/selling/product-bundle",
 	},
 ];
 
 frappe.help.help_links["Form/Selling Settings"] = [
 	{
 		label: "Selling Settings",
-		url: docsUrl + "user/manual/en/selling/setup/selling-settings",
+		url: docsUrl + "user/manual/en/selling/selling-settings",
 	},
 ];
 
@@ -397,7 +410,7 @@
 	},
 	{
 		label: "Recurring Purchase Order",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 ];
 
@@ -420,7 +433,7 @@
 	},
 	{
 		label: "Recurring Purchase Order",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 	{
 		label: "Subcontracting",
@@ -435,24 +448,17 @@
 	},
 ];
 
-frappe.help.help_links["List/POS Profile"] = [
-	{
-		label: "POS Profile",
-		url: docsUrl + "user/manual/en/setting-up/pos-setting",
-	},
-];
-
 frappe.help.help_links["List/Price List"] = [
 	{
 		label: "Price List",
-		url: docsUrl + "user/manual/en/setting-up/price-lists",
+		url: docsUrl + "user/manual/en/stock/price-lists",
 	},
 ];
 
 frappe.help.help_links["List/Authorization Rule"] = [
 	{
 		label: "Authorization Rule",
-		url: docsUrl + "user/manual/en/setting-up/authorization-rule",
+		url: docsUrl + "user/manual/en/customize-erpnext/authorization-rule",
 	},
 ];
 
@@ -468,27 +474,14 @@
 		label: "Stock Reconciliation",
 		url:
 			docsUrl +
-			"user/manual/en/setting-up/stock-reconciliation-for-non-serialized-item",
+			"user/manual/en/stock/stock-reconciliation",
 	},
 ];
 
 frappe.help.help_links["Tree/Territory"] = [
 	{
 		label: "Territory",
-		url: docsUrl + "user/manual/en/setting-up/territory",
-	},
-];
-
-frappe.help.help_links["Form/Dropbox Backup"] = [
-	{
-		label: "Dropbox Backup",
-		url: docsUrl + "user/manual/en/setting-up/third-party-backups",
-	},
-	{
-		label: "Setting Up Dropbox Backup",
-		url:
-			docsUrl +
-			"user/manual/en/setting-up/articles/setting-up-dropbox-backups",
+		url: docsUrl + "user/manual/en/selling/territory",
 	},
 ];
 
@@ -502,12 +495,6 @@
 		url: docsUrl + "user/manual/en/setting-up/company-setup",
 	},
 	{
-		label: "Managing Multiple Companies",
-		url:
-			docsUrl +
-			"user/manual/en/setting-up/articles/managing-multiple-companies",
-	},
-	{
 		label: "Delete All Related Transactions for a Company",
 		url:
 			docsUrl +
@@ -517,21 +504,6 @@
 
 //Accounts
 
-frappe.help.help_links["modules/Accounts"] = [
-	{
-		label: "Introduction to Accounts",
-		url: docsUrl + "user/manual/en/accounts/",
-	},
-	{
-		label: "Chart of Accounts",
-		url: docsUrl + "user/manual/en/accounts/chart-of-accounts.html",
-	},
-	{
-		label: "Multi Currency Accounting",
-		url: docsUrl + "user/manual/en/accounts/multi-currency-accounting",
-	},
-];
-
 frappe.help.help_links["Tree/Account"] = [
 	{
 		label: "Chart of Accounts",
@@ -552,7 +524,7 @@
 	},
 	{
 		label: "Accounts Opening Balance",
-		url: docsUrl + "user/manual/en/accounts/opening-accounts",
+		url: docsUrl + "user/manual/en/accounts/opening-balance",
 	},
 	{
 		label: "Sales Return",
@@ -560,7 +532,7 @@
 	},
 	{
 		label: "Recurring Sales Invoice",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 ];
 
@@ -571,7 +543,7 @@
 	},
 	{
 		label: "Accounts Opening Balance",
-		url: docsUrl + "user/manual/en/accounts/opening-accounts",
+		url: docsUrl + "user/manual/en/accounts/opening-balances",
 	},
 	{
 		label: "Sales Return",
@@ -579,21 +551,28 @@
 	},
 	{
 		label: "Recurring Sales Invoice",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 ];
 
-frappe.help.help_links["pos"] = [
+frappe.help.help_links["point-of-sale"] = [
 	{
 		label: "Point of Sale Invoice",
-		url: docsUrl + "user/manual/en/accounts/point-of-sale-pos-invoice",
+		url: docsUrl + "user/manual/en/accounts/point-of-sales",
 	},
 ];
 
 frappe.help.help_links["List/POS Profile"] = [
 	{
 		label: "Point of Sale Profile",
-		url: docsUrl + "user/manual/en/setting-up/pos-setting",
+		url: docsUrl + "user/manual/en/accounts/pos-profile",
+	},
+];
+
+frappe.help.help_links["Form/POS Profile"] = [
+	{
+		label: "POS Profile",
+		url: docsUrl + "user/manual/en/accounts/pos-profile",
 	},
 ];
 
@@ -604,11 +583,11 @@
 	},
 	{
 		label: "Accounts Opening Balance",
-		url: docsUrl + "user/manual/en/accounts/opening-accounts",
+		url: docsUrl + "user/manual/en/accounts/opening-balance",
 	},
 	{
 		label: "Recurring Purchase Invoice",
-		url: docsUrl + "user/manual/en/accounts/recurring-orders-and-invoices",
+		url: docsUrl + "user/manual/en/accounts/articles/recurring-orders-and-invoices",
 	},
 ];
 
@@ -623,7 +602,7 @@
 	},
 	{
 		label: "Accounts Opening Balance",
-		url: docsUrl + "user/manual/en/accounts/opening-accounts",
+		url: docsUrl + "user/manual/en/accounts/opening-balance",
 	},
 ];
 
@@ -644,7 +623,7 @@
 frappe.help.help_links["List/Asset"] = [
 	{
 		label: "Managing Fixed Assets",
-		url: docsUrl + "user/manual/en/accounts/opening-balance/fixed_assets",
+		url: docsUrl + "user/manual/en/asset",
 	},
 ];
 
@@ -659,6 +638,8 @@
 	{ label: "Budgeting", url: docsUrl + "user/manual/en/accounts/budgeting" },
 ];
 
+//Stock
+
 frappe.help.help_links["List/Item"] = [
 	{ label: "Item", url: docsUrl + "user/manual/en/stock/item" },
 	{
@@ -676,7 +657,7 @@
 	},
 	{
 		label: "Managing Fixed Assets",
-		url: docsUrl + "user/manual/en/accounts/opening-balance/fixed_assets",
+		url: docsUrl + "user/manual/en/asset",
 	},
 	{
 		label: "Item Codification",
@@ -711,7 +692,7 @@
 	},
 	{
 		label: "Managing Fixed Assets",
-		url: docsUrl + "user/manual/en/accounts/opening-balance/fixed_assets",
+		url: docsUrl + "user/manual/en/asset",
 	},
 	{
 		label: "Item Codification",
@@ -771,10 +752,6 @@
 		url:
 			docsUrl + "user/manual/en/stock/articles/track-items-using-barcode",
 	},
-	{
-		label: "Subcontracting",
-		url: docsUrl + "user/manual/en/manufacturing/subcontracting",
-	},
 ];
 
 frappe.help.help_links["List/Installation Note"] = [
@@ -784,21 +761,10 @@
 	},
 ];
 
-frappe.help.help_links["Tree"] = [
-	{
-		label: "Managing Tree Structure Masters",
-		url:
-			docsUrl +
-			"user/manual/en/setting-up/articles/managing-tree-structure-masters",
-	},
-];
-
 frappe.help.help_links["List/Budget"] = [
 	{ label: "Budgeting", url: docsUrl + "user/manual/en/accounts/budgeting" },
 ];
 
-//Stock
-
 frappe.help.help_links["List/Material Request"] = [
 	{
 		label: "Material Request",
@@ -861,6 +827,10 @@
 	{ label: "Serial No", url: docsUrl + "user/manual/en/stock/serial-no" },
 ];
 
+frappe.help.help_links["List/Batch"] = [
+	{ label: "Batch", url: docsUrl + "user/manual/en/stock/batch" },
+];
+
 frappe.help.help_links["Form/Batch"] = [
 	{ label: "Batch", url: docsUrl + "user/manual/en/stock/batch" },
 ];
@@ -868,35 +838,35 @@
 frappe.help.help_links["Form/Packing Slip"] = [
 	{
 		label: "Packing Slip",
-		url: docsUrl + "user/manual/en/stock/tools/packing-slip",
+		url: docsUrl + "user/manual/en/stock/packing-slip",
 	},
 ];
 
 frappe.help.help_links["Form/Quality Inspection"] = [
 	{
 		label: "Quality Inspection",
-		url: docsUrl + "user/manual/en/stock/tools/quality-inspection",
+		url: docsUrl + "user/manual/en/stock/quality-inspection",
 	},
 ];
 
 frappe.help.help_links["Form/Landed Cost Voucher"] = [
 	{
 		label: "Landed Cost Voucher",
-		url: docsUrl + "user/manual/en/stock/tools/landed-cost-voucher",
+		url: docsUrl + "user/manual/en/stock/landed-cost-voucher",
 	},
 ];
 
 frappe.help.help_links["Tree/Item Group"] = [
 	{
 		label: "Item Group",
-		url: docsUrl + "user/manual/en/stock/setup/item-group",
+		url: docsUrl + "user/manual/en/stock/item-group",
 	},
 ];
 
 frappe.help.help_links["Form/Item Attribute"] = [
 	{
 		label: "Item Attribute",
-		url: docsUrl + "user/manual/en/stock/setup/item-attribute",
+		url: docsUrl + "user/manual/en/stock/item-attribute",
 	},
 ];
 
@@ -911,7 +881,7 @@
 frappe.help.help_links["Form/Stock Reconciliation"] = [
 	{
 		label: "Opening Stock Entry",
-		url: docsUrl + "user/manual/en/stock/opening-stock",
+		url: docsUrl + "user/manual/en/stock/stock-reconciliation",
 	},
 ];
 
@@ -938,13 +908,13 @@
 ];
 
 frappe.help.help_links["Form/Campaign"] = [
-	{ label: "Campaign", url: docsUrl + "user/manual/en/CRM/setup/campaign" },
+	{ label: "Campaign", url: docsUrl + "user/manual/en/CRM/campaign" },
 ];
 
 frappe.help.help_links["Tree/Sales Person"] = [
 	{
 		label: "Sales Person",
-		url: docsUrl + "user/manual/en/CRM/setup/sales-person",
+		url: docsUrl + "user/manual/en/CRM/sales-person",
 	},
 ];
 
@@ -953,30 +923,13 @@
 		label: "Sales Person Target",
 		url:
 			docsUrl +
-			"user/manual/en/selling/setup/sales-person-target-allocation",
+			"user/manual/en/selling/sales-person-target-allocation",
 	},
-];
-
-//Support
-
-frappe.help.help_links["List/Feedback Trigger"] = [
 	{
-		label: "Feedback Trigger",
-		url: docsUrl + "user/manual/en/setting-up/feedback/setting-up-feedback",
-	},
-];
-
-frappe.help.help_links["List/Feedback Request"] = [
-	{
-		label: "Feedback Request",
-		url: docsUrl + "user/manual/en/setting-up/feedback/submit-feedback",
-	},
-];
-
-frappe.help.help_links["List/Feedback Request"] = [
-	{
-		label: "Feedback Request",
-		url: docsUrl + "user/manual/en/setting-up/feedback/submit-feedback",
+		label: "Sales Person in Transactions",
+		url:
+			docsUrl +
+			"user/manual/en/selling/articles/sales-persons-in-the-sales-transactions",
 	},
 ];
 
@@ -1019,7 +972,7 @@
 frappe.help.help_links["Form/BOM Update Tool"] = [
 	{
 		label: "BOM Update Tool",
-		url: docsUrl + "user/manual/en/manufacturing/tools/bom-update-tool",
+		url: docsUrl + "user/manual/en/manufacturing/bom-update-tool",
 	},
 ];
 
@@ -1036,7 +989,7 @@
 	},
 ];
 
-frappe.help.help_links["Form/Custom Field"] = [
+frappe.help.help_links["List/Custom Field"] = [
 	{
 		label: "Custom Field",
 		url: docsUrl + "user/manual/en/customize-erpnext/custom-field",
diff --git a/erpnext/regional/__init__.py b/erpnext/regional/__init__.py
index 45a689e..d7dcbf4 100644
--- a/erpnext/regional/__init__.py
+++ b/erpnext/regional/__init__.py
@@ -31,3 +31,4 @@
 		"document_name": doc.name,
 		"data": data
 	}).insert(ignore_permissions=True)
+
diff --git a/erpnext/regional/doctype/ksa_vat_purchase_account/__init__.py b/erpnext/regional/doctype/ksa_vat_purchase_account/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_purchase_account/__init__.py
diff --git a/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.json b/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.json
new file mode 100644
index 0000000..89ba3e9
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.json
@@ -0,0 +1,49 @@
+{
+ "actions": [],
+ "creation": "2021-07-13 09:17:09.862163",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "title",
+  "item_tax_template",
+  "account"
+ ],
+ "fields": [
+  {
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Account",
+   "options": "Account",
+   "reqd": 1
+  },
+  {
+   "fieldname": "title",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Title",
+   "reqd": 1
+  },
+  {
+   "fieldname": "item_tax_template",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Item Tax Template",
+   "options": "Item Tax Template",
+   "reqd": 1
+  }
+ ],
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2021-08-04 06:42:38.205597",
+ "modified_by": "Administrator",
+ "module": "Regional",
+ "name": "KSA VAT Purchase Account",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.py b/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.py
new file mode 100644
index 0000000..3920bc5
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_purchase_account/ksa_vat_purchase_account.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Havenir Solutions and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+
+class KSAVATPurchaseAccount(Document):
+	pass
diff --git a/erpnext/regional/doctype/ksa_vat_sales_account/__init__.py b/erpnext/regional/doctype/ksa_vat_sales_account/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_sales_account/__init__.py
diff --git a/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.js b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.js
new file mode 100644
index 0000000..72613f4
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2021, Havenir Solutions and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('KSA VAT Sales Account', {
+	// refresh: function(frm) {
+
+	// }
+});
diff --git a/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.json b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.json
new file mode 100644
index 0000000..df27478
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.json
@@ -0,0 +1,49 @@
+{
+ "actions": [],
+ "creation": "2021-07-13 08:46:33.820968",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "title",
+  "item_tax_template",
+  "account"
+ ],
+ "fields": [
+  {
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Account",
+   "options": "Account",
+   "reqd": 1
+  },
+  {
+   "fieldname": "title",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Title",
+   "reqd": 1
+  },
+  {
+   "fieldname": "item_tax_template",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Item Tax Template",
+   "options": "Item Tax Template",
+   "reqd": 1
+  }
+ ],
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2021-08-04 06:42:00.081407",
+ "modified_by": "Administrator",
+ "module": "Regional",
+ "name": "KSA VAT Sales Account",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.py b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.py
new file mode 100644
index 0000000..7c2689f
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_sales_account/ksa_vat_sales_account.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Havenir Solutions and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+
+class KSAVATSalesAccount(Document):
+	pass
diff --git a/erpnext/regional/doctype/ksa_vat_sales_account/test_ksa_vat_sales_account.py b/erpnext/regional/doctype/ksa_vat_sales_account/test_ksa_vat_sales_account.py
new file mode 100644
index 0000000..1d6a6a7
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_sales_account/test_ksa_vat_sales_account.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Havenir Solutions and Contributors
+# See license.txt
+
+# import frappe
+import unittest
+
+
+class TestKSAVATSalesAccount(unittest.TestCase):
+	pass
diff --git a/erpnext/regional/doctype/ksa_vat_setting/__init__.py b/erpnext/regional/doctype/ksa_vat_setting/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/__init__.py
diff --git a/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.js b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.js
new file mode 100644
index 0000000..00b62b9
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2021, Havenir Solutions and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('KSA VAT Setting', {
+	onload: function () {
+		frappe.breadcrumbs.add('Accounts', 'KSA VAT Setting');
+	}
+});
diff --git a/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.json b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.json
new file mode 100644
index 0000000..3361946
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.json
@@ -0,0 +1,49 @@
+{
+ "actions": [],
+ "autoname": "field:company",
+ "creation": "2021-07-13 08:49:01.100356",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "company",
+  "ksa_vat_sales_accounts",
+  "ksa_vat_purchase_accounts"
+ ],
+ "fields": [
+  {
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Company",
+   "options": "Company",
+   "reqd": 1,
+   "unique": 1
+  },
+  {
+   "fieldname": "ksa_vat_sales_accounts",
+   "fieldtype": "Table",
+   "label": "KSA VAT Sales Accounts",
+   "options": "KSA VAT Sales Account",
+   "reqd": 1
+  },
+  {
+   "fieldname": "ksa_vat_purchase_accounts",
+   "fieldtype": "Table",
+   "label": "KSA VAT Purchase Accounts",
+   "options": "KSA VAT Purchase Account",
+   "reqd": 1
+  }
+ ],
+ "links": [],
+ "modified": "2021-08-26 04:29:06.499378",
+ "modified_by": "Administrator",
+ "module": "Regional",
+ "name": "KSA VAT Setting",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "company",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.py b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.py
new file mode 100644
index 0000000..bdae116
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Havenir Solutions and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+
+class KSAVATSetting(Document):
+	pass
diff --git a/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting_list.js b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting_list.js
new file mode 100644
index 0000000..269cbec
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/ksa_vat_setting_list.js
@@ -0,0 +1,5 @@
+frappe.listview_settings['KSA VAT Setting'] = {
+	onload () {
+		frappe.breadcrumbs.add('Accounts');
+	}
+}
\ No newline at end of file
diff --git a/erpnext/regional/doctype/ksa_vat_setting/test_ksa_vat_setting.py b/erpnext/regional/doctype/ksa_vat_setting/test_ksa_vat_setting.py
new file mode 100644
index 0000000..7207901
--- /dev/null
+++ b/erpnext/regional/doctype/ksa_vat_setting/test_ksa_vat_setting.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Havenir Solutions and Contributors
+# See license.txt
+
+# import frappe
+import unittest
+
+
+class TestKSAVATSetting(unittest.TestCase):
+	pass
diff --git a/erpnext/regional/report/ksa_vat/__init__.py b/erpnext/regional/report/ksa_vat/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/report/ksa_vat/__init__.py
diff --git a/erpnext/regional/report/ksa_vat/ksa_vat.js b/erpnext/regional/report/ksa_vat/ksa_vat.js
new file mode 100644
index 0000000..d46d260
--- /dev/null
+++ b/erpnext/regional/report/ksa_vat/ksa_vat.js
@@ -0,0 +1,60 @@
+// Copyright (c) 2016, Havenir Solutions and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["KSA VAT"] = {
+	onload() {
+		frappe.breadcrumbs.add('Accounts');
+	},
+	"filters": [
+		{
+			"fieldname": "company",
+			"label": __("Company"),
+			"fieldtype": "Link",
+			"options": "Company",
+			"reqd": 1,
+			"default": frappe.defaults.get_user_default("Company")
+		},
+		{
+			"fieldname": "from_date",
+			"label": __("From Date"),
+			"fieldtype": "Date",
+			"reqd": 1,
+			"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+		},
+		{
+			"fieldname": "to_date",
+			"label": __("To Date"),
+			"fieldtype": "Date",
+			"reqd": 1,
+			"default": frappe.datetime.get_today()
+		}
+	],
+	"formatter": function(value, row, column, data, default_formatter) {
+		if (data
+			&& (data.title=='VAT on Sales' || data.title=='VAT on Purchases')
+			&& data.title==value) {
+			value = $(`<span>${value}</span>`);
+			var $value = $(value).css("font-weight", "bold");
+			value = $value.wrap("<p></p>").parent().html();
+			return value
+		}else if (data.title=='Grand Total'){
+			if (data.title==value) {
+				value = $(`<span>${value}</span>`);
+				var $value = $(value).css("font-weight", "bold");
+				value = $value.wrap("<p></p>").parent().html();
+				return value
+			}else{
+				value = default_formatter(value, row, column, data);
+				value = $(`<span>${value}</span>`);
+				var $value = $(value).css("font-weight", "bold");
+				value = $value.wrap("<p></p>").parent().html();
+				console.log($value)
+				return value
+			}
+		}else{
+			value = default_formatter(value, row, column, data);
+			return value;
+		}
+	},
+};
diff --git a/erpnext/regional/report/ksa_vat/ksa_vat.json b/erpnext/regional/report/ksa_vat/ksa_vat.json
new file mode 100644
index 0000000..036e260
--- /dev/null
+++ b/erpnext/regional/report/ksa_vat/ksa_vat.json
@@ -0,0 +1,32 @@
+{
+ "add_total_row": 0,
+ "columns": [],
+ "creation": "2021-07-13 08:54:38.000949",
+ "disable_prepared_report": 1,
+ "disabled": 1,
+ "docstatus": 0,
+ "doctype": "Report",
+ "filters": [],
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2021-08-26 04:14:37.202594",
+ "modified_by": "Administrator",
+ "module": "Regional",
+ "name": "KSA VAT",
+ "owner": "Administrator",
+ "prepared_report": 1,
+ "ref_doctype": "GL Entry",
+ "report_name": "KSA VAT",
+ "report_type": "Script Report",
+ "roles": [
+  {
+   "role": "System Manager"
+  },
+  {
+   "role": "Accounts Manager"
+  },
+  {
+   "role": "Accounts User"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/regional/report/ksa_vat/ksa_vat.py b/erpnext/regional/report/ksa_vat/ksa_vat.py
new file mode 100644
index 0000000..a42ebc9
--- /dev/null
+++ b/erpnext/regional/report/ksa_vat/ksa_vat.py
@@ -0,0 +1,176 @@
+# Copyright (c) 2013, Havenir Solutions and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+
+import json
+
+import frappe
+from frappe import _
+from frappe.utils import get_url_to_list
+
+
+def execute(filters=None):
+	columns = columns = get_columns()
+	data = get_data(filters)
+	return columns, data
+
+def get_columns():
+	return [
+		{
+			"fieldname": "title",
+			"label": _("Title"),
+			"fieldtype": "Data",
+			"width": 300
+		},
+		{
+			"fieldname": "amount",
+			"label": _("Amount (SAR)"),
+			"fieldtype": "Currency",
+			"width": 150,
+		},
+		{
+			"fieldname": "adjustment_amount",
+			"label": _("Adjustment (SAR)"),
+			"fieldtype": "Currency",
+			"width": 150,
+		},
+		{
+			"fieldname": "vat_amount",
+			"label": _("VAT Amount (SAR)"),
+			"fieldtype": "Currency",
+			"width": 150,
+		}
+	]
+
+def get_data(filters):
+	data = []
+
+	# Validate if vat settings exist
+	company = filters.get('company')
+	if frappe.db.exists('KSA VAT Setting', company) is None:
+		url = get_url_to_list('KSA VAT Setting')
+		frappe.msgprint(_('Create <a href="{}">KSA VAT Setting</a> for this company').format(url))
+		return data
+
+	ksa_vat_setting = frappe.get_doc('KSA VAT Setting', company)
+
+	# Sales Heading
+	append_data(data, 'VAT on Sales', '', '', '')
+
+	grand_total_taxable_amount = 0
+	grand_total_taxable_adjustment_amount = 0
+	grand_total_tax = 0
+
+	for vat_setting in ksa_vat_setting.ksa_vat_sales_accounts:
+		total_taxable_amount, total_taxable_adjustment_amount, \
+			total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Sales Invoice')
+
+		# Adding results to data
+		append_data(data, vat_setting.title, total_taxable_amount,
+			total_taxable_adjustment_amount, total_tax)
+
+		grand_total_taxable_amount += total_taxable_amount
+		grand_total_taxable_adjustment_amount += total_taxable_adjustment_amount
+		grand_total_tax += total_tax
+
+	# Sales Grand Total
+	append_data(data, 'Grand Total', grand_total_taxable_amount,
+		grand_total_taxable_adjustment_amount, grand_total_tax)
+
+	# Blank Line
+	append_data(data, '', '', '', '')
+
+	# Purchase Heading
+	append_data(data, 'VAT on Purchases', '', '', '')
+
+	grand_total_taxable_amount = 0
+	grand_total_taxable_adjustment_amount = 0
+	grand_total_tax = 0
+
+	for vat_setting in ksa_vat_setting.ksa_vat_purchase_accounts:
+		total_taxable_amount, total_taxable_adjustment_amount, \
+			total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Purchase Invoice')
+
+		# Adding results to data
+		append_data(data, vat_setting.title, total_taxable_amount,
+			total_taxable_adjustment_amount, total_tax)
+
+		grand_total_taxable_amount += total_taxable_amount
+		grand_total_taxable_adjustment_amount += total_taxable_adjustment_amount
+		grand_total_tax += total_tax
+
+	# Purchase Grand Total
+	append_data(data, 'Grand Total', grand_total_taxable_amount,
+		grand_total_taxable_adjustment_amount, grand_total_tax)
+
+	return data
+
+def get_tax_data_for_each_vat_setting(vat_setting, filters, doctype):
+	'''
+	(KSA, {filters}, 'Sales Invoice') => 500, 153, 10 \n
+	calculates and returns \n
+	total_taxable_amount, total_taxable_adjustment_amount, total_tax'''
+	from_date = filters.get('from_date')
+	to_date = filters.get('to_date')
+
+	# Initiate variables
+	total_taxable_amount = 0
+	total_taxable_adjustment_amount = 0
+	total_tax = 0
+	# Fetch All Invoices
+	invoices = frappe.get_list(doctype,
+	filters ={
+		'docstatus': 1,
+		'posting_date': ['between', [from_date, to_date]]
+	}, fields =['name', 'is_return'])
+
+	for invoice in invoices:
+		invoice_items = frappe.get_list(f'{doctype} Item',
+		filters ={
+			'docstatus': 1,
+			'parent': invoice.name,
+			'item_tax_template': vat_setting.item_tax_template
+		}, fields =['item_code', 'net_amount'])
+
+		for item in invoice_items:
+			# Summing up total taxable amount
+			if invoice.is_return == 0:
+				total_taxable_amount += item.net_amount
+
+			if invoice.is_return == 1:
+				total_taxable_adjustment_amount += item.net_amount
+
+			# Summing up total tax
+			total_tax += get_tax_amount(item.item_code, vat_setting.account, doctype, invoice.name)
+
+	return total_taxable_amount, total_taxable_adjustment_amount, total_tax
+
+
+
+def append_data(data, title, amount, adjustment_amount, vat_amount):
+	"""Returns data with appended value."""
+	data.append({"title": _(title), "amount": amount, "adjustment_amount": adjustment_amount, "vat_amount": vat_amount})
+
+def get_tax_amount(item_code, account_head, doctype, parent):
+	if doctype == 'Sales Invoice':
+		tax_doctype = 'Sales Taxes and Charges'
+
+	elif doctype == 'Purchase Invoice':
+		tax_doctype = 'Purchase Taxes and Charges'
+
+	item_wise_tax_detail = frappe.get_value(tax_doctype, {
+		'docstatus': 1,
+		'parent': parent,
+		'account_head': account_head
+	}, 'item_wise_tax_detail')
+
+	tax_amount = 0
+	if item_wise_tax_detail and len(item_wise_tax_detail) > 0:
+		item_wise_tax_detail = json.loads(item_wise_tax_detail)
+		for key, value in item_wise_tax_detail.items():
+			if key == item_code:
+				tax_amount = value[1]
+				break
+
+	return tax_amount
diff --git a/erpnext/regional/saudi_arabia/setup.py b/erpnext/regional/saudi_arabia/setup.py
index 9b3677d..6113f48 100644
--- a/erpnext/regional/saudi_arabia/setup.py
+++ b/erpnext/regional/saudi_arabia/setup.py
@@ -2,10 +2,36 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-
-from erpnext.regional.united_arab_emirates.setup import make_custom_fields, add_print_formats
-
+import frappe
+from frappe.permissions import add_permission, update_permission_property
+from erpnext.regional.united_arab_emirates.setup import make_custom_fields as uae_custom_fields, add_print_formats
+from erpnext.regional.saudi_arabia.wizard.operations.setup_ksa_vat_setting import create_ksa_vat_setting
+from frappe.custom.doctype.custom_field.custom_field import create_custom_field
 
 def setup(company=None, patch=True):
-	make_custom_fields()
+	uae_custom_fields()
 	add_print_formats()
+	add_permissions()
+	create_ksa_vat_setting(company)
+	make_qrcode_field()
+
+def add_permissions():
+	"""Add Permissions for KSA VAT Setting."""
+	add_permission('KSA VAT Setting', 'All', 0)
+	for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
+		add_permission('KSA VAT Setting', role, 0)
+		update_permission_property('KSA VAT Setting', role, 0, 'write', 1)
+		update_permission_property('KSA VAT Setting', role, 0, 'create', 1)
+
+	"""Enable KSA VAT Report"""
+	frappe.db.set_value('Report', 'KSA VAT', 'disabled', 0)
+
+def make_qrcode_field():
+	"""Created QR code Image file"""
+	qr_code_field = dict(
+		fieldname='qr_code',
+		label='QR Code',
+		fieldtype='Attach Image',
+		read_only=1, no_copy=1, hidden=1)
+
+	create_custom_field('Sales Invoice', qr_code_field)
diff --git a/erpnext/regional/saudi_arabia/utils.py b/erpnext/regional/saudi_arabia/utils.py
new file mode 100644
index 0000000..cc6c0af
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/utils.py
@@ -0,0 +1,77 @@
+import io
+import os
+
+import frappe
+from pyqrcode import create as qr_create
+
+from erpnext import get_region
+
+
+def create_qr_code(doc, method):
+	"""Create QR Code after inserting Sales Inv
+	"""
+
+	region = get_region(doc.company)
+	if region not in ['Saudi Arabia']:
+		return
+
+	# if QR Code field not present, do nothing
+	if not hasattr(doc, 'qr_code'):
+		return
+
+	# Don't create QR Code if it already exists
+	qr_code = doc.get("qr_code")
+	if qr_code and frappe.db.exists({"doctype": "File", "file_url": qr_code}):
+		return
+
+	meta = frappe.get_meta('Sales Invoice')
+
+	for field in meta.get_image_fields():
+		if field.fieldname == 'qr_code':
+			# Creating public url to print format
+			default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=doc.doctype), "value")
+
+			# System Language
+			language = frappe.get_system_settings('language')
+
+			# creating qr code for the url
+			url = f"{ frappe.utils.get_url() }/{ doc.doctype }/{ doc.name }?format={ default_print_format or 'Standard' }&_lang={ language }&key={ doc.get_signature() }"
+			qr_image = io.BytesIO()
+			url = qr_create(url, error='L')
+			url.png(qr_image, scale=2, quiet_zone=1)
+
+			# making file
+			filename = f"QR-CODE-{doc.name}.png".replace(os.path.sep, "__")
+			_file = frappe.get_doc({
+				"doctype": "File",
+				"file_name": filename,
+				"is_private": 0,
+				"content": qr_image.getvalue(),
+				"attached_to_doctype": doc.get("doctype"),
+				"attached_to_name": doc.get("name"),
+				"attached_to_field": "qr_code"
+			})
+
+			_file.save()
+
+			# assigning to document
+			doc.db_set('qr_code', _file.file_url)
+			doc.notify_update()
+
+			break
+
+
+def delete_qr_code_file(doc, method):
+	"""Delete QR Code on deleted sales invoice"""
+
+	region = get_region(doc.company)
+	if region not in ['Saudi Arabia']:
+		return
+
+	if hasattr(doc, 'qr_code'):
+		if doc.get('qr_code'):
+			file_doc = frappe.get_list('File', {
+				'file_url': doc.get('qr_code')
+			})
+			if len(file_doc):
+				frappe.delete_doc('File', file_doc[0].name)
\ No newline at end of file
diff --git a/erpnext/regional/saudi_arabia/wizard/__init__.py b/erpnext/regional/saudi_arabia/wizard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/wizard/__init__.py
diff --git a/erpnext/regional/saudi_arabia/wizard/data/__init__.py b/erpnext/regional/saudi_arabia/wizard/data/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/wizard/data/__init__.py
diff --git a/erpnext/regional/saudi_arabia/wizard/data/ksa_vat_settings.json b/erpnext/regional/saudi_arabia/wizard/data/ksa_vat_settings.json
new file mode 100644
index 0000000..709d65b
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/wizard/data/ksa_vat_settings.json
@@ -0,0 +1,47 @@
+[
+    {
+        "type": "Sales Account",
+        "accounts": [
+            {
+                "title": "Standard rated Sales",
+                "item_tax_template": "KSA VAT 5%",
+                "account": "VAT 5%"
+            },
+            {
+                "title": "Zero rated domestic sales",
+                "item_tax_template": "KSA VAT Zero",
+                "account": "VAT Zero"
+            },
+            {
+                "title": "Exempted sales",
+                "item_tax_template": "KSA VAT Exempted",
+                "account": "VAT Zero"
+            }
+        ]
+    },
+    {
+        "type": "Purchase Account",
+        "accounts": [
+            {
+                "title": "Standard rated domestic purchases",
+                "item_tax_template": "KSA VAT 5%",
+                "account": "VAT 5%"
+            },
+            {
+                "title": "Imports subject to VAT paid at customs",
+                "item_tax_template": "KSA Excise 50%",
+                "account": "Excise 50%"
+            },
+            {
+                "title": "Zero rated purchases",
+                "item_tax_template": "KSA VAT Zero",
+                "account": "VAT Zero"
+            },
+            {
+                "title": "Exempted purchases",
+                "item_tax_template": "KSA VAT Exempted",
+                "account": "VAT Zero"
+            }
+        ]
+    }
+]
\ No newline at end of file
diff --git a/erpnext/regional/saudi_arabia/wizard/operations/__init__.py b/erpnext/regional/saudi_arabia/wizard/operations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/wizard/operations/__init__.py
diff --git a/erpnext/regional/saudi_arabia/wizard/operations/setup_ksa_vat_setting.py b/erpnext/regional/saudi_arabia/wizard/operations/setup_ksa_vat_setting.py
new file mode 100644
index 0000000..3c89edd
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/wizard/operations/setup_ksa_vat_setting.py
@@ -0,0 +1,46 @@
+import json
+import os
+
+import frappe
+
+from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
+
+
+def create_ksa_vat_setting(company):
+    """On creation of first company. Creates KSA VAT Setting"""
+
+    company = frappe.get_doc('Company', company)
+    setup_taxes_and_charges(company.name, company.country)
+
+    file_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'ksa_vat_settings.json')
+    with open(file_path, 'r') as json_file:
+        account_data = json.load(json_file)
+
+    # Creating KSA VAT Setting
+    ksa_vat_setting = frappe.get_doc({
+        'doctype': 'KSA VAT Setting',
+        'company': company.name
+    })
+
+    for data in account_data:
+        if data['type'] == 'Sales Account':
+            for row in data['accounts']:
+                item_tax_template = row['item_tax_template']
+                account = row['account']
+                ksa_vat_setting.append('ksa_vat_sales_accounts', {
+                    'title': row['title'],
+                    'item_tax_template': f'{item_tax_template} - {company.abbr}',
+                    'account': f'{account} - {company.abbr}'
+                })
+
+        elif data['type'] == 'Purchase Account':
+            for row in data['accounts']:
+                item_tax_template = row['item_tax_template']
+                account = row['account']
+                ksa_vat_setting.append('ksa_vat_purchase_accounts', {
+                    'title': row['title'],
+                    'item_tax_template': f'{item_tax_template} - {company.abbr}',
+                    'account': f'{account} - {company.abbr}'
+                })
+
+    ksa_vat_setting.save()
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 9367609..dcf478b 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -110,7 +110,7 @@
 		if self.order_type == 'Sales' and not self.skip_delivery_note:
 			delivery_date_list = [d.delivery_date for d in self.get("items") if d.delivery_date]
 			max_delivery_date = max(delivery_date_list) if delivery_date_list else None
-			if not self.delivery_date:
+			if (max_delivery_date and not self.delivery_date) or (max_delivery_date and getdate(self.delivery_date) != getdate(max_delivery_date)):
 				self.delivery_date = max_delivery_date
 			if self.delivery_date:
 				for d in self.get("items"):
@@ -119,8 +119,6 @@
 					if getdate(self.transaction_date) > getdate(d.delivery_date):
 						frappe.msgprint(_("Expected Delivery Date should be after Sales Order Date"),
 							indicator='orange', title=_('Warning'))
-				if getdate(self.delivery_date) != getdate(max_delivery_date):
-					self.delivery_date = max_delivery_date
 			else:
 				frappe.throw(_("Please enter Delivery Date"))
 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 9bf142c..ad1b3b4 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -395,8 +395,7 @@
    "fieldtype": "Link",
    "label": "Billing Address Name",
    "options": "Address",
-   "print_hide": 1,
-   "read_only": 1
+   "print_hide": 1
   },
   {
    "fieldname": "tax_id",
@@ -1309,7 +1308,7 @@
  "idx": 146,
  "is_submittable": 1,
  "links": [],
- "modified": "2021-09-28 13:10:09.761714",
+ "modified": "2021-10-08 14:29:13.428984",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Delivery Note",
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
index 2463a21..40ae340 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
@@ -142,6 +142,7 @@
    "oldfieldtype": "Data",
    "print_width": "150px",
    "read_only": 1,
+   "search_index": 1,
    "width": "150px"
   },
   {
@@ -316,7 +317,7 @@
  "in_create": 1,
  "index_web_pages_for_search": 1,
  "links": [],
- "modified": "2020-09-07 11:10:35.318872",
+ "modified": "2021-10-08 12:42:51.857631",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Stock Ledger Entry",
@@ -338,4 +339,4 @@
  ],
  "sort_field": "modified",
  "sort_order": "DESC"
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index caa1d42..382fdfa 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -181,4 +181,3 @@
 
 	frappe.db.add_index("Stock Ledger Entry", ["voucher_no", "voucher_type"])
 	frappe.db.add_index("Stock Ledger Entry", ["batch_no", "item_code", "warehouse"])
-	frappe.db.add_index("Stock Ledger Entry", ["voucher_detail_no"])