resolved merge conflicts
diff --git a/.travis.yml b/.travis.yml
index 0b3b49f..beab4e1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,8 @@
   - mysql
 
 install:
+  - pip install flake8==3.3.0
+  - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
   - sudo rm /etc/apt/sources.list.d/docker.list
   - sudo apt-get purge -y mysql-common mysql-server mysql-client
   - nvm install v7.10.0
diff --git a/README.md b/README.md
index 1fae1ce..b44a246 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,7 @@
 
 ERPNext is built on the [Frappe](https://github.com/frappe/frappe) Framework, a full-stack web app framework in Python & JavaScript.
 
-- [User Guide](https://frappe.github.io/erpnext/)
-- [Getting Help](http://erpnext.org/getting-help.html)
+- [User Guide](https://erpnext.org/docs/user)
 - [Discussion Forum](https://discuss.erpnext.com/)
 
 ---
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
index 9893a5b..cb95bd1 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
@@ -84,7 +84,7 @@
 					try:
 						csv_content.setdefault(file_type, [])\
 							.append(read_csv_content(csvfile.read()))
-					except Exception, e:
+					except Exception as e:
 						continue
 	return csv_content
 
diff --git a/erpnext/accounts/doctype/account/test_make_tax_account.js b/erpnext/accounts/doctype/account/test_make_tax_account.js
new file mode 100644
index 0000000..a0e09a1
--- /dev/null
+++ b/erpnext/accounts/doctype/account/test_make_tax_account.js
@@ -0,0 +1,46 @@
+QUnit.module('accounts');
+QUnit.test("test account", assert => {
+	assert.expect(3);
+	let done = assert.async();
+	frappe.run_serially([
+		() => frappe.set_route('Tree', 'Account'),
+		() => frappe.click_button('Expand All'),
+		() => frappe.click_link('Duties and Taxes - '+ frappe.get_abbr(frappe.defaults.get_default("Company"))),
+		() => {
+			if($('a:contains("CGST"):visible').length == 0){
+				return frappe.map_tax.make('CGST', 9);
+			}
+		},
+		() => {
+			if($('a:contains("SGST"):visible').length == 0){
+				return frappe.map_tax.make('SGST', 9);
+			}
+		},
+		() => {
+			if($('a:contains("IGST"):visible').length == 0){
+				return frappe.map_tax.make('IGST', 18);
+			}
+		},
+		() => {
+			assert.ok($('a:contains("CGST"):visible').length!=0, "CGST Checked");
+			assert.ok($('a:contains("SGST"):visible').length!=0, "SGST Checked");
+			assert.ok($('a:contains("IGST"):visible').length!=0, "IGST Checked");
+		},
+		() => done()
+	]);
+});
+
+
+frappe.map_tax = {
+	make:function(text,rate){
+		return frappe.run_serially([
+			() => frappe.click_button('Add Child'),
+			() => frappe.timeout(0.2),
+			() => cur_dialog.set_value('account_name',text),
+			() => cur_dialog.set_value('account_type','Tax'),
+			() => cur_dialog.set_value('tax_rate',rate),
+			() => cur_dialog.set_value('account_currency','INR'),
+			() => frappe.click_button('Create New'),
+		]);
+	}
+};
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index 577c77f..9047a4e 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -43,8 +43,26 @@
 		$.each(frm.doc.accounts || [], function(i, row) {
 			erpnext.journal_entry.set_exchange_rate(frm, row.doctype, row.name);
 		})
+	},
+
+	company: function(frm) {
+		frappe.call({
+			method: "frappe.client.get_value",
+			args: {
+				doctype: "Company",
+				filters: {"name": frm.doc.company},
+				fieldname: "cost_center"
+			},
+			callback: function(r){
+				if(r.message){
+					$.each(frm.doc.accounts || [], function(i, jvd) {
+						frappe.model.set_value(jvd.doctype, jvd.name, "cost_center", r.message.cost_center);
+					});
+				}
+			}
+		});
 	}
-})
+});
 
 erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
 	onload: function() {
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index eb0f474..4a15f39 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -339,7 +339,8 @@
 					method: "erpnext.setup.utils.get_exchange_rate",
 					args: {
 						from_currency: frm.doc.paid_from_account_currency,
-						to_currency: company_currency
+						to_currency: company_currency,
+						transaction_date: frm.doc.posting_date
 					},
 					callback: function(r, rt) {
 						frm.set_value("source_exchange_rate", r.message);
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py
index 86682d3..8d6a2db 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.py
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py
@@ -14,6 +14,7 @@
 		self.check_for_duplicate()
 		self.validate_all_link_fields()
 		self.validate_duplicate_groups()
+		self.check_default_payment()
 		self.validate_customer_territory_group()
 
 	def check_for_duplicate(self):
@@ -49,6 +50,14 @@
 		if len(customer_groups) != len(set(customer_groups)):
 			frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group")
 
+	def check_default_payment(self):
+		if self.payments:
+			default_mode_of_payment = [d.default for d in self.payments if d.default]
+			if not default_mode_of_payment:
+				frappe.throw(_("Set default mode of payment"))
+
+			if len(default_mode_of_payment) > 1:
+				frappe.throw(_("Multiple default mode of payment is not allowed"))
 	def validate_customer_territory_group(self):
 		if not self.territory:
 			frappe.throw(_("Territory is Required in POS Profile"), title="Mandatory Field")
diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py
index 534abb6..803ee8e 100644
--- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py
+++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py
@@ -31,6 +31,8 @@
 		frappe.db.sql("delete from `tabPOS Profile`")
 
 def make_pos_profile():
+	frappe.db.sql("delete from `tabPOS Profile`")
+
 	pos_profile = frappe.get_doc({
 		"company": "_Test Company",
 		"cost_center": "_Test Cost Center - _TC",
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 3c9de12..57f75b4 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -485,7 +485,7 @@
 		si_doc.insert()
 		si_doc.submit()
 		frappe.db.commit()
-	except Exception, e:
+	except Exception as e:
 		if frappe.message_log: frappe.message_log.pop()
 		frappe.db.rollback()
 		save_invoice(e, si_doc, name)
diff --git a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
index 13d7f15..531622d 100644
--- a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
+++ b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
  "beta": 0, 
@@ -11,16 +12,51 @@
  "editable_grid": 1, 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:parent.doctype == 'POS Profile'", 
+   "fieldname": "default", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Default", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "mode_of_payment", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Mode of Payment", 
    "length": 0, 
    "no_copy": 0, 
@@ -30,6 +66,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -37,9 +74,11 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "0.0", 
    "depends_on": "eval:parent.doctype == 'Sales Invoice'", 
    "fieldname": "amount", 
@@ -48,7 +87,9 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Amount", 
    "length": 0, 
    "no_copy": 0, 
@@ -58,6 +99,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -65,16 +107,20 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -82,6 +128,7 @@
    "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, 
@@ -89,16 +136,20 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "account", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Account", 
    "length": 0, 
    "no_copy": 0, 
@@ -108,6 +159,7 @@
    "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, 
@@ -115,16 +167,20 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "type", 
    "fieldtype": "Read Only", 
    "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": "Type", 
    "length": 0, 
    "no_copy": 0, 
@@ -134,6 +190,7 @@
    "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, 
@@ -141,16 +198,20 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "base_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Base Amount (Company Currency)", 
    "length": 0, 
    "no_copy": 1, 
@@ -160,6 +221,7 @@
    "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, 
@@ -167,17 +229,17 @@
    "unique": 0
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
  "image_view": 0, 
  "in_create": 0, 
- "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-07-11 03:28:07.779228", 
+ "modified": "2017-07-24 17:25:03.765856", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice Payment", 
@@ -187,7 +249,9 @@
  "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
  "sort_field": "modified", 
  "sort_order": "DESC", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js
new file mode 100644
index 0000000..2667ee6
--- /dev/null
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js
@@ -0,0 +1,26 @@
+QUnit.module('Sales Taxes and Charges Template');
+
+QUnit.test("test sales taxes and charges template", function(assert) {
+	assert.expect(1);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Sales Taxes and Charges Template', [
+				{title: "TEST In State GST"},
+				{taxes:[
+					[
+						{charge_type:"On Net Total"},
+						{account_head:"CGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
+					],
+					[
+						{charge_type:"On Net Total"},
+						{account_head:"SGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
+					]
+				]}
+			]);
+		},
+		() => {assert.ok(cur_frm.doc.title=='TEST In State GST');},
+		() => done()
+	]);
+});
+
diff --git a/erpnext/accounts/page/pos/test_pos.js b/erpnext/accounts/page/pos/test_pos.js
new file mode 100644
index 0000000..62c6e31
--- /dev/null
+++ b/erpnext/accounts/page/pos/test_pos.js
@@ -0,0 +1,60 @@
+QUnit.test("test:POS Profile", function(assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make("POS Profile", [
+				{naming_series: "SINV"},
+				{company: "_Test Company"},
+				{country: "India"},
+				{currency: "INR"},
+				{write_off_account: "Write Off - _TC"},
+				{write_off_cost_center: "Main - _TC"},
+				{payments: [
+					[
+						{"default": 1},
+						{"mode_of_payment": "Cash"}
+					]]
+				}
+			]);
+		},
+		() => cur_frm.save(),
+		() => frappe.timeout(2),
+		() => {
+			assert.equal(cur_frm.doc.payments[0].default, 1, "Default mode of payment tested");
+		},
+		() => done()
+	]);
+});
+
+QUnit.test("test:Sales Invoice", function(assert) {
+	assert.expect(2);
+	let done = assert.async();
+
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make("Sales Invoice", [
+				{customer: "_Test Customer 2"},
+				{company: "_Test Company"},
+				{is_pos: 1},
+				{posting_date: frappe.datetime.get_today()},
+				{due_date: frappe.datetime.get_today()},
+				{items: [
+					[
+						{"item_code": "_Test Item"},
+						{"qty": 5}
+					]]
+				}
+			]);
+		},
+		() => frappe.timeout(2),
+		() => cur_frm.save(),
+		() => frappe.timeout(2),
+		() => {
+			assert.equal(cur_frm.doc.payments[0].default, 1, "Default mode of payment tested");
+			assert.equal(cur_frm.doc.payments[0].mode_of_payment, "Cash", "Default mode of payment tested");
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 560ba4d..cce1e6f 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -20,36 +20,36 @@
 
 def get_fiscal_years(transaction_date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False):
 	fiscal_years = frappe.cache().hget("fiscal_years", company) or []
-	
-	if not fiscal_years:		
+
+	if not fiscal_years:
 		# if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate)
 		cond = ""
 		if fiscal_year:
 			cond += " and fy.name = {0}".format(frappe.db.escape(fiscal_year))
 		if company:
 			cond += """
-				and (not exists (select name 
-					from `tabFiscal Year Company` fyc 
-					where fyc.parent = fy.name) 
-				or exists(select company 
-					from `tabFiscal Year Company` fyc 
-					where fyc.parent = fy.name 
+				and (not exists (select name
+					from `tabFiscal Year Company` fyc
+					where fyc.parent = fy.name)
+				or exists(select company
+					from `tabFiscal Year Company` fyc
+					where fyc.parent = fy.name
 					and fyc.company=%(company)s)
 				)
 			"""
 
 		fiscal_years = frappe.db.sql("""
-			select 
-				fy.name, fy.year_start_date, fy.year_end_date 
-			from 
+			select
+				fy.name, fy.year_start_date, fy.year_end_date
+			from
 				`tabFiscal Year` fy
-			where 
+			where
 				disabled = 0 {0}
-			order by 
+			order by
 				fy.year_start_date desc""".format(cond), {
 				"company": company
 			}, as_dict=True)
-			
+
 		frappe.cache().hset("fiscal_years", company, fiscal_years)
 
 	if transaction_date:
@@ -60,10 +60,10 @@
 		if fiscal_year and fy.name == fiscal_year:
 			matched = True
 
-		if (transaction_date and getdate(fy.year_start_date) <= transaction_date 
+		if (transaction_date and getdate(fy.year_start_date) <= transaction_date
 			and getdate(fy.year_end_date) >= transaction_date):
 			matched = True
-			
+
 		if matched:
 			if as_dict:
 				return (fy,)
@@ -72,7 +72,7 @@
 
 	error_msg = _("""{0} {1} not in any active Fiscal Year.""").format(label, formatdate(transaction_date))
 	if verbose==1: frappe.msgprint(error_msg)
-	raise FiscalYearError, error_msg
+	raise FiscalYearError(error_msg)
 
 def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None):
 	years = [f[0] for f in get_fiscal_years(date, label=_(label), company=company)]
@@ -158,7 +158,6 @@
 		return flt(bal)
 
 def get_count_on(account, fieldname, date):
-
 	cond = []
 	if date:
 		cond.append("posting_date <= '%s'" % frappe.db.escape(cstr(date)))
@@ -195,11 +194,6 @@
 				select name from `tabAccount` ac where ac.name = gle.account
 				and ac.lft >= %s and ac.rgt <= %s
 			)""" % (acc.lft, acc.rgt))
-
-			# If group and currency same as company,
-			# always return balance based on debit and credit in company currency
-			if acc.account_currency == frappe.db.get_value("Company", acc.company, "default_currency"):
-				in_account_currency = False
 		else:
 			cond.append("""gle.account = "%s" """ % (frappe.db.escape(account, percent=False), ))
 
@@ -227,7 +221,7 @@
 						WHERE docstatus < 2 and posting_date <= %(date)s and against_voucher = %(voucher_no)s
 						and party = %(party)s and name != %(name)s"""
 						.format(select_fields),
-						{"date": date, "voucher_no": gle.voucher_no, 
+						{"date": date, "voucher_no": gle.voucher_no,
 							"party": gle.party, "name": gle.name})[0][0]
 
 					outstanding_amount = flt(gle.get(dr_or_cr)) - flt(gle.get(cr_or_dr)) - payment_amount
@@ -274,7 +268,7 @@
 
 	if not args:
 		args = frappe.local.form_dict
-	
+
 	args.doctype = "Cost Center"
 	args = make_tree_args(**args)
 
@@ -534,18 +528,18 @@
 			account_balance = get_balance_on(account_data.get('account'), posting_date, in_account_currency=False)
 			stock_value = get_stock_value_on(warehouse, posting_date)
 			if abs(flt(stock_value) - flt(account_balance)) > 0.005:
-				difference.setdefault(account, flt(stock_value) - flt(account_balance))
+				difference.setdefault(account_data.get('account'), flt(stock_value) - flt(account_balance))
 
 	return difference
 
-def get_currency_precision():	
+def get_currency_precision():
 	precision = cint(frappe.db.get_default("currency_precision"))
 	if not precision:
 		number_format = frappe.db.get_default("number_format") or "#,###.##"
 		precision = get_number_format_info(number_format)[2]
-	
+
 	return precision
-	
+
 def get_stock_rbnb_difference(posting_date, company):
 	stock_items = frappe.db.sql_list("""select distinct item_code
 		from `tabStock Ledger Entry` where company=%s""", company)
@@ -654,7 +648,7 @@
 @frappe.whitelist()
 def get_children():
 	from erpnext.accounts.report.financial_statements import sort_root_accounts
-	
+
 	args = frappe.local.form_dict
 	doctype, company = args['doctype'], args['company']
 	fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
@@ -696,9 +690,6 @@
 	return acc
 
 def create_payment_gateway_account(gateway):
-	create_payment_gateway_account(gateway)
-
-def create_payment_gateway_account(gateway):
 	from erpnext.setup.setup_wizard.setup_wizard import create_bank_account
 
 	company = frappe.db.get_value("Global Defaults", None, "default_company")
@@ -738,4 +729,4 @@
 
 	except frappe.DuplicateEntryError:
 		# already exists, due to a reinstall?
-		pass
\ No newline at end of file
+		pass
diff --git a/erpnext/buying/__init__.py b/erpnext/buying/__init__.py
index e69de29..baffc48 100644
--- a/erpnext/buying/__init__.py
+++ b/erpnext/buying/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 7e5020a..26c8c61 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -39,6 +39,8 @@
 		super(PurchaseOrder, self).validate()
 
 		self.set_status()
+
+		self.validate_supplier()
 		validate_for_items(self)
 		self.check_for_closed_status()
 
@@ -65,6 +67,17 @@
 			}
 		})
 
+	def validate_supplier(self):
+		prevent_po = frappe.db.get_value("Supplier", self.supplier, 'prevent_pos')
+		if prevent_po:
+			standing = frappe.db.get_value("Supplier Scorecard",self.supplier, 'status')
+			frappe.throw(_("Purchase Orders are not allowed for {0} due to a scorecard standing of {1}.").format(self.supplier, standing))
+
+		warn_po = frappe.db.get_value("Supplier", self.supplier, 'warn_pos')
+		if warn_po:
+			standing = frappe.db.get_value("Supplier Scorecard",self.supplier, 'status')
+			frappe.msgprint(_("{0} currently has a {1} Supplier Scorecard standing, and Purchase Orders to this supplier should be issued with caution.").format(self.supplier, standing), title=_("Caution"), indicator='orange')
+
 	def validate_minimum_order_qty(self):
 		items = list(set([d.item_code for d in self.get("items")]))
 
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
index ce759aa..558e072 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -44,6 +44,9 @@
 					freeze: true,
 					args: {
 						rfq_name: frm.doc.name
+					},
+					callback: function(r){
+						frm.reload_doc();
 					}
 				});
 			});
@@ -51,6 +54,91 @@
 
 	},
 
+	get_suppliers_button: function (frm) {
+		var doc = frm.doc;
+		var dialog = new frappe.ui.Dialog({
+			title: __("Get Suppliers"),
+			fields: [
+				{	"fieldtype": "Select", "label": __("Get Suppliers By"),
+					"fieldname": "search_type",
+					"options": "Tag\nSupplier Type", "reqd": 1 },
+				{	"fieldtype": "Link", "label": __("Supplier Type"),
+					"fieldname": "supplier_type",
+					"options": "Supplier Type",	"reqd": 0,
+					"depends_on": "eval:doc.search_type == 'Supplier Type'"},
+				{	"fieldtype": "Data", "label": __("Tag"),
+					"fieldname": "tag",	"reqd": 0,
+					"depends_on": "eval:doc.search_type == 'Tag'" },
+				{	"fieldtype": "Button", "label": __("Add All Suppliers"),
+					"fieldname": "add_suppliers", "cssClass": "btn-primary"},
+			]
+		});
+
+		dialog.fields_dict.add_suppliers.$input.click(function() {
+			var args = dialog.get_values();
+			if(!args) return;
+			dialog.hide();
+
+			//Remove blanks
+			for (var j = 0; j < frm.doc.suppliers.length; j++) {
+				if(!frm.doc.suppliers[j].hasOwnProperty("supplier")) {
+					frm.get_field("suppliers").grid.grid_rows[j].remove();
+				}
+			}
+
+			 function load_suppliers(r) {
+				if(r.message) {
+					for (var i = 0; i < r.message.length; i++) {
+						var exists = false;
+						if (r.message[i].constructor === Array){
+							var supplier = r.message[i][0];
+						} else {
+							var supplier = r.message[i].name;
+						}
+
+						for (var j = 0; j < doc.suppliers.length;j++) {
+							if (supplier === doc.suppliers[j].supplier) {
+								exists = true;
+							}
+						}
+						if(!exists) {
+							var d = frm.add_child('suppliers');
+							d.supplier = supplier;
+							frm.script_manager.trigger("supplier", d.doctype, d.name);
+						}
+					}
+				}
+				frm.refresh_field("suppliers");
+			}
+
+			if (args.search_type === "Tag" && args.tag) {
+				return frappe.call({
+					type: "GET",
+					method: "frappe.desk.tags.get_tagged_docs",
+					args: {
+						"doctype": "Supplier",
+						"tag": args.tag
+					},
+					callback: load_suppliers
+				});
+			} else if (args.supplier_type) {
+				return frappe.call({
+					method: "frappe.client.get_list",
+					args: {
+						doctype: "Supplier",
+						order_by: "name",
+						fields: ["name"],
+						filters: [["Supplier", "supplier_type", "=", args.supplier_type]]
+
+					},
+					callback: load_suppliers
+				});
+			}
+		});
+		dialog.show();
+
+	},
+
 	make_suppplier_quotation: function(frm) {
 		var doc = frm.doc;
 		var dialog = new frappe.ui.Dialog({
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
index ac345d9..44068ce 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
@@ -25,7 +25,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_global_search": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Series", 
    "length": 0, 
@@ -59,7 +59,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_global_search": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Company", 
    "length": 0, 
@@ -156,7 +156,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_global_search": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Date", 
    "length": 0, 
@@ -242,6 +242,36 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "get_suppliers_button", 
+   "fieldtype": "Button", 
+   "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": "Get Suppliers", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "items_section", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -406,7 +436,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_global_search": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Message for Supplier", 
    "length": 0, 
@@ -786,7 +816,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-06-13 14:29:13.171291", 
+ "modified": "2017-07-21 14:06:46.309322", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Request for Quotation", 
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 9109239..e9603fb 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -21,6 +21,7 @@
 class RequestforQuotation(BuyingController):
 	def validate(self):
 		self.validate_duplicate_supplier()
+		self.validate_supplier_list()
 		validate_for_items(self)
 		self.update_email_id()
 
@@ -29,6 +30,17 @@
 		if len(supplier_list) != len(set(supplier_list)):
 			frappe.throw(_("Same supplier has been entered multiple times"))
 
+	def validate_supplier_list(self):
+		for d in self.suppliers:
+			prevent_rfqs = frappe.db.get_value("Supplier", d.supplier, 'prevent_rfqs')
+			if prevent_rfqs:
+				standing = frappe.db.get_value("Supplier Scorecard",d.supplier, 'status')
+				frappe.throw(_("RFQs are not allowed for {0} due to a scorecard standing of {1}").format(d.supplier, standing))
+			warn_rfqs = frappe.db.get_value("Supplier", d.supplier, 'warn_rfqs')
+			if warn_rfqs:
+				standing = frappe.db.get_value("Supplier Scorecard",d.supplier, 'status')
+				frappe.msgprint(_("{0} currently has a {1} Supplier Scorecard standing, and RFQs to this supplier should be issued with caution.").format(d.supplier, standing), title=_("Caution"), indicator='orange')
+
 	def update_email_id(self):
 		for rfq_supplier in self.suppliers:
 			if not rfq_supplier.email_id:
@@ -40,6 +52,8 @@
 
 	def on_submit(self):
 		frappe.db.set(self, 'status', 'Submitted')
+		for supplier in self.suppliers:
+			supplier.email_sent = 0
 
 	def on_cancel(self):
 		frappe.db.set(self, 'status', 'Cancelled')
@@ -54,6 +68,8 @@
 
 				self.update_supplier_part_no(rfq_supplier)
 				self.supplier_rfq_mail(rfq_supplier, update_password_link, self.get_link())
+				rfq_supplier.email_sent = 1
+				rfq_supplier.save()
 
 	def get_link(self):
 		# RFQ link for supplier portal
@@ -84,7 +100,10 @@
 		else:
 			contact = frappe.new_doc("Contact")
 			contact.first_name = rfq_supplier.supplier_name or rfq_supplier.supplier
-			contact.supplier = rfq_supplier.supplier
+			contact.append('links', {
+				'link_doctype': 'Supplier',
+				'link_name': rfq_supplier.supplier
+			})
 
 		if not contact.email_id and not contact.user:
 			contact.email_id = user.name
diff --git a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json
index 7bc0def..a7c5a37 100644
--- a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json
+++ b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
  "beta": 0, 
@@ -12,6 +13,7 @@
  "engine": "InnoDB", 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
@@ -42,6 +44,39 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "depends_on": "eval:doc.docstatus >= 1", 
+   "fieldname": "email_sent", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Email Sent", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -72,6 +107,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -102,6 +138,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -130,6 +167,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -160,6 +198,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -190,6 +229,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
@@ -219,17 +259,17 @@
    "unique": 0
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
  "image_view": 0, 
  "in_create": 0, 
- "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2017-02-17 16:42:57.254211", 
+ "modified": "2017-07-24 06:52:19.542717", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Request for Quotation Supplier", 
diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json
index 58a1fc7..711e05d 100644
--- a/erpnext/buying/doctype/supplier/supplier.json
+++ b/erpnext/buying/doctype/supplier/supplier.json
@@ -326,6 +326,126 @@
    "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn RFQs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn POs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent RFQs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent POs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
    "collapsible": 1, 
    "columns": 0, 
    "fieldname": "section_break_7", 
@@ -850,7 +970,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-06-13 14:29:16.310834", 
+ "modified": "2017-07-06 16:40:46.935608", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Supplier", 
diff --git a/erpnext/buying/doctype/supplier_scorecard/__init__.py b/erpnext/buying/doctype/supplier_scorecard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.js b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.js
new file mode 100644
index 0000000..a3a1414
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.js
@@ -0,0 +1,146 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe, refresh_field */
+
+frappe.ui.form.on("Supplier Scorecard", {
+
+	onload: function(frm) {
+
+		if (frm.doc.indicator_color !== "")	{
+			frm.set_indicator_formatter("status", function(doc) {
+				return doc.indicator_color.toLowerCase();
+			});
+		}
+		if (frm.doc.__unsaved == 1)	{
+			loadAllCriteria(frm);
+			loadAllStandings(frm);
+		}
+
+	},
+	refresh: function(frm) {
+		if (frm.dashboard.hasOwnProperty('heatmap')) {
+			frm.dashboard.heatmap.setLegend([0,20,40,60,80,101],["#991600","#169900"]);
+		}
+	}
+
+});
+
+frappe.ui.form.on("Supplier Scorecard Scoring Standing", {
+
+	standing_name: function(frm, cdt, cdn) {
+		if (frm.doc.standing_name != undefined) {
+			var d = frappe.get_doc(cdt, cdn);
+			return frm.call({
+				method: "erpnext.buying.doctype.supplier_scorecard_standing.supplier_scorecard_standing.get_scoring_standing",
+				child: d,
+				args: {
+					standing_name: d.standing_name
+				}
+			});
+		}
+	}
+});
+
+frappe.ui.form.on("Supplier Scorecard Scoring Variable", {
+
+	variable_label: function(frm, cdt, cdn) {
+		if (frm.doc.variable_label != undefined) {
+			var d = frappe.get_doc(cdt, cdn);
+			return frm.call({
+				method: "erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable.get_scoring_variable",
+				child: d,
+				args: {
+					variable_label: d.variable_label
+				}
+			});
+		}
+	}
+});
+
+frappe.ui.form.on("Supplier Scorecard Scoring Criteria", {
+
+	criteria_name: function(frm, cdt, cdn) {
+		if (frm.doc.criteria_name != undefined) {
+			var d = frappe.get_doc(cdt, cdn);
+			frm.call({
+				method: "erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria.get_variables",
+				args: {
+					criteria_name: d.criteria_name
+				},
+				callback: function(r) {
+					for (var i = 0; i < r.message.length; i++)
+					{
+						var exists = false;
+						for (var j = 0; j < frm.doc.variables.length; j++)
+						{
+							if(!frm.doc.variables[j].hasOwnProperty("variable_label")) {
+								frm.get_field("variables").grid.grid_rows[j].remove();
+							}
+							else if(frm.doc.variables[j].variable_label === r.message[i]) {
+								exists = true;
+							}
+						}
+						if (!exists){
+							var new_row = frm.add_child("variables");
+							new_row.variable_label = r.message[i];
+							frm.script_manager.trigger("variable_label", new_row.doctype, new_row.name);
+						}
+
+					}
+					refresh_field("variables");
+				}
+			});
+			return frm.call({
+				method: "erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria.get_scoring_criteria",
+				child: d,
+				args: {
+					criteria_name: d.criteria_name
+				}
+			});
+		}
+	}
+});
+
+var loadAllCriteria = function(frm) {
+	frappe.call({
+		method: "erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria.get_criteria_list",
+		callback: function(r) {
+			for (var j = 0; j < frm.doc.criteria.length; j++)
+			{
+				if(!frm.doc.criteria[j].hasOwnProperty("criteria_name")) {
+					frm.get_field("criteria").grid.grid_rows[j].remove();
+				}
+			}
+			for (var i = 0; i < r.message.length; i++)
+			{
+				var new_row = frm.add_child("criteria");
+				new_row.criteria_name = r.message[i].name;
+				frm.script_manager.trigger("criteria_name", new_row.doctype, new_row.name);
+			}
+			refresh_field("criteria");
+		}
+	});
+};
+var loadAllStandings = function(frm) {
+	frappe.call({
+		method: "erpnext.buying.doctype.supplier_scorecard_standing.supplier_scorecard_standing.get_standings_list",
+		callback: function(r) {
+			for (var j = 0; j < frm.doc.standings.length; j++)
+			{
+				if(!frm.doc.standings[j].hasOwnProperty("standing_name")) {
+					frm.get_field("standings").grid.grid_rows[j].remove();
+				}
+			}
+			for (var i = 0; i < r.message.length; i++)
+			{
+				var new_row = frm.add_child("standings");
+				new_row.standing_name = r.message[i].name;
+				frm.script_manager.trigger("standing_name", new_row.doctype, new_row.name);
+			}
+			refresh_field("standings");
+		}
+	});
+};
+
+
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json
new file mode 100644
index 0000000..d7f24c9
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json
@@ -0,0 +1,701 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:supplier", 
+ "beta": 1, 
+ "creation": "2017-05-29 01:40:54.786555", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "supplier", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Supplier", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "supplier_score", 
+   "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": "Supplier Score", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "indicator_color", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Indicator Color", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "status", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Status", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Per Month", 
+   "fieldname": "period", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Evaluation Period", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Per Month\nPer Week\nPer Year", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "scoring_setup", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Scoring Setup", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "{total_score} * max( 0, min ( 1 , (12 - {period_number}) / 12) )", 
+   "description": "Scorecard variables can be used, as well as:\n{total_score} (the total score from that period),\n{period_number} (the number of periods to present day)\n", 
+   "fieldname": "weighting_function", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Weighting Function", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "standings", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Scoring Standings", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Scoring Standing", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "criteria_setup", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Setup", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "criteria", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Scoring Criteria", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Scoring Criteria", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "variables", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Supplier Variables", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Scoring Variable", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "collapsible_depends_on": "eval: doc.status != 'Unknown'", 
+   "columns": 0, 
+   "fieldname": "scorecard_actions", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Scorecard Actions", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn for new Request for Quotations", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn for new Purchase Orders", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent RFQs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent POs", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_16", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_supplier", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Supplier", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_employee", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Employee", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee", 
+   "fieldtype": "Link", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:11.874949", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 0, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py
new file mode 100644
index 0000000..e13d22a
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py
@@ -0,0 +1,262 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import throw, _
+from frappe.model.document import Document
+import time
+from datetime import timedelta
+from frappe.utils import nowdate, get_last_day, getdate, add_days, add_years
+from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import make_supplier_scorecard
+
+class SupplierScorecard(Document):
+
+	def validate(self):
+		self.validate_standings()
+		self.validate_criteria_weights()
+		self.calculate_total_score()
+		self.update_standing()
+
+	def on_update(self):
+		score = make_all_scorecards(self.name)
+		if score > 0:
+			self.save()
+
+	def validate_standings(self):
+		# Check that there are no overlapping scores and check that there are no missing scores
+		score = 0
+		for c1 in self.standings:
+			for c2 in self.standings:
+				if c1 != c2:
+					if (c1.max_grade > c2.min_grade and c1.min_grade < c2.max_grade):
+						throw(_('Overlap in scoring between {0} and {1}').format(c1.standing_name,c2.standing_name))
+				if c2.min_grade == score:
+					score = c2.max_grade
+		if score < 100:
+			throw(_('Unable to find score starting at {0}. You need to have standing scores covering 0 to 100').format(score))
+
+	def validate_criteria_weights(self):
+
+		weight = 0
+		for c in self.criteria:
+			weight += c.weight
+
+		if weight != 100:
+			throw(_('Criteria weights must add up to 100%'))
+
+	def calculate_total_score(self):
+		scorecards = frappe.db.sql("""
+			SELECT
+				scp.name
+			FROM
+				`tabSupplier Scorecard Period` scp
+			WHERE
+				scp.scorecard = %(sc)s
+			ORDER BY
+				scp.end_date DESC""",
+				{"sc": self.name}, as_dict=1)
+
+		period = 0
+		total_score = 0
+		total_max_score = 0
+		for scp in scorecards:
+			my_sc = frappe.get_doc('Supplier Scorecard Period', scp.name)
+			my_scp_weight = self.weighting_function
+			my_scp_weight = my_scp_weight.replace('{period_number}', str(period))
+
+			my_scp_maxweight = my_scp_weight.replace('{total_score}', '100')
+			my_scp_weight = my_scp_weight.replace('{total_score}', str(my_sc.total_score))
+
+			max_score = my_sc.calculate_weighted_score(my_scp_maxweight)
+			score = my_sc.calculate_weighted_score(my_scp_weight)
+
+			total_score += score
+			total_max_score += max_score
+			period += 1
+		if total_max_score > 0:
+			self.supplier_score = round(100.0 * (total_score / total_max_score) ,1)
+		else:
+			self.supplier_score =  100
+
+	def update_standing(self):
+		# Get the setup document
+
+		for standing in self.standings:
+			if (not standing.min_grade or (standing.min_grade <= self.supplier_score)) and \
+				(not standing.max_grade or (standing.max_grade > self.supplier_score)):
+				self.status = standing.standing_name
+				self.indicator_color = standing.standing_color
+				self.notify_supplier = standing.notify_supplier
+				self.notify_employee = standing.notify_employee
+				self.employee_link = standing.employee_link
+
+				#Update supplier standing info
+				for fieldname in ('prevent_pos', 'prevent_rfqs','warn_rfqs','warn_pos'):
+					self.set(fieldname, standing.get(fieldname))
+					frappe.db.set_value("Supplier", self.supplier, fieldname, self.get(fieldname))
+
+
+@frappe.whitelist()
+def get_timeline_data(doctype, name):
+	# Get a list of all the associated scorecards
+	scs = frappe.get_doc(doctype, name)
+	out = {}
+	timeline_data = {}
+	scorecards = frappe.db.sql("""
+		SELECT
+			sc.name
+		FROM
+			`tabSupplier Scorecard Period` sc
+		WHERE
+			sc.scorecard = %(scs)s""",
+			{"scs": scs.name}, as_dict=1)
+
+	for sc in scorecards:
+		start_date, end_date, total_score = frappe.db.get_value('Supplier Scorecard Period', sc.name, ['start_date', 'end_date', 'total_score'])
+		for single_date in daterange(start_date, end_date):
+			timeline_data[time.mktime(single_date.timetuple())] =  total_score
+
+	out['timeline_data'] = timeline_data
+	return out
+
+def daterange(start_date, end_date):
+    for n in range(int ((end_date - start_date).days)+1):
+        yield start_date + timedelta(n)
+
+def refresh_scorecards():
+	scorecards = frappe.db.sql("""
+		SELECT
+			sc.name
+		FROM
+			`tabSupplier Scorecard` sc""",
+			{}, as_dict=1)
+	for sc in scorecards:
+		# Check to see if any new scorecard periods are created
+		if make_all_scorecards(sc.name) > 0:
+			# Save the scorecard to update the score and standings
+			sc.save()
+
+
+@frappe.whitelist()
+def make_all_scorecards(docname):
+
+	sc = frappe.get_doc('Supplier Scorecard', docname)
+	supplier = frappe.get_doc('Supplier',sc.supplier)
+
+	start_date = getdate(supplier.creation)
+	end_date = get_scorecard_date(sc.period, start_date)
+	todays = getdate(nowdate())
+
+	scp_count = 0
+	first_start_date = todays
+	last_end_date = todays
+
+	while (start_date < todays) and (end_date <= todays):
+		# check to make sure there is no scorecard period already created
+		scorecards = frappe.db.sql("""
+			SELECT
+				scp.name
+			FROM
+				`tabSupplier Scorecard Period` scp
+			WHERE
+				scp.scorecard = %(sc)s
+				AND (
+					(scp.start_date > %(end_date)s
+					AND scp.end_date < %(start_date)s)
+				OR
+					(scp.start_date < %(end_date)s
+					AND scp.end_date > %(start_date)s))
+			ORDER BY
+				scp.end_date DESC""",
+				{"sc": docname, "start_date": start_date, "end_date": end_date, "supplier": supplier}, as_dict=1)
+		if len(scorecards) == 0:
+			period_card = make_supplier_scorecard(docname, None)
+			period_card.start_date = start_date
+			period_card.end_date = end_date
+			period_card.save()
+			scp_count = scp_count + 1
+			if start_date < first_start_date:
+				first_start_date = start_date
+			last_end_date = end_date
+
+		start_date = getdate(add_days(end_date,1))
+		end_date = get_scorecard_date(sc.period, start_date)
+	if scp_count > 0:
+		frappe.msgprint(_("Created {0} scorecards for {1} between: ").format(scp_count, sc.supplier) + str(first_start_date) + " - " + str(last_end_date))
+	return scp_count
+
+def get_scorecard_date(period, start_date):
+	if period == 'Per Week':
+		end_date = getdate(add_days(start_date,7))
+	elif period == 'Per Month':
+		end_date = get_last_day(start_date)
+	elif period == 'Per Year':
+		end_date = add_days(add_years(start_date,1), -1)
+	return end_date
+
+def make_default_records():
+	install_variable_docs = [
+		{"param_name": "total_accepted_items", "variable_label": "Total Accepted Items", \
+			"path": "get_total_accepted_items"},
+		{"param_name": "total_accepted_amount", "variable_label": "Total Accepted Amount", \
+			"path": "get_total_accepted_amount"},
+		{"param_name": "total_rejected_items", "variable_label": "Total Rejected Items", \
+			"path": "get_total_rejected_items"},
+		{"param_name": "total_rejected_amount", "variable_label": "Total Rejected Amount", \
+			"path": "get_total_rejected_amount"},
+		{"param_name": "total_received_items", "variable_label": "Total Received Items", \
+			"path": "get_total_received_items"},
+		{"param_name": "total_received_amount", "variable_label": "Total Received Amount", \
+			"path": "get_total_received_amount"},
+		{"param_name": "rfq_response_days", "variable_label": "RFQ Response Days", \
+			"path": "get_rfq_response_days"},
+		{"param_name": "sq_total_items", "variable_label": "SQ Total Items", \
+			"path": "get_sq_total_items"},
+		{"param_name": "sq_total_number", "variable_label": "SQ Total Number", \
+			"path": "get_sq_total_number"},
+		{"param_name": "rfq_total_number", "variable_label": "RFQ Total Number", \
+			"path": "get_rfq_total_number"},
+		{"param_name": "rfq_total_items", "variable_label": "RFQ Total Items", \
+			"path": "get_rfq_total_items"},
+		{"param_name": "tot_item_days", "variable_label": "Total Item Days", \
+			"path": "get_item_workdays"},
+		{"param_name": "on_time_shipment_num", "variable_label": "# of On Time Shipments", "path": \
+			"get_on_time_shipments"},
+		{"param_name": "cost_of_delayed_shipments", "variable_label": "Cost of Delayed Shipments", \
+			"path": "get_cost_of_delayed_shipments"},
+		{"param_name": "cost_of_on_time_shipments", "variable_label": "Cost of On Time Shipments", \
+			"path": "get_cost_of_on_time_shipments"},
+		{"param_name": "total_working_days", "variable_label": "Total Working Days", \
+			"path": "get_total_workdays"},
+		{"param_name": "tot_cost_shipments", "variable_label": "Total Cost of Shipments", \
+			"path": "get_total_cost_of_shipments"},
+		{"param_name": "tot_days_late", "variable_label": "Total Days Late", \
+			"path": "get_total_days_late"},
+		{"param_name": "total_shipments", "variable_label": "Total Shipments", \
+			"path": "get_total_shipments"}
+	]
+	install_standing_docs = [
+		{"min_grade": 0.0, "prevent_rfqs": 1, "notify_supplier": 0, "max_grade": 30.0, "prevent_pos": 1, \
+			"standing_color": "Red", "notify_employee": 0, "standing_name": "Very Poor"},
+		{"min_grade": 30.0, "prevent_rfqs": 1, "notify_supplier": 0, "max_grade": 50.0, "prevent_pos": 0, \
+			"standing_color": "Red", "notify_employee": 0, "standing_name": "Poor"},
+		{"min_grade": 50.0, "prevent_rfqs": 0, "notify_supplier": 0, "max_grade": 80.0, "prevent_pos": 0, \
+			"standing_color": "Green", "notify_employee": 0, "standing_name": "Average"},
+		{"min_grade": 80.0, "prevent_rfqs": 0, "notify_supplier": 0, "max_grade": 100.0, "prevent_pos": 0, \
+			"standing_color": "Blue", "notify_employee": 0, "standing_name": "Excellent"},
+	]
+
+	for d in install_variable_docs:
+		try:
+			d['doctype'] = "Supplier Scorecard Variable"
+			frappe.get_doc(d).insert()
+		except frappe.NameError:
+			pass
+	for d in install_standing_docs:
+		try:
+			d['doctype'] = "Supplier Scorecard Standing"
+			frappe.get_doc(d).insert()
+		except frappe.NameError:
+			pass
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py
new file mode 100644
index 0000000..ff7f119
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py
@@ -0,0 +1,15 @@
+from frappe import _
+
+def get_data():
+	return {
+		'heatmap': True,
+		'heatmap_message': _('This covers all scorecards tied to this Setup'),
+		'fieldname': 'supplier',
+		'method' : 'erpnext.buying.doctype.supplier_scorecard.supplier_scorecard.get_timeline_data',
+		'transactions': [
+			{
+				'label': _('Scorecards'),
+				'items': ['Supplier Scorecard Period']
+			}
+		]
+	}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_list.js b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_list.js
new file mode 100644
index 0000000..c50916e
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_list.js
@@ -0,0 +1,17 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe, __ */
+
+frappe.listview_settings["Supplier Scorecard"] = {
+	add_fields: ["indicator_color", "status"],
+	get_indicator: function(doc) {
+
+		if (doc.indicator_color) {
+			return [__(doc.status), doc.indicator_color.toLowerCase(), "status,=," + doc.status];
+		} else {
+			return [__("Unknown"), "darkgrey", "status,=,''"];
+		}
+	},
+
+};
diff --git a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py
new file mode 100644
index 0000000..d64d3f6
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py
@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestSupplierScorecard(unittest.TestCase):
+
+	def test_create_scorecard(self):
+		delete_test_scorecards()
+		my_doc = make_supplier_scorecard()
+		doc = my_doc.insert()
+		self.assertEqual(doc.name, valid_scorecard[0].get("supplier"))
+
+	def test_criteria_weight(self):
+		delete_test_scorecards()
+		my_doc = make_supplier_scorecard()
+		for d in my_doc.criteria:
+			d.weight = 0
+		self.assertRaises(frappe.ValidationError,my_doc.insert)
+
+	def test_missing_variable(self):
+		delete_test_scorecards()
+		my_doc = make_supplier_scorecard()
+		del my_doc.variables
+		self.assertRaises(frappe.ValidationError,my_doc.insert)
+
+def make_supplier_scorecard():
+	my_doc = frappe.get_doc(valid_scorecard[0])
+
+	# Make sure the criteria exist (making them)
+	for d in valid_scorecard[0].get("criteria"):
+		if not frappe.db.exists("Supplier Scorecard Criteria", d.get("criteria_name")):
+			d["doctype"] = "Supplier Scorecard Criteria"
+			d["name"] = d.get("criteria_name")
+			my_criteria = frappe.get_doc(d)
+			my_criteria.insert()
+	return my_doc
+
+
+def delete_test_scorecards():
+	my_doc = make_supplier_scorecard()
+	if frappe.db.exists("Supplier Scorecard", my_doc.name):
+		# Delete all the periods, then delete the scorecard
+		frappe.db.sql("""delete from `tabSupplier Scorecard Period` where scorecard = %(scorecard)s""", {'scorecard': my_doc.name})
+		frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Criteria` where parenttype = 'Supplier Scorecard Period'""")
+		frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Standing` where parenttype = 'Supplier Scorecard Period'""")
+		frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Variable` where parenttype = 'Supplier Scorecard Period'""")
+		frappe.delete_doc(my_doc.doctype, my_doc.name)
+
+valid_scorecard = [
+	{
+		"standings":[
+			{
+				"min_grade":0.0,"name":"Very Poor",
+				"prevent_rfqs":1,
+				"notify_supplier":0,
+				"doctype":"Supplier Scorecard Standing",
+				"max_grade":30.0,
+				"prevent_pos":1,
+				"warn_pos":0,
+				"warn_rfqs":0,
+				"standing_color":"Red",
+				"notify_employee":0,
+				"standing_name":"Very Poor",
+				"parenttype":"Supplier Scorecard",
+				"parentfield":"standings"
+			},
+			{
+				"min_grade":30.0,
+				"name":"Poor",
+				"prevent_rfqs":1,
+				"notify_supplier":0,
+				"doctype":"Supplier Scorecard Standing",
+				"max_grade":50.0,
+				"prevent_pos":0,
+				"warn_pos":0,
+				"warn_rfqs":0,
+				"standing_color":"Red",
+				"notify_employee":0,
+				"standing_name":"Poor",
+				"parenttype":"Supplier Scorecard",
+				"parentfield":"standings"
+			},
+			{
+				"min_grade":50.0,
+				"name":"Average",
+				"prevent_rfqs":0,
+				"notify_supplier":0,
+				"doctype":"Supplier Scorecard Standing",
+				"max_grade":80.0,
+				"prevent_pos":0,
+				"warn_pos":0,
+				"warn_rfqs":0,
+				"standing_color":"Green",
+				"notify_employee":0,
+				"standing_name":"Average",
+				"parenttype":"Supplier Scorecard",
+				"parentfield":"standings"
+			},
+			{
+				"min_grade":80.0,
+				"name":"Excellent",
+				"prevent_rfqs":0,
+				"notify_supplier":0,
+				"doctype":"Supplier Scorecard Standing",
+				"max_grade":100.0,
+				"prevent_pos":0,
+				"warn_pos":0,
+				"warn_rfqs":0,
+				"standing_color":"Blue",
+				"notify_employee":0,
+				"standing_name":"Excellent",
+				"parenttype":"Supplier Scorecard",
+				"parentfield":"standings"
+			}
+		],
+		"prevent_pos":0,
+		"variables": [
+			{
+				"param_name":"cost_of_on_time_shipments",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"Cost of On Time Shipments",
+				"path":"get_cost_of_on_time_shipments",
+				"parentfield":"variables"
+			},
+			{
+				"param_name":"tot_cost_shipments",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"Total Cost of Shipments",
+				"path":"get_total_cost_of_shipments",
+				"parentfield":"variables"
+			},
+			{
+				"param_name":"tot_days_late",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"Total Days Late",
+				"path":"get_total_days_late",
+				"parentfield":"variables"
+			},
+			{
+				"param_name":"total_working_days",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"Total Working Days",
+				"path":"get_total_workdays",
+				"parentfield":"variables"
+			},
+			{
+				"param_name":"on_time_shipment_num",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"# of On Time Shipments",
+				"path":"get_on_time_shipments",
+				"parentfield":"variables"
+			},
+			{
+				"param_name":"total_shipments",
+				"doctype":"Supplier Scorecard Scoring Variable",
+				"parenttype":"Supplier Scorecard",
+				"variable_label":"Total Shipments",
+				"path":"get_total_shipments",
+				"parentfield":"variables"
+			}
+		],
+		"period":"Per Month",
+		"doctype":"Supplier Scorecard",
+		"warn_pos":0,
+		"warn_rfqs":0,
+		"notify_supplier":0,
+		"criteria":[
+			{
+				"weight":100.0,
+				"doctype":"Supplier Scorecard Scoring Criteria",
+				"formula":"(({cost_of_on_time_shipments} / {tot_cost_shipments}) if {tot_cost_shipments} > 0 else 1 )* 100 ",
+				"criteria_name":"Delivery",
+				"max_score":100.0,
+			}
+		],
+		"supplier":"_Test Supplier",
+		"name":"_Test Supplier",
+		"weighting_function":"{total_score} * max( 0, min ( 1 , (12 - {period_number}) / 12) )",
+	}
+]
+
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/__init__.py b/erpnext/buying/doctype/supplier_scorecard_criteria/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.js b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.js
new file mode 100644
index 0000000..9f8a2de
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe */
+
+frappe.ui.form.on("Supplier Scorecard Criteria", {
+	refresh: function() {}
+});
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json
new file mode 100644
index 0000000..229c386
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json
@@ -0,0 +1,184 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:criteria_name", 
+ "beta": 1, 
+ "creation": "2017-05-29 01:32:43.064891", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "criteria_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 1
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "weight", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Weight", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "100", 
+   "fieldname": "max_score", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Max Score", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "formula", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Formula", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-17 10:30:47.458285", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Criteria", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py
new file mode 100644
index 0000000..8514022
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+import re
+from frappe.model.document import Document
+
+class InvalidFormulaVariable(frappe.ValidationError): pass
+
+class SupplierScorecardCriteria(Document):
+	def validate(self):
+		self.validate_variables()
+		self.validate_formula()
+
+	def validate_variables(self):
+		# make sure all the variables exist
+		_get_variables(self)
+
+	def validate_formula(self):
+		# evaluate the formula with 0's to make sure it is valid
+		test_formula = self.formula.replace("\r", "").replace("\n", "")
+
+		regex = r"\{(.*?)\}"
+
+		mylist = re.finditer(regex, test_formula, re.MULTILINE | re.DOTALL)
+		for dummy1, match in enumerate(mylist):
+			for dummy2 in range(0, len(match.groups())):
+				test_formula = test_formula.replace('{' + match.group(1) + '}', "0")
+
+		test_formula = test_formula.replace('&lt;','<').replace('&gt;','>')
+		try:
+			frappe.safe_eval(test_formula,  None, {'max':max, 'min': min})
+		except Exception:
+			frappe.throw(_("Error evaluating the criteria formula"))
+
+
+
+@frappe.whitelist()
+def get_scoring_criteria(criteria_name):
+	criteria = frappe.get_doc("Supplier Scorecard Criteria", criteria_name)
+
+	return criteria
+
+
+@frappe.whitelist()
+def get_criteria_list():
+	criteria = frappe.db.sql("""
+		SELECT
+			scs.name
+		FROM
+			`tabSupplier Scorecard Criteria` scs""",
+			{}, as_dict=1)
+
+	return criteria
+
+@frappe.whitelist()
+def get_variables(criteria_name):
+	criteria = frappe.get_doc("Supplier Scorecard Criteria", criteria_name)
+	return _get_variables(criteria)
+
+def _get_variables(criteria):
+	my_variables = []
+	regex = r"\{(.*?)\}"
+
+	mylist = re.finditer(regex, criteria.formula, re.MULTILINE | re.DOTALL)
+	for dummy1, match in enumerate(mylist):
+		for dummy2 in range(0, len(match.groups())):
+			try:
+				#var = frappe.get_doc("Supplier Scorecard Variable", {'param_name' : d})
+				var = frappe.db.sql("""
+					SELECT
+						scv.name
+					FROM
+						`tabSupplier Scorecard Variable` scv
+					WHERE
+						param_name=%(param)s""",
+						{'param':match.group(1)},)[0][0]
+				my_variables.append(var)
+			except Exception:
+				# Ignore the ones where the variable can't be found
+				frappe.throw(_('Unable to find variable: ') + str(match.group(1)), InvalidFormulaVariable)
+				#pass
+
+
+	#frappe.msgprint(str(my_variables))
+	return my_variables
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py
new file mode 100644
index 0000000..4eef4b4
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestSupplierScorecardCriteria(unittest.TestCase):
+	def test_variables_exist(self):
+		delete_test_scorecards()
+		for d in test_good_criteria:
+			frappe.get_doc(d).insert()
+
+		self.assertRaises(frappe.ValidationError,frappe.get_doc(test_bad_criteria[0]).insert)
+
+	def test_formula_validate(self):
+		delete_test_scorecards()
+		self.assertRaises(frappe.ValidationError,frappe.get_doc(test_bad_criteria[1]).insert)
+		self.assertRaises(frappe.ValidationError,frappe.get_doc(test_bad_criteria[2]).insert)
+
+def delete_test_scorecards():
+	# Delete all the periods so we can delete all the criteria
+	frappe.db.sql("""delete from `tabSupplier Scorecard Period`""")
+	frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Criteria` where parenttype = 'Supplier Scorecard Period'""")
+	frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Standing` where parenttype = 'Supplier Scorecard Period'""")
+	frappe.db.sql("""delete from `tabSupplier Scorecard Scoring Variable` where parenttype = 'Supplier Scorecard Period'""")
+
+	for d in test_good_criteria:
+		if frappe.db.exists("Supplier Scorecard Criteria", d.get("name")):
+			# Delete all the periods, then delete the scorecard
+			frappe.delete_doc(d.get("doctype"), d.get("name"))
+
+	for d in test_bad_criteria:
+		if frappe.db.exists("Supplier Scorecard Criteria", d.get("name")):
+			# Delete all the periods, then delete the scorecard
+			frappe.delete_doc(d.get("doctype"), d.get("name"))
+
+test_good_criteria = [
+	{
+		"name":"Delivery",
+		"weight":40.0,
+		"doctype":"Supplier Scorecard Criteria",
+		"formula":"(({cost_of_on_time_shipments} / {tot_cost_shipments}) if {tot_cost_shipments} > 0 else 1 )* 100",
+		"criteria_name":"Delivery",
+		"max_score":100.0
+	},
+]
+
+test_bad_criteria = [
+	{
+		"name":"Fake Criteria 1",
+		"weight":40.0,
+		"doctype":"Supplier Scorecard Criteria",
+		"formula":"(({fake_variable} / {tot_cost_shipments}) if {tot_cost_shipments} > 0 else 1 )* 100", # Invalid variable name
+		"criteria_name":"Fake Criteria 1",
+		"max_score":100.0
+	},
+	{
+		"name":"Fake Criteria 2",
+		"weight":40.0,
+		"doctype":"Supplier Scorecard Criteria",
+		"formula":"(({cost_of_on_time_shipments} / {tot_cost_shipments}))* 100", # Force 0 divided by 0
+		"criteria_name":"Fake Criteria 2",
+		"max_score":100.0
+	},
+	{
+		"name":"Fake Criteria 3",
+		"weight":40.0,
+		"doctype":"Supplier Scorecard Criteria",
+		"formula":"(({cost_of_on_time_shipments} {cost_of_on_time_shipments} / {tot_cost_shipments}))* 100", # Two variables beside eachother
+		"criteria_name":"Fake Criteria 3",
+		"max_score":100.0
+	},
+]
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_period/__init__.py b/erpnext/buying/doctype/supplier_scorecard_period/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_period/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.js b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.js
new file mode 100644
index 0000000..c51e8ab
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe */
+
+
+frappe.ui.form.on("Supplier Scorecard Period", {
+	onload: function(frm) {
+		frm.get_field("variables").grid.toggle_display("value", true);
+		frm.get_field("criteria").grid.toggle_display("score", true);
+
+
+	}
+});
diff --git a/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.json b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.json
new file mode 100644
index 0000000..0cf6514
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.json
@@ -0,0 +1,397 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "naming_series:", 
+ "beta": 1, 
+ "creation": "2017-05-30 00:38:18.773013", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "supplier", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Supplier", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "naming_series", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Naming Series", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "SSC-", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "total_score", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Period Score", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "start_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Start Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "end_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "End Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "section_break_11", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Calculations", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "criteria", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Criteria", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Scoring Criteria", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "variables", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Variables", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Scoring Variable", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "sec_ref", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Reference", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "scorecard", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Supplier Scorecard Setup", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 1, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:26.130861", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Period", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 0, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py
new file mode 100644
index 0000000..90b65bd
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import throw, _
+from frappe.model.document import Document
+from frappe.model.mapper import get_mapped_doc
+import erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable as variable_functions
+
+class SupplierScorecardPeriod(Document):
+
+	def validate(self):
+		self.validate_criteria_weights()
+		self.calculate_variables()
+		self.calculate_criteria()
+		self.calculate_score()
+
+	def validate_criteria_weights(self):
+
+		weight = 0
+		for c in self.criteria:
+			weight += c.weight
+
+		if weight != 100:
+			throw(_('Criteria weights must add up to 100%'))
+
+	def calculate_variables(self):
+		for var in self.variables:
+
+			if '.' in var.path:
+				method_to_call = import_string_path(var.path)
+				var.value = method_to_call(self)
+			else:
+				method_to_call = getattr(variable_functions, var.path)
+				var.value = method_to_call(self)
+
+
+
+	def calculate_criteria(self):
+		#Get the criteria
+		for crit in self.criteria:
+
+			#me = ""
+			my_eval_statement = crit.formula.replace("\r", "").replace("\n", "")
+			#for let in my_eval_statement:
+			#	me += let.encode('hex') + " "
+			#frappe.msgprint(me)
+
+			for var in self.variables:
+				if var.value:
+					if var.param_name in my_eval_statement:
+						my_eval_statement = my_eval_statement.replace('{' + var.param_name + '}', "{:.2f}".format(var.value))
+				else:
+					if var.param_name in my_eval_statement:
+						my_eval_statement = my_eval_statement.replace('{' + var.param_name + '}', '0.0')
+
+			#frappe.msgprint(my_eval_statement )
+
+			my_eval_statement = my_eval_statement.replace('&lt;','<').replace('&gt;','>')
+
+			try:
+				crit.score = min(crit.max_score, max( 0 ,frappe.safe_eval(my_eval_statement,  None, {'max':max, 'min': min})))
+			except Exception:
+				frappe.throw(_("Could not solve criteria score function for {0}. Make sure the formula is valid.".format(crit.criteria_name)),frappe.ValidationError)
+				crit.score = 0
+
+	def calculate_score(self):
+		myscore = 0
+		for crit in self.criteria:
+			myscore += crit.score * crit.weight/100.0
+		self.total_score = myscore
+
+	def calculate_weighted_score(self, weighing_function):
+		my_eval_statement = weighing_function.replace("\r", "").replace("\n", "")
+
+		for var in self.variables:
+			if var.value:
+				if var.param_name in my_eval_statement:
+					my_eval_statement = my_eval_statement.replace('{' + var.param_name + '}', "{:.2f}".format(var.value))
+			else:
+				if var.param_name in my_eval_statement:
+					my_eval_statement = my_eval_statement.replace('{' + var.param_name + '}', '0.0')
+
+		my_eval_statement = my_eval_statement.replace('&lt;','<').replace('&gt;','>')
+
+		try:
+			weighed_score = frappe.safe_eval(my_eval_statement,  None, {'max':max, 'min': min})
+		except Exception:
+			frappe.throw(_("Could not solve weighted score function. Make sure the formula is valid."),frappe.ValidationError)
+			weighed_score = 0
+		return weighed_score
+
+
+
+def import_string_path(path):
+    components = path.split('.')
+    mod = __import__(components[0])
+    for comp in components[1:]:
+        mod = getattr(mod, comp)
+    return mod
+
+
+def post_process(source, target):
+	pass
+
+
+@frappe.whitelist()
+def make_supplier_scorecard(source_name, target_doc=None):
+	#def update_item(obj, target, source_parent):
+	#	target.qty = flt(obj.qty) - flt(obj.received_qty)
+	#	target.stock_qty = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor)
+	#	target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.rate)
+	#	target.base_amount = (flt(obj.qty) - flt(obj.received_qty)) * \
+	#		flt(obj.rate) * flt(source_parent.conversion_rate)
+
+	doc = get_mapped_doc("Supplier Scorecard", source_name,	{
+		"Supplier Scorecard": {
+			"doctype": "Supplier Scorecard Period"
+		},
+		"Supplier Scorecard Scoring Variable": {
+			"doctype": "Supplier Scorecard Scoring Variable",
+			"add_if_empty": True
+		},
+		"Supplier Scorecard Scoring Constraint": {
+			"doctype": "Supplier Scorecard Scoring Constraint",
+			"add_if_empty": True
+		}
+	}, target_doc, post_process)
+
+	return doc
+
diff --git a/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py
new file mode 100644
index 0000000..8baa318
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import unittest
+
+class TestSupplierScorecardPeriod(unittest.TestCase):
+	pass
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/__init__.py b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.json b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.json
new file mode 100644
index 0000000..567738a
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.json
@@ -0,0 +1,280 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 1, 
+ "creation": "2017-05-29 01:32:17.988454", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 3, 
+   "fieldname": "criteria_name", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Criteria", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_2", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "weight", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Weight", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_4", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "100", 
+   "fieldname": "max_score", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Max Score", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_6", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "formula", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Criteria Formula", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "score", 
+   "fieldtype": "Percent", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Score", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:41.532361", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Scoring Criteria", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py
new file mode 100644
index 0000000..b64abed
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class SupplierScorecardScoringCriteria(Document):
+	pass
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_standing/__init__.py b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.json b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.json
new file mode 100644
index 0000000..1fc04bb
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.json
@@ -0,0 +1,491 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 1, 
+ "creation": "2017-05-29 01:36:22.697234", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 3, 
+   "fieldname": "standing_name", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Standing Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Standing", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "standing_color", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Color", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Blue\nPurple\nGreen\nYellow\nOrange\nRed", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_4", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "min_grade", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Min Grade", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "max_grade", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Max Grade", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "actions", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Actions", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn RFQs", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn Purchase Orders", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent RFQs", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent Purchase Orders", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_10", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_supplier", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Supplier", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_employee", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Employee", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_link", 
+   "fieldtype": "Link", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee ", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:20.615684", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Scoring Standing", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py
new file mode 100644
index 0000000..e8ad79f
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class SupplierScorecardScoringStanding(Document):
+	pass
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_variable/__init__.py b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.json b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.json
new file mode 100644
index 0000000..f0e043e
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.json
@@ -0,0 +1,222 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 1, 
+ "creation": "2017-05-29 01:30:06.105240", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 3, 
+   "fieldname": "variable_label", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Variable Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Supplier Scorecard Variable", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Description", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_custom", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Custom?", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "param_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Parameter Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "path", 
+   "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": "Path", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "value", 
+   "fieldtype": "Float", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Value", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:36.671502", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Scoring Variable", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py
new file mode 100644
index 0000000..58a8a99
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class SupplierScorecardScoringVariable(Document):
+	pass
diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/__init__.py b/erpnext/buying/doctype/supplier_scorecard_standing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_standing/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.js b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.js
new file mode 100644
index 0000000..dccfcc3
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.js
@@ -0,0 +1,10 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe */
+
+frappe.ui.form.on("Supplier Scorecard Standing", {
+	refresh: function() {
+
+	}
+});
diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.json b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.json
new file mode 100644
index 0000000..b61b4ed
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.json
@@ -0,0 +1,424 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:standing_name", 
+ "beta": 1, 
+ "creation": "2017-05-29 01:36:47.893639", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "standing_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Standing Name", 
+   "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": 1
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "standing_color", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Color", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Blue\nPurple\nGreen\nYellow\nOrange\nRed", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "min_grade", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Min Grade", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "max_grade", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Max Grade", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_5", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn RFQs", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "warn_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Warn Purchase Orders", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_rfqs", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent RFQs", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "prevent_pos", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Prevent Purchase Orders", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_supplier", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Supplier", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "notify_employee", 
+   "fieldtype": "Check", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Notify Other", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_link", 
+   "fieldtype": "Link", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Other", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:16.560273", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Standing", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 0, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py
new file mode 100644
index 0000000..1ba5d06
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class SupplierScorecardStanding(Document):
+	pass
+
+
+@frappe.whitelist()
+def get_scoring_standing(standing_name):
+	standing = frappe.get_doc("Supplier Scorecard Standing", standing_name)
+
+	return standing
+
+
+@frappe.whitelist()
+def get_standings_list():
+	standings = frappe.db.sql("""
+		SELECT
+			scs.name
+		FROM
+			`tabSupplier Scorecard Standing` scs""",
+			{}, as_dict=1)
+
+	return standings
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py b/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py
new file mode 100644
index 0000000..4d96651
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import unittest
+
+class TestSupplierScorecardStanding(unittest.TestCase):
+	pass
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/__init__.py b/erpnext/buying/doctype/supplier_scorecard_variable/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/__init__.py
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.js b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.js
new file mode 100644
index 0000000..2d74fdd
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.js
@@ -0,0 +1,10 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+/* global frappe */
+
+frappe.ui.form.on("Supplier Scorecard Variable", {
+	refresh: function() {
+
+	}
+});
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.json b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.json
new file mode 100644
index 0000000..d244840
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.json
@@ -0,0 +1,242 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:variable_label", 
+ "beta": 1, 
+ "creation": "2017-05-29 01:30:34.688389", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "variable_label", 
+   "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": "Variable Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 1
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_custom", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Custom?", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "param_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Parameter Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "path", 
+   "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": "Path", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_5", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Description", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-12 07:33:31.395262", 
+ "modified_by": "Administrator", 
+ "module": "Buying", 
+ "name": "Supplier Scorecard Variable", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py
new file mode 100644
index 0000000..17c911a
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py
@@ -0,0 +1,503 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+import sys
+from frappe import _
+from frappe.model.document import Document
+from frappe.utils import getdate
+
+class VariablePathNotFound(frappe.ValidationError): pass
+
+class SupplierScorecardVariable(Document):
+	def validate(self):
+		self.validate_path_exists()
+
+	def validate_path_exists(self):
+		if '.' in self.path:
+			try:
+				from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import import_string_path
+				import_string_path(self.path)
+			except AttributeError:
+				frappe.throw(_("Could not find path for " + self.path), VariablePathNotFound)
+
+		else:
+			if not hasattr(sys.modules[__name__], self.path):
+				frappe.throw(_("Could not find path for " + self.path), VariablePathNotFound)
+
+
+@frappe.whitelist()
+def get_scoring_variable(variable_label):
+	variable = frappe.get_doc("Supplier Scorecard Variable", variable_label)
+
+	return variable
+
+def get_total_workdays(scorecard):
+	""" Gets the number of days in this period"""
+	delta = getdate(scorecard.end_date) - getdate(scorecard.start_date)
+	return delta.days
+
+def get_item_workdays(scorecard):
+	""" Gets the number of days in this period"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+	total_item_days = frappe.db.sql("""
+			SELECT
+				SUM(DATEDIFF( %(end_date)s, po_item.schedule_date) * (po_item.qty))
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Order` po
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.received_qty < po_item.qty
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.parent = po.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not total_item_days:
+		total_item_days = 0
+	return total_item_days
+
+
+
+def get_total_cost_of_shipments(scorecard):
+	""" Gets the total cost of all shipments in the period (based on Purchase Orders)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(po_item.base_amount)
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Order` po
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.docstatus = 1
+				AND po_item.parent = po.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if data:
+		return data
+	else:
+		return 0
+
+def get_cost_of_delayed_shipments(scorecard):
+	""" Gets the total cost of all delayed shipments in the period (based on Purchase Receipts - POs)"""
+	return get_total_cost_of_shipments(scorecard) - get_cost_of_on_time_shipments(scorecard)
+
+def get_cost_of_on_time_shipments(scorecard):
+	""" Gets the total cost of all on_time shipments in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+
+	total_delivered_on_time_costs = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.base_amount)
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Order` po,
+				`tabPurchase Receipt` pr
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.schedule_date >= pr.posting_date
+				AND pr_item.docstatus = 1
+				AND pr_item.purchase_order_item = po_item.name
+				AND po_item.parent = po.name
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if total_delivered_on_time_costs:
+		return total_delivered_on_time_costs
+	else:
+		return 0
+
+
+def get_total_days_late(scorecard):
+	""" Gets the number of item days late in the period (based on Purchase Receipts vs POs)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+	total_delivered_late_days = frappe.db.sql("""
+			SELECT
+				SUM(DATEDIFF(pr.posting_date,po_item.schedule_date)* pr_item.qty)
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Order` po,
+				`tabPurchase Receipt` pr
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.schedule_date < pr.posting_date
+				AND pr_item.docstatus = 1
+				AND pr_item.purchase_order_item = po_item.name
+				AND po_item.parent = po.name
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+	if not total_delivered_late_days:
+		total_delivered_late_days = 0
+
+	total_missed_late_days = frappe.db.sql("""
+			SELECT
+				SUM(DATEDIFF( %(end_date)s, po_item.schedule_date) * (po_item.qty - po_item.received_qty))
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Order` po
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.received_qty < po_item.qty
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.parent = po.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not total_missed_late_days:
+		total_missed_late_days = 0
+	return total_missed_late_days + total_delivered_late_days
+
+def get_on_time_shipments(scorecard):
+	""" Gets the number of late shipments (counting each item) in the period (based on Purchase Receipts vs POs)"""
+
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	total_items_delivered_on_time = frappe.db.sql("""
+			SELECT
+				COUNT(pr_item.qty)
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Order` po,
+				`tabPurchase Receipt` pr
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.schedule_date <= pr.posting_date
+				AND po_item.qty = pr_item.qty
+				AND pr_item.docstatus = 1
+				AND pr_item.purchase_order_item = po_item.name
+				AND po_item.parent = po.name
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not total_items_delivered_on_time:
+		total_items_delivered_on_time = 0
+	return total_items_delivered_on_time
+
+def get_late_shipments(scorecard):
+	""" Gets the number of late shipments (counting each item) in the period (based on Purchase Receipts vs POs)"""
+	return get_total_shipments(scorecard) - get_on_time_shipments(scorecard)
+
+def get_total_received(scorecard):
+	""" Gets the total number of received shipments in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(pr_item.base_amount)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_received_amount(scorecard):
+	""" Gets the total amount (in company currency) received in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.received_qty * pr_item.base_rate)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_received_items(scorecard):
+	""" Gets the total number of received shipments in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.received_qty)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_rejected_amount(scorecard):
+	""" Gets the total amount (in company currency) rejected in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.rejected_qty * pr_item.base_rate)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_rejected_items(scorecard):
+	""" Gets the total number of rejected items in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.rejected_qty)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_accepted_amount(scorecard):
+	""" Gets the total amount (in company currency) accepted in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.qty * pr_item.base_rate)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_accepted_items(scorecard):
+	""" Gets the total number of rejected items in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				SUM(pr_item.qty)
+			FROM
+				`tabPurchase Receipt Item` pr_item,
+				`tabPurchase Receipt` pr
+			WHERE
+				pr.supplier = %(supplier)s
+				AND pr.posting_date BETWEEN %(start_date)s AND %(end_date)s
+				AND pr_item.docstatus = 1
+				AND pr_item.parent = pr.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_total_shipments(scorecard):
+	""" Gets the total number of ordered shipments to arrive in the period (based on Purchase Receipts)"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(po_item.base_amount)
+			FROM
+				`tabPurchase Order Item` po_item,
+				`tabPurchase Order` po
+			WHERE
+				po.supplier = %(supplier)s
+				AND po_item.schedule_date BETWEEN %(start_date)s AND %(end_date)s
+				AND po_item.docstatus = 1
+				AND po_item.parent = po.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_rfq_total_number(scorecard):
+	""" Gets the total number of RFQs sent to supplier"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(rfq.name) as total_rfqs
+			FROM
+				`tabRequest for Quotation Item` rfq_item,
+				`tabRequest for Quotation Supplier` rfq_sup,
+				`tabRequest for Quotation` rfq
+			WHERE
+				rfq_sup.supplier = %(supplier)s
+				AND rfq.transaction_date BETWEEN %(start_date)s AND %(end_date)s
+				AND rfq_item.docstatus = 1
+				AND rfq_item.parent = rfq.name
+				AND rfq_sup.parent = rfq.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+
+	if not data:
+		data = 0
+	return data
+
+def get_rfq_total_items(scorecard):
+	""" Gets the total number of RFQ items sent to supplier"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(rfq_item.name) as total_rfqs
+			FROM
+				`tabRequest for Quotation Item` rfq_item,
+				`tabRequest for Quotation Supplier` rfq_sup,
+				`tabRequest for Quotation` rfq
+			WHERE
+				rfq_sup.supplier = %(supplier)s
+				AND rfq.transaction_date BETWEEN %(start_date)s AND %(end_date)s
+				AND rfq_item.docstatus = 1
+				AND rfq_item.parent = rfq.name
+				AND rfq_sup.parent = rfq.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+	if not data:
+		data = 0
+	return data
+
+
+def get_sq_total_number(scorecard):
+	""" Gets the total number of RFQ items sent to supplier"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(sq.name) as total_sqs
+			FROM
+				`tabRequest for Quotation Item` rfq_item,
+				`tabSupplier Quotation Item` sq_item,
+				`tabRequest for Quotation Supplier` rfq_sup,
+				`tabRequest for Quotation` rfq,
+				`tabSupplier Quotation` sq
+			WHERE
+				rfq_sup.supplier = %(supplier)s
+				AND rfq.transaction_date BETWEEN %(start_date)s AND %(end_date)s
+				AND sq_item.request_for_quotation_item = rfq_item.name
+				AND sq_item.docstatus = 1
+				AND rfq_item.docstatus = 1
+				AND sq.supplier = %(supplier)s
+				AND sq_item.parent = sq.name
+				AND rfq_item.parent = rfq.name
+				AND rfq_sup.parent = rfq.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+	if not data:
+		data = 0
+	return data
+
+def get_sq_total_items(scorecard):
+	""" Gets the total number of RFQ items sent to supplier"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+
+	# Look up all PO Items with delivery dates between our dates
+	data = frappe.db.sql("""
+			SELECT
+				COUNT(sq_item.name) as total_sqs
+			FROM
+				`tabRequest for Quotation Item` rfq_item,
+				`tabSupplier Quotation Item` sq_item,
+				`tabSupplier Quotation` sq,
+				`tabRequest for Quotation Supplier` rfq_sup,
+				`tabRequest for Quotation` rfq
+			WHERE
+				rfq_sup.supplier = %(supplier)s
+				AND rfq.transaction_date BETWEEN %(start_date)s AND %(end_date)s
+				AND sq_item.request_for_quotation_item = rfq_item.name
+				AND sq_item.docstatus = 1
+				AND sq.supplier = %(supplier)s
+				AND sq_item.parent = sq.name
+				AND rfq_item.docstatus = 1
+				AND rfq_item.parent = rfq.name
+				AND rfq_sup.parent = rfq.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+	if not data:
+		data = 0
+	return data
+
+def get_rfq_response_days(scorecard):
+	""" Gets the total number of days it has taken a supplier to respond to rfqs in the period"""
+	supplier = frappe.get_doc('Supplier', scorecard.supplier)
+	total_sq_days = frappe.db.sql("""
+			SELECT
+				SUM(DATEDIFF(sq.transaction_date, rfq.transaction_date))
+			FROM
+				`tabRequest for Quotation Item` rfq_item,
+				`tabSupplier Quotation Item` sq_item,
+				`tabSupplier Quotation` sq,
+				`tabRequest for Quotation Supplier` rfq_sup,
+				`tabRequest for Quotation` rfq
+			WHERE
+				rfq_sup.supplier = %(supplier)s
+				AND rfq.transaction_date BETWEEN %(start_date)s AND %(end_date)s
+				AND sq_item.request_for_quotation_item = rfq_item.name
+				AND sq_item.docstatus = 1
+				AND sq.supplier = %(supplier)s
+				AND sq_item.parent = sq.name
+				AND rfq_item.docstatus = 1
+				AND rfq_item.parent = rfq.name
+				AND rfq_sup.parent = rfq.name""",
+				{"supplier": supplier.name, "start_date": scorecard.start_date, "end_date": scorecard.end_date}, as_dict=0)[0][0]
+	if not total_sq_days:
+		total_sq_days = 0
+
+
+	return total_sq_days
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py
new file mode 100644
index 0000000..45a2c62
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+from erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable import VariablePathNotFound
+
+
+class TestSupplierScorecardVariable(unittest.TestCase):
+	def test_variable_exist(self):
+		for d in test_existing_variables:
+			my_doc = frappe.get_doc("Supplier Scorecard Variable", d.get("name"))
+			self.assertEquals(my_doc.param_name, d.get('param_name'))
+			self.assertEquals(my_doc.variable_label, d.get('variable_label'))
+			self.assertEquals(my_doc.path, d.get('path'))
+
+	def test_path_exists(self):
+		for d in test_good_variables:
+			if frappe.db.exists(d):
+				frappe.delete_doc(d.get("doctype"), d.get("name"))
+			frappe.get_doc(d).insert()
+
+		for d in test_bad_variables:
+			self.assertRaises(VariablePathNotFound,frappe.get_doc(d).insert)
+
+test_existing_variables = [
+	{
+		"param_name":"total_accepted_items",
+		"name":"Total Accepted Items",
+		"doctype":"Supplier Scorecard Variable",
+		"variable_label":"Total Accepted Items",
+		"path":"get_total_accepted_items"
+	},
+]
+
+test_good_variables = [
+	{
+		"param_name":"good_variable1",
+		"name":"Good Variable 1",
+		"doctype":"Supplier Scorecard Variable",
+		"variable_label":"Good Variable 1",
+		"path":"get_total_accepted_items"
+	},
+]
+
+test_bad_variables = [
+	{
+		"param_name":"fake_variable1",
+		"name":"Fake Variable 1",
+		"doctype":"Supplier Scorecard Variable",
+		"variable_label":"Fake Variable 1",
+		"path":"get_fake_variable1"
+	},
+]
\ No newline at end of file
diff --git a/erpnext/change_log/v6/v6_13_1.md b/erpnext/change_log/v6/v6_13_1.md
index 1f0a568..4b2c4a9 100644
--- a/erpnext/change_log/v6/v6_13_1.md
+++ b/erpnext/change_log/v6/v6_13_1.md
@@ -1 +1 @@
-- [ERPNext Manual in German](http://frappe.github.io/erpnext/user/manual/de/) contributed by [CWT Connector & Wire Technology GmbH](http://www.cwt-assembly.com/)
+- [ERPNext Manual in German](http://erpnext.org/docs/user/manual/de/) contributed by [CWT Connector & Wire Technology GmbH](http://www.cwt-assembly.com/)
diff --git a/erpnext/change_log/v6/v6_2_0.md b/erpnext/change_log/v6/v6_2_0.md
index 004e90c..f4da651 100644
--- a/erpnext/change_log/v6/v6_2_0.md
+++ b/erpnext/change_log/v6/v6_2_0.md
@@ -1 +1 @@
-- **[Multi-currency Accounting](https://frappe.github.io/erpnext/user/guides/accounts/multi-currency-accounting)**: You can now have an Account in a different currency than your Company's currency
+- **[Multi-currency Accounting](https://frappe.io/docs/user/guides/accounts/multi-currency-accounting)**: You can now have an Account in a different currency than your Company's currency
diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py
index 990ca7a..ba29125 100644
--- a/erpnext/config/buying.py
+++ b/erpnext/config/buying.py
@@ -142,6 +142,32 @@
 			]
 		},
 		{
+			"label": _("Supplier Scorecard"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Supplier Scorecard",
+					"description": _("All Supplier scorecards."),
+				},
+				{
+					"type": "doctype",
+					"name": "Supplier Scorecard Variable",
+					"description": _("Templates of supplier scorecard variables.")
+				},
+				{
+					"type": "doctype",
+					"name": "Supplier Scorecard Criteria",
+					"description": _("Templates of supplier scorecard criteria."),
+				},
+				{
+					"type": "doctype",
+					"name": "Supplier Scorecard Standing",
+					"description": _("Templates of supplier standings."),
+				},
+
+			]
+		},
+		{
 			"label": _("Other Reports"),
 			"icon": "fa fa-list",
 			"items": [
diff --git a/erpnext/config/docs.py b/erpnext/config/docs.py
index 2d2cc0a..7c91455 100644
--- a/erpnext/config/docs.py
+++ b/erpnext/config/docs.py
@@ -1,12 +1,11 @@
 from __future__ import unicode_literals
 
-docs_version = "7.x.x"
-
 source_link = "https://github.com/frappe/erpnext"
 docs_base_url = "https://frappe.github.io/erpnext"
-headline = "ERPNext Documentation"
-sub_heading = "Detailed explanation for all ERPNext features and developer API"
-long_description = """ERPNext is a fully featured ERP system designed for Small and Medium Sized
+headline = "ERP Made Simple"
+sub_heading = "ERPNext User Guides and API References"
+long_description = """
+ERPNext is a fully featured ERP system designed for Small and Medium Sized
 business. ERPNext covers a wide range of features including Accounting, CRM,
 Inventory management, Selling, Purchasing, Manufacturing, Projects, HR &
 Payroll, Website, E-Commerce and much more.
@@ -17,7 +16,15 @@
 
 ERPNext is Open Source under the GNU General Public Licence v3 and has been
 listed as one of the Best Open Source Softwares in the world by many online
-blogs."""
+blogs.
+
+### Getting Started
+
+To install ERPNext on a server, you will need to install [Frappe Bench](https://github.com/frappe/bench).
+
+You can also start a free 30 day trial at [https://erpnext.com](https://erpnext.com)
+
+"""
 
 splash_light_background = True
 google_analytics_id = 'UA-8911157-22'
diff --git a/erpnext/config/projects.py b/erpnext/config/projects.py
index 1a70aee..a8514b2 100644
--- a/erpnext/config/projects.py
+++ b/erpnext/config/projects.py
@@ -18,6 +18,11 @@
 					"description": _("Project activity / task."),
 				},
 				{
+					"type": "doctype",
+					"name": "Project Type",
+					"description": _("Define Project type."),
+				},
+				{
 					"type": "report",
 					"route": "List/Task/Gantt",
 					"doctype": "Task",
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 8130af9..6d69a48 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -60,6 +60,7 @@
 
  # searches for customer
 def customer_query(doctype, txt, searchfield, start, page_len, filters):
+	conditions = []
 	cust_master_name = frappe.defaults.get_user_default("cust_master_name")
 
 	if cust_master_name == "Customer Name":
@@ -79,7 +80,7 @@
 	return frappe.db.sql("""select {fields} from `tabCustomer`
 		where docstatus < 2
 			and ({scond}) and disabled=0
-			{mcond}
+			{fcond} {mcond}
 		order by
 			if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
 			if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999),
@@ -88,7 +89,8 @@
 		limit %(start)s, %(page_len)s""".format(**{
 			"fields": fields,
 			"scond": searchfields,
-			"mcond": get_match_cond(doctype)
+			"mcond": get_match_cond(doctype),
+			"fcond": get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
 		}), {
 			'txt': "%%%s%%" % txt,
 			'_txt': txt.replace("%", ""),
diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py
index 0e2d6d0..14738c5 100644
--- a/erpnext/controllers/tests/test_mapper.py
+++ b/erpnext/controllers/tests/test_mapper.py
@@ -4,7 +4,7 @@
 
 import random, json
 import frappe.utils
-from frappe.utils import nowdate
+from frappe.utils import nowdate, add_months
 from frappe.model import mapper
 from frappe.test_runner import make_test_records
 
@@ -44,7 +44,9 @@
 			"doctype": "Quotation",
 			"quotation_to": "Customer",
 			"customer": customer,
-			"order_type": "Sales"
+			"order_type": "Sales",
+			"transaction_date" : nowdate(),
+			"valid_till" : add_months(nowdate(), 1)
 		})
 		for item in item_list:
 			qtn.append("items", {"qty": "2", "item_code": item.item_code})
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index b078036..04d1bc5 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -30,7 +30,7 @@
 	else:
 		filters.append((doctype, "docstatus", "=", 1))
 
-	if user != "Guest" and is_website_user():
+	if (user != "Guest" and is_website_user()) or doctype == 'Request for Quotation':
 		parties_doctype = 'Request for Quotation Supplier' if doctype == 'Request for Quotation' else doctype
 		# find party for this contact
 		customers, suppliers = get_customers_suppliers(parties_doctype, user)
diff --git a/erpnext/crm/doctype/item/test_item.js b/erpnext/crm/doctype/item/test_item.js
new file mode 100644
index 0000000..baaa21f
--- /dev/null
+++ b/erpnext/crm/doctype/item/test_item.js
@@ -0,0 +1,94 @@
+QUnit.test("test: item", function (assert) {
+	assert.expect(6);
+	let done = assert.async();
+	let keyboard_cost  = 800;
+	let screen_cost  = 4000;
+	let CPU_cost  = 15000;
+	let scrap_cost = 100;
+	let no_of_items_to_stock = 100;
+	let is_stock_item = 1;
+	frappe.run_serially([
+		// test item creation
+		() => frappe.set_route("List", "Item"),
+
+		// Create a keyboard item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Keyboard"},
+				{item_group: "Products"},
+				{is_stock_item: is_stock_item},
+				{standard_rate: keyboard_cost},
+				{opening_stock: no_of_items_to_stock},
+				{default_warehouse: "Stores - RB"}
+			]
+		),
+		() => {
+			assert.ok(cur_frm.doc.item_name.includes('Keyboard'),
+				'Item Keyboard created correctly');
+			assert.ok(cur_frm.doc.item_code.includes('Keyboard'),
+				'item_code for Keyboard set correctly');
+			assert.ok(cur_frm.doc.item_group.includes('Products'),
+				'item_group for Keyboard set correctly');
+			assert.equal(cur_frm.doc.is_stock_item, is_stock_item,
+				'is_stock_item for Keyboard set correctly');
+			assert.equal(cur_frm.doc.standard_rate, keyboard_cost,
+				'standard_rate for Keyboard set correctly');
+			assert.equal(cur_frm.doc.opening_stock, no_of_items_to_stock,
+				'opening_stock for Keyboard set correctly');
+		},
+
+		// Create a Screen item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Screen"},
+				{item_group: "Products"},
+				{is_stock_item: is_stock_item},
+				{standard_rate: screen_cost},
+				{opening_stock: no_of_items_to_stock},
+				{default_warehouse: "Stores - RB"}
+			]
+		),
+
+		// Create a CPU item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "CPU"},
+				{item_group: "Products"},
+				{is_stock_item: is_stock_item},
+				{standard_rate: CPU_cost},
+				{opening_stock: no_of_items_to_stock},
+				{default_warehouse: "Stores - RB"}
+			]
+		),
+
+		// Create a laptop item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Laptop"},
+				{item_group: "Products"},
+				{default_warehouse: "Stores - RB"}
+			]
+		),
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Computer"},
+				{item_group: "Products"},
+				{is_stock_item: 0},
+			]
+		),
+
+		// Create a scrap item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Scrap item"},
+				{item_group: "Products"},
+				{is_stock_item: is_stock_item},
+				{standard_rate: scrap_cost},
+				{opening_stock: no_of_items_to_stock},
+				{default_warehouse: "Stores - RB"}
+			]
+		),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/docs/assets/img/buying/supplier-scorecard-criteria.png b/erpnext/docs/assets/img/buying/supplier-scorecard-criteria.png
new file mode 100644
index 0000000..0bc73c8
--- /dev/null
+++ b/erpnext/docs/assets/img/buying/supplier-scorecard-criteria.png
Binary files differ
diff --git a/erpnext/docs/assets/img/buying/supplier-scorecard-standing.png b/erpnext/docs/assets/img/buying/supplier-scorecard-standing.png
new file mode 100644
index 0000000..8c507cb
--- /dev/null
+++ b/erpnext/docs/assets/img/buying/supplier-scorecard-standing.png
Binary files differ
diff --git a/erpnext/docs/assets/img/buying/supplier-scorecard-weighing.png b/erpnext/docs/assets/img/buying/supplier-scorecard-weighing.png
new file mode 100644
index 0000000..d32e69e
--- /dev/null
+++ b/erpnext/docs/assets/img/buying/supplier-scorecard-weighing.png
Binary files differ
diff --git a/erpnext/docs/assets/img/buying/supplier-scorecard.png b/erpnext/docs/assets/img/buying/supplier-scorecard.png
new file mode 100644
index 0000000..1f8de17
--- /dev/null
+++ b/erpnext/docs/assets/img/buying/supplier-scorecard.png
Binary files differ
diff --git a/erpnext/docs/assets/img/pos-setting/default_mop.png b/erpnext/docs/assets/img/pos-setting/default_mop.png
new file mode 100644
index 0000000..bd1e7a0
--- /dev/null
+++ b/erpnext/docs/assets/img/pos-setting/default_mop.png
Binary files differ
diff --git a/erpnext/docs/assets/img/pos-setting/item_customer_group.png b/erpnext/docs/assets/img/pos-setting/item_customer_group.png
new file mode 100644
index 0000000..6117a8f
--- /dev/null
+++ b/erpnext/docs/assets/img/pos-setting/item_customer_group.png
Binary files differ
diff --git a/erpnext/docs/assets/img/pos-setting/pos-setting.png b/erpnext/docs/assets/img/pos-setting/pos-setting.png
deleted file mode 100644
index 6061199..0000000
--- a/erpnext/docs/assets/img/pos-setting/pos-setting.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/pos-setting/pos_profile.png b/erpnext/docs/assets/img/pos-setting/pos_profile.png
new file mode 100644
index 0000000..a8bd4ac
--- /dev/null
+++ b/erpnext/docs/assets/img/pos-setting/pos_profile.png
Binary files differ
diff --git a/erpnext/docs/assets/img/setup/email/email-account-incoming-conditions.png b/erpnext/docs/assets/img/setup/email/email-account-incoming-conditions.png
new file mode 100644
index 0000000..61a86f5
--- /dev/null
+++ b/erpnext/docs/assets/img/setup/email/email-account-incoming-conditions.png
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png b/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png
deleted file mode 100644
index eb529f1..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png b/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png
deleted file mode 100644
index ee7a19b..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-role-all.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-role-all.png
deleted file mode 100644
index 0aececd..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-role-all.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-ignore-user-permissions.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-ignore-user-permissions.png
deleted file mode 100644
index 5f55e37..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permissions-ignore-user-permissions.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-lead-role-permissions.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-lead-role-permissions.png
deleted file mode 100644
index 23564fa..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permissions-lead-role-permissions.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif b/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif
deleted file mode 100644
index 609bf25..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-quotation-sales-user.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-quotation-sales-user.png
deleted file mode 100644
index dd9ed49..0000000
--- a/erpnext/docs/assets/img/users-and-permissions/user-permissions-quotation-sales-user.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-perms/ignore-user-permissions.png b/erpnext/docs/assets/img/users-and-permissions/user-perms/ignore-user-permissions.png
new file mode 100644
index 0000000..56e0d44
--- /dev/null
+++ b/erpnext/docs/assets/img/users-and-permissions/user-perms/ignore-user-permissions.png
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-perms/new-user-permission.png b/erpnext/docs/assets/img/users-and-permissions/user-perms/new-user-permission.png
new file mode 100644
index 0000000..d2762dd
--- /dev/null
+++ b/erpnext/docs/assets/img/users-and-permissions/user-perms/new-user-permission.png
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-perms/permitted-documents.png b/erpnext/docs/assets/img/users-and-permissions/user-perms/permitted-documents.png
new file mode 100644
index 0000000..2558b62
--- /dev/null
+++ b/erpnext/docs/assets/img/users-and-permissions/user-perms/permitted-documents.png
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-perms/select-document-types.png b/erpnext/docs/assets/img/users-and-permissions/user-perms/select-document-types.png
new file mode 100644
index 0000000..b54d36a
--- /dev/null
+++ b/erpnext/docs/assets/img/users-and-permissions/user-perms/select-document-types.png
Binary files differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-perms/view-selected-documents.png b/erpnext/docs/assets/img/users-and-permissions/user-perms/view-selected-documents.png
new file mode 100644
index 0000000..bc2ce78
--- /dev/null
+++ b/erpnext/docs/assets/img/users-and-permissions/user-perms/view-selected-documents.png
Binary files differ
diff --git a/erpnext/docs/user/manual/de/setting-up/users-and-permissions/user-permissions.md b/erpnext/docs/user/manual/de/setting-up/users-and-permissions/user-permissions.md
index a751693..68fc412 100644
--- a/erpnext/docs/user/manual/de/setting-up/users-and-permissions/user-permissions.md
+++ b/erpnext/docs/user/manual/de/setting-up/users-and-permissions/user-permissions.md
@@ -1,45 +1,5 @@
 # Benutzer-Berechtigungen
-<span class="text-muted contributed-by">Beigetragen von CWT Connector & Wire Technology GmbH</span>
 
-Verwenden Sie den Benutzerberechtigungen-Manager um den Zugriff eines Benutzers auf eine Menge von Dokumenten einzuschränken.
+This document has been changed but not yet translated. Please see the English Version
 
-Rollenbasierte Berechtigungen definieren den Rahmen an Dokumententypen, innerhalb derer sich ein Benutzer mit einer Anzahl von Rollen bewegen darf. Sie können jedoch noch feinere Einstellungen treffen, wenn Sie für einen Benutzer Benutzerberechtigungen definieren. Wenn Sie bestimmte Dokumente in der Liste der Benutzerberechtigungen eintragen, dann können Sie den Zugriff dieses Benutzers auf bestimmte Dokumente eines bestimmten DocTypes begrenzen, unter der Bedingung, dass die Option "Benutzerberechtigungen anwenden" im Rollenberechtigungs-Manager aktiviert ist.
-
-Beginnen Sie wie folgt:
-
-> Einstellungen > Berechtigungen > Benutzerrechte-Manager
-
-
-Abbildung: Übersicht aus dem Benutzerberechtigungs-Manager die aufzeigt, wie Benutzer nur auf bestimmte Firmen zugreifen können
-
-#### Beispiel
-
-Der Benutzer "aromn@example.com" hat die Rolle "Nutzer Vertrieb" und wir möchten die Zugriffsrechte des Benutzers so einschränken, dass er nur auf Datensätze einer bestimmten Firma, nämlich der Wind Power LLC, zugreifen kann.
-
-1\. Wir fügen eine Benutzerberechtigungs-Zeile für die Firma hinzu.
-
-Abbildung: Hinzufügen einer Zeile "Benutzer-Berechtigung" für die Kombination aus dem Benutzer "aromn@example.com" und der Firma Wind Power LLC
-
-2\. Die Rolle "Alle" hat nur Leseberechtigungen für die Firma, "Benutzer-Berechtigungen anwenden" ist aktiviert.
-
-Abbildung: Leseberechtigung mit aktivierter Option "Benutzer-Berechtigungen anwenden" für den DocType Firma
-
-3\. Die oben abgebildete Kombination der zwei Regeln führt dazu, dass der Benutzer "aromn@example.com" für die Firma Wind Power LLC nur Leserechte hat.
-
-Abbildung: Der Zugriff wird auf die Firma Wind Power LLC beschränkt
-
-4\. Wir möchten nun diese Benutzer-Berechtigung für "Firma" auf andere Dokumente wie "Angebot", "Kundenauftrag" etc. übertragen. Diese Formulare haben **Verknüpfungsfelder zu "Firma"**. Als Ergebnis werden Benutzer-Berechtigungen von "Firma" auch auf diese Dokumente übertragen, was dazu führt, dass der Benutzer "aromn@example.com" auf diese Dokumente zugreifen kann, wenn Sie mit Wind Power LLC verbunden sind.
-
-Abbildung: Benutzer mit der Rolle "Nutzer Vertrieb" können, basierend auf Ihren Benutzer-Berechtigungen, Angebote lesen, schreiben, erstellen, übertragen und stornieren, wenn "Benutzer-Berechtigungen anwenden" aktiviert ist.
-
-Abbildung: Die Auflistung der Angebote enthält nur Ergebnisse für die Firma Wind Power LLC für den Benutzer "aromn@example.com"
-
-5\. Benutzer-Berechtigungen werden automatisch auf Basis von verknüpften Feldern angewandt, genauso wie wir es bei den Angeboten gesehen haben. Aber: Das Lead-Formular hat vier Verknüpfungsfelder: "Region", "Firma", "Eigentümer des Leads" und "Nächster Kontakt durch". Nehmen wir an, Sie möchten dass die Leads den Zugriff des Benutzers basierend auf Ihrer Region einschränken, obwohl Sie für die DocTypes "Benutzer", "Region" und "Firma" Benutzer-Berechtigungen angelegt haben. Dann gehen Sie wir folgt vor: Aktivieren Sie die Option "Benutzer-Berechtigungen ignorieren" für die Verknüpfungsfelder "Firma", "Eigentümer des Leads" und "Nächster Kontakt durch".
-
-Abbildung: Der Vertriebsmitarbeiter kann Leads lesen, schreiben und erstellen, eingeschränkt durch Benutzer-Berechtigungen.
-
-Abbildung: Markieren Sie "Benutzer-Berechtigungen ignorieren" für die Felder "Firma", "Lead-Inhaber" und "Nächster Kontakt durch" über Setup > Anpassen > Formular anpassen > Lead.
-
-Abbildung: Aufgrund der obigen Kombination kann der Benutzer "aromn@example.com" nur auf Leads der Region "United States" zugreifen.
-
-{next}
+<a href="{{docs_base_url}}/erpnext/user/manual/en/setting-up/users-and-permissions/user-permissions">User Permission</a>
diff --git a/erpnext/docs/user/manual/en/accounts/point-of-sale-pos-invoice.md b/erpnext/docs/user/manual/en/accounts/point-of-sale-pos-invoice.md
index 78d2226..763c142 100644
--- a/erpnext/docs/user/manual/en/accounts/point-of-sale-pos-invoice.md
+++ b/erpnext/docs/user/manual/en/accounts/point-of-sale-pos-invoice.md
@@ -15,7 +15,7 @@
 In ERPNext all Sales and Purchase transactions, like Sales Invoice, Quotation, Sales Order, Purchase Order etc. can be edited via the POS. There two steps to Setup POS:
 
 1. Enable POS View via (Setup > Customize > Feature Setup)
-2. Create a [POS Setting]({{docs_base_url}}/user/manual/en/setting-up/pos-setting.html) record
+2. Create a [POS Profile]({{docs_base_url}}/user/manual/en/setting-up/pos-setting.html) record
 
 #### Different sections of the POS
 
diff --git a/erpnext/docs/user/manual/en/buying/index.txt b/erpnext/docs/user/manual/en/buying/index.txt
index 25c8797..4bd75f1 100644
--- a/erpnext/docs/user/manual/en/buying/index.txt
+++ b/erpnext/docs/user/manual/en/buying/index.txt
@@ -5,3 +5,4 @@
 setup
 articles
 purchase-taxes
+supplier-scorecard
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/buying/supplier-scorecard.md b/erpnext/docs/user/manual/en/buying/supplier-scorecard.md
new file mode 100644
index 0000000..cecdf9c
--- /dev/null
+++ b/erpnext/docs/user/manual/en/buying/supplier-scorecard.md
@@ -0,0 +1,76 @@
+A Supplier Scorecard is an evaluation tool used to assess the performance of 
+suppliers. Supplier scorecards can be used to keep track of item quality, 
+delivery and responsiveness of suppliers across long periods of time. This data 
+is typically used to help in purchasing decisions.
+
+A Supplier Scorecard is manually created for each supplier.
+
+In ERPNext, you can create a supplier scorecard by going to:
+
+> Buying > Documents > Supplier Scorecard > New Supplier Scorecard
+
+### Create Supplier Scorecard
+A supplier scorecard is created for each supplier individually. Only one supplier scorecard can be created for each 
+supplier. 
+<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/supplier-scorecard.png">
+
+#### Final Score and Standings
+The supplier scorecard consists of a set evaluation periods, during which the performance of a supplier is 
+evaluated. This period can be daily, monthly or yearly. The current score is calculated from the score of each evaluation 
+period based on the weighting function. The default formula is linearly weight over the previous 12 scoring periods. 
+<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/supplier-scorecard-weighing.png">
+This formula is customizable.
+
+The supplier standing is used to quickly sort suppliers based on their performance. These are customizable for each supplier. 
+The scorecard standing of a supplier can also be used to restrict suppliers from being included in Request for Quotations or 
+being issued Purchase Orders.
+<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/supplier-scorecard-standing.png">
+
+#### Evaluation Criteria and Variables
+A supplier can be evaluated on several individual evaluation criteria, including (but not limited to) quotation response time, 
+delivered item quality, and delivery timeliness. These criteria are weighed to determine the final period score.
+<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/supplier-scorecard-criteria.png">
+The method for calculating each criteria is determined through the criteria formula field, which can use a number of pre-established variables.
+The value of each of these variables is calculated over the scoring period for each supplier. Examples of such variables include:
+ - The total number of items received from the supplier
+ - The total number of accepted items from the supplier
+ - The total number of rejected items from the supplier
+ - The total number of deliveries from the supplier
+ - The total amount (in dollars) received from a supplier
+Additional variables can be added through server-side customizations.
+
+The criteria formula should be customized to evaluate the suppliers in each criteria in a way that best fits the Company requirements.
+
+##### Evaluation Formulas
+The evaluation formula uses the pre-established or custom variables to evaluate an aspect of supplier performance over the scoring period. Formulas can use the following mathematical functions:
+
+* addition: + 
+* subtraction: -
+* multiplication: *
+* division: /
+* min: min(x,y)
+* max: max(x,y)
+* if/else: (x) if (formula) else (y)
+* less than: <
+* greated than: >
+* variables: {variable_name}
+
+It is crucial that the formula be solvable for all variable values. This is most often an issue if the value resolves to 0. For example:
+```
+{total_accepted_items} / {total_received_items}
+```
+
+This example would resolve to 0 / 0 in periods where there are no received items, and therefore should have a check to protect in this case:
+```
+({total_accepted_items} / {total_received_items}) if {total_received_items} > 0 else 1.
+```
+
+### Evaluating the Supplier
+An evaluation is generated for each Supplier Scorecard Period by clicking the "Generate Missing Scorecard Periods" button. The supplier 
+current score can be seen, as well as a visual graphic showing the performance of the supplier over time. Any actions against the supplier 
+are also noted here, including warnings when create RFQs and POs or locking out those features for this supplier altogether.
+
+
+
+
+{next}
diff --git a/erpnext/docs/user/manual/en/customize-erpnext/articles/making-custom-reports-in-erpnext.md b/erpnext/docs/user/manual/en/customize-erpnext/articles/making-custom-reports-in-erpnext.md
index 7bc965b..3d5174f 100644
--- a/erpnext/docs/user/manual/en/customize-erpnext/articles/making-custom-reports-in-erpnext.md
+++ b/erpnext/docs/user/manual/en/customize-erpnext/articles/making-custom-reports-in-erpnext.md
@@ -12,12 +12,12 @@
 
 Query Report is written in SQL which pull values from account's database and fetch in the report. Though SQL queries can be written from front end, like HTML, its restricted in hosted users. Because it will allow users with no access to specific report to query data directly from the database.
 
-Check Purchase Order Item to be Received report in Stock module for example of Query report. Click [here](https://frappe.github.io/frappe/user/en/guides/reports-and-printing/how-to-make-query-report.html) to learn how to create Query Report.
+Check Purchase Order Item to be Received report in Stock module for example of Query report. Click [here](https://frappe.io/docs/user/en/guides/reports-and-printing/how-to-make-query-report.html) to learn how to create Query Report.
 
 ### 3. Script Report
 
 Script Reports are written in Python and stored on server side. These are complex reports which involves logic and calculation. Since these reports are written on server side, customizing it from hosted account is not possible. 
 
-Check Financial Analytics report in Accounts module for example of Script Report. Click [here](https://frappe.github.io/frappe/user/en/guides/reports-and-printing/how-to-make-script-reports.html) to learn how to create Script Report.
+Check Financial Analytics report in Accounts module for example of Script Report. Click [here](https://frappe.io/docs/user/en/guides/reports-and-printing/how-to-make-script-reports.html) to learn how to create Script Report.
 
 <!-- markdown --> 
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/customize-erpnext/customize-form.md b/erpnext/docs/user/manual/en/customize-erpnext/customize-form.md
index f52cee1..dd14a43 100644
--- a/erpnext/docs/user/manual/en/customize-erpnext/customize-form.md
+++ b/erpnext/docs/user/manual/en/customize-erpnext/customize-form.md
@@ -1,5 +1,5 @@
 <!--markdown-->
-Before we venture to learn form customization tool, click [here](https://frappe.github.io/frappe/user/en/tutorial/doctypes.html) to understand the architecture of forms in ERPNext. It shall help you in using Customize Form tool more efficiently.
+Before we venture to learn form customization tool, click [here](https://frappe.io/docs/user/en/tutorial/doctypes.html) to understand the architecture of forms in ERPNext. It shall help you in using Customize Form tool more efficiently.
 
 Customize Form is the tool which allows user to customize property of the standard fields, and insert [custom fields]({{docs_base_url}}/user/manual/en/customize-erpnext/custom-field.html) as per the requirement. Let's assume we need to set Project Name field as a mandatory field in the Sales Order form. Following are the steps which shall be followed to achieve this.
 
diff --git a/erpnext/docs/user/manual/en/introduction/getting-started-with-erpnext.md b/erpnext/docs/user/manual/en/introduction/getting-started-with-erpnext.md
index 7e783f6..2f59eb4 100644
--- a/erpnext/docs/user/manual/en/introduction/getting-started-with-erpnext.md
+++ b/erpnext/docs/user/manual/en/introduction/getting-started-with-erpnext.md
@@ -1,3 +1,7 @@
+<!-- Getting Started with ERPNext-->
+
+# Getting Started with ERPNext
+
 There are many ways to get started with ERPNext.
 
 ### 1\. See the Demo
diff --git a/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md b/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
index 060033c..f1d1b0f 100644
--- a/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
+++ b/erpnext/docs/user/manual/en/schools/admission/program-enrollment.md
@@ -1,5 +1,5 @@
 This form allows you to enroll a student to a program. A student can be enrolled to multiple programs.  
 
-<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/admission/program-enrollment.png">
+<img class="screenshot" alt="Student Applicant Enrollment" src="{{docs_base_url}}/assets/img/schools/admission/program-enrollment.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/admission/student-applicant.md b/erpnext/docs/user/manual/en/schools/admission/student-applicant.md
index 2b33cf9..0a08f11 100644
--- a/erpnext/docs/user/manual/en/schools/admission/student-applicant.md
+++ b/erpnext/docs/user/manual/en/schools/admission/student-applicant.md
@@ -3,7 +3,7 @@
 A Student Applicant record needs to be created when a student applies for a program at your institute.
 You can Approve or Reject a student applicant. By accepting a student applicant you can add them to the student master.
 
-<img class="screenshot" alt="Student Applicant" src="{{url_prefix}}/assets/img/schools/admission/student-applicant.png">
+<img class="screenshot" alt="Student Applicant" src="{{docs_base_url}}/assets/img/schools/admission/student-applicant.png">
 
 ### Application Status
 
@@ -23,6 +23,6 @@
 Once you approve a Student Applicant you can enroll them to a program. When you click the 'Enroll' buttom,
 the system shall create a student against that applicant and redirect you to the [Program Enrollment form]({{docs_base_url}}/user/manual/en/schools/student/program-enrollment.html).
 
-<img class="screenshot" alt="Student Applicant Enrollment" src="{{url_prefix}}/assets/img/schools/admission/student-applicant-enroll.png">
+<img class="screenshot" alt="Student Applicant Enrollment" src="{{docs_base_url}}/assets/img/schools/admission/student-applicant-enroll.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/fees/fee-category.md b/erpnext/docs/user/manual/en/schools/fees/fee-category.md
index d6694b5..b333ffe 100644
--- a/erpnext/docs/user/manual/en/schools/fees/fee-category.md
+++ b/erpnext/docs/user/manual/en/schools/fees/fee-category.md
@@ -2,6 +2,6 @@
 
 List of all different type of fees collected.
 
-<img class="screenshot" alt="Fees Category" src="{{url_prefix}}/assets/img/schools/fees/fee-category.png">
+<img class="screenshot" alt="Fees Category" src="{{docs_base_url}}/assets/img/schools/fees/fee-category.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/fees/fee-structure.md b/erpnext/docs/user/manual/en/schools/fees/fee-structure.md
index 08d09e5..a796b0c 100644
--- a/erpnext/docs/user/manual/en/schools/fees/fee-structure.md
+++ b/erpnext/docs/user/manual/en/schools/fees/fee-structure.md
@@ -2,6 +2,6 @@
 
 A Fee Structure is a template that can be used while making fee records.
 
-<img class="screenshot" alt="Fees Structure" src="{{url_prefix}}/assets/img/schools/fees/fee-structure.png">
+<img class="screenshot" alt="Fees Structure" src="{{docs_base_url}}/assets/img/schools/fees/fee-structure.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/fees/fees.md b/erpnext/docs/user/manual/en/schools/fees/fees.md
index 242abf8..5745ec1 100644
--- a/erpnext/docs/user/manual/en/schools/fees/fees.md
+++ b/erpnext/docs/user/manual/en/schools/fees/fees.md
@@ -3,6 +3,6 @@
 Maintain a record of fees collected from students.
 The [Fee Structure]({{docs_base_url}}/user/manual/en/schools/fees/fee-structure.html) is fetched based on the selected Program and Academic Term.
 
-<img class="screenshot" alt="Fees" src="{{url_prefix}}/assets/img/schools/fees/fees.png">
+<img class="screenshot" alt="Fees" src="{{docs_base_url}}/assets/img/schools/fees/fees.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/fees/index.md b/erpnext/docs/user/manual/en/schools/fees/index.md
index f75c537..ab07182 100644
--- a/erpnext/docs/user/manual/en/schools/fees/index.md
+++ b/erpnext/docs/user/manual/en/schools/fees/index.md
@@ -2,7 +2,7 @@
 
 This section contains 'Fee' related documents.
 
-<img class="screenshot" alt="Fees Section" src="{{url_prefix}}/assets/img/schools/fees/fees-section.png">
+<img class="screenshot" alt="Fees Section" src="{{docs_base_url}}/assets/img/schools/fees/fees-section.png">
 
 ### Topics
 
diff --git a/erpnext/docs/user/manual/en/schools/index.md b/erpnext/docs/user/manual/en/schools/index.md
index e2172ff..16fd31d 100644
--- a/erpnext/docs/user/manual/en/schools/index.md
+++ b/erpnext/docs/user/manual/en/schools/index.md
@@ -1,6 +1,6 @@
 
 The School Modules is designed to meet requirements of Schools, Colleges & Educational Institutes.
 
-<img class="screenshot" alt="Fees Section" src="{{url_prefix}}/assets/img/schools/module.png">
+<img class="screenshot" alt="Fees Section" src="{{docs_base_url}}/assets/img/schools/module.png">
 
 {index}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/schedule/course-schedule.md b/erpnext/docs/user/manual/en/schools/schedule/course-schedule.md
index 9c27f61..d766f66 100644
--- a/erpnext/docs/user/manual/en/schools/schedule/course-schedule.md
+++ b/erpnext/docs/user/manual/en/schools/schedule/course-schedule.md
@@ -3,13 +3,13 @@
 Course Schedule is the schedule of a session conducted by an Instructor for a particular Course.
 You can see the overall course schedule in the Calendar view.
 
-<img class="screenshot" alt="Course Schedule" src="{{url_prefix}}/assets/img/schools/schedule/course-schedule.png">
+<img class="screenshot" alt="Course Schedule" src="{{docs_base_url}}/assets/img/schools/schedule/course-schedule.png">
 
 ### Marking Attendance
 
 You can mark attendance for a Student Group against a Course Schedule.
 
-<img class="screenshot" alt="Course Schedule Attendance" src="{{url_prefix}}/assets/img/schools/schedule/course-schedule-att.png">
+<img class="screenshot" alt="Course Schedule Attendance" src="{{docs_base_url}}/assets/img/schools/schedule/course-schedule-att.png">
 
 - To make attendance, expand the attendance section.
 - Check the students who were present for that session.
@@ -20,6 +20,6 @@
 Once you have marked Attendance against a Course Schedule the Attendance section in the Course Schedule shall be hidden. 
 A View Attendance button shall appear. Click on that button to view all attendance records created against that Course Schedule.
 
-<img class="screenshot" alt="Course Schedule Attendance" src="{{url_prefix}}/assets/img/schools/schedule/course-schedule-att-1.png">
+<img class="screenshot" alt="Course Schedule Attendance" src="{{docs_base_url}}/assets/img/schools/schedule/course-schedule-att-1.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/schedule/examination.md b/erpnext/docs/user/manual/en/schools/schedule/examination.md
index cd5d838..14bc182 100644
--- a/erpnext/docs/user/manual/en/schools/schedule/examination.md
+++ b/erpnext/docs/user/manual/en/schools/schedule/examination.md
@@ -2,7 +2,7 @@
 
 The Examination record can be used to track the exam schedule and the results of that exam.
 
-<img class="screenshot" alt="Examination" src="{{url_prefix}}/assets/img/schools/schedule/examination.png">
+<img class="screenshot" alt="Examination" src="{{docs_base_url}}/assets/img/schools/schedule/examination.png">
 
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/schedule/index.md b/erpnext/docs/user/manual/en/schools/schedule/index.md
index 3fd993e..8d343bf 100644
--- a/erpnext/docs/user/manual/en/schools/schedule/index.md
+++ b/erpnext/docs/user/manual/en/schools/schedule/index.md
@@ -1,6 +1,6 @@
 # Schedule
 
-<img class="screenshot" alt="Schedule Section" src="{{url_prefix}}/assets/img/schools/schedule/schedule-section.png">
+<img class="screenshot" alt="Schedule Section" src="{{docs_base_url}}/assets/img/schools/schedule/schedule-section.png">
 
 ### Topics
 
diff --git a/erpnext/docs/user/manual/en/schools/schedule/scheduling-tool.md b/erpnext/docs/user/manual/en/schools/schedule/scheduling-tool.md
index 84b3908..a5eb9f2 100644
--- a/erpnext/docs/user/manual/en/schools/schedule/scheduling-tool.md
+++ b/erpnext/docs/user/manual/en/schools/schedule/scheduling-tool.md
@@ -2,7 +2,7 @@
 
 This tool can be used to create 'Course Schedules'. 
 
-<img class="screenshot" alt="Scheduling Tool" src="{{url_prefix}}/assets/img/schools/schedule/scheduling-tool.png">
+<img class="screenshot" alt="Scheduling Tool" src="{{docs_base_url}}/assets/img/schools/schedule/scheduling-tool.png">
 
 ### Creating Course Schedules
 
diff --git a/erpnext/docs/user/manual/en/schools/schedule/student-attendance.md b/erpnext/docs/user/manual/en/schools/schedule/student-attendance.md
index 474b543..ef89e5d 100644
--- a/erpnext/docs/user/manual/en/schools/schedule/student-attendance.md
+++ b/erpnext/docs/user/manual/en/schools/schedule/student-attendance.md
@@ -2,6 +2,6 @@
 
 Maintains attendance record of the student. Attendance Records can be created against Course Schedules.
 
-<img class="screenshot" alt="Student Attendance" src="{{url_prefix}}/assets/img/schools/schedule/student-attendance.png">
+<img class="screenshot" alt="Student Attendance" src="{{docs_base_url}}/assets/img/schools/schedule/student-attendance.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/academic-term.md b/erpnext/docs/user/manual/en/schools/setup/academic-term.md
index dbce6d9..f268fd0 100644
--- a/erpnext/docs/user/manual/en/schools/setup/academic-term.md
+++ b/erpnext/docs/user/manual/en/schools/setup/academic-term.md
@@ -1,6 +1,6 @@
 # Academic Term
 
-<img class="screenshot" alt="Academic Term" src="{{url_prefix}}/assets/img/schools/setup/academic-term.png">
+<img class="screenshot" alt="Academic Term" src="{{docs_base_url}}/assets/img/schools/setup/academic-term.png">
 
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/academic-year.md b/erpnext/docs/user/manual/en/schools/setup/academic-year.md
index 4a15393..1d836f8 100644
--- a/erpnext/docs/user/manual/en/schools/setup/academic-year.md
+++ b/erpnext/docs/user/manual/en/schools/setup/academic-year.md
@@ -1,5 +1,5 @@
 # Academic Year
 
-<img class="screenshot" alt="Academic Year" src="{{url_prefix}}/assets/img/schools/setup/academic-year.png">
+<img class="screenshot" alt="Academic Year" src="{{docs_base_url}}/assets/img/schools/setup/academic-year.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/course.md b/erpnext/docs/user/manual/en/schools/setup/course.md
index da5fa37..b6c1aca 100644
--- a/erpnext/docs/user/manual/en/schools/setup/course.md
+++ b/erpnext/docs/user/manual/en/schools/setup/course.md
@@ -1,5 +1,5 @@
 # Course
 
-<img class="screenshot" alt="Course" src="{{url_prefix}}/assets/img/schools/setup/course.png">
+<img class="screenshot" alt="Course" src="{{docs_base_url}}/assets/img/schools/setup/course.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/index.md b/erpnext/docs/user/manual/en/schools/setup/index.md
index 5a360dd..23054ad 100644
--- a/erpnext/docs/user/manual/en/schools/setup/index.md
+++ b/erpnext/docs/user/manual/en/schools/setup/index.md
@@ -1,6 +1,6 @@
 # Setup
 
-<img class="screenshot" alt="Setup Section" src="{{url_prefix}}/assets/img/schools/setup/setup-section.png">
+<img class="screenshot" alt="Setup Section" src="{{docs_base_url}}/assets/img/schools/setup/setup-section.png">
 
 ### Topics
 
diff --git a/erpnext/docs/user/manual/en/schools/setup/instructor.md b/erpnext/docs/user/manual/en/schools/setup/instructor.md
index adbfe2a..7bfd348 100644
--- a/erpnext/docs/user/manual/en/schools/setup/instructor.md
+++ b/erpnext/docs/user/manual/en/schools/setup/instructor.md
@@ -1,5 +1,5 @@
 # Instructor
 
-<img class="screenshot" alt="Instructor" src="{{url_prefix}}/assets/img/schools/setup/instructor.png">
+<img class="screenshot" alt="Instructor" src="{{docs_base_url}}/assets/img/schools/setup/instructor.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/program.md b/erpnext/docs/user/manual/en/schools/setup/program.md
index 813019b..2f1c207 100644
--- a/erpnext/docs/user/manual/en/schools/setup/program.md
+++ b/erpnext/docs/user/manual/en/schools/setup/program.md
@@ -1,5 +1,5 @@
 # Program
 
-<img class="screenshot" alt="Program" src="{{url_prefix}}/assets/img/schools/setup/program.png">
+<img class="screenshot" alt="Program" src="{{docs_base_url}}/assets/img/schools/setup/program.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/setup/room.md b/erpnext/docs/user/manual/en/schools/setup/room.md
index 052e962..9ec39e8 100644
--- a/erpnext/docs/user/manual/en/schools/setup/room.md
+++ b/erpnext/docs/user/manual/en/schools/setup/room.md
@@ -1,6 +1,6 @@
 # Room
 
 
-<img class="screenshot" alt="Room" src="{{url_prefix}}/assets/img/schools/setup/room.png">
+<img class="screenshot" alt="Room" src="{{docs_base_url}}/assets/img/schools/setup/room.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/student-batch.md b/erpnext/docs/user/manual/en/schools/student/student-batch.md
index 0f29d46..3a6c82f 100644
--- a/erpnext/docs/user/manual/en/schools/student/student-batch.md
+++ b/erpnext/docs/user/manual/en/schools/student/student-batch.md
@@ -2,6 +2,6 @@
 
 Student batch is a collection of students from Student Groups.
 
-<img class="screenshot" alt="Student" src="{{url_prefix}}/assets/img/schools/student/student-batch.png">
+<img class="screenshot" alt="Student" src="{{docs_base_url}}/assets/img/schools/student/student-batch.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/student/student-group-creation-tool.md b/erpnext/docs/user/manual/en/schools/student/student-group-creation-tool.md
index 1fcd87c..c5e23b7 100644
--- a/erpnext/docs/user/manual/en/schools/student/student-group-creation-tool.md
+++ b/erpnext/docs/user/manual/en/schools/student/student-group-creation-tool.md
@@ -1,6 +1,6 @@
 This tool allows you to create student groups in bulk. You can specify multiple parameters to create them.
 
 
-<img class="screenshot" alt="Student Group Creation Tool" src="{{url_prefix}}/assets/img/schools/student/student-group-creation-tool.png">
+<img class="screenshot" alt="Student Group Creation Tool" src="{{docs_base_url}}/assets/img/schools/student/student-group-creation-tool.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/student-group.md b/erpnext/docs/user/manual/en/schools/student/student-group.md
index eaa60f7..91118c7 100644
--- a/erpnext/docs/user/manual/en/schools/student/student-group.md
+++ b/erpnext/docs/user/manual/en/schools/student/student-group.md
@@ -3,6 +3,6 @@
 A student group is a collection of students taking a same course. You can create Course Schedules and Examinations against a Student Group.
 A student group needs to be created for every course in a particular academic term and academic year.
 
-<img class="screenshot" alt="Student Group" src="{{url_prefix}}/assets/img/schools/student/student-group.png">
+<img class="screenshot" alt="Student Group" src="{{docs_base_url}}/assets/img/schools/student/student-group.png">
 
 {next}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/schools/student/student-log.md b/erpnext/docs/user/manual/en/schools/student/student-log.md
index 787dacb..028d136 100644
--- a/erpnext/docs/user/manual/en/schools/student/student-log.md
+++ b/erpnext/docs/user/manual/en/schools/student/student-log.md
@@ -3,6 +3,6 @@
 You can make a note of student activities using student log.
 Logs can be categorised as 'General', 'Academic', 'Medical' or 'Achievement'
 
-<img class="screenshot" alt="Student" src="{{url_prefix}}/assets/img/schools/student/student-log.png">
+<img class="screenshot" alt="Student" src="{{docs_base_url}}/assets/img/schools/student/student-log.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/schools/student/student.md b/erpnext/docs/user/manual/en/schools/student/student.md
index a86d36e..2caaf06 100644
--- a/erpnext/docs/user/manual/en/schools/student/student.md
+++ b/erpnext/docs/user/manual/en/schools/student/student.md
@@ -5,6 +5,6 @@
 
 You can view everything related to a particular student on this page. Eg : Fees, Student Group, etc
 
-<img class="screenshot" alt="Student" src="{{url_prefix}}/assets/img/schools/student/student.png">
+<img class="screenshot" alt="Student" src="{{docs_base_url}}/assets/img/schools/student/student.png">
 
 {next}
diff --git a/erpnext/docs/user/manual/en/selling/quotation.md b/erpnext/docs/user/manual/en/selling/quotation.md
index 1f7b06c..324a666 100644
--- a/erpnext/docs/user/manual/en/selling/quotation.md
+++ b/erpnext/docs/user/manual/en/selling/quotation.md
@@ -83,6 +83,6 @@
 
 While making your sales transactions like a Quotation (or Sales Order) you
 can also give discounts to your customers. In the Discount section, add
-the discount in percentage or fixed amount. Read [Discount](https://frappe.github.io/erpnext/user/manual/en/selling/articles/applying-discount) for more explanation.
+the discount in percentage or fixed amount. Read [Discount](https://erpnext.org/docs/user/manual/en/selling/articles/applying-discount) for more explanation.
 
 {next}
diff --git a/erpnext/docs/user/manual/en/setting-up/articles/integrating-erpnext-with-other-application.md b/erpnext/docs/user/manual/en/setting-up/articles/integrating-erpnext-with-other-application.md
index 3cbf159..7ab6849 100644
--- a/erpnext/docs/user/manual/en/setting-up/articles/integrating-erpnext-with-other-application.md
+++ b/erpnext/docs/user/manual/en/setting-up/articles/integrating-erpnext-with-other-application.md
@@ -2,6 +2,6 @@
 
 For now, ERPNext has out-of-the-box integration available for some applications like Shopify, your SMS gateway and payment gateway. To integrate ERPNext with other application, you can use REST API of Frappe. Check following links to learn more about REST API of Frappe.
 
-[Frappe Rest API](https://frappe.github.io/frappe/user/en/guides/integration/rest_api.html)
+[Frappe Rest API](https://frappe.io/docs/user/en/guides/integration/rest_api.html)
 
 <!-- markdown -->
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/setting-up/email/email-account.md b/erpnext/docs/user/manual/en/setting-up/email/email-account.md
index ad448b0..d5aca1a 100644
--- a/erpnext/docs/user/manual/en/setting-up/email/email-account.md
+++ b/erpnext/docs/user/manual/en/setting-up/email/email-account.md
@@ -26,6 +26,12 @@
 
 <img class="screenshot" alt="Incoming EMail" src="{{docs_base_url}}/assets/img/setup/email/email-account-incoming.png">
 
+### Setting Import Conditions for Email Import
+
+Email Accounts allows you to set conditions according to the data of the incoming emails. The email will be imported to ERPNext only if the all conditions are true. For example if you want to import an email if the subject is "Some important email", you put doc.subject == "Some important email" in the conditions textbox. You can also set more complex conditions by combining them, as shown on the following screenshot.
+
+<img class="screenshot" alt="Incoming EMail Conditions" src="{{docs_base_url}}/assets/img/setup/email/email-account-incoming-conditions.png">
+
 ### How ERPNext handles replies
 
 In ERPNext when you send an email to a contact like a customer, the sender will be the user who sent the email. In the **Reply-To** property, the Email Address will be of the default incoming account (like `replies@yourcompany.com`). ERPNext will automatically extract these emails from the incoming account and tag it to the relevant communication
diff --git a/erpnext/docs/user/manual/en/setting-up/pos-setting.md b/erpnext/docs/user/manual/en/setting-up/pos-setting.md
index 9bfd819..01e353b 100644
--- a/erpnext/docs/user/manual/en/setting-up/pos-setting.md
+++ b/erpnext/docs/user/manual/en/setting-up/pos-setting.md
@@ -1,4 +1,4 @@
-# Point of Sale Setting
+# Point of Sale Profile
 
 POS includes advanced features to cater to different functionality, such as
 inventory management, CRM, financials, warehousing, etc., all built into the
@@ -10,11 +10,17 @@
 and efficient as possible. To do this, you can create a POS Setting for a user
 from:
 
-> Accounts > Setup > Point-of-Sale Setting
+> Accounts > Setup > Point-of-Sale Profile
 
 Set default values as defined.
 
-<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/pos-setting.png">
+<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/pos_profile.png">
+
+To set the default mode of payment, enabled the option default in the mode of payments table
+<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/default_mop.png">
+
+User can sale the particular products to the particular customers from the POS by adding item groups, customer groups in the POS Profile.
+<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/item_customer_group.png">
 
 > Important : If you specify a particular User, the POS setting will be
 applied only to that User. If the User option is left blank, the setting will
diff --git a/erpnext/docs/user/manual/en/setting-up/users-and-permissions/user-permissions.md b/erpnext/docs/user/manual/en/setting-up/users-and-permissions/user-permissions.md
index 7fae95c..f90cf44 100644
--- a/erpnext/docs/user/manual/en/setting-up/users-and-permissions/user-permissions.md
+++ b/erpnext/docs/user/manual/en/setting-up/users-and-permissions/user-permissions.md
@@ -1,60 +1,52 @@
 # User Permissions
 
-Role Base Permissions define the periphery of document types within which a user with a set of Roles can move around in. However, you can have an even finer control by defining User Permissions for a User. By setting specific documents in User Permissions list, you can limit access for that User to specific documents of a particular DocType, on the condition that "Apply User Permissions" is checked in Role Permissions Manager.
+Along with Role based permissions, you can also set user level permissions that are based on rules that are evaluated against the data containted in the document being accessed. This is particularly useful when you want to restrict based on:
 
-To start with, go to:
+1. Allow user to access data belonging to one Company
+1. Allow user to access data related to a specific Customer or Territory
 
-> Setup > Permissions > User Permissions Manager
+### Creating User Permissions
 
-User Permissions Manager displaying how users can access only a specific Company.
+To create a User Permission, go to Setup > Permission > User Permissions
 
-#### Example
+When you create a new record you will have to specify
 
-User 'tom.hagen@riosolutions.com' has Sales User role and we want to limit the user to access records for only a specific Company 'Rio Solutions'.
+1. The user for which the rule has to be applied
+1. The type of document which will be allowed (for example "Company")
+1. The specific item that you want to allow (the name of the "Company)
 
-  1. We add a User Permissions row for Company.
-	
-	<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permissions-new.gif" class="screen" alt="User Permissions For Company">
+<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-perms/new-user-permission.png" class="screenshot" alt="Creating a new user permission">
 
-	Add User Permissions row for a combination of User 'tom.hagen@riosolutions.com' and Company 'Rio Solutions'.
+If you want to apply the permissions to all Roles for that user, keep the "Apply Permissions for all Roles of this User" checked. If you check this, it will automatically setup the rules for Roles to check for User Permissions.
 
-  1. Also Role "All" has only Read permission for Company, with 'Apply User Permissions' checked.
-	
-	<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permissions-company-role-all.png" class="screen" alt="Role Permissions for All on Company">
+### Choosing Which Roles to Apply
 
-	Read Permission with Apply User Permissions checked for DocType Company.
+You can also manually edit the the roles for which you want the user permissions to apply. To do that go the the **Role Permission Manager** and select the role for which you want to Edit the User Permissions.
 
-  1. The combined effect of the above two rules lead to User 'tom.hagen@riosolutions.com' having only Read access to Company 'Rio Solutions'.
-	
-	<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permission-company.png" class="screen" alt="Effect of Role and User Permissions on Company">
-	
-	Access is limited to Company 'Rio Solutions'.
+Note that the "Apply User Permissions" is already checked for this role. Then click on "Select Document Types"
 
-  1. We want this User Permission on Company to get applied on other documents like Quotation, Sales Order, etc.
-	 
-	 These forms have a **Link Field based on Company**. As a result, User Permissions on Company also get applied on these documents, which leads to User 'tom.hagen@riosolutions' to acces these documents having Company 'Rio Solutions'.
+<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-perms/select-document-types.png" class="screenshot" alt="Select Document Types to Edit the Setting">
 
-    <img class="screen" alt="Sales User Role Permissions for Quotation" src="{{docs_base_url}}/assets/img/users-and-permissions/user-permissions-quotation-sales-user.png" >
-	 
-	 Users with Sales User Role can Read, Write, Create, Submit and Cancel Quotations based on their User Permissions, since 'Apply User Permissions' is checked.
+Here you will see that Company has already been checked. If you want user permissions not be applied for that particular rule, you can un check it.
 
-	<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permission-quotation.png" class="screenshot" alt="Quotation List limited to results for Company 'Rio Solutions'">
+<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-perms/view-selected-documents.png" class="screenshot" alt="Select Document Types to Edit the Setting">
 
-	Quotation List is limited to results for Company 'Rio Solutions' for User 'tom.hagen@riosolutions.com'.
+### Ignoring User Permissions on Certain Fields
 
-  1. User Permissions get applied automatically based on Link Fields, just like how it worked for Quotation. But, Lead Form has 4 Link fields: Territory, Company, Lead Owner and Next Contact By. Say, you want Leads to limit access to Users based only on Territory, even though you have defined User Permissions for DocTypes User, Territory and Company. You can do this by setting 'Ignore User Permissions' for Link fields: Company, Lead Owner and Next Contact By.  
-    
-<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permissions-lead-role-permissions.png" class="screen" alt="Role Permissions on Lead for Sales User Role">
+Another way of allowing documents to be seen that have been restricited by User Permissions is to check "Ignore User Permissions" on a particular field by going to **Customize Form**
 
-Sales User can Read, Write and Create Leads limited by User Permissions.
+For example you don't want Assets to be restricited for any user, then select **Asset** in **Customize Form** and in the Company field, check on "Ignore User Permissions"
 
-<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-permissions-ignore-user-permissions.png" class="screenshot" alt="Set Ingore User Permissions from Setup > Customize > Customize Form">	
+<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-perms/ignore-user-user-permissions.png" class="screenshot" alt="Ignore User Permissions on specific properties">
 
-Check 'Ingore User Permissions' for Company, Lead Owner and Next Contact By fields using Setup > Customize > Customize Form for Lead.
+### Strict Permisssions
 
-<img src="{{docs_base_url}}/assets/img/users-and-permissions/permissions-lead-list.png" class="screenshot" alt="Lead List is limited to records with Territory 'United States'">	
+Since User Permissions are applied via Roles, there may be many users belonging to a particular Role. Suppose you have three users belonging to Role "Accounts User" and you have applied **User Permissions** to only one user, then the permissions will only be restricted to that user.
 
-Due to the effect of the above combination, User 'tom.hagen@riosolutions.com' can only access Leads with Territory 'United States'.
+You can change this setting incase you want the user permissions to be assigned to all users, even if they are not assigned any user permissions by going to **System Settings** and checking "Apply Strict User Permissions"
 
-{next}
+### Checking How User Permissions are Applied
 
+Finally once you have created your air-tight permission model, and you want to check how it applies to various users, you can see it via the **Permitted Documents for User** report. Using this report, you can select the **User** and document type and check how user permissions get applied.
+
+<img src="{{docs_base_url}}/assets/img/users-and-permissions/user-perms/permitted-documents.png" class="screenshot" alt="Permitted Documents for User report">
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 472d8f9..3a8569b 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -62,75 +62,85 @@
 	{"from_route": "/orders/<path:name>", "to_route": "order",
 		"defaults": {
 			"doctype": "Sales Order",
-			"parents": [{"title": _("Orders"), "name": "orders"}]
+			"parents": [{"label": _("Orders"), "route": "orders"}]
 		}
 	},
 	{"from_route": "/invoices", "to_route": "Sales Invoice"},
 	{"from_route": "/invoices/<path:name>", "to_route": "order",
 		"defaults": {
 			"doctype": "Sales Invoice",
-			"parents": [{"title": _("Invoices"), "name": "invoices"}]
+			"parents": [{"label": _("Invoices"), "route": "invoices"}]
 		}
 	},
-	{"from_route": "/quotations", "to_route": "Supplier Quotation"},
-	{"from_route": "/quotations/<path:name>", "to_route": "order",
+	{"from_route": "/supplier-quotations", "to_route": "Supplier Quotation"},
+	{"from_route": "/supplier-quotations/<path:name>", "to_route": "order",
 		"defaults": {
 			"doctype": "Supplier Quotation",
-			"parents": [{"title": _("Supplier Quotation"), "name": "quotations"}]
+			"parents": [{"label": _("Supplier Quotation"), "route": "quotations"}]
 		}
 	},
-	{"from_route": "/quotation", "to_route": "Quotation"},
+	{"from_route": "/quotations", "to_route": "Quotation"},
+	{"from_route": "/quotations/<path:name>", "to_route": "order",
+		"defaults": {
+			"doctype": "Quotation",
+			"parents": [{"label": _("Quotations"), "route": "quotation"}]
+		}
+	},
 	{"from_route": "/shipments", "to_route": "Delivery Note"},
 	{"from_route": "/shipments/<path:name>", "to_route": "order",
 		"defaults": {
 			"doctype": "Delivery Note",
-			"parents": [{"title": _("Shipments"), "name": "shipments"}]
+			"parents": [{"label": _("Shipments"), "route": "shipments"}]
 		}
 	},
 	{"from_route": "/rfq", "to_route": "Request for Quotation"},
 	{"from_route": "/rfq/<path:name>", "to_route": "rfq",
 		"defaults": {
 			"doctype": "Request for Quotation",
-			"parents": [{"title": _("Request for Quotation"), "name": "rfq"}]
+			"parents": [{"label": _("Request for Quotation"), "route": "rfq"}]
 		}
 	},
 	{"from_route": "/addresses", "to_route": "Address"},
 	{"from_route": "/addresses/<path:name>", "to_route": "addresses",
 		"defaults": {
 			"doctype": "Address",
-			"parents": [{"title": _("Addresses"), "name": "addresses"}]
+			"parents": [{"label": _("Addresses"), "route": "addresses"}]
 		}
 	},
 	{"from_route": "/jobs", "to_route": "Job Opening"},
 	{"from_route": "/admissions", "to_route": "Student Admission"},
-	{"from_route": "/boms", "to_route": "BOM"}
+	{"from_route": "/boms", "to_route": "BOM"},
+	{"from_route": "/timesheets", "to_route": "Timesheet"},
 ]
 
 standard_portal_menu_items = [
 	{"title": _("Projects"), "route": "/project", "reference_doctype": "Project"},
 	{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation", "role": "Supplier"},
-	{"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
-	{"title": _("Quotations"), "route": "/quotation", "reference_doctype": "Quotation", "role":"Customer"},
+	{"title": _("Supplier Quotation"), "route": "/supplier-quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
+	{"title": _("Quotations"), "route": "/quotations", "reference_doctype": "Quotation", "role":"Customer"},
 	{"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order", "role":"Customer"},
 	{"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice", "role":"Customer"},
 	{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
 	{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"},
 	{"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"},
-	{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}
+	{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"},
+	{"title": _("Timesheets"), "route": "/timesheets", "reference_doctype": "Timesheet", "role":"Customer"}
 ]
 
 default_roles = [
 	{'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id'},
 	{'role': 'Supplier', 'doctype':'Contact', 'email_field': 'email_id'},
-	{'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'}
+	{'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'},
 ]
 
 has_website_permission = {
 	"Sales Order": "erpnext.controllers.website_list_for_contact.has_website_permission",
+	"Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Supplier Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission",
-	"Issue": "erpnext.support.doctype.issue.issue.has_website_permission"
+	"Issue": "erpnext.support.doctype.issue.issue.has_website_permission",
+	"Timesheet": "erpnext.controllers.website_list_for_contact.has_website_permission"
 }
 
 dump_report_map = "erpnext.startup.report_data_map.data_map"
@@ -184,6 +194,7 @@
 		"erpnext.accounts.doctype.asset.depreciation.post_depreciation_entries",
 		"erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings.send_summary",
 		"erpnext.stock.doctype.serial_no.serial_no.update_maintenance_status",
+		"erpnext.buying.doctype.supplier_scorecard.supplier_scorecard.refresh_scorecards",
 		"erpnext.setup.doctype.company.company.cache_companies_monthly_sales_history"
 	]
 }
diff --git a/erpnext/hr/doctype/attendance/test_attendance.js b/erpnext/hr/doctype/attendance/test_attendance.js
new file mode 100644
index 0000000..82347ad
--- /dev/null
+++ b/erpnext/hr/doctype/attendance/test_attendance.js
@@ -0,0 +1,35 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Attendance [HR]", function (assert) {
+	assert.expect(4);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test attendance creation for one employee
+		() => frappe.set_route("List", "Attendance", "List"),
+		() => frappe.timeout(0.5),
+		() => frappe.new_doc("Attendance"),
+		() => frappe.timeout(1),
+		() => assert.equal("Attendance", cur_frm.doctype,
+			"Form for new Attendance opened successfully."),
+		// set values in form
+		() => cur_frm.set_value("company", "Test Company"),
+		() => frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name'),
+		(employee) => cur_frm.set_value("employee", employee.message.name),
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		// check docstatus of attendance before submit [Draft]
+		() => assert.equal("0", cur_frm.doc.docstatus,
+			"attendance is currently drafted"),
+		// check docstatus of attendance after submit [Present]
+		() => cur_frm.savesubmit(),
+		() => frappe.timeout(0.5),
+		() => frappe.click_button('Yes'),
+		() => assert.equal("1", cur_frm.doc.docstatus,
+			"attendance is saved after submit"),
+		// check if auto filled date is present day
+		() => assert.equal(frappe.datetime.nowdate(), cur_frm.doc.attendance_date,
+			"attendance for Present day is marked"),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/branch/test_branch.js b/erpnext/hr/doctype/branch/test_branch.js
new file mode 100644
index 0000000..446db75
--- /dev/null
+++ b/erpnext/hr/doctype/branch/test_branch.js
@@ -0,0 +1,22 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Branch [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test branch creation
+		() => frappe.set_route("List", "Branch", "List"),
+		() => frappe.new_doc("Branch"),
+		() => frappe.timeout(1),
+		() => frappe.click_link('Edit in full page'),
+		() => cur_frm.set_value("branch", "Test Branch"),
+
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Branch", cur_frm.doc.branch,
+			'name of branch correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/department/test_department.js b/erpnext/hr/doctype/department/test_department.js
new file mode 100644
index 0000000..1c413e9
--- /dev/null
+++ b/erpnext/hr/doctype/department/test_department.js
@@ -0,0 +1,22 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Department [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test department creation
+		() => frappe.set_route("List", "Department", "List"),
+		() => frappe.new_doc("Department"),
+		() => frappe.timeout(1),
+		() => frappe.click_link('Edit in full page'),
+		() => cur_frm.set_value("department_name", "Test Department"),
+		() => cur_frm.set_value("leave_block_list", "Test Leave block list"),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Department", cur_frm.doc.department_name,
+			'name of department correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/designation/test_designation.js b/erpnext/hr/doctype/designation/test_designation.js
new file mode 100644
index 0000000..a012877
--- /dev/null
+++ b/erpnext/hr/doctype/designation/test_designation.js
@@ -0,0 +1,22 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Designation [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test designation creation
+		() => frappe.set_route("List", "Designation", "List"),
+		() => frappe.new_doc("Designation"),
+		() => frappe.timeout(1),
+		() => frappe.click_link('Edit in full page'),
+		() => cur_frm.set_value("designation_name", "Test Designation"),
+		() => cur_frm.set_value("description", "This designation is just for testing."),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Designation", cur_frm.doc.designation_name,
+			'name of designation correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee/test_employee.js b/erpnext/hr/doctype/employee/test_employee.js
new file mode 100644
index 0000000..64a6b7a
--- /dev/null
+++ b/erpnext/hr/doctype/employee/test_employee.js
@@ -0,0 +1,39 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Employee [HR]", function (assert) {
+	assert.expect(3);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+
+	frappe.run_serially([
+		// test employee creation
+		() => frappe.set_route("List", "Employee", "List"),
+		() => frappe.new_doc("Employee"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("employee_name", "Test Employee 1"),
+		() => cur_frm.set_value("salutation", "Ms"),
+		() => cur_frm.set_value("company", "Test Company"),
+		() => cur_frm.set_value("date_of_joining", frappe.datetime.add_months(today_date, -2)),	// joined 2 month from now
+		() => cur_frm.set_value("date_of_birth", frappe.datetime.add_months(today_date, -240)),	// age is 20 years
+		() => cur_frm.set_value("employment_type", "Test Employment type"),
+		() => cur_frm.set_value("holiday_list", "Test Holiday list"),
+		() => cur_frm.set_value("branch", "Test Branch"),
+		() => cur_frm.set_value("department", "Test Department"),
+		() => cur_frm.set_value("designation", "Test Designation"),
+		() => frappe.click_button('Add Row'),
+		() => cur_frm.fields_dict.leave_approvers.grid.grid_rows[0].doc.leave_approver="Administrator",
+		// save data
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		// check name of employee
+		() => assert.equal("Test Employee 1", cur_frm.doc.employee_name,
+			'name of employee correctly saved'),
+		// check auto filled gender according to salutation
+		() => assert.equal("Female", cur_frm.doc.gender,
+			'gender correctly saved as per salutation'),
+		// check auto filled retirement date [60 years from DOB]
+		() => assert.equal(frappe.datetime.add_months(today_date, 480), cur_frm.doc.date_of_retirement,	// 40 years from now
+			'retirement date correctly saved as per date of birth'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js b/erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
new file mode 100644
index 0000000..a71ba0f
--- /dev/null
+++ b/erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
@@ -0,0 +1,49 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Employee attendance tool [HR]", function (assert) {
+	assert.expect(3);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+	let date_of_attendance = frappe.datetime.add_days(today_date, -1);	// previous day
+
+	frappe.run_serially([
+		// create employee
+		() => {
+			return frappe.tests.make('Employee', [
+				{salutation: "Mr"},
+				{employee_name: "Test Employee 2"},
+				{company: "Test Company"},
+				{date_of_joining: frappe.datetime.add_months(today_date, -2)},	// joined 2 month from now
+				{date_of_birth: frappe.datetime.add_months(today_date, -240)},	// age is 20 years
+				{employment_type: "Test Employment type"},
+				{holiday_list: "Test Holiday list"},
+				{branch: "Test Branch"},
+				{department: "Test Department"},
+				{designation: "Test Designation"}
+			]);
+		},
+		() => frappe.set_route("Form", "Employee Attendance Tool"),
+		() => frappe.timeout(0.5),
+		() => assert.equal("Employee Attendance Tool", cur_frm.doctype,
+			"Form for Employee Attendance Tool opened successfully."),
+		// set values in form
+		() => cur_frm.set_value("date", date_of_attendance),
+		() => cur_frm.set_value("branch", "Test Branch"),
+		() => cur_frm.set_value("department", "Test Department"),
+		() => cur_frm.set_value("company", "Test Company"),
+		() => frappe.timeout(1),
+		() => frappe.click_button('Check all'),
+		() => frappe.click_button('Mark Present'),
+		// check if attendance is marked
+		() => frappe.set_route("List", "Attendance", "List"),
+		() => frappe.timeout(1),
+		() => {
+			assert.deepEqual(["Test Employee 2", "Test Employee 1"], [cur_list.data[0].employee_name, cur_list.data[1].employee_name],
+				"marked attendance correctly saved for both employee");
+			let marked_attendance = cur_list.data.filter(d => d.attendance_date == date_of_attendance);
+			assert.equal(marked_attendance.length, 2,
+				'both the attendance are marked for correct date');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.js b/erpnext/hr/doctype/employee_loan/employee_loan.js
index 9720bcb..33d3a85 100644
--- a/erpnext/hr/doctype/employee_loan/employee_loan.js
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.js
@@ -23,6 +23,14 @@
 			};
 		});
 
+		frm.set_query("employee", function() {
+			return {
+				"filters": {
+					"company": frm.doc.company,
+				}
+			};
+		});
+
 		$.each(["payment_account", "employee_loan_account"], function (i, field) {
 			frm.set_query(field, function () {
 				return {
diff --git a/erpnext/hr/doctype/employment_type/test_employment_type.js b/erpnext/hr/doctype/employment_type/test_employment_type.js
new file mode 100644
index 0000000..0ddd3e0
--- /dev/null
+++ b/erpnext/hr/doctype/employment_type/test_employment_type.js
@@ -0,0 +1,21 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Employment type [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test employment type creation
+		() => frappe.set_route("List", "Employment Type", "List"),
+		() => frappe.new_doc("Employment Type"),
+		() => frappe.timeout(1),
+		() => frappe.click_link('Edit in full page'),
+		() => cur_frm.set_value("employee_type_name", "Test Employment type"),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Employment type", cur_frm.doc.employee_type_name,
+			'name of employment type correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/holiday_list/test_holiday_list.js b/erpnext/hr/doctype/holiday_list/test_holiday_list.js
new file mode 100644
index 0000000..bfcafa9
--- /dev/null
+++ b/erpnext/hr/doctype/holiday_list/test_holiday_list.js
@@ -0,0 +1,42 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Holiday list [HR]", function (assert) {
+	assert.expect(3);
+	let done = assert.async();
+	let date = frappe.datetime.add_months(frappe.datetime.nowdate(), -2);		// date 2 months from now
+
+	frappe.run_serially([
+		// test holiday list creation
+		() => frappe.set_route("List", "Holiday List", "List"),
+		() => frappe.new_doc("Holiday List"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("holiday_list_name", "Test Holiday list"),
+		() => cur_frm.set_value("from_date", date),
+		() => cur_frm.set_value("weekly_off", "Sunday"),		// holiday list for sundays
+		() => frappe.click_button('Get Weekly Off Dates'),
+
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Holiday list", cur_frm.doc.holiday_list_name,
+			'name of holiday list correctly saved'),
+
+		// check if holiday list contains correct days
+		() => {
+			var list = cur_frm.doc.holidays;
+			var list_length = list.length;
+			var i = 0;
+			for ( ; i < list_length; i++)
+				if (list[i].description != 'Sunday') break;
+			assert.equal(list_length, i, "all holidays are sundays in holiday list");
+		},
+
+		// check if to_date is set one year from from_date
+		() => {
+			var date_year_later = frappe.datetime.add_days(frappe.datetime.add_months(date, 12), -1);		// date after one year
+			assert.equal(date_year_later, cur_frm.doc.to_date,
+				"to date set correctly");
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_allocation/test_leave_allocation.js b/erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
new file mode 100644
index 0000000..5d189d2
--- /dev/null
+++ b/erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
@@ -0,0 +1,37 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Leave allocation [HR]", function (assert) {
+	assert.expect(3);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+
+	frappe.run_serially([
+		// test creating leave alloction
+		() => frappe.set_route("List", "Leave Allocation", "List"),
+		() => frappe.new_doc("Leave Allocation"),
+		() => frappe.timeout(1),
+		() => frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name'),
+		(employee) => cur_frm.set_value("employee", employee.message.name),
+		() => cur_frm.set_value("leave_type", "Test Leave type"),
+		() => cur_frm.set_value("to_date", frappe.datetime.add_months(today_date, 2)),	// for two months
+		() => cur_frm.set_value("description", "This is just for testing"),
+		() => cur_frm.set_value("new_leaves_allocated", 2),
+		() => frappe.click_check('Add unused leaves from previous allocations'),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => cur_frm.savesubmit(),
+		() => frappe.timeout(1),
+		() => assert.equal("Confirm", cur_dialog.title,
+			'confirmation for leave alloction shown'),
+		() => frappe.click_button('Yes'),
+		() => frappe.timeout(1),
+		// check auto filled from date
+		() => assert.equal(today_date, cur_frm.doc.from_date,
+			"from date correctly set"),
+		// check for total leaves
+		() => assert.equal(cur_frm.doc.carry_forwarded_leaves + 2, cur_frm.doc.total_leaves_allocated,
+			"total leave calculation is correctly set"),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.js b/erpnext/hr/doctype/leave_application/test_leave_application.js
new file mode 100644
index 0000000..51e8ed6
--- /dev/null
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.js
@@ -0,0 +1,50 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Leave application [HR]", function (assert) {
+	assert.expect(5);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+	let leave_date = frappe.datetime.add_days(today_date, 1);	// leave for tomorrow
+
+	frappe.run_serially([
+		// test creating leave application
+		() => frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name'),
+		(employee) => {
+			return frappe.tests.make('Leave Application', [
+				{leave_type: "Test Leave type"},
+				{from_date: leave_date},	// for today
+				{to_date: leave_date},
+				{half_day: 1},
+				{employee: employee.message.name},
+				{leave_approver: "Administrator"},
+				{follow_via_email: 0}
+			]);
+		},
+		() => frappe.timeout(1),
+		// check calculated total leave days
+		() => assert.equal("0.5", cur_frm.doc.total_leave_days,
+			"leave application for half day"),
+		() => assert.ok(!cur_frm.doc.docstatus,
+			"leave application not submitted with status as open"),
+		() => cur_frm.set_value("status", "Approved"),	// approve the application [as administrator]
+		() => frappe.timeout(0.5),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => cur_frm.savesubmit(),
+		() => frappe.timeout(1),
+		() => frappe.click_button('Yes'),
+		() => frappe.timeout(1),
+		() => assert.ok(cur_frm.doc.docstatus,
+			"leave application submitted after approval"),
+		// check auto filled posting date [today]
+		() => assert.equal(today_date, cur_frm.doc.posting_date,
+			"posting date correctly set"),
+		() => frappe.set_route("List", "Leave Application", "List"),
+		() => frappe.timeout(1),
+		// check approved application in list
+		() => assert.deepEqual(["Test Employee 1", "Approved"], [cur_list.data[0].employee_name, cur_list.data[0].status],
+			"leave for correct employee is approved"),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_block_list/test_leave_block_list.js b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.js
new file mode 100644
index 0000000..1241d3d
--- /dev/null
+++ b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.js
@@ -0,0 +1,27 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Leave block list [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+
+	frappe.run_serially([
+		// test leave block list creation
+		() => frappe.set_route("List", "Leave Block List", "List"),
+		() => frappe.new_doc("Leave Block List"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("leave_block_list_name", "Test Leave block list"),
+		() => cur_frm.set_value("company", "Test Company"),
+		() => frappe.click_button('Add Row'),
+		() => {
+			cur_frm.fields_dict.leave_block_list_dates.grid.grid_rows[0].doc.block_date = today_date;
+			cur_frm.fields_dict.leave_block_list_dates.grid.grid_rows[0].doc.reason = "Blocked leave test";
+		},
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Leave block list", cur_frm.doc.leave_block_list_name,
+			'name of blocked leave list correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js b/erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js
new file mode 100644
index 0000000..e71ff6e
--- /dev/null
+++ b/erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js
@@ -0,0 +1,36 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Leave control panel [HR]", function (assert) {
+	assert.expect(2);
+	let done = assert.async();
+	let today_date = frappe.datetime.nowdate();
+
+	frappe.run_serially([
+		// test leave allocation using leave control panel
+		() => frappe.set_route("Form", "Leave Control Panel"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("leave_type", "Test Leave type"),
+		() => cur_frm.set_value("company", "Test Company"),
+		() => cur_frm.set_value("employment_type", "Test Employment Type"),
+		() => cur_frm.set_value("branch", "Test Branch"),
+		() => cur_frm.set_value("department", "Test Department"),
+		() => cur_frm.set_value("designation", "Test Designation"),
+		() => cur_frm.set_value("from_date", frappe.datetime.add_months(today_date, -2)),
+		() => cur_frm.set_value("to_date", frappe.datetime.add_days(today_date, -1)),	// for two months [not today]
+		() => cur_frm.set_value("no_of_days", 3),
+		// allocate leaves
+		() => frappe.click_button('Allocate'),
+		() => frappe.timeout(1),
+		() => assert.equal("Message", cur_dialog.title,
+			"leave alloction message shown"),
+		() => frappe.click_button('Close'),
+		() => frappe.set_route("List", "Leave Allocation", "List"),
+		() => frappe.timeout(1),
+		() => {
+			let leave_allocated = cur_list.data.filter(d => d.leave_type == "Test Leave type");
+			assert.equal(2, leave_allocated.length,
+				'leave allocation successfully done for both the employee');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_type/test_leave_type.js b/erpnext/hr/doctype/leave_type/test_leave_type.js
new file mode 100644
index 0000000..4cde49b
--- /dev/null
+++ b/erpnext/hr/doctype/leave_type/test_leave_type.js
@@ -0,0 +1,22 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Leave type [HR]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test leave type creation
+		() => frappe.set_route("List", "Leave Type", "List"),
+		() => frappe.new_doc("Leave Type"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("leave_type_name", "Test Leave type"),
+		() => cur_frm.set_value("max_days_allowed", "5"),
+		() => frappe.click_check('Is Carry Forward'),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Leave type", cur_frm.doc.leave_type_name,
+			'leave type correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py
index b58c787..287ce61 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.py
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.py
@@ -311,7 +311,7 @@
 				journal_entry.submit()
 				jv_name = journal_entry.name
 				self.update_salary_slip_status(jv_name = jv_name)
-			except Exception, e:
+			except Exception as e:
 				frappe.msgprint(e)
 		return jv_name
 
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
index fc1a8ae..78d5aee 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
@@ -121,7 +121,7 @@
 		try:
 			check_record(d)
 			ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
-		except Exception, e:
+		except Exception as e:
 			error = True
 			ret.append('Error for row (#%d) %s : %s' % (row_idx,
 				len(row)>1 and row[1] or "", cstr(e)))
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index ce895898..7130a3e 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -52,8 +52,8 @@
 		validate_uom_is_integer(self, "stock_uom", "stock_qty", "BOM Item")
 
 		self.update_stock_qty()
-		self.validate_materials()
 		self.set_bom_material_details()
+		self.validate_materials()
 		self.validate_operations()
 		self.calculate_cost()
 
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.js b/erpnext/manufacturing/doctype/bom/test_bom.js
new file mode 100644
index 0000000..80a4ede
--- /dev/null
+++ b/erpnext/manufacturing/doctype/bom/test_bom.js
@@ -0,0 +1,63 @@
+QUnit.test("test: item", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test item creation
+		() => frappe.set_route("List", "Item"),
+
+		// Create a BOM for a laptop
+		() => frappe.tests.make(
+			"BOM", [
+				{item: "Laptop"},
+				{quantity: 1},
+				{with_operations: 1},
+				{company: "Razer Blade"},
+				{operations: [
+					[
+						{operation: "Assemble CPU"},
+						{time_in_mins: 60},
+					],
+					[
+						{operation: "Assemble Keyboard"},
+						{time_in_mins: 30},
+					],
+					[
+						{operation: "Assemble Screen"},
+						{time_in_mins: 30},
+					]
+				]},
+				{scrap_items: [
+					[
+						{item_code: "Scrap item"}
+					]
+				]},
+				{items: [
+					[
+						{item_code: "CPU"},
+						{qty: 1}
+					],
+					[
+						{item_code: "Keyboard"},
+						{qty: 1}
+					],
+					[
+						{item_code: "Screen"},
+						{qty: 1}
+					]
+				]},
+			]
+		),
+		() => cur_frm.savesubmit(),
+		() => frappe.timeout(1),
+		() => frappe.click_button('Yes'),
+		() => frappe.timeout(1),
+
+		() => {
+			assert.ok(cur_frm.doc.operating_cost + cur_frm.doc.raw_material_cost -
+			cur_frm.doc.scrap_material_cost == cur_frm.doc.total_cost, 'Total_Cost calculated correctly');
+		},
+
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/operation/test_operation.js b/erpnext/manufacturing/doctype/operation/test_operation.js
new file mode 100644
index 0000000..9fedaac
--- /dev/null
+++ b/erpnext/manufacturing/doctype/operation/test_operation.js
@@ -0,0 +1,65 @@
+QUnit.test("test: operation", function (assert) {
+	assert.expect(2);
+	let done = assert.async();
+	let set_op_name = (text) => {
+		$(`input.input-with-feedback.form-control.bold:visible`).val(`${text}`);
+	};
+	let click_create = () => {
+		$(`.btn-primary:contains("Create"):visible`).click();
+	};
+
+	frappe.run_serially([
+		// test operation creation
+		() => frappe.set_route("List", "Operation"),
+
+		// Create a Keyboard operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "Keyboard assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble Keyboard"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+		() => {
+			assert.ok(cur_frm.docname.includes('Assemble Keyboard'),
+				'Assemble Keyboard created successfully');
+			assert.ok(cur_frm.doc.workstation.includes('Keyboard assembly workstation'),
+				'Keyboard assembly workstation was linked successfully');
+		},
+
+		// Create a Screen operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "Screen assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble Screen"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+
+		// Create a CPU operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "CPU assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble CPU"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.js b/erpnext/manufacturing/doctype/production_order/test_production_order.js
new file mode 100644
index 0000000..57299db
--- /dev/null
+++ b/erpnext/manufacturing/doctype/production_order/test_production_order.js
@@ -0,0 +1,41 @@
+QUnit.test("test: production order", function (assert) {
+	assert.expect(2);
+	let done = assert.async();
+	let laptop_quantity = 5;
+	let single_laptop_cost = 1340; // Calculated in workstation (time * per_hour_cost) for every item
+
+	frappe.run_serially([
+		// test production order
+		() => frappe.set_route("List", "Production Order"),
+		() => frappe.timeout(0.5),
+
+		// Create a laptop production order
+		() => frappe.new_doc("Production Order"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("production_item", "Laptop"),
+		() => frappe.timeout(2),
+		() => cur_frm.set_value("company", "Razer Blade"),
+		() => frappe.timeout(2),
+		() => cur_frm.set_value("qty", laptop_quantity),
+		() => frappe.timeout(2),
+		() => cur_frm.set_value("scrap_warehouse", "Laptop Scrap Warehouse - RB"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("wip_warehouse", "Work In Progress - RB"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("fg_warehouse", "Finished Goods - RB"),
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+
+		() => {
+			assert.equal(cur_frm.doc.planned_operating_cost, cur_frm.doc.total_operating_cost, "Total and Planned Cost is equal");
+			assert.equal(cur_frm.doc.planned_operating_cost, laptop_quantity*single_laptop_cost, "Total cost is calculated correctly "+cur_frm.doc.planned_operating_cost);
+		},
+
+		() => cur_frm.savesubmit(),
+		() => frappe.timeout(1),
+		() => frappe.click_button('Yes'),
+		() => frappe.timeout(1),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/test_production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/test_production_planning_tool.py
index 4f80b6a..af4220c 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/test_production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/test_production_planning_tool.py
@@ -15,7 +15,7 @@
 test_dependencies = ["Item","BOM"]
 
 class TestEvent(unittest.TestCase):
-	
+
 	def test_materials_requests_all_raw_multi_level(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
 			"_Test PPT Item Sub A","_Test PPT Item Sub B","_Test PPT Item Sub C","_Test PPT Item SC A",
@@ -23,10 +23,10 @@
 		quantities = [14,9,36,1,0,0,0,0,0,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=1, only_raw_materials=1, \
 			include_subcontracted=1)
-	
+
 	def test_materials_requests_multi_no_subcontracted(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
 			"_Test PPT Item Sub A","_Test PPT Item Sub B","_Test PPT Item Sub C","_Test PPT Item SC A",
@@ -34,12 +34,12 @@
 		quantities = [14,5,20,0,0,0,0,0,0,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		# This one should fail for now
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=1, only_raw_materials=1, \
 			include_subcontracted=0)
 
-		
+
 
 	def test_materials_requests_manufacture_and_sub_multi_level(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
@@ -48,10 +48,10 @@
 		quantities = [14,9,36,1,2,5,2,1,4,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=1, only_raw_materials=0, \
 			include_subcontracted=1)
-	
+
 	def test_materials_requests_manufacture_multi_level(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
 			"_Test PPT Item Sub A","_Test PPT Item Sub B","_Test PPT Item Sub C","_Test PPT Item SC A",
@@ -59,12 +59,12 @@
 		quantities = [14,5,20,0,2,5,2,1,4,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=1, only_raw_materials=0, \
 			include_subcontracted=0)
-	
-	
-	
+
+
+
 	def test_materials_requests_single_level_purch_only(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
 			"_Test PPT Item Sub A","_Test PPT Item Sub B","_Test PPT Item Sub C","_Test PPT Item SC A",
@@ -72,10 +72,10 @@
 		quantities = [2,0,0,0,0,0,0,1,0,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=0, only_raw_materials=1, \
 			include_subcontracted=0)
-	
+
 	def test_materials_requests_single_level(self):
 		items = ["_Test PPT Item Raw A","_Test PPT Item Raw B","_Test PPT Item Raw C","_Test PPT Item Raw D",
 			"_Test PPT Item Sub A","_Test PPT Item Sub B","_Test PPT Item Sub C","_Test PPT Item SC A",
@@ -83,32 +83,32 @@
 		quantities = [2,0,0,0,2,1,0,1,0,0]
 		types = ["Purchase","Purchase","Purchase","Purchase","Manufacture","Manufacture","Manufacture","Purchase",
 			"Purchase","Manufacture"]
-		
+
 		self.runtest_materials_requests(items, quantities, types, use_multi_level_bom=0, only_raw_materials=0, \
 			include_subcontracted=0)
-	
+
 	def runtest_materials_requests(self, items, quantities, types,use_multi_level_bom, only_raw_materials, \
 		include_subcontracted):
-		
+
 		clear_material_requests()
 		create_test_records()
-		
-		ppt = run_production_planning_tool(use_multi_level_bom=use_multi_level_bom, 
-			only_raw_materials=only_raw_materials, include_subcontracted=include_subcontracted, 
-			item_code = "_Test PPT Item Master", bom_no = "BOM-_Test PPT Item Master-001", 
-			planned_qty = 1, planned_start_date = "5/5/2029", 
+
+		ppt = run_production_planning_tool(use_multi_level_bom=use_multi_level_bom,
+			only_raw_materials=only_raw_materials, include_subcontracted=include_subcontracted,
+			item_code = "_Test PPT Item Master", bom_no = "BOM-_Test PPT Item Master-001",
+			planned_qty = 1, planned_start_date = "5/5/2029",
 			warehouse = "_Test Warehouse - _TC", company = "_Test Company")
-			
+
 		create_material_requests(ppt)
-		
+
 		for item, qty, type in zip(items, quantities, types):
 			self.assertEqual(qty, get_requested_qty(item))
 			for mat_req_type in get_requested_types(item):
-				self.assertEqual(type, mat_req_type) 
-				
+				self.assertEqual(type, mat_req_type)
+
 def create_test_records():
 	from erpnext.stock.doctype.item.test_item import make_item
-	
+
 	subA = make_item("_Test PPT Item Sub A",{
 		"item_code": "_Test PPT Item Sub A",
 		"item_name": "_Test PPT Item Sub A",
@@ -119,7 +119,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	subB = make_item("_Test PPT Item Sub B",{
 		"item_code": "_Test PPT Item Sub B",
 		"item_name": "_Test PPT Item Sub B",
@@ -130,7 +130,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	subC = make_item("_Test PPT Item Sub C",{
 		"item_code": "_Test PPT Item Sub C",
 		"item_name": "_Test PPT Item Sub C",
@@ -141,7 +141,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	sCA = make_item("_Test PPT Item SC A",{
 		"item_code": "_Test PPT Item SC A",
 		"item_name": "_Test PPT Item SC A",
@@ -172,7 +172,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	rawA = make_item("_Test PPT Item Raw A",{
 		"item_code": "_Test PPT Item Raw A",
 		"item_name": "_Test PPT Item Raw A",
@@ -183,7 +183,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	rawB = make_item("_Test PPT Item Raw B",{
 		"item_code": "_Test PPT Item Raw B",
 		"item_name": "_Test PPT Item Raw B",
@@ -194,7 +194,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	rawC = make_item("_Test PPT Item Raw C",{
 		"item_code": "_Test PPT Item Raw C",
 		"item_name": "_Test PPT Item Raw C",
@@ -205,7 +205,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	rawD = make_item("_Test PPT Item Raw D",{
 		"item_code": "_Test PPT Item Raw D",
 		"item_name": "_Test PPT Item Raw D",
@@ -216,7 +216,7 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
+
 	master = make_item("_Test PPT Item Master",{
 		"item_code": "_Test PPT Item Master",
 		"item_name": "_Test PPT Item Master",
@@ -227,9 +227,9 @@
 		"stock_uom": "_Test UOM",
 		"item_group": "_Test Item Group",
 		"default_warehouse": "_Test Warehouse - _TC"})
-		
-	
-	
+
+
+
 	bom_subB = make_bom("BOM-_Test PPT Item Sub B-001",{"quantity":1.0,
 		"item": "_Test PPT Item Sub B",
 		"is_active": 1,
@@ -239,39 +239,39 @@
 				"rate":100, "amount": 100, "stock_uom": "_Test UOM"},
 			{"item_code": "_Test PPT Item Raw C", "doctype":"BOM Item", "stock_qty":4, "rate":100,
 				"amount": 400,"stock_uom": "_Test UOM"}])
-	
+
 	bom_subC = make_bom("BOM-_Test PPT Item Sub C-001",{"quantity":1,
 		"item": "_Test PPT Item Sub C",
 		"is_active": 1,
 		"is_default": 1,
 		"docstatus": 1,
 		"with_operations": 0}, [
-			{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",   
+			{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",
 				"doctype":"BOM Item", "stock_qty":6, "rate":100, "amount": 600},
-			{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",   
+			{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",
 				"bom_no":"BOM-_Test PPT Item Sub B-001", "doctype":"BOM Item", "stock_qty":2,
 				"rate":100, "amount": 200}])
-		
+
 	bom_sCA = make_bom("BOM-_Test PPT Item SC A-001",{"quantity":1,
 		"item": "_Test PPT Item SC A",
 		"is_active": 1,
 		"is_default": 1,
 		"docstatus": 1,
 		"with_operations": 0}, [
-			{"item_code": "_Test PPT Item Raw D","item_name": "_Test PPT Item Raw D",  
+			{"item_code": "_Test PPT Item Raw D","item_name": "_Test PPT Item Raw D",
 				"doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100}])
-	
+
 	bom_sCB = make_bom("BOM-_Test PPT Item SC B-001",{"quantity":1,
 		"item": "_Test PPT Item SC B",
 		"is_active": 1,
 		"is_default": 1,
 		"docstatus": 1,
 		"with_operations": 0}, [
-			{"item_code": "_Test PPT Item Raw B","item_name": "_Test PPT Item Raw B", 
+			{"item_code": "_Test PPT Item Raw B","item_name": "_Test PPT Item Raw B",
 				"doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100},
-			{"item_code": "_Test PPT Item Raw C","item_name": "_Test PPT Item Raw C",   
+			{"item_code": "_Test PPT Item Raw C","item_name": "_Test PPT Item Raw C",
 				"doctype":"BOM Item", "stock_qty":4, "rate":100, "amount": 400}])
-	
+
 	bom_subA = make_bom("BOM-_Test PPT Item Sub A-001",{"quantity":1,
 		"item": "_Test PPT Item Sub A",
 		"is_active": 1,
@@ -279,29 +279,29 @@
 		"docstatus": 1,
 		"with_operations": 0}, [
 			{"item_code": "_Test PPT Item Sub C","item_name": "_Test PPT Item Sub C",
-				"bom_no":"BOM-_Test PPT Item Sub C-001", "doctype":"BOM Item",  
+				"bom_no":"BOM-_Test PPT Item Sub C-001", "doctype":"BOM Item",
 				"stock_qty":1, "rate":100, "amount": 100},
-			{"item_code": "_Test PPT Item SC B","item_name": "_Test PPT Item SC B",  
+			{"item_code": "_Test PPT Item SC B","item_name": "_Test PPT Item SC B",
 				"bom_no":"BOM-_Test PPT Item SC B-001", "doctype":"BOM Item", "stock_qty":2,
-				"rate":100, "amount": 200}])		
-				
+				"rate":100, "amount": 200}])
+
 	bom_master = make_bom("BOM-_Test PPT Item Master-001",{"quantity":1,
 		"item": "_Test PPT Item Master",
 		"is_active": 1,
 		"is_default": 1,
 		"docstatus": 1,
 		"with_operations": 0}, [
-			{"item_code": "_Test PPT Item Sub A","item_name": "_Test PPT Item Sub A",   
-				"bom_no":"BOM-_Test PPT Item Sub A-001", 
+			{"item_code": "_Test PPT Item Sub A","item_name": "_Test PPT Item Sub A",
+				"bom_no":"BOM-_Test PPT Item Sub A-001",
 				"doctype":"BOM Item", "stock_qty":2, "rate":100, "amount": 200},
-			{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",   
-				"bom_no":"BOM-_Test PPT Item Sub B-001", 
+			{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",
+				"bom_no":"BOM-_Test PPT Item Sub B-001",
 				"doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100},
-			{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",  
+			{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",
 				"doctype":"BOM Item", "stock_qty":2, "rate":100,
 				"amount": 200},
-			{"item_code": "_Test PPT Item SC A","item_name": "_Test PPT Item SC A",   
-				"bom_no":"BOM-_Test PPT Item SC A-001",  
+			{"item_code": "_Test PPT Item SC A","item_name": "_Test PPT Item SC A",
+				"bom_no":"BOM-_Test PPT Item SC A-001",
 				"doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100}
 			])
 
@@ -309,7 +309,7 @@
 def make_bom(name, properties=None, items=None):
 	if frappe.db.exists("BOM", name):
 		return frappe.get_doc("BOM", name)
-		
+
 	bom = frappe.new_doc("BOM")
 	item = frappe.get_doc({
 		"doctype": "BOM",
@@ -317,20 +317,20 @@
 		"quantity": "1",
 		"with_operations": 0
 	})
-	
+
 	if properties:
 		bom.update(properties)
-	
+
 	if items:
 		for item in items:
 			bom.append("items", item)
-	
+
 
 	bom.insert()
 	bom.submit()
-	
+
 	return bom
-	
+
 def clear_material_requests():
 	frappe.db.sql("delete from `tabMaterial Request Item`")
 	frappe.db.sql("delete from `tabMaterial Request`")
@@ -339,53 +339,50 @@
 def run_production_planning_tool(**args):
 	ppt = frappe.new_doc("Production Planning Tool")
 	args = frappe._dict(args)
-	
+
 	if args.use_multi_level_bom:
 		ppt.use_multi_level_bom = args.use_multi_level_bom
 	else:
 		ppt.use_multi_level_bom = 0
-		
+
 	if args.only_raw_materials:
 		ppt.only_raw_materials = args.only_raw_materials
 	else:
 		ppt.only_raw_materials = 0
-		
+
 	if args.include_subcontracted:
 		ppt.include_subcontracted = args.include_subcontracted
 	else:
 		ppt.include_subcontracted = 0
-		
+
 	if args.warehouse:
-		ppt.purchase_request_for_warehouse = args.warehouse 
-		
+		ppt.purchase_request_for_warehouse = args.warehouse
+
 	if args.company:
 		ppt.company = args.company
 	ppt.create_material_requests_for_all_required_qty = 1
-	
-	ppt.append("items",{"item_code": args.item_code, "bom_no": args.bom_no, "planned_qty": args.planned_qty, 
-		"planned_start_date": args.planned_start_date, "warehouse": args.warehouse})
-	
-	return ppt
 
-def create_production_orders(ppt):
-	raise_production_orders(ppt)
+	ppt.append("items",{"item_code": args.item_code, "bom_no": args.bom_no, "planned_qty": args.planned_qty,
+		"planned_start_date": args.planned_start_date, "warehouse": args.warehouse})
+
+	return ppt
 
 def create_material_requests(ppt):
 	ppt.raise_material_requests()
-	
+
 def get_requested_qty(item_code):
 	total_qty = 0
-	for d in frappe.db.sql("""select item.qty as qty 
-		from `tabMaterial Request` mat_req, `tabMaterial Request Item` item 
+	for d in frappe.db.sql("""select item.qty as qty
+		from `tabMaterial Request` mat_req, `tabMaterial Request Item` item
 		where item.item_code = %(item_code)s and item.parent = mat_req.name""", {"item_code":item_code}, as_dict=1):
 		total_qty += d.qty
 	return total_qty
 
 def get_requested_types(item_code):
 	types = []
-	for d in frappe.db.sql("""select mat_req.material_request_type as type 
-		from `tabMaterial Request` mat_req, `tabMaterial Request Item` item 
+	for d in frappe.db.sql("""select mat_req.material_request_type as type
+		from `tabMaterial Request` mat_req, `tabMaterial Request Item` item
 		where item.item_code = %(item_code)s and item.parent = mat_req.name""", {"item_code":item_code}, as_dict=1):
 		types.append(d.type)
 	return types
-	
+
diff --git a/erpnext/manufacturing/doctype/workstation/test_workstation.js b/erpnext/manufacturing/doctype/workstation/test_workstation.js
new file mode 100644
index 0000000..1df53d0
--- /dev/null
+++ b/erpnext/manufacturing/doctype/workstation/test_workstation.js
@@ -0,0 +1,89 @@
+QUnit.test("test: workstation", function (assert) {
+	assert.expect(9);
+	let done = assert.async();
+	let elec_rate = 50;
+	let rent = 100;
+	let consumable_rate = 20;
+	let labour_rate = 500;
+	frappe.run_serially([
+		// test workstation creation
+		() => frappe.set_route("List", "Workstation"),
+
+		// Create a keyboard workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "Keyboard assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+		() => {
+			assert.ok(cur_frm.doc.workstation_name.includes('Keyboard assembly workstation'),
+				'Keyboard assembly workstation created successfully');
+			assert.equal(cur_frm.doc.hour_rate_electricity, elec_rate,
+				'electricity rate set correctly');
+			assert.equal(cur_frm.doc.hour_rate_rent, rent,
+				'rent set correctly');
+			assert.equal(cur_frm.doc.hour_rate_consumable, consumable_rate,
+				'consumable rate set correctly');
+			assert.equal(cur_frm.doc.hour_rate_labour, labour_rate,
+				'labour rate set correctly');
+			assert.equal(cur_frm.doc.working_hours[0].enabled, 1,
+				'working hours enabled');
+			assert.ok(cur_frm.doc.working_hours[0].start_time.includes('11:00:0'),
+				'start time set correctly');
+			assert.ok(cur_frm.doc.working_hours[0].end_time.includes('18:00:0'),
+				'end time set correctly');
+			assert.ok(cur_frm.doc.hour_rate_electricity+cur_frm.doc.hour_rate_rent+
+				cur_frm.doc.hour_rate_consumable+cur_frm.doc.hour_rate_labour==
+				cur_frm.doc.hour_rate, 'Net hour rate set correctly');
+		},
+
+		// Create a Screen workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "Screen assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+
+		// Create a CPU workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "CPU assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2923d6d..3899bf6 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -422,7 +422,16 @@
 erpnext.patches.v8_3.set_restrict_to_domain_for_module_def
 erpnext.patches.v8_1.update_expense_claim_status
 erpnext.patches.v8_3.update_company_total_sales
+<<<<<<< HEAD
+erpnext.patches.v8_4.make_scorecard_records
+erpnext.patches.v8_1.set_delivery_date_in_so_item
+erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs
+erpnext.patches.v8_5.remove_quotations_route_in_sidebar
+erpnext.patches.v8_5.update_existing_data_in_project_type
+erpnext.patches.v8_5.set_default_mode_of_payment
+=======
 erpnext.patches.v8_1.set_delivery_date_in_so_item #2017-07-28
 erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs
 erpnext.patches.v8_5.update_customer_group_in_POS_profile
-erpnext.patches.v8_6.update_timesheet_company_from_PO
\ No newline at end of file
+erpnext.patches.v8_6.update_timesheet_company_from_PO
+>>>>>>> master
diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py
index 640fe6b..c21b605 100644
--- a/erpnext/patches/v4_0/apply_user_permissions.py
+++ b/erpnext/patches/v4_0/apply_user_permissions.py
@@ -12,8 +12,6 @@
 	frappe.clear_cache()
 
 def update_hr_permissions():
-	from frappe.core.page.user_permissions import user_permissions
-
 	# add set user permissions rights to HR Manager
 	frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application')
 		and role='HR Manager' and permlevel=0 and `read`=1""")
diff --git a/erpnext/patches/v4_0/rename_sitemap_to_route.py b/erpnext/patches/v4_0/rename_sitemap_to_route.py
index 257580b..ffb1fda 100644
--- a/erpnext/patches/v4_0/rename_sitemap_to_route.py
+++ b/erpnext/patches/v4_0/rename_sitemap_to_route.py
@@ -12,6 +12,6 @@
 		frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route")
 		frappe.model.rename_field("Sales Partner", "parent_website_sitemap",
 			 "parent_website_route")
-	except Exception, e:
+	except Exception as e:
 		if e.args[0]!=1054:
-			raise
\ No newline at end of file
+			raise
diff --git a/erpnext/patches/v4_2/add_currency_turkish_lira.py b/erpnext/patches/v4_2/add_currency_turkish_lira.py
index dac1fe9..1a46089 100644
--- a/erpnext/patches/v4_2/add_currency_turkish_lira.py
+++ b/erpnext/patches/v4_2/add_currency_turkish_lira.py
@@ -6,5 +6,5 @@
 
 def execute():
 	return
-	country = get_country_info(country="Turkey")
-	add_country_and_currency("Turkey", country)
+	# country = get_country_info(country="Turkey")
+	# add_country_and_currency("Turkey", country)
diff --git a/erpnext/patches/v4_2/default_website_style.py b/erpnext/patches/v4_2/default_website_style.py
index d168c86..e8f9502 100644
--- a/erpnext/patches/v4_2/default_website_style.py
+++ b/erpnext/patches/v4_2/default_website_style.py
@@ -3,9 +3,9 @@
 
 def execute():
 	return
-	frappe.reload_doc('website', 'doctype', 'style_settings')
-	style_settings = frappe.get_doc("Style Settings", "Style Settings")
-	if not style_settings.apply_style:
-		style_settings.update(default_properties)
-		style_settings.apply_style = 1
-		style_settings.save()
+	# frappe.reload_doc('website', 'doctype', 'style_settings')
+	# style_settings = frappe.get_doc("Style Settings", "Style Settings")
+	# if not style_settings.apply_style:
+	# 	style_settings.update(default_properties)
+	# 	style_settings.apply_style = 1
+	# 	style_settings.save()
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
index 126acfc..510fe3a 100644
--- a/erpnext/patches/v4_4/make_email_accounts.py
+++ b/erpnext/patches/v4_4/make_email_accounts.py
@@ -78,7 +78,7 @@
 def insert_or_update(account):
 	try:
 		account.insert()
-	except frappe.NameError, e:
+	except frappe.NameError as e:
 		if e.args[0]=="Email Account":
 			existing_account = frappe.get_doc("Email Account", e.args[1])
 			for key, value in account.as_dict().items():
diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
index 2b92b17..58da059 100644
--- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
+++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
@@ -34,7 +34,7 @@
 				voucher = frappe.get_doc(voucher_type, voucher_no)
 				voucher.make_gl_entries()
 				frappe.db.commit()
-			except Exception, e:
+			except Exception as e:
 				print frappe.get_traceback()
 				rejected.append([voucher_type, voucher_no])
 				frappe.db.rollback()
diff --git a/erpnext/patches/v7_0/update_party_status.py b/erpnext/patches/v7_0/update_party_status.py
index f3733db..9ca3d02 100644
--- a/erpnext/patches/v7_0/update_party_status.py
+++ b/erpnext/patches/v7_0/update_party_status.py
@@ -2,19 +2,19 @@
 
 def execute():
 	return
-	for party_type in ('Customer', 'Supplier'):
-		frappe.reload_doctype(party_type)
-
-		# set all as default status
-		frappe.db.sql('update `tab{0}` set status=%s'.format(party_type), default_status[party_type])
-
-		for doctype in status_depends_on[party_type]:
-			filters = get_filters_for(doctype)
-			parties = frappe.get_all(doctype, fields="{0} as party".format(party_type.lower()),
-				filters=filters, limit_page_length=1)
-
-			parties = filter(None, [p.party for p in parties])
-
-			if parties:
-				frappe.db.sql('update `tab{0}` set status="Open" where name in ({1})'.format(party_type,
-					', '.join(len(parties) * ['%s'])), parties)
\ No newline at end of file
+	# for party_type in ('Customer', 'Supplier'):
+	# 	frappe.reload_doctype(party_type)
+	#
+	# 	# set all as default status
+	# 	frappe.db.sql('update `tab{0}` set status=%s'.format(party_type), default_status[party_type])
+	#
+	# 	for doctype in status_depends_on[party_type]:
+	# 		filters = get_filters_for(doctype)
+	# 		parties = frappe.get_all(doctype, fields="{0} as party".format(party_type.lower()),
+	# 			filters=filters, limit_page_length=1)
+	#
+	# 		parties = filter(None, [p.party for p in parties])
+	#
+	# 		if parties:
+	# 			frappe.db.sql('update `tab{0}` set status="Open" where name in ({1})'.format(party_type,
+	# 				', '.join(len(parties) * ['%s'])), parties)
\ No newline at end of file
diff --git a/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py b/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py
index 3fc477e..4065438 100644
--- a/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py
+++ b/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py
@@ -19,6 +19,6 @@
 def rename_field_if_exists(doctype, old_fieldname, new_fieldname):
 	try:
 		rename_field(doctype, old_fieldname, new_fieldname)
-	except Exception, e:
+	except Exception as e:
 		if e.args[0] != 1054:
 			raise
diff --git a/erpnext/patches/v8_1/delete_deprecated_reports.py b/erpnext/patches/v8_1/delete_deprecated_reports.py
index 887277a..99d77c1 100644
--- a/erpnext/patches/v8_1/delete_deprecated_reports.py
+++ b/erpnext/patches/v8_1/delete_deprecated_reports.py
@@ -51,4 +51,4 @@
 		frappe.delete_doc("Auto Email Report", auto_email_report)
 
 	elif report in ["Customer Addresses And Contacts", "Supplier Addresses And Contacts"]:
-		frapppe.db.set_value("Auto Email Report", auto_email_report, "report", report)
\ No newline at end of file
+		frappe.db.set_value("Auto Email Report", auto_email_report, "report", report)
\ No newline at end of file
diff --git a/erpnext/patches/v8_4/__init__.py b/erpnext/patches/v8_4/__init__.py
new file mode 100644
index 0000000..baffc48
--- /dev/null
+++ b/erpnext/patches/v8_4/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/patches/v8_4/make_scorecard_records.py b/erpnext/patches/v8_4/make_scorecard_records.py
new file mode 100644
index 0000000..73afa27
--- /dev/null
+++ b/erpnext/patches/v8_4/make_scorecard_records.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+from erpnext.buying.doctype.supplier_scorecard.supplier_scorecard import make_default_records
+def execute():
+	frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_variable')
+	frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_standing')
+	make_default_records()
\ No newline at end of file
diff --git a/erpnext/patches/v8_5/remove_quotations_route_in_sidebar.py b/erpnext/patches/v8_5/remove_quotations_route_in_sidebar.py
new file mode 100644
index 0000000..2d7df4a
--- /dev/null
+++ b/erpnext/patches/v8_5/remove_quotations_route_in_sidebar.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doctype("Portal Settings")
+
+	frappe.db.sql("""
+		delete from
+			`tabPortal Menu Item`
+		where
+			(route = '/quotations' and title = 'Supplier Quotation')
+		or (route = '/quotation' and title = 'Quotations')
+	""")
\ No newline at end of file
diff --git a/erpnext/patches/v8_5/set_default_mode_of_payment.py b/erpnext/patches/v8_5/set_default_mode_of_payment.py
new file mode 100644
index 0000000..34ecbb0
--- /dev/null
+++ b/erpnext/patches/v8_5/set_default_mode_of_payment.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doctype("POS Profile")
+	frappe.reload_doctype("Sales Invoice Payment")
+
+	frappe.db.sql("""
+		update
+			`tabSales Invoice Payment`
+		set `tabSales Invoice Payment`.default = 1
+		where
+			`tabSales Invoice Payment`.parenttype = 'POS Profile'
+			and `tabSales Invoice Payment`.idx=1""")
\ No newline at end of file
diff --git a/erpnext/patches/v8_5/update_existing_data_in_project_type.py b/erpnext/patches/v8_5/update_existing_data_in_project_type.py
new file mode 100644
index 0000000..497da06
--- /dev/null
+++ b/erpnext/patches/v8_5/update_existing_data_in_project_type.py
@@ -0,0 +1,19 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doc("projects", "doctype", "project_type")
+	frappe.reload_doc("projects", "doctype", "project")
+
+	project_types = ["Internal", "External", "Other"]
+
+	for project_type in project_types:
+		if not frappe.db.exists("Project Type", project_type):
+			p_type = frappe.get_doc({
+				"doctype": "Project Type",
+				"project_type": project_type
+			})
+			p_type.insert()
\ No newline at end of file
diff --git a/erpnext/projects/doctype/activity_type/activity_type.json b/erpnext/projects/doctype/activity_type/activity_type.json
index 65a0fa1..dc50a09 100644
--- a/erpnext/projects/doctype/activity_type/activity_type.json
+++ b/erpnext/projects/doctype/activity_type/activity_type.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 1, 
  "allow_rename": 1, 
  "autoname": "field:activity_type", 
@@ -12,6 +13,7 @@
  "editable_grid": 0, 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -22,7 +24,8 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Activity Type", 
    "length": 0, 
@@ -39,6 +42,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -49,6 +53,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Default Costing Rate", 
@@ -67,6 +72,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -77,6 +83,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -94,6 +101,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -104,6 +112,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
+   "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Default Billing Rate", 
@@ -120,20 +129,51 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "fieldname": "disabled", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Disabled", 
+   "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
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "icon": "icon-flag", 
  "idx": 1, 
  "image_view": 0, 
  "in_create": 0, 
- "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-13 12:38:18.218618", 
+ "modified": "2017-07-25 20:11:05.229092", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Activity Type", 
@@ -149,11 +189,11 @@
    "export": 1, 
    "if_owner": 0, 
    "import": 1, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
+   "restrict": 0, 
    "role": "System Manager", 
    "set_user_permissions": 0, 
    "share": 1, 
@@ -175,6 +215,7 @@
    "print": 1, 
    "read": 1, 
    "report": 1, 
+   "restrict": 0, 
    "role": "Projects User", 
    "set_user_permissions": 0, 
    "share": 1, 
@@ -196,6 +237,7 @@
    "print": 0, 
    "read": 1, 
    "report": 0, 
+   "restrict": 0, 
    "role": "Employee", 
    "set_user_permissions": 0, 
    "share": 0, 
@@ -206,6 +248,8 @@
  "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
  "sort_order": "ASC", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/projects/doctype/activity_type/test_activity_type.js b/erpnext/projects/doctype/activity_type/test_activity_type.js
new file mode 100644
index 0000000..8023121
--- /dev/null
+++ b/erpnext/projects/doctype/activity_type/test_activity_type.js
@@ -0,0 +1,20 @@
+QUnit.test("test: Activity Type", function (assert) {
+	// number of asserts
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// insert a new Activity Type
+		() => frappe.set_route("List", "Activity Type", "List"),
+		() => frappe.new_doc("Activity Type"),
+		() => frappe.timeout(1),
+		() => frappe.click_link('Edit in full page'),
+		() => cur_frm.set_value("activity_type", "Test Activity"),
+		() => frappe.click_button('Save'),
+		() => frappe.timeout(1),
+		() => {
+			assert.equal(cur_frm.doc.name,"Test Activity");
+		},
+		() => done()
+	]);
+});
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index 28eb730..101e4ff 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -84,7 +84,7 @@
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "project_type", 
-   "fieldtype": "Select", 
+   "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -97,7 +97,7 @@
    "no_copy": 0, 
    "oldfieldname": "project_type", 
    "oldfieldtype": "Data", 
-   "options": "Internal\nExternal\nOther", 
+   "options": "Project Type", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1255,7 +1255,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 4, 
- "modified": "2017-07-19 14:36:20.857673", 
+ "modified": "2017-07-26 14:36:20.857673", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Project", 
diff --git a/erpnext/projects/doctype/project/project_timesheet.js b/erpnext/projects/doctype/project/project_timesheet.js
new file mode 100644
index 0000000..32df04f
--- /dev/null
+++ b/erpnext/projects/doctype/project/project_timesheet.js
@@ -0,0 +1,91 @@
+
+QUnit.test("test project", function(assert) {
+	assert.expect(6);
+	let done = assert.async();
+	var task_title = ["Documentation","Implementation","Testing"];
+
+	// To create a timesheet with different tasks and costs
+	let timesheet = (title,start_time,end_time,bill_rate,cost_rate) => {
+		return frappe.run_serially([
+			() => frappe.db.get_value('Task', {'subject': title}, 'name'),
+			(task) => {
+				// Creating timesheet for a project
+				return frappe.tests.make('Timesheet', [
+					{time_logs:[
+						[
+							{activity_type: 'Communication'},
+							{from_time: start_time},
+							{to_time: end_time},
+							{hours: 2},
+							{project: 'Test App'},
+							{task: task.name},
+							{billable: '1'},
+							{billing_rate: bill_rate},
+							{costing_rate: cost_rate}
+						]
+					]}
+				]);
+			},
+			// To check if a correct billable and costing amount is calculated for every task
+			() => {
+				if(title=== 'Documentation')
+				{
+					assert.ok(cur_frm.get_field('total_billable_amount').get_value()==20,
+						'Billable amount for Documentation task is correctly calculated');
+					assert.ok(cur_frm.get_field('total_costing_amount').get_value()==16,
+						'Costing amount for Documentation task is correctly calculated');
+				}
+				if(title=== 'Implementation')
+				{
+					assert.ok(cur_frm.get_field('total_billable_amount').get_value()==40,
+						'Billable amount for Implementation task is correctly calculated');
+					assert.ok(cur_frm.get_field('total_costing_amount').get_value()==32,
+						'Costing amount for Implementation task is correctly calculated');
+				}
+				if(title=== 'Testing')
+				{
+					assert.ok(cur_frm.get_field('total_billable_amount').get_value()==60,
+						'Billable amount for Testing task correctly calculated');
+					assert.ok(cur_frm.get_field('total_costing_amount').get_value()==50,
+						'Costing amount for Testing task is correctly calculated');
+				}
+			},
+		]);
+	};
+	frappe.run_serially([
+		() => {
+			// Creating project with task
+			return frappe.tests.make('Project', [
+				{ project_name: 'Test App'},
+				{ expected_start_date: '2017-07-22'},
+				{ expected_end_date: '2017-09-22'},
+				{ estimated_costing: '10,000.00'},
+				{ tasks:[
+					[
+						{title: 'Documentation'},
+						{start_date: '2017-07-24'},
+						{end_date: '2017-07-31'},
+						{description: 'To make a proper documentation defining requirements etc'}
+					],
+					[
+						{title: 'Implementation'},
+						{start_date: '2017-08-01'},
+						{end_date: '2017-08-01'},
+						{description: 'Writing algorithms and to code the functionalities'}
+					],
+					[
+						{title: 'Testing'},
+						{start_date: '2017-08-01'},
+						{end_date: '2017-08-15'},
+						{description: 'To make the test cases and test the functionalities'}
+					]
+				]}
+			]);
+		},
+		// Creating Timesheet with different tasks
+		() => timesheet(task_title[0],'2017-07-24 13:00:00','2017-07-24 13:00:00',10,8),
+		() => timesheet(task_title[1],'2017-07-25 13:00:00','2017-07-25 15:00:00',20,16),
+		() => timesheet(task_title[2],'2017-07-26 13:00:00','2017-07-26 15:00:00',30,25),
+		() => done()
+	]);
+});
diff --git a/erpnext/projects/doctype/project_type/__init__.py b/erpnext/projects/doctype/project_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/__init__.py
diff --git a/erpnext/projects/doctype/project_type/project_type.js b/erpnext/projects/doctype/project_type/project_type.js
new file mode 100644
index 0000000..a1f941f
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/project_type.js
@@ -0,0 +1,6 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Project Type', {
+
+});
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project_type/project_type.json b/erpnext/projects/doctype/project_type/project_type.json
new file mode 100644
index 0000000..b9a5b54
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/project_type.json
@@ -0,0 +1,163 @@
+{
+ "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
+ "allow_import": 0, 
+ "allow_rename": 1, 
+ "autoname": "field:project_type", 
+ "beta": 0, 
+ "creation": "2017-07-18 13:32:46.031115", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "project_type", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Project Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Description", 
+   "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
+  }
+ ], 
+ "has_web_view": 0, 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-07-26 17:19:30.126346", 
+ "modified_by": "Administrator", 
+ "module": "Projects", 
+ "name": "Project Type", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Projects Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 0, 
+   "delete": 0, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Projects User", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 0
+  }
+ ], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "show_name_in_global_search": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project_type/project_type.py b/erpnext/projects/doctype/project_type/project_type.py
new file mode 100644
index 0000000..f46876e
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/project_type.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+import frappe
+from frappe import _
+
+class ProjectType(Document):
+	def on_trash(self):
+		if self.name == "External":
+			frappe.throw(_("You cannot delete Project Type 'External'"))
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project_type/test_project_type.js b/erpnext/projects/doctype/project_type/test_project_type.js
new file mode 100644
index 0000000..c2198c4
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/test_project_type.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Project Type", function (assert) {
+	let done = assert.async();
+
+	// number of asserts
+	assert.expect(1);
+
+	frappe.run_serially('Project Type', [
+		// insert a new Project Type
+		() => frappe.tests.make([
+			// values to be set
+			{key: 'value'}
+		]),
+		() => {
+			assert.equal(cur_frm.doc.key, 'value');
+		},
+		() => done()
+	]);
+
+});
diff --git a/erpnext/projects/doctype/project_type/test_project_type.py b/erpnext/projects/doctype/project_type/test_project_type.py
new file mode 100644
index 0000000..ee23390
--- /dev/null
+++ b/erpnext/projects/doctype/project_type/test_project_type.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import unittest
+
+class TestProjectType(unittest.TestCase):
+	pass
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index bb3d902..6e7042e 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -174,6 +174,7 @@
 		for data in self.get('time_logs'):
 			self.check_workstation_timings(data)
 			self.validate_overlap(data)
+			validate_activity(data)
 
 	def validate_overlap(self, data):
 		if self.production_order:
@@ -279,7 +280,6 @@
 			ts_detail.billing_rate = 0.0
 			ts_detail.costing_rate = 0.0
 
-
 @frappe.whitelist()
 def get_projectwise_timesheet_data(project, parent=None):
 	cond = ''
@@ -391,3 +391,26 @@
 			"end": end
 		}, as_dict=True, update={"allDay": 0})
 
+def get_timesheets_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"):
+	user = frappe.session.user
+	# find customer name from contact.
+	customer = frappe.db.sql('''SELECT dl.link_name FROM `tabContact` AS c inner join \
+		`tabDynamic Link` AS dl ON c.first_name=dl.link_name WHERE c.email_id=%s''',user)
+	# find list of Sales Invoice for made for customer.
+	sales_invoice = frappe.db.sql('''SELECT name FROM `tabSales Invoice` WHERE customer = %s''',customer)
+	if customer:
+		# Return timesheet related data to web portal.
+		return frappe. db.sql('''SELECT ts.name, tsd.activity_type, ts.status, ts.total_billable_hours, \
+			tsd.sales_invoice, tsd.project  FROM `tabTimesheet` AS ts inner join `tabTimesheet Detail` \
+			AS tsd ON tsd.parent = ts.name where tsd.sales_invoice IN %s order by\
+			end_date asc limit {0} , {1}'''.format(limit_start, limit_page_length), [sales_invoice], as_dict = True)
+
+def get_list_context(context=None):
+	return {
+		"show_sidebar": True,
+		"show_search": True,
+		'no_breadcrumbs': True,
+		"title": _("Timesheets"),
+		"get_list": get_timesheets_list,
+		"row_template": "templates/includes/timesheet/timesheet_row.html"
+	}
diff --git a/erpnext/public/css/email.css b/erpnext/public/css/email.css
new file mode 100644
index 0000000..8cf1a31
--- /dev/null
+++ b/erpnext/public/css/email.css
@@ -0,0 +1,29 @@
+.panel-header {
+  background-color: #fafbfc;
+  border: 1px solid #d1d8dd;
+  border-radius: 3px 3px 0 0;
+}
+.panel-body {
+  background-color: #fff;
+  border: 1px solid #d1d8dd;
+  border-top: none;
+  border-radius: 0 0 3px 3px;
+  overflow-wrap: break-word;
+}
+.sender-avatar {
+  width: 24px;
+  height: 24px;
+  border-radius: 3px;
+  vertical-align: middle;
+}
+.sender-avatar-placeholder {
+  width: 24px;
+  height: 24px;
+  border-radius: 3px;
+  vertical-align: middle;
+  line-height: 24px;
+  text-align: center;
+  color: #d1d8dd;
+  border: 1px solid #d1d8dd;
+  background-color: #fff;
+}
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index a54f30d..83644db 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -584,7 +584,7 @@
 		var payment_status = true;
 		if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){
 			$.each(this.frm.doc['payments'] || [], function(index, data){
-				if(data.type == "Cash" && payment_status && total_amount_to_pay > 0) {
+				if(data.default && payment_status && total_amount_to_pay > 0) {
 					data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
 					data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
 					payment_status = false;
diff --git a/erpnext/public/js/help_links.js b/erpnext/public/js/help_links.js
index 6ac60c2..7de87b7 100644
--- a/erpnext/public/js/help_links.js
+++ b/erpnext/public/js/help_links.js
@@ -14,7 +14,7 @@
 frappe.help.help_links['permission-manager'] = [
 	{ label: 'Role Permissions Manager', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/users-and-permissions/role-based-permissions' },
 	{ label: 'Managing Perm Level in Permissions Manager', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/articles/managing-perm-level' },
-	{ label: 'User Permissions Manager', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/users-and-permissions/user-permissions' },
+	{ label: 'User Permissions', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/users-and-permissions/user-permissions' },
 	{ label: 'Sharing', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/users-and-permissions/sharing' },
 	{ label: 'Password', url: 'https://frappe.github.io/erpnext/user/manual/en/setting-up/articles/change-password' },
 ]
diff --git a/erpnext/public/js/pos/pos_selected_item.html b/erpnext/public/js/pos/pos_selected_item.html
index 0ed6c71..6f2772b 100644
--- a/erpnext/public/js/pos/pos_selected_item.html
+++ b/erpnext/public/js/pos/pos_selected_item.html
@@ -17,6 +17,6 @@
 	</div> 
 	<div class="pos-list-row">
 		<div class="cell">{{ __("Amount") }}:</div>
-		<input type="tel" class="form-control cell pos-amount" value="{%= amount %}"/>
+		<input type="tel" class="form-control cell pos-amount" disabled value="{%= amount %}"/>
 	</div>
 </div>
\ No newline at end of file
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index 29ef12c..d551885 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -46,13 +46,15 @@
 				fieldtype: "Attach Image", fieldname: "attach_logo",
 				label: __("Attach Logo"),
 				description: __("100px by 100px"),
-				is_private: 0
+				is_private: 0,
+				align: 'center'
 			},
 			{
 				fieldname: 'company_name',
 				label: frappe.setup.domain === 'Education' ?
 					__('Institute Name') : __('Company Name'),
-				fieldtype: 'Data', reqd: 1
+				fieldtype: 'Data',
+				reqd: 1
 			},
 			{
 				fieldname: 'company_abbr',
@@ -422,15 +424,6 @@
 
 frappe.setup.on("before_load", function () {
 	erpnext_slides.map(frappe.setup.add_slide);
-
-	// change header brand
-	let $brand = $('header .setup-wizard-brand');
-	if($brand.find('.erpnext-icon').length === 0) {
-		$brand.find('.frappe-icon').hide();
-		$brand.append(`<span>
-			<img src="/assets/erpnext/images/erp-icon.svg" class="brand-icon erpnext-icon"
-			style="width:36px;"><span class="brand-name">ERPNext</span></span>`);
-	}
 });
 
 var test_values_edu = {
diff --git a/erpnext/public/less/email.less b/erpnext/public/less/email.less
new file mode 100644
index 0000000..4077c49
--- /dev/null
+++ b/erpnext/public/less/email.less
@@ -0,0 +1,32 @@
+@import "../../../../frappe/frappe/public/less/variables.less";
+
+.panel-header {
+	background-color: @light-bg;
+	border: 1px solid @border-color;
+	border-radius: 3px 3px 0 0;
+}
+
+.panel-body {
+	background-color: #fff;
+	border: 1px solid @border-color;
+	border-top: none;
+	border-radius: 0 0 3px 3px;
+	overflow-wrap: break-word;
+}
+
+.sender-avatar {
+	width: 24px;
+	height: 24px;
+	border-radius: 3px;
+	vertical-align: middle;
+}
+
+.sender-avatar-placeholder {
+	.sender-avatar;
+
+	line-height: 24px;
+	text-align: center;
+	color: @border-color;
+	border: 1px solid @border-color;
+	background-color: #fff;
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/academic_term/test_academic_term.js b/erpnext/schools/doctype/academic_term/test_academic_term.js
new file mode 100644
index 0000000..688ad54
--- /dev/null
+++ b/erpnext/schools/doctype/academic_term/test_academic_term.js
@@ -0,0 +1,24 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Academic Term', function(assert){
+	assert.expect(4);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Academic Term', [
+				{academic_year: '2016-17'},
+				{term_name: "Semester 1"},
+				{term_start_date: '2016-07-20'},
+				{term_end_date:'2017-06-20'},
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.academic_year=='2016-17');
+			assert.ok(cur_frm.doc.term_name=='Semester 1');
+			assert.ok(cur_frm.doc.term_start_date=='2016-07-20');
+			assert.ok(cur_frm.doc.term_end_date=='2017-06-20');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/academic_year/test_academic_year.js b/erpnext/schools/doctype/academic_year/test_academic_year.js
new file mode 100644
index 0000000..7bf1772
--- /dev/null
+++ b/erpnext/schools/doctype/academic_year/test_academic_year.js
@@ -0,0 +1,23 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Academic Year', function(assert){
+	assert.expect(3);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Academic Year', [
+				{academic_year_name: '2016-17'},
+				{year_start_date: '2016-07-20'},
+				{year_end_date:'2017-06-20'},
+			]);
+		},
+
+		() => {
+			assert.ok(cur_frm.doc.academic_year_name=='2016-17');
+			assert.ok(cur_frm.doc.year_start_date=='2016-07-20');
+			assert.ok(cur_frm.doc.year_end_date=='2017-06-20');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js b/erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js
new file mode 100644
index 0000000..6c0540e
--- /dev/null
+++ b/erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js
@@ -0,0 +1,16 @@
+// School Assessment module
+QUnit.module('schools');
+
+QUnit.test('Test: Assessment Criteria', function(assert){
+	assert.expect(0);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Assessment Criteria', [
+				{assessment_criteria: 'Pass'},
+				{assessment_criteria_group: 'Reservation'}
+			]);
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js b/erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js
new file mode 100644
index 0000000..92dba1d
--- /dev/null
+++ b/erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js
@@ -0,0 +1,15 @@
+// School Assessment module
+QUnit.module('schools');
+
+QUnit.test('Test: Assessment Criteria Group', function(assert){
+	assert.expect(0);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Assessment Criteria Group', [
+				{assessment_criteria_group: 'Reservation'}
+			]);
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/course/test_course.js b/erpnext/schools/doctype/course/test_course.js
new file mode 100644
index 0000000..4866730
--- /dev/null
+++ b/erpnext/schools/doctype/course/test_course.js
@@ -0,0 +1,36 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('test course', function(assert) {
+	assert.expect(8);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Course', [
+				{course_name: 'Test_Subject'},
+				{course_code: 'Test_Sub'},
+				{department: 'Test Department'},
+				{course_abbreviation: 'Test_Sub'},
+				{course_intro: 'Test Subject Intro'},
+				{default_grading_scale: 'GTU'},
+				{assessment_criteria: [
+					[
+						{assessment_criteria: 'Pass'},
+						{weightage: 100}
+					]
+				]}
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.course_name == 'Test_Subject', 'Course name correctly set');
+			assert.ok(cur_frm.doc.course_code == 'Test_Sub', 'Course code correctly set');
+			assert.ok(cur_frm.doc.department == 'Test Department', 'Department selected correctly');
+			assert.ok(cur_frm.doc.course_abbreviation == 'Test_Sub');
+			assert.ok(cur_frm.doc.course_intro == 'Test Subject Intro');
+			assert.ok(cur_frm.doc.default_grading_scale == 'GTU', 'Grading scale selected correctly');
+			assert.ok(cur_frm.doc.assessment_criteria[0].assessment_criteria == 'Pass', 'Assessment criteria selected correctly');
+			assert.ok(cur_frm.doc.assessment_criteria[0].weightage == '100');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/grading_scale/test_grading_scale.js b/erpnext/schools/doctype/grading_scale/test_grading_scale.js
new file mode 100644
index 0000000..6539343
--- /dev/null
+++ b/erpnext/schools/doctype/grading_scale/test_grading_scale.js
@@ -0,0 +1,28 @@
+// School Assessment module
+QUnit.module('schools');
+
+QUnit.test('Test: Grading Scale', function(assert){
+	assert.expect(0);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Grading Scale', [
+				{grading_scale_name: 'GTU'},
+				{description: 'The score will be set according to 10 based system.'},
+				{intervals: [
+					[
+						{grade_code: 'AA'},
+						{threshold: '90'},
+						{grade_description: 'Distinction'}
+					],
+					[
+						{grade_code: 'FF'},
+						{threshold: '0'},
+						{grade_description: 'Fail'}
+					]
+				]}
+			]);
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/instructor/test_instructor.js b/erpnext/schools/doctype/instructor/test_instructor.js
new file mode 100644
index 0000000..a9e2561
--- /dev/null
+++ b/erpnext/schools/doctype/instructor/test_instructor.js
@@ -0,0 +1,20 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Instructor', function(assert){
+	assert.expect(2);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make("Instructor", [
+				{instructor_name: 'Instructor 1'},
+				{department: 'Test Department'}
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.instructor_name == 'Instructor 1');
+			assert.ok(cur_frm.doc.department = 'Test Department');
+		},
+		() => done()
+	]);
+});
diff --git a/erpnext/schools/doctype/program/test_program.js b/erpnext/schools/doctype/program/test_program.js
new file mode 100644
index 0000000..16bc932
--- /dev/null
+++ b/erpnext/schools/doctype/program/test_program.js
@@ -0,0 +1,78 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Program', function(assert){
+	assert.expect(11);
+	let done = assert.async();
+	let fee_structure_code;
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Program', [
+				{program_name: 'Standard Test'},
+				{program_code: 'Standard Test'},
+				{department: 'Test Department'},
+				{program_abbreviation: 'Standard Test'},
+				{courses: [
+					[
+						{course: 'Test_Sub'},
+						{required: true}
+					]
+				]}
+			]);
+		},
+
+		() => cur_frm.save(),
+		// Setting up Fee Category to select in Program doctype
+		() => {
+			return frappe.tests.make('Fee Category', [
+				{category_name: 'Reservation'},
+				{description: 'Special Provision'}
+			]);
+		},
+		// Setting up Fee Structure to be selected in Program doctype
+		() => {
+			return frappe.tests.make('Fee Structure', [
+				{program: 'Standard Test'},
+				{academic_term: '2016-17 (Semester 1)'},
+				{student_category: 'Reservation'},
+				{components: [
+					[
+						{fees_category: 'Reservation'},
+						{amount: 20000}
+					]
+				]}
+			]);
+		},
+		() => {fee_structure_code = frappe.get_route()[2];}, // Storing naming convention of Fee Structure entry
+		() => frappe.set_route('Form', ('Program/Standard Test')), // Routing to our current Program doctype
+
+		() => $('.shaded-section~ .visible-section+ .visible-section .grid-add-row').trigger('click'), // clicking on Add Row button
+		// Storing data that were inter-dependent
+		() => cur_frm.doc.fees[0].academic_term = '2016-17 (Semester 1)',
+		() => cur_frm.doc.fees[0].student_category = 'Reservation',
+		() => cur_frm.doc.fees[0].due_date = '2016-08-20',
+		() => $('.error').trigger('click'),
+		() => $('.bold.input-sm').trigger('focus'),
+		() => frappe.timeout(1),
+		() => $('.bold.input-sm').trigger('focus'),
+		() => $('.bold.input-sm').val(fee_structure_code),
+		() => $('.bold.input-sm').trigger('focus'),
+		() => frappe.timeout(1),
+		() => cur_frm.save(),
+
+		() => {
+			assert.ok(cur_frm.doc.program_name == 'Standard Test');
+			assert.ok(cur_frm.doc.program_code == 'Standard Test');
+			assert.ok(cur_frm.doc.department == 'Test Department');
+			assert.ok(cur_frm.doc.program_abbreviation == 'Standard Test');
+			assert.ok(cur_frm.doc.courses[0].course == 'Test_Sub');
+			assert.ok(cur_frm.doc.courses[0].required == true);
+			assert.ok(cur_frm.doc.fees[0].academic_term == '2016-17 (Semester 1)');
+			assert.ok(cur_frm.doc.fees[0].fee_structure == fee_structure_code);
+			assert.ok(cur_frm.doc.fees[0].student_category == 'Reservation');
+			assert.ok(cur_frm.doc.fees[0].due_date == '2016-08-20');
+			assert.ok(cur_frm.doc.fees[0].amount == 20000);
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/room/test_room.js b/erpnext/schools/doctype/room/test_room.js
new file mode 100644
index 0000000..0a93a85
--- /dev/null
+++ b/erpnext/schools/doctype/room/test_room.js
@@ -0,0 +1,22 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Room', function(assert){
+	assert.expect(3);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Room', [
+				{room_name: 'Room 1'},
+				{room_number: '1'},
+				{seating_capacity: '60'},
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.room_name == 'Room 1');
+			assert.ok(cur_frm.doc.room_number = '1');
+			assert.ok(cur_frm.doc.seating_capacity = '60');
+		},
+		() => done()
+	]);
+});
diff --git a/erpnext/schools/doctype/school_settings/test_school_settings.js b/erpnext/schools/doctype/school_settings/test_school_settings.js
new file mode 100644
index 0000000..6414056
--- /dev/null
+++ b/erpnext/schools/doctype/school_settings/test_school_settings.js
@@ -0,0 +1,25 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test("Test: School Settings", function(assert){
+	assert.expect(3);
+	let done = assert.async();
+	frappe.run_serially([
+		() => frappe.set_route("List", "School Settings"),
+		() => frappe.timeout(0.4),
+		() => {
+			return frappe.tests.set_form_values(cur_frm, [
+				{current_academic_year: '2016-17'},
+				{current_academic_term: '2016-17 (Semester 1)'},
+				{attendance_freeze_date: '2016-07-20'}
+			]);
+		},
+		() => {
+			cur_frm.save();
+			assert.ok(cur_frm.doc.current_academic_year=="2016-17");
+			assert.ok(cur_frm.doc.current_academic_term=="2016-17 (Semester 1)");
+			assert.ok(cur_frm.doc.attendance_freeze_date=="2016-07-20");
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_batch_name/test_student_batch_name.js b/erpnext/schools/doctype/student_batch_name/test_student_batch_name.js
new file mode 100644
index 0000000..6a10dc1
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch_name/test_student_batch_name.js
@@ -0,0 +1,19 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Batch Name', function(assert){
+	assert.expect(1);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Student Batch Name', [
+				{batch_name: 'A'}
+			]);
+		},
+		() => cur_frm.save(),
+		() => {
+			assert.ok(cur_frm.doc.batch_name=='A');
+		},
+		() => done()
+	]);
+});
diff --git a/erpnext/schools/doctype/student_category/test_student_category.js b/erpnext/schools/doctype/student_category/test_student_category.js
new file mode 100644
index 0000000..5e3109a
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/test_student_category.js
@@ -0,0 +1,19 @@
+// Testing Setup Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Category', function(assert){
+	assert.expect(1);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Student Category', [
+				{category: 'Reservation'}
+			]);
+		},
+		() => cur_frm.save(),
+		() => {
+			assert.ok(cur_frm.doc.name=='Reservation');
+		},
+		() => done()
+	]);
+});
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index 1b77418..52c6b6d 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -81,6 +81,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:doc.customer_type!='Company'", 
    "fieldname": "salutation", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -143,6 +144,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:doc.customer_type != 'Company'", 
    "fieldname": "gender", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1200,7 +1202,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-06-28 14:55:39.910819", 
+ "modified": "2017-07-24 00:55:07.445783", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Customer", 
diff --git a/erpnext/selling/doctype/product_bundle/test_product_bundle.js b/erpnext/selling/doctype/product_bundle/test_product_bundle.js
new file mode 100644
index 0000000..ba5ba0d
--- /dev/null
+++ b/erpnext/selling/doctype/product_bundle/test_product_bundle.js
@@ -0,0 +1,36 @@
+QUnit.test("test sales order", function(assert) {
+	assert.expect(4);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Product Bundle', [
+				{new_item_code: 'Computer'},
+				{items: [
+					[
+						{item_code:'CPU'},
+						{qty:1}
+					],
+					[
+						{item_code:'Screen'},
+						{qty:1}
+					],
+					[
+						{item_code:'Keyboard'},
+						{qty:1}
+					]
+				]},
+			]);
+		},
+		() => cur_frm.save(),
+		() => {
+			// get_item_details
+			assert.ok(cur_frm.doc.items[0].item_code=='CPU', "Item Code correct");
+			assert.ok(cur_frm.doc.items[1].item_code=='Screen', "Item Code correct");
+			assert.ok(cur_frm.doc.items[2].item_code=='Keyboard', "Item Code correct");
+			assert.ok(cur_frm.doc.new_item_code == "Computer", "Parent Item correct");
+		},
+		() => frappe.timeout(0.3),
+		() => done()
+	]);
+});
+
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 43fa20f..b90f725 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -27,9 +27,19 @@
 
 		var me = this;
 
+		if (doc.valid_till && frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) < 0) {
+			this.frm.set_intro(__("Validity period of this quotation has ended"));
+		}
+
+		if (doc.__islocal) {
+			this.frm.set_value('valid_till', frappe.datetime.add_months(doc.transaction_date, 1))
+		}
+
 		if(doc.docstatus == 1 && doc.status!=='Lost') {
-			cur_frm.add_custom_button(__('Make Sales Order'),
-				cur_frm.cscript['Make Sales Order']);
+			if(!doc.valid_till || frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) > 0) {
+				cur_frm.add_custom_button(__('Make Sales Order'),
+					cur_frm.cscript['Make Sales Order']);
+			}
 
 			if(doc.status!=="Ordered") {
 				cur_frm.add_custom_button(__('Set as Lost'),
diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json
index 2109023..33eed19 100644
--- a/erpnext/selling/doctype/quotation/quotation.json
+++ b/erpnext/selling/doctype/quotation/quotation.json
@@ -369,6 +369,36 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "valid_till", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_global_search": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Valid Till", 
+   "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, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "default": "Sales", 
    "fieldname": "order_type", 
    "fieldtype": "Select", 
@@ -2572,7 +2602,7 @@
  "istable": 0, 
  "max_attachments": 1, 
  "menu_index": 0, 
- "modified": "2017-07-19 13:49:33.388736", 
+ "modified": "2017-07-25 08:14:35.355019", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Quotation", 
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 420b84a..5eb8b06 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.mapper import get_mapped_doc
-from frappe.utils import flt
+from frappe.utils import flt, nowdate, getdate
 from frappe import _
 
 from erpnext.controllers.selling_controller import SellingController
@@ -21,9 +21,14 @@
 		self.validate_order_type()
 		self.validate_uom_is_integer("stock_uom", "qty")
 		self.validate_quotation_to()
+		self.validate_valid_till()
 		if self.items:
 			self.with_items = 1
 
+	def validate_valid_till(self):
+		if self.valid_till and self.valid_till < self.transaction_date:
+			frappe.throw(_("Valid till date cannot be before transaction date"))
+
 	def has_sales_order(self):
 		return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
 
@@ -100,6 +105,9 @@
 
 @frappe.whitelist()
 def make_sales_order(source_name, target_doc=None):
+	quotation = frappe.db.get_value("Quotation", source_name, ["transaction_date", "valid_till"], as_dict = 1)
+	if quotation.valid_till and (quotation.valid_till < quotation.transaction_date or quotation.valid_till < getdate(nowdate())):
+		frappe.throw(_("Validity period of this quotation has ended."))
 	return _make_sales_order(source_name, target_doc)
 
 def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index fa69df4..a985283 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -3,7 +3,7 @@
 from __future__ import unicode_literals
 
 import frappe
-from frappe.utils import flt
+from frappe.utils import flt, add_days, nowdate, add_months
 import unittest
 
 test_dependencies = ["Product Bundle"]
@@ -13,10 +13,11 @@
 		from erpnext.selling.doctype.quotation.quotation import make_sales_order
 
 		quotation = frappe.copy_doc(test_records[0])
+		quotation.transaction_date = nowdate()
+		quotation.valid_till = add_months(quotation.transaction_date, 1)
 		quotation.insert()
 
 		self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name)
-
 		quotation.submit()
 
 		sales_order = make_sales_order(quotation.name)
@@ -27,11 +28,28 @@
 		self.assertEquals(sales_order.get("items")[0].prevdoc_docname, quotation.name)
 		self.assertEquals(sales_order.customer, "_Test Customer")
 
+<<<<<<< HEAD
+		for d in sales_order.get("items"):
+			d.delivery_date = add_months(quotation.transaction_date, 1)
+=======
 		sales_order.delivery_date = "2014-01-01"
+>>>>>>> master
 		sales_order.naming_series = "_T-Quotation-"
-		sales_order.transaction_date = "2013-05-12"
+		sales_order.transaction_date = nowdate()
 		sales_order.insert()
 
+	def test_valid_till(self):
+		from erpnext.selling.doctype.quotation.quotation import make_sales_order
+
+		quotation = frappe.copy_doc(test_records[0])
+		quotation.valid_till = add_days(quotation.transaction_date, -1)
+		self.assertRaises(frappe.ValidationError, quotation.validate)
+
+		quotation.valid_till = add_days(nowdate(), -1)
+		quotation.insert()
+		quotation.submit()
+		self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name)
+
 	def test_create_quotation_with_margin(self):
 		from erpnext.selling.doctype.quotation.quotation import make_sales_order
 		from erpnext.selling.doctype.sales_order.sales_order \
@@ -44,6 +62,8 @@
 		test_records[0]['items'][0]['margin_rate_or_amount'] = 18.75
 
 		quotation = frappe.copy_doc(test_records[0])
+		quotation.transaction_date = nowdate()
+		quotation.valid_till = add_months(quotation.transaction_date, 1)
 		quotation.insert()
 
 		self.assertEquals(quotation.get("items")[0].rate, rate_with_margin)
diff --git a/erpnext/selling/doctype/quotation/test_records.json b/erpnext/selling/doctype/quotation/test_records.json
index 5637fb9..7a9d3eb 100644
--- a/erpnext/selling/doctype/quotation/test_records.json
+++ b/erpnext/selling/doctype/quotation/test_records.json
@@ -23,14 +23,15 @@
     "parentfield": "items", 
     "qty": 10.0, 
     "rate": 100.0,
-	  "uom": "_Test UOM 1",
+	"uom": "_Test UOM 1",
     "stock_uom": "_Test UOM 1",
-	  "conversion_factor": 1.0
+	"conversion_factor": 1.0
    }
   ], 
   "quotation_to": "Customer", 
   "selling_price_list": "_Test Price List", 
   "territory": "_Test Territory", 
-  "transaction_date": "2013-02-21"
+  "transaction_date": "2013-02-21",
+  "valid_till": "2013-03-21"
  }
 ]
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index ce8c18a..7c0d7f9 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -16,7 +16,7 @@
 		frappe.set_user("Administrator")
 
 		for role in ("Stock User", "Sales User"):
-			set_user_permission_doctypes(doctype="Sales Order", role=role,
+			set_user_permission_doctypes(doctypes="Sales Order", role=role,
 				apply_user_permissions=0, user_permission_doctypes=None)
 
 	def test_make_material_request(self):
@@ -137,10 +137,10 @@
 		total_projected_qty = get_total_projected_qty('_Test Item')
 		item_doc_after_cancel = frappe.get_doc('Item', '_Test Item')
 		self.assertEqual(total_projected_qty,  item_doc_after_cancel.total_projected_qty)
-		
+
 	def test_reserved_qty_for_over_delivery_via_sales_invoice(self):
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
-		
+
 		# set over-delivery tolerance
 		frappe.db.set_value('Item', "_Test Item", 'tolerance', 50)
 
@@ -158,9 +158,9 @@
 		total_projected_qty = get_total_projected_qty('_Test Item')
 		item_doc = frappe.get_doc('Item', '_Test Item')
 		self.assertEqual(total_projected_qty,  item_doc.total_projected_qty)
-		
+
 		self.assertEqual(get_reserved_qty(), existing_reserved_qty)
-		
+
 		so.load_from_db()
 		self.assertEqual(so.get("items")[0].delivered_qty, 12)
 		self.assertEqual(so.per_delivered, 100)
@@ -170,7 +170,7 @@
 		total_projected_qty = get_total_projected_qty('_Test Item')
 		item_doc = frappe.get_doc('Item', '_Test Item')
 		self.assertEqual(total_projected_qty,  item_doc.total_projected_qty)
-		
+
 		so.load_from_db()
 		self.assertEqual(so.get("items")[0].delivered_qty, 0)
 		self.assertEqual(so.per_delivered, 0)
@@ -178,8 +178,8 @@
 	def test_reserved_qty_for_partial_delivery_with_packing_list(self):
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
 		make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
-		
-		
+
+
 		existing_reserved_qty_item1 = get_reserved_qty("_Test Item")
 		existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100")
 
@@ -227,7 +227,7 @@
 	def test_reserved_qty_for_over_delivery_with_packing_list(self):
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
 		make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
-		
+
 		# set over-delivery tolerance
 		frappe.db.set_value('Item', "_Test Product Bundle Item", 'tolerance', 50)
 
@@ -257,7 +257,7 @@
 
 	def test_warehouse_user(self):
 		for role in ("Stock User", "Sales User"):
-			set_user_permission_doctypes(doctype="Sales Order", role=role,
+			set_user_permission_doctypes(doctypes="Sales Order", role=role,
 				apply_user_permissions=1, user_permission_doctypes=["Warehouse"])
 
 		frappe.permissions.add_user_permission("Warehouse", "_Test Warehouse 1 - _TC", "test@example.com")
@@ -283,6 +283,7 @@
 		frappe.set_user("test2@example.com")
 		so.insert()
 
+		frappe.set_user("Administrator")
 		frappe.permissions.remove_user_permission("Warehouse", "_Test Warehouse 1 - _TC", "test@example.com")
 		frappe.permissions.remove_user_permission("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com")
 		frappe.permissions.remove_user_permission("Company", "_Test Company 1", "test2@example.com")
@@ -363,7 +364,7 @@
 		from erpnext.buying.doctype.purchase_order.purchase_order import update_status
 
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
-		
+
 		po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1,
         'default_supplier': '_Test Supplier',
 		    "expense_account": "_Test Account Cost for Goods Sold - _TC",
diff --git a/erpnext/setup/doctype/company/tests/test_company.js b/erpnext/setup/doctype/company/tests/test_company.js
new file mode 100644
index 0000000..afa3296
--- /dev/null
+++ b/erpnext/setup/doctype/company/tests/test_company.js
@@ -0,0 +1,23 @@
+QUnit.module('setup');
+
+QUnit.test("Test: Company [SetUp]", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test company creation
+		() => frappe.set_route("List", "Company", "List"),
+		() => frappe.new_doc("Company"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("company_name", "Test Company"),
+		() => cur_frm.set_value("abbr", "TC"),
+		() => cur_frm.set_value("domain", "Services"),
+		() => cur_frm.set_value("default_currency", "INR"),
+		// save form
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+		() => assert.equal("Test Company", cur_frm.doc.company_name,
+			'name of company correctly saved'),
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/tests/test_company_production.js b/erpnext/setup/doctype/company/tests/test_company_production.js
new file mode 100644
index 0000000..73bd710
--- /dev/null
+++ b/erpnext/setup/doctype/company/tests/test_company_production.js
@@ -0,0 +1,19 @@
+QUnit.test("Test: Company", function (assert) {
+	assert.expect(0);
+
+	let done = assert.async();
+
+	frappe.run_serially([
+		// Added company for Production Order testing
+		() => frappe.set_route("List", "Company"),
+		() => frappe.new_doc("Company"),
+		() => frappe.timeout(1),
+		() => cur_frm.set_value("company_name", "Razer Blade"),
+		() => cur_frm.set_value("abbr", "RB"),
+		() => cur_frm.set_value("default_currency", "USD"),
+		() => cur_frm.save(),
+		() => frappe.timeout(1),
+
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
index cd4d977..57fce28 100644
--- a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
+++ b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
@@ -22,7 +22,7 @@
 			<ul class="list-unstyled">
 				<li><a class="text-muted" href="#">{%= __("Go to the Desktop and start using ERPNext") %}</a></li>
 				<li><a class="text-muted" href="#modules/Learn">{%= __("View a list of all the help videos") %}</a></li>
-				<li><a class="text-muted" href="https://frappe.github.io/erpnext/user" target="_blank">{%= __("Read the ERPNext Manual") %}</a></li>
+				<li><a class="text-muted" href="https://erpnext.org/docs/user" target="_blank">{%= __("Read the ERPNext Manual") %}</a></li>
 				<li><a class="text-muted" href="https://discuss.erpnext.com" target="_blank">{%= __("Community Forum") %}</a></li>
 			</ul>
 
diff --git a/erpnext/setup/setup_wizard/install_fixtures.py b/erpnext/setup/setup_wizard/install_fixtures.py
index 43baf2f..ea6da04 100644
--- a/erpnext/setup/setup_wizard/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/install_fixtures.py
@@ -185,6 +185,10 @@
 		{'doctype': "Party Type", "party_type": "Supplier"},
 		{'doctype': "Party Type", "party_type": "Employee"},
 
+		{'doctype': "Project Type", "project_type": "Internal"},
+		{'doctype': "Project Type", "project_type": "External"},
+		{'doctype': "Project Type", "project_type": "Other"},
+
 		{"doctype": "Offer Term", "offer_term": _("Date of Joining")},
 		{"doctype": "Offer Term", "offer_term": _("Annual Salary")},
 		{"doctype": "Offer Term", "offer_term": _("Probationary Period")},
@@ -213,6 +217,10 @@
 
 	records += [{'doctype': 'Lead Source', 'source_name': _(d)} for d in default_lead_sources]
 
+	# Records for the Supplier Scorecard
+	from erpnext.buying.doctype.supplier_scorecard.supplier_scorecard import make_default_records
+	make_default_records()
+
 	from frappe.modules import scrub
 	for r in records:
 		doc = frappe.new_doc(r.get("doctype"))
@@ -225,10 +233,10 @@
 
 		try:
 			doc.insert(ignore_permissions=True)
-		except frappe.DuplicateEntryError, e:
+		except frappe.DuplicateEntryError as e:
 			# pass DuplicateEntryError and continue
 			if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
 				# make sure DuplicateEntryError is for the exact same doc and not a related doc
 				pass
 			else:
-				raise
\ No newline at end of file
+				raise
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 93dad16..888099f 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -50,6 +50,7 @@
 	frappe.db.sql("delete from `tabItem Price`")
 
 	frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
+	enable_all_roles_and_domains()
 
 	frappe.db.commit()
 
@@ -94,3 +95,29 @@
 	except:
 		frappe.msgprint(_("Unable to find exchange rate for {0} to {1} for key date {2}. Please create a Currency Exchange record manually").format(from_currency, to_currency, transaction_date))
 		return 0.0
+
+def enable_all_roles_and_domains():
+	""" enable all roles and domain for testing """
+	roles = frappe.get_list("Role", filters={"disabled": 1})
+	for role in roles:
+		_role = frappe.get_doc("Role", role.get("name"))
+		_role.disabled = 0
+		_role.flags.ignore_mandatory = True
+		_role.flags.ignore_permissions = True
+		_role.save()
+
+	# add all roles to users
+	user = frappe.get_doc("User", "Administrator")
+	user.add_roles(*[role.get("name") for role in roles])
+
+	domains = frappe.get_list("Domain")
+	if not domains:
+		return
+
+	domain_settings = frappe.get_doc("Domain Settings", "Domain Settings")
+	domain_settings.set("active_domains", [])
+	for domain in domains:
+		row = domain_settings.append("active_domains", {})
+		row.domain=domain.get("name")
+
+	domain_settings.save()
diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py
index f221a8a..22b2895 100644
--- a/erpnext/shopping_cart/test_shopping_cart.py
+++ b/erpnext/shopping_cart/test_shopping_cart.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import unittest
 import frappe
+from frappe.utils import nowdate, add_months
 from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_party
 from erpnext.tests.utils import create_test_contact_and_address
 
@@ -126,6 +127,8 @@
 			"selling_price_list": "_Test Price List Rest of the World",
 			"currency": "USD",
 			"taxes_and_charges" : "_Test Tax 1",
+			"transaction_date" : nowdate(),
+			"valid_till" : add_months(nowdate(), 1),
 			"items": [{
 				"item_code": "_Test Item",
 				"qty": 1
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 2c6aab5..5dc97f6 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -132,7 +132,8 @@
 		from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
 
 		# default warehouse, or Stores
-		default_warehouse = (frappe.db.get_single_value('Stock Settings', 'default_warehouse')
+		default_warehouse = (self.default_warehouse
+			or frappe.db.get_single_value('Stock Settings', 'default_warehouse')
 			or frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')}))
 
 		if default_warehouse:
@@ -696,7 +697,7 @@
 	if verbose:
 		msgprint(msg, raise_exception=True)
 	else:
-		raise frappe.ValidationError, msg
+		raise frappe.ValidationError(msg)
 
 
 def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 3361020..fc0b9b2 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -36,9 +36,14 @@
 			frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty"));
 		}
 	},
+
 	item_code: function(frm, doctype, name) {
 		frm.script_manager.copy_from_first_row('items', frm.selected_doc,
 			'schedule_date');
+	},
+
+	schedule_date: function(frm, cdt, cdn) {
+		erpnext.utils.copy_value_in_all_row(frm.doc, cdt, cdn, "items", "schedule_date");
 	}
 });
 
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index fdb65cd..92de229 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -32,7 +32,7 @@
 		set_perpetual_inventory(0)
 
 		for role in ("Stock User", "Sales User"):
-			set_user_permission_doctypes(doctype="Stock Entry", role=role,
+			set_user_permission_doctypes(doctypes="Stock Entry", role=role,
 				apply_user_permissions=0, user_permission_doctypes=None)
 
 	def test_fifo(self):
@@ -188,18 +188,18 @@
 			[["_Test Item", "_Test Warehouse - _TC", -45.0], ["_Test Item", "_Test Warehouse 1 - _TC", 45.0]])
 
 		stock_in_hand_account = get_inventory_account(mtn.company, mtn.get("items")[0].s_warehouse)
-		
+
 		fixed_asset_account = get_inventory_account(mtn.company, mtn.get("items")[0].t_warehouse)
-			
+
 		if stock_in_hand_account == fixed_asset_account:
 			# no gl entry as both source and target warehouse has linked to same account.
 			self.assertFalse(frappe.db.sql("""select * from `tabGL Entry`
 				where voucher_type='Stock Entry' and voucher_no=%s""", mtn.name))
-			
+
 		else:
 			stock_value_diff = abs(frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Stock Entry",
 				"voucher_no": mtn.name, "warehouse": "_Test Warehouse - _TC"}, "stock_value_difference"))
-		
+
 			self.check_gl_entries("Stock Entry", mtn.name,
 				sorted([
 					[stock_in_hand_account, 0.0, stock_value_diff],
@@ -467,7 +467,7 @@
 	# permission tests
 	def test_warehouse_user(self):
 		for role in ("Stock User", "Sales User"):
-			set_user_permission_doctypes(doctype="Stock Entry", role=role,
+			set_user_permission_doctypes(doctypes="Stock Entry", role=role,
 				apply_user_permissions=1, user_permission_doctypes=["Warehouse"])
 
 		frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC", "test@example.com", "User Permission")
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 9c42529..360ebca 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -143,16 +143,16 @@
 
 			# item should not be serialized
 			if item.has_serial_no == 1:
-				raise frappe.ValidationError, _("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code)
+				raise frappe.ValidationError(_("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code))
 
 			# item managed batch-wise not allowed
 			if item.has_batch_no == 1:
-				raise frappe.ValidationError, _("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code)
+				raise frappe.ValidationError(_("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code))
 
 			# docstatus should be < 2
 			validate_cancelled_item(item_code, item.docstatus, verbose=0)
 
-		except Exception, e:
+		except Exception as e:
 			self.validation_messages.append(_("Row # ") + ("%d: " % (row_num)) + cstr(e))
 
 	def update_stock_ledger(self):
diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.js b/erpnext/stock/doctype/warehouse/test_warehouse.js
new file mode 100644
index 0000000..3763613
--- /dev/null
+++ b/erpnext/stock/doctype/warehouse/test_warehouse.js
@@ -0,0 +1,19 @@
+QUnit.test("test: warehouse", function (assert) {
+	assert.expect(0);
+	let done = assert.async();
+
+	frappe.run_serially([
+		// test warehouse creation
+		() => frappe.set_route("List", "Warehouse"),
+
+		// Create a Laptop Scrap Warehouse
+		() => frappe.tests.make(
+			"Warehouse", [
+				{warehouse_name: "Laptop Scrap Warehouse"},
+				{company: "Razer Blade"}
+			]
+		),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index a3ae0eb..80ef708 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -243,7 +243,8 @@
 
 	if meta.get_field("currency"):
 		validate_price_list(args)
-		validate_conversion_rate(args, meta)
+		if args.price_list:
+			validate_conversion_rate(args, meta)
 
 		price_list_rate = get_price_list_rate_for(args.price_list, item_doc.name)
 
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 8022691..7c6b34b 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -378,7 +378,7 @@
 		if self.verbose:
 			frappe.throw(msg, NegativeStockError, title='Insufficent Stock')
 		else:
-			raise NegativeStockError, msg
+			raise NegativeStockError(msg)
 
 def get_previous_sle(args, for_update=False):
 	"""
diff --git a/erpnext/support/doctype/issue/issue.js b/erpnext/support/doctype/issue/issue.js
index 2bee422..bef8cb4 100644
--- a/erpnext/support/doctype/issue/issue.js
+++ b/erpnext/support/doctype/issue/issue.js
@@ -20,9 +20,11 @@
 	timeline_refresh: function(frm) {
 		// create button for "Add to Knowledge Base"
 		if(frappe.model.can_create('Help Article')) {
-			$('<button class="btn btn-xs btn-default btn-add-to-kb pull-right" style="margin-top: -2px">'+
+			// Removing Knowledge Base button if exists to avoid multiple occurance
+			frm.timeline.wrapper.find('.comment-header .asset-details .btn-add-to-kb').remove();
+			$('<button class="btn btn-xs btn-default btn-add-to-kb hidden-xs pull-right" style="margin-top: -2px">'+
 				__('Add to Knowledge Base') + '</button>')
-				.appendTo(frm.timeline.wrapper.find('.comment-header'))
+				.appendTo(frm.timeline.wrapper.find('.comment-header .asset-details'))
 				.on('click', function() {
 					var content = $(this).parents('.timeline-item:first').find('.timeline-item-content').html();
 					var doc = frappe.model.get_new_doc('Help Article');
diff --git a/erpnext/support/web_form/issues/issues.json b/erpnext/support/web_form/issues/issues.json
index 6474799..264b9df 100644
--- a/erpnext/support/web_form/issues/issues.json
+++ b/erpnext/support/web_form/issues/issues.json
@@ -7,16 +7,18 @@
  "allow_multiple": 1, 
  "allow_print": 0, 
  "amount": 0.0, 
- "breadcrumbs": "[{\"title\":\"Issues\", \"name\":\"issues\"}]", 
+ "amount_based_on_field": 0, 
+ "breadcrumbs": "[{\"label\":_(\"Issues\"), \"route\":\"issues\"}]", 
  "creation": "2016-06-24 15:50:33.186483", 
  "doc_type": "Issue", 
  "docstatus": 0, 
  "doctype": "Web Form", 
  "idx": 0, 
+ "introduction_text": "", 
  "is_standard": 1, 
  "login_required": 1, 
  "max_attachment_size": 0, 
- "modified": "2016-12-07 04:26:13.917693", 
+ "modified": "2017-07-25 22:49:10.762704", 
  "modified_by": "Administrator", 
  "module": "Support", 
  "name": "issues", 
diff --git a/erpnext/templates/emails/daily_work_summary.html b/erpnext/templates/emails/daily_work_summary.html
index 726de3b..a22e09c 100644
--- a/erpnext/templates/emails/daily_work_summary.html
+++ b/erpnext/templates/emails/daily_work_summary.html
@@ -1,28 +1,25 @@
 <table border="0" cellpadding="0" cellspacing="0" width="100%">
 	<tr>
-		<div style="color: #333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; word-wrap: break-word; overflow-wrap: break-word;">
-			<h3>{{ title }}</h3>
-		</div>
+		<h3>{{ title }}</h3>
 	</tr>
 </table>
 {% for reply in replies %}
-<table border="0" cellpadding="0" cellspacing="0" width="100%"
-	style="background-color: #fafbfc; border: 1px solid #d1d8dd; border-radius: 3px 3px 0 0">
+<table class="panel-header" border="0" cellpadding="0" cellspacing="0" width="100%">
 	<tr height="10"></tr>
 	<tr>
 		<td width="15"></td>
 		<td valign="top" width="24">
 			{% if reply.image %}
-			<img width="24" height="24" embed="{{ reply.image }}" style="border-radius: 3px; vertical-align: middle;" />
+			<img class="sender-avatar" width="24" height="24" embed="{{ reply.image }}"/>
 			{% else %}
-			<div style="width: 24px; height: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;background: #fff; border-radius: 3px; border: 1px solid #d1d8dd; text-align: center; line-height: 24px; color: #d1d8dd;">
+			<div class="sender-avatar-placeholder">
 				{{ reply.sender_name[0] }}
 			</div>
 			{% endif %}
 		</td>
 		<td width="10"></td>
 		<td>
-			<div style="font-size: 12px; color: #8D99A6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; word-wrap: break-word; line-height: 22px; overflow-wrap: break-word; text-decoration: none;">
+			<div class="text-medium text-muted">
 				<span>{{ reply.sender_name }}</span>
 			</div>
 		</td>
@@ -30,13 +27,12 @@
 	</tr>
 	<tr height="10"></tr>
 </table>
-<table border="0" cellpadding="0" cellspacing="0" width="100%"
-	style="background-color: #fff; border: 1px solid #d1d8dd; border-top: none; border-radius: 0 0 3px 3px">
+<table class="panel-body" border="0" cellpadding="0" cellspacing="0" width="100%">
 	<tr height="10"></tr>
 	<tr>
 		<td width="15"></td>
 		<td>
-			<div style="font-size: 14px; color: #333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; word-wrap: break-word; line-height: 22px; overflow-wrap: break-word; text-decoration: none;">
+			<div>
 				{{ reply.content }}
 			</div>
 		</td>
@@ -51,7 +47,7 @@
 {% if did_not_reply %}
 <table border="0" cellpadding="0" cellspacing="0" width="100%">
 	<tr>
-		<div style="font-size: 14px; color: #8D99A6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; word-wrap: break-word; line-height: 22px; overflow-wrap: break-word; text-decoration: none;">
+		<div class="text-muted">
 			<p>{{ did_not_reply_title }}: {{ did_not_reply }}</p>
 		</div>
 	</tr>
diff --git a/erpnext/templates/includes/announcement/announcement_row.html b/erpnext/templates/includes/announcement/announcement_row.html
index d807bfc..3099441 100644
--- a/erpnext/templates/includes/announcement/announcement_row.html
+++ b/erpnext/templates/includes/announcement/announcement_row.html
@@ -3,12 +3,12 @@
 		<div class="row">
 			<a href="/announcements?announcement={{doc.name}}">
 				<div class="col-xs-12">
-					<h1 class="blog-header">{{ doc.subject }}</h1>
+					<h1>{{ doc.subject }}</h1>
 					<p class="post-description more">{{ doc.description }}</p>
 					<p class="post-by text-muted small">
 						<i>{{ doc.posted_by }}</i>
-						<i class="blog-dot"></i> {{ frappe.format_date(doc.modified) }}
-						<i class="blog-dot"></i> {{ doc.num_attachments }} attachments
+						<i class="spacer-dot"></i> {{ frappe.format_date(doc.modified) }}
+						<i class="spacer-dot"></i> {{ doc.num_attachments }} attachments
 					</p>
 				</div>
 			</a>
diff --git a/erpnext/templates/includes/timesheet/timesheet_row.html b/erpnext/templates/includes/timesheet/timesheet_row.html
new file mode 100644
index 0000000..e9cfcda
--- /dev/null
+++ b/erpnext/templates/includes/timesheet/timesheet_row.html
@@ -0,0 +1,13 @@
+<div class="web-list-item">
+	<a href="/timesheets?name={{ doc.name | urlencode }}" class="no-decoration">
+		<div class="row">
+			<div class="col-xs-3">
+				<span class="indicator {{ "red" if doc.status=="Cancelled" else "green" if doc.status=="Billed" else "blue" if doc.status=="Submitted" else "darkgrey" }}">{{ doc.name }}</span>
+			</div>
+			<div class="col-xs-3"> Billable Hours: {{ doc.total_billable_hours}} </div>
+			<div class="col-xs-2"> {{ _(doc.sales_invoice) }} </div>
+			<div class="col-xs-2"> {{ _(doc.project) }} </div>
+			<div class="col-xs-2"> {{ _(doc.activity_type) }} </div>
+		</div>
+	</a>
+</div>
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html
index da9eb33..3e4eca3 100644
--- a/erpnext/templates/pages/order.html
+++ b/erpnext/templates/pages/order.html
@@ -80,7 +80,7 @@
 			<div class="page-header-actions-block" data-html-block="header-actions">
 				<p>
 				    <a href="/api/method/erpnext.accounts.doctype.payment_request.payment_request.make_payment_request?dn={{ doc.name }}&dt={{ doc.doctype }}&submit_doc=1"
-				        class="btn btn-primary btn-sm">Pay {{ doc.get_formatted("grand_total") }} </a>
+				        class="btn btn-primary btn-sm">{{ _("Pay") }} {{ doc.get_formatted("grand_total") }} </a>
 				</p>
 			</div>
 			{% endif %}
diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py
index b453c7e..7551a0f 100644
--- a/erpnext/templates/pages/order.py
+++ b/erpnext/templates/pages/order.py
@@ -18,6 +18,7 @@
                 context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)
 
 	context.parents = frappe.form_dict.parents
+	context.title = frappe.form_dict.name
 	context.payment_ref = frappe.db.get_value("Payment Request",
 		{"reference_name": frappe.form_dict.name}, "name")
 
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index 40b1c59..a3ab3c4 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -1,6 +1,44 @@
 erpnext/tests/ui/make_fixtures.js #long
+erpnext/setup/doctype/company/tests/test_company.js
 erpnext/accounts/doctype/account/test_account.js
+erpnext/accounts/doctype/account/test_make_tax_account.js
+erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js
 erpnext/crm/doctype/lead/test_lead.js
 erpnext/crm/doctype/opportunity/test_opportunity.js
 erpnext/selling/doctype/quotation/test_quotation.js
+erpnext/setup/doctype/company/tests/test_company_production.js
+erpnext/crm/doctype/item/test_item.js
+erpnext/manufacturing/doctype/workstation/test_workstation.js
+erpnext/manufacturing/doctype/operation/test_operation.js
+erpnext/manufacturing/doctype/bom/test_bom.js
+erpnext/projects/doctype/project/project_timesheet.js
+erpnext/hr/doctype/holiday_list/test_holiday_list.js
+erpnext/hr/doctype/branch/test_branch.js
+erpnext/hr/doctype/leave_block_list/test_leave_block_list.js
+erpnext/hr/doctype/department/test_department.js
+erpnext/hr/doctype/designation/test_designation.js
+erpnext/hr/doctype/employment_type/test_employment_type.js
+erpnext/hr/doctype/employee/test_employee.js
+erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
+erpnext/hr/doctype/attendance/test_attendance.js
+erpnext/hr/doctype/leave_type/test_leave_type.js
+erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js
+erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
+erpnext/hr/doctype/leave_application/test_leave_application.js
+erpnext/schools/doctype/academic_year/test_academic_year.js
+erpnext/schools/doctype/academic_term/test_academic_term.js
+erpnext/schools/doctype/school_settings/test_school_settings.js
+erpnext/schools/doctype/student_batch_name/test_student_batch_name.js
+erpnext/schools/doctype/student_category/test_student_category.js
+erpnext/schools/doctype/room/test_room.js
+erpnext/schools/doctype/instructor/test_instructor.js
+erpnext/stock/doctype/warehouse/test_warehouse.js
+erpnext/manufacturing/doctype/production_order/test_production_order.js
+erpnext/accounts/page/pos/test_pos.js
+erpnext/selling/doctype/product_bundle/test_product_bundle.js
+erpnext/schools/doctype/grading_scale/test_grading_scale.js
+erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js
+erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js
+erpnext/schools/doctype/course/test_course.js
+erpnext/schools/doctype/program/test_program.js
 erpnext/selling/doctype/sales_order/test_sales_order.js
\ No newline at end of file