Merge branch 'hotfix'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 1c9b0b4..65ccec4 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -4,7 +4,7 @@
 import frappe
 from erpnext.hooks import regional_overrides
 
-__version__ = '8.11.2'
+__version__ = '8.11.3'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index f8399bf..0416b19 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -260,9 +260,7 @@
 			this.calculate_outstanding_amount();
 		}
 
-		if (this.frm.doc.customer) {
-			this.party_field.$input.val(this.frm.doc.customer);
-		}
+		this.set_customer_value_in_party_field();
 
 		if (!this.frm.doc.write_off_account) {
 			this.frm.doc.write_off_account = doc.write_off_account
@@ -273,6 +271,12 @@
 		}
 	},
 
+	set_customer_value_in_party_field: function() {
+		if (this.frm.doc.customer) {
+			this.party_field.$input.val(this.frm.doc.customer);
+		}
+	},
+
 	get_invoice_doc: function (si_docs) {
 		var me = this;
 		this.si_docs = this.get_doc_from_localstorage();
@@ -686,6 +690,7 @@
 
 	set_focus: function () {
 		if (this.default_customer || this.frm.doc.customer) {
+			this.set_customer_value_in_party_field();
 			this.serach_item.$input.focus();
 		} else {
 			this.party_field.$input.focus();
diff --git a/erpnext/accounts/print_format/gst_pos_invoice/gst_pos_invoice.json b/erpnext/accounts/print_format/gst_pos_invoice/gst_pos_invoice.json
index 051a123..5debb5c 100644
--- a/erpnext/accounts/print_format/gst_pos_invoice/gst_pos_invoice.json
+++ b/erpnext/accounts/print_format/gst_pos_invoice/gst_pos_invoice.json
@@ -1,5 +1,5 @@
 {
- "align_labels_left": 0, 
+ "align_labels_right": 0, 
  "creation": "2017-08-08 12:33:04.773099", 
  "custom_format": 1, 
  "disabled": 0, 
@@ -10,7 +10,7 @@
  "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{% if doc.company_address_display %}\n\t\t{% set company_address = doc.company_address_display.replace(\"\\n\", \" \").replace(\"<br>\", \" \") %}\n\t\t{% if \"GSTIN\" not in company_address %}\n\t\t\t{{ company_address }}\n\t\t\t<b>{{ _(\"GSTIN\") }}:</b>{{ doc.company_gstin }}\n\t\t{% else %}\n\t\t\t{{ company_address.replace(\"GSTIN\", \"<br>GSTIN\") }}\n\t\t{% endif %}\n\t{% endif %}\n\t<br>\n\t<b>{{ doc.select_print_heading or _(\"Invoice\") }}</b><br>\n</p>\n<p>\n\t<b>{{ _(\"Receipt No\") }}:</b> {{ doc.name }}<br>\n\t<b>{{ _(\"Date\") }}:</b> {{ doc.get_formatted(\"posting_date\") }}<br>\n\t{% if doc.grand_total > 50000 %}\n\t\t{% set customer_address = doc.address_display.replace(\"\\n\", \" \").replace(\"<br>\", \" \") %}\n\t\t<b>{{ _(\"Customer\") }}:</b><br>\n\t\t{{ doc.customer_name }}<br>\n\t\t{{ customer_address }}\n\t{% endif %}\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"40%\">{{ _(\"Item\") }}</b></th>\n\t\t\t<th width=\"30%\" class=\"text-right\">{{ _(\"Qty\") }}</th>\n\t\t\t<th width=\"30%\" class=\"text-right\">{{ _(\"Amount\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{%- for item in doc.items -%}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t<br>{{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.gst_hsn_code -%}\n\t\t\t\t\t<br><b>{{ _(\"HSN/SAC\") }}:</b> {{ item.gst_hsn_code }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t<br><b>{{ _(\"Serial No\") }}:</b> {{ item.serial_no }}\n\t\t\t\t{%- endif -%}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ item.qty }}<br>@ {{ item.rate }}</td>\n\t\t\t<td class=\"text-right\">{{ item.get_formatted(\"amount\") }}</td>\n\t\t</tr>\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ _(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"net_total\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- for row in doc.taxes -%}\n\t\t{%- if not row.included_in_print_rate -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t{%- endfor -%}\n\t\t{%- if doc.discount_amount -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ _(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n<p><b>Tax Breakup:</b></p>\n<div style=\"font-size: 8px\">\n\t{{ doc.other_charges_calculation }}\n</div>\n<p>{{ doc.terms or \"\" }}</p>\n<p class=\"text-center\">{{ _(\"Thank you, please visit again.\") }}</p>", 
  "idx": 0, 
  "line_breaks": 0, 
- "modified": "2017-08-29 15:54:19.467642", 
+ "modified": "2017-09-14 15:54:19.467642", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "GST POS Invoice", 
diff --git a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
index 28c853c..49696d2 100644
--- a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
+++ b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
@@ -1,5 +1,5 @@
 {
- "align_labels_left": 0, 
+ "align_labels_right": 0, 
  "creation": "2016-05-05 17:16:18.564460", 
  "custom_format": 1, 
  "disabled": 0, 
@@ -10,7 +10,7 @@
  "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ company }}<br>\n\t{{  __(\"POS No : \") }} {{ offline_pos_name }}<br>\n</p>\n<p>\n\t<b>{{ __(\"Customer\") }}:</b> {{ customer }}<br>\n</p>\n\n<p>\n\t<b>{{ __(\"Date\") }}:</b> {{ dateutil.global_date_format(posting_date) }}<br>\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"50%\">{{ __(\"Item\") }}</b></th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Qty\") }}</th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Amount\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{% for item in items %}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_name }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ format_number(item.qty, null,precision(\"difference\")) }}<br>@ {{ format_currency(item.rate, currency) }}</td>\n\t\t\t<td class=\"text-right\">{{ format_currency(item.amount, currency) }}</td>\n\t\t</tr>\n\t\t{% endfor %}\n\t</tbody>\n</table>\n\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% for row in taxes %}\n\t\t{% if not row.included_in_print_rate %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t{% endfor %}\n\t\t{% if discount_amount %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ __(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ __(\"Paid Amount\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(paid_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n\n<hr>\n<p>{{ terms }}</p>\n<p class=\"text-center\">{{ __(\"Thank you, please visit again.\") }}</p>", 
  "idx": 0, 
  "line_breaks": 0, 
- "modified": "2017-05-19 14:36:04.740728", 
+ "modified": "2017-09-14 14:36:04.740728", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Point of Sale", 
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 5a0b967..9cc0616 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -16,6 +16,8 @@
 class BuyingController(StockController):
 	def __setup__(self):
 		if hasattr(self, "taxes"):
+			self.flags.print_taxes_with_zero_amount = cint(frappe.db.get_single_value("Print Settings",
+				 "print_taxes_with_zero_amount"))
 			self.print_templates = {
 				"taxes": "templates/print_formats/includes/taxes.html"
 			}
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 10b3607..d8b4202 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -14,6 +14,8 @@
 class SellingController(StockController):
 	def __setup__(self):
 		if hasattr(self, "taxes"):
+			self.flags.print_taxes_with_zero_amount = cint(frappe.db.get_single_value("Print Settings",
+				 "print_taxes_with_zero_amount"))
 			self.print_templates = {
 				"taxes": "templates/print_formats/includes/taxes.html"
 			}
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 5fedc72..5bd476e 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -367,15 +367,11 @@
 				frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
 
 	def set_actual_dates(self):
+		self.actual_start_date = None
+		self.actual_end_date = None
 		if self.get("operations"):
-			actual_date = frappe.db.sql("""select min(actual_start_time) as start_date,
-				max(actual_end_time) as end_date from `tabProduction Order Operation`
-				where parent = %s and docstatus=1""", self.name, as_dict=1)[0]
-			self.actual_start_date = actual_date.start_date
-			self.actual_end_date = actual_date.end_date
-		else:
-			self.actual_start_date = None
-			self.actual_end_date = None
+			self.actual_start_date = min([d.actual_start_time for d in self.get("operations")])
+			self.actual_end_date = max([d.actual_end_time for d in self.get("operations")])
 
 	def delete_timesheet(self):
 		for timesheet in frappe.get_all("Timesheet", ["name"], {"production_order": self.name}):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 7ec2753..5bfd34e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -434,4 +434,6 @@
 erpnext.patches.v8_5.remove_project_type_property_setter
 erpnext.patches.v8_7.add_more_gst_fields
 erpnext.patches.v8_7.fix_purchase_receipt_status
-erpnext.patches.v8_6.rename_bom_update_tool
\ No newline at end of file
+erpnext.patches.v8_6.rename_bom_update_tool
+erpnext.patches.v8_9.set_print_zero_amount_taxes
+erpnext.patches.v8_9.set_default_customer_group
\ No newline at end of file
diff --git a/erpnext/patches/v8_9/__init__.py b/erpnext/patches/v8_9/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/erpnext/patches/v8_9/__init__.py
@@ -0,0 +1 @@
+
diff --git a/erpnext/patches/v8_9/set_default_customer_group.py b/erpnext/patches/v8_9/set_default_customer_group.py
new file mode 100644
index 0000000..b121998
--- /dev/null
+++ b/erpnext/patches/v8_9/set_default_customer_group.py
@@ -0,0 +1,6 @@
+import frappe
+
+def execute():
+	selling_settings = frappe.get_single('Selling Settings')
+	selling_settings.set_default_customer_group_and_territory()
+	selling_settings.save()
diff --git a/erpnext/patches/v8_9/set_print_zero_amount_taxes.py b/erpnext/patches/v8_9/set_print_zero_amount_taxes.py
new file mode 100644
index 0000000..33d3ced
--- /dev/null
+++ b/erpnext/patches/v8_9/set_print_zero_amount_taxes.py
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+import frappe
+
+from erpnext.setup.install import create_print_zero_amount_taxes_custom_field
+
+def execute():
+	create_print_zero_amount_taxes_custom_field()
\ No newline at end of file
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 1a54cc3..b0dfdcb 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
@@ -14,7 +14,8 @@
 		dict(fieldtype='Data', label='Export Type', width=120),
 		dict(fieldtype='Data', label='E-Commerce GSTIN', width=130),
 		dict(fieldtype='Data', label='HSN Code', width=120),
-		dict(fieldtype='Data', label='Supplier Invoice No', width=120)
+		dict(fieldtype='Data', label='Supplier Invoice No', width=120),
+		dict(fieldtype='Date', label='Supplier Invoice Date', width=100)
 	], additional_query_columns=[
 		'supplier_gstin',
 		'company_gstin',
@@ -23,5 +24,6 @@
 		'export_type',
 		'ecommerce_gstin',
 		'gst_hsn_code',
-		'bill_no'
+		'bill_no',
+		'bill_date'
 	])
diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py
index ee7d203..d297883 100644
--- a/erpnext/selling/doctype/selling_settings/selling_settings.py
+++ b/erpnext/selling/doctype/selling_settings/selling_settings.py
@@ -8,6 +8,7 @@
 import frappe.defaults
 from frappe.utils import cint
 from frappe.custom.doctype.property_setter.property_setter import make_property_setter
+from frappe.utils.nestedset import get_root_of
 
 from frappe.model.document import Document
 
@@ -31,3 +32,9 @@
 		for doctype in ("Sales Order", "Sales Invoice", "Delivery Note"):
 			make_property_setter(doctype, "tax_id", "hidden", self.hide_tax_id, "Check")
 			make_property_setter(doctype, "tax_id", "print_hide", self.hide_tax_id, "Check")
+
+	def set_default_customer_group_and_territory(self):
+		if not self.customer_group:
+			self.customer_group = get_root_of('Customer Group')
+		if not self.territory:
+			self.territory = get_root_of('Territory')
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 9bf15ce..81f909a 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -5,6 +5,8 @@
 
 import frappe
 from frappe import _
+from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
+from frappe.custom.doctype.custom_field.custom_field import create_custom_field
 
 default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
 	<a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
@@ -13,7 +15,7 @@
 	frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
 	set_single_defaults()
 	create_compact_item_print_custom_field()
-	from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
+	create_print_zero_amount_taxes_custom_field()
 	add_all_roles_to("Administrator")
 	frappe.db.commit()
 
@@ -44,11 +46,19 @@
 	frappe.db.set_default("date_format", "dd-mm-yyyy")
 
 def create_compact_item_print_custom_field():
-	from frappe.custom.doctype.custom_field.custom_field import create_custom_field
 	create_custom_field('Print Settings', {
 		'label': _('Compact Item Print'),
 		'fieldname': 'compact_item_print',
 		'fieldtype': 'Check',
 		'default': 1,
 		'insert_after': 'with_letterhead'
+	})
+
+def create_print_zero_amount_taxes_custom_field():
+	create_custom_field('Print Settings', {
+		'label': _('Print taxes with zero amount'),
+		'fieldname': 'print_taxes_with_zero_amount',
+		'fieldtype': 'Check',
+		'default': 0,
+		'insert_after': 'allow_print_for_cancelled'
 	})
\ No newline at end of file
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index 4dec3d7..c40ad55 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -176,6 +176,7 @@
 	selling_settings.so_required = "No"
 	selling_settings.dn_required = "No"
 	selling_settings.allow_multiple_items = 1
+	selling_settings.set_default_customer_group_and_territory()
 	selling_settings.save()
 
 	buying_settings = frappe.get_doc("Buying Settings")
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index 6b503b3..3164306 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -4,7 +4,6 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe.utils.nestedset import get_root_of
 
 def boot_session(bootinfo):
 	"""boot session - send website info if guest"""
@@ -17,9 +16,9 @@
 
 		load_country_and_currency(bootinfo)
 		bootinfo.sysdefaults.territory = frappe.db.get_single_value('Selling Settings',
-			'territory') or get_root_of('Territory')
+			'territory')
 		bootinfo.sysdefaults.customer_group = frappe.db.get_single_value('Selling Settings',
-			'customer_group') or get_root_of('Customer Group')
+			'customer_group')
 
 		bootinfo.notification_settings = frappe.get_doc("Notification Control",
 			"Notification Control")
diff --git a/erpnext/templates/print_formats/includes/taxes.html b/erpnext/templates/print_formats/includes/taxes.html
index b782763..41f216e 100644
--- a/erpnext/templates/print_formats/includes/taxes.html
+++ b/erpnext/templates/print_formats/includes/taxes.html
@@ -1,7 +1,7 @@
 {%- macro render_discount_amount(doc) -%}
 	{%- if doc.discount_amount -%}
 		<div class="row">
-			<div class="col-xs-5 {%- if not doc._align_labels_left %} text-right{%- endif -%}">
+			<div class="col-xs-5 {%- if doc._align_labels_right %} text-right{%- endif -%}">
 				<label>{{ _("Discount Amount") }}</label></div>
 			<div class="col-xs-7 text-right">
 				- {{ doc.get_formatted("discount_amount", doc) }}
@@ -17,7 +17,7 @@
 			{{ render_discount_amount(doc) }}
 		{%- endif -%}
 		{%- for charge in data -%}
-			{%- if charge.tax_amount and not charge.included_in_print_rate -%}
+			{%- if (charge.tax_amount or doc.flags.print_taxes_with_zero_amount) and not charge.included_in_print_rate -%}
 			<div class="row">
 				<div class="col-xs-5 {%- if doc._align_labels_right %} text-right{%- endif -%}">
 					<label>{{ charge.get_formatted("description") }}</label></div>