[enhance] UAE/KSA VAT/Excise implementation (#11923)

diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index bd7c74c..7247323 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -146,6 +146,36 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "tax_id", 
+   "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": "Tax Id", 
+   "length": 0, 
+   "no_copy": 0, 
+   "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, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "due_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -3883,7 +3913,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-11-29 13:44:40.722157", 
+ "modified": "2017-12-07 15:37:30.173811", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 80d24b3..9555d51 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -535,7 +535,7 @@
 	for tax in doc.taxes:
 		if getattr(tax, "category", None) and tax.category=="Valuation":
 			continue
-		if tax.description not in tax_accounts and tax.tax_amount_after_discount_amount:
+		if tax.description not in tax_accounts:
 			tax_accounts.append(tax.description)
 
 	headers = get_itemised_tax_breakup_header(doc.doctype + " Item", tax_accounts)
diff --git a/erpnext/docs/assets/img/regional/uae/__init__.py b/erpnext/docs/assets/img/regional/uae/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/__init__.py
diff --git a/erpnext/docs/assets/img/regional/uae/detailed-invoice.png b/erpnext/docs/assets/img/regional/uae/detailed-invoice.png
new file mode 100644
index 0000000..6cfcb04
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/detailed-invoice.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/simplified-invoice.png b/erpnext/docs/assets/img/regional/uae/simplified-invoice.png
new file mode 100644
index 0000000..1678f9e
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/simplified-invoice.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/tax-code-item.png b/erpnext/docs/assets/img/regional/uae/tax-code-item.png
new file mode 100644
index 0000000..2278bd9
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/tax-code-item.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/tax-id-company.png b/erpnext/docs/assets/img/regional/uae/tax-id-company.png
new file mode 100644
index 0000000..56a2a7b
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/tax-id-company.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/tax-id-customer.png b/erpnext/docs/assets/img/regional/uae/tax-id-customer.png
new file mode 100644
index 0000000..d7dfb3b
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/tax-id-customer.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/uae-tax-templates.png b/erpnext/docs/assets/img/regional/uae/uae-tax-templates.png
new file mode 100644
index 0000000..d2a2c26
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/uae-tax-templates.png
Binary files differ
diff --git a/erpnext/docs/assets/img/regional/uae/vat-invoice.gif b/erpnext/docs/assets/img/regional/uae/vat-invoice.gif
new file mode 100644
index 0000000..227036d
--- /dev/null
+++ b/erpnext/docs/assets/img/regional/uae/vat-invoice.gif
Binary files differ
diff --git a/erpnext/docs/user/manual/en/regional/united_arab_emirates/index.txt b/erpnext/docs/user/manual/en/regional/united_arab_emirates/index.txt
new file mode 100644
index 0000000..cf167db
--- /dev/null
+++ b/erpnext/docs/user/manual/en/regional/united_arab_emirates/index.txt
@@ -0,0 +1 @@
+uae-vat-setup
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/regional/united_arab_emirates/uae-vat-setup.md b/erpnext/docs/user/manual/en/regional/united_arab_emirates/uae-vat-setup.md
new file mode 100644
index 0000000..b2a38c9
--- /dev/null
+++ b/erpnext/docs/user/manual/en/regional/united_arab_emirates/uae-vat-setup.md
@@ -0,0 +1,45 @@
+# VAT/EXCISE Tax Implementation for UAE/KSA
+
+### 1. Setting up Tax Registration No for customer, supplier and company
+
+Set tax registation number in the field tax id for the customer, supplier and company
+
+1. For Customer
+<img class="screenshot" alt="TRN in Customer" src="/docs/assets/img/regional/uae/tax-id-customer.png">
+
+2. For Company
+<img class="screenshot" alt="TRN in Company" src="/docs/assets/img/regional/uae/tax-id-company.png">
+
+### 2. Setting up TAX Code for Products
+Setup tax code in the item master, system will fetch same code in the sales/purchase invoice on selection of an item.
+
+<img class="screenshot" alt="Tax Code in Item" src="/docs/assets/img/regional/uae/tax-code-item.png">
+### 3. Default Tax Templates
+
+ERPNext provides you default tax template for vat(5%, zero, exempted) and excise(50%, 100%). You can create your own [tax template](/docs/user/manual/en/setting-up/setting-up-taxes.html).
+
+<img class="screenshot" alt="Default Tax Template" src="/docs/assets/img/regional/uae/uae-tax-templates.png">
+
+### 3. Making VAT Ready Invoices
+
+If you have setup the TRN of your Customers and Suppliers, and your tax template, you are ready to go for making VAT Ready Invoices!
+
+For **Sales Invoice**,
+
+1. Select the correct Customer and Item and the address where the transaction will happen.
+2. Check if the TRN of your Company and Supplier have been correctly set.
+3. Check if the TAX Code has been set in the Item
+4. Select the  template that you have created based on the type of transaction
+5. Save and Submit the Invoice
+
+<img class="screenshot" alt="VAT Invoice" src="/docs/assets/img/regional/uae/vat-invoice.gif">
+
+### 4. Print Tax Invoice
+
+ERPNext provides 2 default print foramt
+
+1. Simplified Tax Invoice
+<img class="screenshot" alt="Simplified Tax Invoice" src="/docs/assets/img/regional/uae/simplified-invoice.png">
+
+2. Detailed Tax Invoice
+<img class="screenshot" alt="Detailed Tax Invoice" src="/docs/assets/img/regional/uae/detailed-invoice.png">
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index fe5ceda..c0ad07f 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -479,3 +479,4 @@
 erpnext.patches.v9_2.delete_process_payroll
 erpnext.patches.v10_0.add_agriculture_domain
 erpnext.patches.v10_0.add_non_profit_domain
+erpnext.patches.v10_0.setup_vat_for_uae_and_saudi_arabia
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py b/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py
new file mode 100644
index 0000000..cf6efbb
--- /dev/null
+++ b/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.setup.doctype.company.company import install_country_fixtures
+
+def execute():
+	for d in frappe.get_all('Company',
+		filters={'country': ('in', ['Saudi Arabia', 'United Arab Emirates'])}):
+		install_country_fixtures(d.name)
\ No newline at end of file
diff --git a/erpnext/regional/print_format/detailed_tax_invoice/__init__.py b/erpnext/regional/print_format/detailed_tax_invoice/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/print_format/detailed_tax_invoice/__init__.py
diff --git a/erpnext/regional/print_format/detailed_tax_invoice/detailed_tax_invoice.json b/erpnext/regional/print_format/detailed_tax_invoice/detailed_tax_invoice.json
new file mode 100644
index 0000000..e1c43e7
--- /dev/null
+++ b/erpnext/regional/print_format/detailed_tax_invoice/detailed_tax_invoice.json
@@ -0,0 +1,22 @@
+{
+ "align_labels_right": 0, 
+ "creation": "2017-12-07 16:26:06.648472", 
+ "custom_format": 0, 
+ "disabled": 0, 
+ "doc_type": "Sales Invoice", 
+ "docstatus": 0, 
+ "doctype": "Print Format", 
+ "font": "Default", 
+ "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"<div class=\\\"print-heading\\\">\\t\\t\\t\\t<h2>TAX Invoice<br><small>{{ doc.name }}</small>\\t\\t\\t\\t</h2></div>\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name_in_arabic\", \"label\": \"Customer Name in Arabic\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"print_hide\": 0, \"fieldname\": \"project\", \"align\": \"left\", \"label\": \"Reverse Charge Applicable\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"address_display\", \"label\": \"Address\"}, {\"print_hide\": 0, \"fieldname\": \"tax_id\", \"label\": \"Tax Id\"}, {\"print_hide\": 0, \"fieldname\": \"contact_display\", \"label\": \"Contact\"}, {\"print_hide\": 0, \"fieldname\": \"contact_mobile\", \"label\": \"Mobile No\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"print_hide\": 0, \"fieldname\": \"company_trn\", \"label\": \"Company TRN\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"image\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"qty\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_code\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"charge_type\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"row_id\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"account_head\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"cost_center\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"item_wise_tax_detail\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"align\": \"left\", \"label\": \"Tax Breakup\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"other_charges_calculation\", \"label\": \"Taxes and Charges Calculation\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Terms\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"terms\", \"label\": \"Terms and Conditions Details\"}]", 
+ "idx": 0, 
+ "line_breaks": 0, 
+ "modified": "2017-12-11 12:16:02.774997", 
+ "modified_by": "Administrator", 
+ "module": "Regional", 
+ "name": "Detailed Tax Invoice", 
+ "owner": "Administrator", 
+ "print_format_builder": 1, 
+ "print_format_type": "Server", 
+ "show_section_headings": 0, 
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/erpnext/regional/print_format/simplified_tax_invoice/__init__.py b/erpnext/regional/print_format/simplified_tax_invoice/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/print_format/simplified_tax_invoice/__init__.py
diff --git a/erpnext/regional/print_format/simplified_tax_invoice/simplified_tax_invoice.json b/erpnext/regional/print_format/simplified_tax_invoice/simplified_tax_invoice.json
new file mode 100644
index 0000000..9609b87
--- /dev/null
+++ b/erpnext/regional/print_format/simplified_tax_invoice/simplified_tax_invoice.json
@@ -0,0 +1,22 @@
+{
+ "align_labels_right": 0, 
+ "creation": "2017-12-07 16:09:44.321242", 
+ "custom_format": 0, 
+ "disabled": 0, 
+ "doc_type": "Sales Invoice", 
+ "docstatus": 0, 
+ "doctype": "Print Format", 
+ "font": "Default", 
+ "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"<div class=\\\"print-heading\\\">\\t\\t\\t\\t<h2>TAX Invoice<br><small>{{ doc.name }}</small>\\t\\t\\t\\t</h2></div>\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name_in_arabic\", \"label\": \"Customer Name in Arabic\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_trn\", \"label\": \"Company TRN\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_code\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"charge_type\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"row_id\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"account_head\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"cost_center\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"item_wise_tax_detail\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"align\": \"left\", \"label\": \"In Words\"}]", 
+ "idx": 0, 
+ "line_breaks": 0, 
+ "modified": "2017-12-11 12:32:00.136741", 
+ "modified_by": "Administrator", 
+ "module": "Regional", 
+ "name": "Simplified Tax Invoice", 
+ "owner": "Administrator", 
+ "print_format_builder": 1, 
+ "print_format_type": "Server", 
+ "show_section_headings": 0, 
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/erpnext/regional/saudi_arabia/__init__.py b/erpnext/regional/saudi_arabia/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/__init__.py
diff --git a/erpnext/regional/saudi_arabia/setup.py b/erpnext/regional/saudi_arabia/setup.py
new file mode 100644
index 0000000..ecce77c
--- /dev/null
+++ b/erpnext/regional/saudi_arabia/setup.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# 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
+from erpnext.setup.setup_wizard.setup_wizard import create_sales_tax
+
+def setup(company=None, patch=True):
+	make_custom_fields()
+	add_print_formats()
+
+	if company:
+		create_sales_tax(company)
\ No newline at end of file
diff --git a/erpnext/regional/united_arab_emirates/__init__.py b/erpnext/regional/united_arab_emirates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/united_arab_emirates/__init__.py
diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py
new file mode 100644
index 0000000..b1b3cc7
--- /dev/null
+++ b/erpnext/regional/united_arab_emirates/setup.py
@@ -0,0 +1,73 @@
+# 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, os, json
+from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
+from erpnext.setup.setup_wizard.setup_wizard import create_sales_tax
+
+def setup(company=None, patch=True):
+	make_custom_fields()
+	add_print_formats()
+
+	if company:
+		create_sales_tax(company)
+
+def make_custom_fields():
+	invoice_fields = [
+		dict(fieldname='vat_section', label='VAT Details', fieldtype='Section Break',
+			insert_after='select_print_heading', print_hide=1, collapsible=1),
+		dict(fieldname='permit_no', label='Permit Number',
+			fieldtype='Data', insert_after='vat_section', print_hide=1),
+		dict(fieldname='reverse_charge_applicable', label='Reverse Charge Applicable',
+			fieldtype='Select', insert_after='permit_no', print_hide=1,
+			options='Y\nN', default='N')
+	]
+
+	purchase_invoice_fields = [
+			dict(fieldname='company_trn', label='Company TRN',
+				fieldtype='Read Only', insert_after='shipping_address',
+				options='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)
+		]
+
+	sales_invoice_fields = [
+			dict(fieldname='company_trn', label='Company TRN',
+				fieldtype='Read Only', insert_after='company_address',
+				options='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),
+		]
+
+	tax_code_field = dict(fieldname='tax_code', label='Tax Code',
+		fieldtype='Read Only', options='item_code.tax_code', insert_after='description',
+		allow_on_submit=1, print_hide=1)
+
+	custom_fields = {
+		'Item': [
+			dict(fieldname='tax_code', label='Tax Code',
+				fieldtype='Data', insert_after='item_group'),
+		],
+		'Customer': [
+			dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic',
+				fieldtype='Data', insert_after='customer_name'),
+		],
+		'Supplier': [
+			dict(fieldname='supplier_name_in_arabic', label='Supplier Name in Arabic',
+				fieldtype='Data', insert_after='supplier_name'),
+		],
+		'Purchase Invoice': purchase_invoice_fields + invoice_fields,
+		'Sales Invoice': sales_invoice_fields + invoice_fields,
+		'Sales Invoice Item': [tax_code_field],
+		'Purchase Invoice Item': [tax_code_field]
+	}
+
+	create_custom_fields(custom_fields)
+
+def add_print_formats():
+	frappe.reload_doc("regional", "print_format", "detailed_tax_invoice")
+	frappe.reload_doc("regional", "print_format", "simplified_tax_invoice")
diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json
index f5909f4..ce39ae1 100644
--- a/erpnext/setup/doctype/company/company.json
+++ b/erpnext/setup/doctype/company/company.json
@@ -649,7 +649,37 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "unique": 0
+   "unique": 0 
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "tax_id", 
+   "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": "Tax ID", 
+   "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, 
+   "unique": 0 
   }, 
   {
    "allow_bulk_edit": 0, 
@@ -1991,6 +2021,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
+ "modified": "2017-12-07 17:40:24.646920", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Company", 
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index f4c9e06..cebcd34 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -324,7 +324,7 @@
 	path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(company_doc.country))
 	if os.path.exists(path.encode("utf-8")):
 		frappe.get_attr("erpnext.regional.{0}.setup.setup"
-			.format(company_doc.country.lower()))(company_doc)
+			.format(frappe.scrub(company_doc.country)))(company_doc)
 
 def update_company_current_month_sales(company):
 	current_month_year = formatdate(today(), "MM-yyyy")
diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json
index cf320f3..0e4ba6b 100644
--- a/erpnext/setup/setup_wizard/data/country_wise_tax.json
+++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json
@@ -1077,6 +1077,29 @@
 		}
 	},
 
+	"Saudi Arabia": {
+		"KSA VAT 5%": {
+			"account_name": "VAT 5%",
+			"tax_rate": 5.00
+		},
+		"KSA VAT Zero": {
+			"account_name": "VAT Zero",
+			"tax_rate": 0.00
+		},
+		"KSA VAT Exempted": {
+			"account_name": "VAT Exempted",
+			"tax_rate": 0.00
+		},
+		"KSA Excise 50%": {
+			"account_name": "Excise 50%",
+			"tax_rate": 50.00
+		},
+		"KSA Excise 100%": {
+			"account_name": "Excise 100%",
+			"tax_rate": 100.00
+		}
+	},
+
 	"Serbia": {
 		"Serbia Tax": {
 			"account_name": "VAT",
@@ -1311,6 +1334,29 @@
 		}
 	},
 
+	"United Arab Emirates": {
+		"UAE VAT 5%": {
+			"account_name": "VAT 5%",
+			"tax_rate": 5.00
+		},
+		"UAE VAT Zero": {
+			"account_name": "VAT Zero",
+			"tax_rate": 0.00
+		},
+		"UAE VAT Exempted": {
+			"account_name": "VAT Exempted",
+			"tax_rate": 0.00
+		},
+		"UAE Excise 50%": {
+			"account_name": "Excise 50%",
+			"tax_rate": 50.00
+		},
+		"UAE Excise 100%": {
+			"account_name": "Excise 100%",
+			"tax_rate": 100.00
+		}
+	},
+
 	"United Kingdom": {
 		"United Kingdom Tax": {
 			"account_name": "VAT",