Merge pull request #5845 from KanchanChauhan/quotation-fix

[Minor Fix]
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 2a30f12..f356bbc 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.0.0-beta'
+__version__ = '7.0.0'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 6f25220..94709a7 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -61,8 +61,8 @@
 				frappe.get_doc(voucher_type, voucher_no).set_total_advance_paid()
 
 	def on_cancel(self):
-		from erpnext.accounts.utils import remove_against_link_from_jv
-		remove_against_link_from_jv(self.doctype, self.name)
+		from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
+		unlink_ref_doc_from_payment_entries(self.doctype, self.name)
 
 		self.make_gl_entries(1)
 		self.update_advance_paid()
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.js b/erpnext/accounts/doctype/payment_request/payment_request.js
index e73da4c..afc3804 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.js
+++ b/erpnext/accounts/doctype/payment_request/payment_request.js
@@ -31,5 +31,21 @@
 			});
 		});
 	}
+	
+	if(!frm.doc.payment_gateway_account && frm.doc.status == "Initiated") {
+		frm.add_custom_button(__('Make Payment Entry'), function(){
+			frappe.call({
+				method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry",
+				args: {"docname": frm.doc.name},
+				freeze: true,
+				callback: function(r){
+					if(!r.exc) {
+						var doc = frappe.model.sync(r.message);
+						frappe.set_route("Form", r.message.doctype, r.message.name);
+					}
+				}
+			});
+		}).addClass("btn-primary");
+	}
 });
 
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index eca0ad0..3a3802f 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -3,11 +3,13 @@
  "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "PR.######", 
+ "beta": 0, 
  "creation": "2015-12-15 22:23:24.745065", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -156,7 +158,7 @@
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
@@ -404,30 +406,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "column_break_16", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
+   "label": "Payment Gateway Details", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -599,13 +578,14 @@
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
+ "image_view": 0, 
  "in_create": 1, 
  "in_dialog": 0, 
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-05-03 10:31:45.692016", 
+ "modified": "2016-07-21 19:11:57.517964", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Payment Request", 
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 0c8df02..30d043f 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -13,7 +13,6 @@
 
 class PaymentRequest(Document):
 	def validate(self):
-		self.validate_payment_gateway_account()
 		self.validate_payment_request()
 		self.validate_currency()
 
@@ -24,19 +23,9 @@
 
 	def validate_currency(self):
 		ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
-		if ref_doc.currency != frappe.db.get_value("Account", self.payment_account, "account_currency"):
+		if self.payment_account and ref_doc.currency != frappe.db.get_value("Account", self.payment_account, "account_currency"):
 			frappe.throw(_("Transaction currency must be same as Payment Gateway currency"))
 
-	def validate_payment_gateway_account(self):
-		if not self.payment_gateway:
-			frappe.throw(_("Payment Gateway Account is not configured"))
-
-	def validate_payment_gateway(self):
-		if self.payment_gateway == "PayPal":
-			if not frappe.db.get_value("PayPal Settings", None, "api_username"):
-				if not frappe.conf.paypal_username:
-					frappe.throw(_("PayPal Settings missing"))
-
 	def on_submit(self):
 		send_mail = True
 		self.make_communication_entry()
@@ -45,7 +34,7 @@
 		if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart":
 			send_mail = False
 
-		if send_mail:
+		if send_mail and not self.flags.mute_email:
 			self.send_payment_request()
 			self.send_email()
 
@@ -66,9 +55,13 @@
 			si.submit()
 
 	def send_payment_request(self):
-		self.payment_url = get_url("/api/method/erpnext.accounts.doctype.payment_request.payment_request.generate_payment_request?name={0}".format(self.name))
+		if self.payment_account:
+			self.payment_url = get_url("/api/method/erpnext.accounts.doctype.payment_request.payment_request.generate_payment_request?name={0}".format(self.name))
+		
 		if self.payment_url:
 			self.db_set('payment_url', self.payment_url)
+			
+		if self.payment_url or not self.payment_gateway_account:
 			self.db_set('status', 'Initiated')
 
 	def set_as_paid(self):
@@ -80,7 +73,7 @@
 
 		return payment_entry
 
-	def create_payment_entry(self):
+	def create_payment_entry(self, submit=True):
 		"""create entry"""
 		frappe.flags.ignore_account_permission = True
 
@@ -111,18 +104,18 @@
 				self.reference_name, self.name)
 		})
 
-		company_details = get_company_defaults(ref_doc.company)
 		if payment_entry.difference_amount:
+			company_details = get_company_defaults(ref_doc.company)
+
 			payment_entry.append("deductions", {
 				"account": company_details.exchange_gain_loss_account,
 				"cost_center": company_details.cost_center,
 				"amount": payment_entry.difference_amount
 			})
-		payment_entry.insert(ignore_permissions=True)
-		payment_entry.submit()
 
-		#set status as paid for Payment Request
-		self.db_set('status', 'Paid')
+		if submit:
+			payment_entry.insert(ignore_permissions=True)
+			payment_entry.submit()
 
 		return payment_entry
 
@@ -140,7 +133,8 @@
 			"payment_url": self.payment_url
 		}
 
-		return frappe.render_template(self.message, context)
+		if self.message:
+			return frappe.render_template(self.message, context)
 
 	def set_failed(self):
 		pass
@@ -171,7 +165,7 @@
 
 	ref_doc = frappe.get_doc(args.dt, args.dn)
 
-	gateway_account = get_gateway_details(args)
+	gateway_account = get_gateway_details(args) or frappe._dict()
 
 	grand_total = get_amount(ref_doc, args.dt)
 
@@ -184,20 +178,24 @@
 	else:
 		pr = frappe.new_doc("Payment Request")
 		pr.update({
-			"payment_gateway_account": gateway_account.name,
-			"payment_gateway": gateway_account.payment_gateway,
-			"payment_account": gateway_account.payment_account,
+			"payment_gateway_account": gateway_account.get("name"),
+			"payment_gateway": gateway_account.get("payment_gateway"),
+			"payment_account": gateway_account.get("payment_account"),
 			"currency": ref_doc.currency,
 			"grand_total": grand_total,
 			"email_to": args.recipient_id or "",
 			"subject": "Payment Request for %s"%args.dn,
-			"message": gateway_account.message,
+			"message": gateway_account.get("message") or get_dummy_message(args.use_dummy_message),
 			"reference_doctype": args.dt,
 			"reference_name": args.dn
 		})
 
 		if args.return_doc:
 			return pr
+
+		if args.mute_email:
+			pr.flags.mute_email = True
+
 		if args.submit_doc:
 			pr.insert(ignore_permissions=True)
 			pr.submit()
@@ -239,9 +237,6 @@
 
 	gateway_account = get_payment_gateway_account({"is_default": 1})
 
-	if not gateway_account:
-		frappe.throw(_("Payment Gateway Account is not configured"))
-
 	return gateway_account
 
 def get_payment_gateway_account(args):
@@ -267,3 +262,29 @@
 @frappe.whitelist(allow_guest=True)
 def resend_payment_email(docname):
 	return frappe.get_doc("Payment Request", docname).send_email()
+
+@frappe.whitelist()
+def make_payment_entry(docname):
+	doc = frappe.get_doc("Payment Request", docname)
+	return doc.create_payment_entry(submit=False).as_dict()
+
+def make_status_as_paid(doc, method):
+	for ref in doc.references:
+		payment_request_name = frappe.db.get_value("Payment Request",
+			{"reference_doctype": ref.reference_doctype, "reference_name": ref.reference_name,
+			"docstatus": 1})
+		
+		if payment_request_name:
+			doc = frappe.get_doc("Payment Request", payment_request_name)
+			if doc.status != "Paid":
+				doc.db_set('status', 'Paid')
+
+def get_dummy_message(use_dummy_message=True):
+	return """
+		<p> Hope you are enjoying a service. Please consider bank details for payment </p>
+		<p> Bank Details <p><br>
+		<p> Bank Name : National Bank </p>
+		<p> Account Number : 123456789000872 </p>
+		<p> IFSC code : NB000001 </p>
+		<p> Account Name : Wind Power LLC </p>
+	"""
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 5be0b69..176e529 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -147,6 +147,14 @@
 				["Purchase Receipt", "purchase_receipt", "pr_detail"]
 			])
 
+	def validate_warehouse(self):
+		if self.update_stock:
+			for d in self.get('items'):
+				if not d.warehouse:
+					frappe.throw(_("Warehouse required at Row No {0}").format(d.idx))
+
+		super(PurchaseInvoice, self).validate_warehouse()
+
 	def set_expense_account(self):
 		auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
 
@@ -155,6 +163,7 @@
 			stock_items = self.get_stock_items()
 
 		if self.update_stock:
+			self.validate_warehouse()
 			warehouse_account = get_warehouse_account()
 
 		for item in self.get("items"):
@@ -553,8 +562,8 @@
 		self.update_status_updater_args()
 
 		if not self.is_return:
-			from erpnext.accounts.utils import remove_against_link_from_jv
-			remove_against_link_from_jv(self.doctype, self.name)
+			from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
+			unlink_ref_doc_from_payment_entries(self.doctype, self.name)
 
 			self.update_prevdoc_status()
 			self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 1df86aa..b284619 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -134,8 +134,8 @@
 	def on_cancel(self):
 		self.check_close_sales_order("sales_order")
 
-		from erpnext.accounts.utils import remove_against_link_from_jv
-		remove_against_link_from_jv(self.doctype, self.name)
+		from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
+		unlink_ref_doc_from_payment_entries(self.doctype, self.name)
 
 		if self.is_return:
 			# NOTE status updating bypassed for is_return
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 635197f..6efb288 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -323,8 +323,19 @@
 	payment_entry.set_missing_values()
 	payment_entry.set_amounts()
 	payment_entry.save(ignore_permissions=True)
+	
+def unlink_ref_doc_from_payment_entries(ref_type, ref_no):
+	remove_ref_doc_link_from_jv(ref_type, ref_no)
+	remove_ref_doc_link_from_pe(ref_type, ref_no)
+	
+	frappe.db.sql("""update `tabGL Entry`
+		set against_voucher_type=null, against_voucher=null,
+		modified=%s, modified_by=%s
+		where against_voucher_type=%s and against_voucher=%s
+		and voucher_no != ifnull(against_voucher, '')""",
+		(now(), frappe.session.user, ref_type, ref_no))
 
-def remove_against_link_from_jv(ref_type, ref_no):
+def remove_ref_doc_link_from_jv(ref_type, ref_no):
 	linked_jv = frappe.db.sql_list("""select parent from `tabJournal Entry Account`
 		where reference_type=%s and reference_name=%s and docstatus < 2""", (ref_type, ref_no))
 
@@ -335,15 +346,30 @@
 			where reference_type=%s and reference_name=%s
 			and docstatus < 2""", (now(), frappe.session.user, ref_type, ref_no))
 
-		frappe.db.sql("""update `tabGL Entry`
-			set against_voucher_type=null, against_voucher=null,
-			modified=%s, modified_by=%s
-			where against_voucher_type=%s and against_voucher=%s
-			and voucher_no != ifnull(against_voucher, '')""",
-			(now(), frappe.session.user, ref_type, ref_no))
-
 		frappe.msgprint(_("Journal Entries {0} are un-linked".format("\n".join(linked_jv))))
+		
+def remove_ref_doc_link_from_pe(ref_type, ref_no):
+	linked_pe = frappe.db.sql_list("""select parent from `tabPayment Entry Reference`
+		where reference_doctype=%s and reference_name=%s and docstatus < 2""", (ref_type, ref_no))
 
+	if linked_pe:
+		frappe.db.sql("""update `tabPayment Entry Reference`
+			set allocated_amount=0, modified=%s, modified_by=%s
+			where reference_doctype=%s and reference_name=%s
+			and docstatus < 2""", (now(), frappe.session.user, ref_type, ref_no))
+			
+		for pe in linked_pe:
+			pe_doc = frappe.get_doc("Payment Entry", pe)
+			pe_doc.set_total_allocated_amount()
+			pe_doc.set_unallocated_amount()
+			pe_doc.clear_unallocated_reference_document_rows()
+			
+			frappe.db.sql("""update `tabPayment Entry` set total_allocated_amount=%s, 
+				base_total_allocated_amount=%s, unallocated_amount=%s, modified=%s, modified_by=%s 
+				where name=%s""", (pe_doc.total_allocated_amount, pe_doc.base_total_allocated_amount, 
+					pe_doc.unallocated_amount, now(), frappe.session.user, pe))
+		
+		frappe.msgprint(_("Payment Entries {0} are un-linked".format("\n".join(linked_pe))))
 
 @frappe.whitelist()
 def get_company_default(company, fieldname):
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py b/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py
index 0812790..61a9700 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py
@@ -1,12 +1,24 @@
 from frappe import _
 
 data = {
-	'docstatus': 1,
 	'fieldname': 'purchase_order',
+	'internal_links': {
+		'Material Request': ['items', 'material_request'],
+		'Supplier Quotation': ['items', 'supplier_quotation'],
+		'Project': ['project'],
+	},
 	'transactions': [
 		{
 			'label': _('Related'),
-			'items': ['Purchase Receipt', 'Purchase Invoice', 'Stock Entry']
+			'items': ['Purchase Receipt', 'Purchase Invoice']
+		},
+		{
+			'label': _('Reference'),
+			'items': ['Material Request', 'Supplier Quotation', 'Project']
+		},
+		{
+			'label': _('Sub-contracting'),
+			'items': ['Stock Entry']
 		},
 	]
 }
\ No newline at end of file
diff --git a/erpnext/config/schools.py b/erpnext/config/schools.py
index ee1a8cb..ad4372b 100644
--- a/erpnext/config/schools.py
+++ b/erpnext/config/schools.py
@@ -13,10 +13,24 @@
 				},
 				{
 					"type": "doctype",
+					"name": "Student Batch"
+				},
+				{
+					"type": "doctype",
 					"name": "Student Group"
 				},
 				{
 					"type": "doctype",
+					"name": "Student Group Creation Tool"
+				}
+			]
+		},
+		{
+			"label": _("Admission"),
+			"items": [
+
+				{
+					"type": "doctype",
 					"name": "Student Applicant"
 				},
 				{
@@ -26,10 +40,6 @@
 				{
 					"type": "doctype",
 					"name": "Program Enrollment Tool"
-				},
-				{
-					"type": "doctype",
-					"name": "Student Group Creation Tool"
 				}
 			]
 		},
@@ -47,11 +57,11 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Scheduling Tool"
+					"name": "Examination"
 				},
 				{
 					"type": "doctype",
-					"name": "Examination"
+					"name": "Scheduling Tool"
 				}
 			]
 		},
@@ -79,6 +89,23 @@
 			]
 		},
 		{
+			"label": _("LMS"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Announcement"
+				},
+				{
+					"type": "doctype",
+					"name": "Topic"
+				},
+				{
+					"type": "doctype",
+					"name": "Discussion"
+				}
+			]
+		},
+		{
 			"label": _("Setup"),
 			"items": [
 				{
diff --git a/erpnext/demo/setup_data.py b/erpnext/demo/setup_data.py
index 918fd54..3367527 100644
--- a/erpnext/demo/setup_data.py
+++ b/erpnext/demo/setup_data.py
@@ -32,9 +32,11 @@
 	setup_employee()
 	setup_salary_structure()
 	setup_salary_structure_for_timesheet()
+	setup_mode_of_payment()
 	setup_account_to_expense_type()
 	setup_user_roles()
 	setup_budget()
+	setup_pos_profile()
 	frappe.db.commit()
 	frappe.clear_cache()
 
@@ -316,6 +318,18 @@
 		ss_doc.hour_rate = flt(random.random() * 10, 2)
 		ss_doc.save(ignore_permissions=True)
 
+def setup_mode_of_payment():
+	account_dict = {'Cash': 'Cash - WPL', 'Bank': 'National Bank - WPL'}
+	for payment_mode in frappe.get_all('Mode of Payment', fields = ["name", "type"]):
+		if payment_mode.type:
+			mop = frappe.get_doc('Mode of Payment', payment_mode.name)
+			mop.append('accounts', {
+				'company': erpnext.get_default_company(),
+				'default_account': account_dict.get(payment_mode.type)
+			})
+
+			mop.save(ignore_permissions=True)
+
 def setup_account():
 	frappe.flags.in_import = True
 	data = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data',
@@ -402,3 +416,17 @@
 		user.add_roles('HR User', 'Projects User')
 		frappe.db.set_global('demo_projects_user', user.name)
 
+def setup_pos_profile():
+	pos = frappe.new_doc('POS Profile')
+	pos.user = frappe.db.get_global('demo_accounts_user')
+	pos.naming_series = 'SINV-'
+	pos.update_stock = 0
+	pos.write_off_account = 'Cost of Goods Sold - WPL'
+	pos.write_off_cost_center = 'Main - WPL'
+
+	pos.append('payments', {
+		'mode_of_payment': frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name'),
+		'amount': 0.0
+	})
+
+	pos.insert()
diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py
index e7dceb3..045c306 100644
--- a/erpnext/demo/user/accounts.py
+++ b/erpnext/demo/user/accounts.py
@@ -10,12 +10,16 @@
 from frappe.desk import query_report
 from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice
 from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
+from frappe.utils.make_random import get_random
+from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry
+from erpnext.demo.user.sales import make_sales_order
+from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
+from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
 
 def work():
 	frappe.set_user(frappe.db.get_global('demo_accounts_user'))
 
 	if random.random() <= 0.6:
-		from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
 		report = "Ordered Items to be Billed"
 		for so in list(set([r[0] for r in query_report.run(report)["result"]
 				if r[0]!="Total"]))[:random.randint(1, 5)]:
@@ -29,7 +33,6 @@
 			frappe.db.commit()
 
 	if random.random() <= 0.6:
-		from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
 		report = "Received Items to be Billed"
 		for pr in list(set([r[0] for r in query_report.run(report)["result"]
 			if r[0]!="Total"]))[:random.randint(1, 5)]:
@@ -46,10 +49,25 @@
 	if random.random() < 0.5:
 		make_payment_entries("Purchase Invoice", "Accounts Payable")
 
+	if random.random() < 0.1:
+		#make payment request against sales invoice
+		sales_invoice_name = get_random("Sales Invoice", filters={"docstatus": 1})
+		if sales_invoice_name:
+			si = frappe.get_doc("Sales Invoice", sales_invoice_name)
+			if si.outstanding_amount > 0:
+				payment_request = make_payment_request(dt="Sales Invoice", dn=si.name, recipient_id=si.contact_email,
+					submit_doc=True, mute_email=True, use_dummy_message=True)
+
+				payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
+				payment_entry.posting_date = frappe.flags.current_date
+				payment_entry.submit()
+
+	make_pos_invoice()
+
 def make_payment_entries(ref_doctype, report):
-	outstanding_invoices = list(set([r[3] for r in query_report.run(report, 
+	outstanding_invoices = list(set([r[3] for r in query_report.run(report,
 	{"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype]))
-	
+
 	# make Payment Entry
 	for inv in outstanding_invoices[:random.randint(1, 2)]:
 		pe = get_payment_entry(ref_doctype, inv)
@@ -60,7 +78,7 @@
 		pe.submit()
 		frappe.db.commit()
 		outstanding_invoices.remove(inv)
-		
+
 	# make payment via JV
 	for inv in outstanding_invoices[:1]:
 		jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv))
@@ -69,4 +87,25 @@
 		jv.cheque_date = frappe.flags.current_date
 		jv.insert()
 		jv.submit()
-		frappe.db.commit()		
\ No newline at end of file
+		frappe.db.commit()
+
+def make_pos_invoice():
+	make_sales_order()
+
+	for data in frappe.get_all('Sales Order', fields=["name"],
+		filters = [["per_billed", "<", "100"]]):
+		si = frappe.get_doc(make_sales_invoice(data.name))
+		si.is_pos =1
+		si.posting_date = frappe.flags.current_date
+		for d in si.get("items"):
+			if not d.income_account:
+				d.income_account = "Sales - {}".format(frappe.db.get_value('Company', si.company, 'abbr'))
+		si.set_missing_values()
+		make_payment_entries_for_pos_invoice(si)
+		si.insert()
+		si.submit()
+
+def make_payment_entries_for_pos_invoice(si):
+	for data in si.payments:
+		data.amount = si.outstanding_amount
+		return
diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py
index 219fa20..28966ec 100644
--- a/erpnext/demo/user/hr.py
+++ b/erpnext/demo/user/hr.py
@@ -108,6 +108,7 @@
 	salary_slip = make_salary_slip(name)
 	salary_slip.insert()
 	salary_slip.submit()
+	frappe.db.commit()
 
 def make_sales_invoice_for_timesheet(name):
 	sales_invoice = make_sales_invoice(name)
@@ -117,7 +118,9 @@
 		'qty': 1,
 		'rate': 1000
 	})
+	sales_invoice.flags.ignore_permissions = 1
 	sales_invoice.set_missing_values()
 	sales_invoice.calculate_taxes_and_totals()
 	sales_invoice.insert()
-	sales_invoice.submit()
\ No newline at end of file
+	sales_invoice.submit()
+	frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py
index 12fad29..e7febd0 100644
--- a/erpnext/demo/user/projects.py
+++ b/erpnext/demo/user/projects.py
@@ -4,9 +4,11 @@
 from __future__ import unicode_literals
 
 import frappe
+from frappe.utils import flt
 from frappe.utils.make_random import can_make
 from frappe.utils.make_random import how_many, get_random
 from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
+from erpnext.demo.user.hr import make_sales_invoice_for_timesheet
 
 def run_projects(current_date):
 	frappe.set_user(frappe.db.get_global('demo_projects_user'))
@@ -19,9 +21,13 @@
 	for data in frappe.get_all("Task", ["name", "project"], {"status": "Open", "exp_end_date": ("<", current_date)}):
 		employee = get_random("Employee")
 		if frappe.db.get_value('Salary Structure', {'employee': employee}, 'salary_slip_based_on_timesheet'):
-			make_timesheet(employee, simulate = True, billable = 1, 
+			ts = make_timesheet(employee, simulate = True, billable = 1,
 				activity_type=get_random("Activity Type"), project=data.project, task =data.name)
 
+			if flt(ts.total_billing_amount) > 0.0:
+				make_sales_invoice_for_timesheet(ts.name)
+				frappe.db.commit()
+
 def close_tasks(current_date):
 	for task in frappe.get_all("Task", ["name"], {"status": "Open", "exp_end_date": ("<", current_date)}):
 		task = frappe.get_doc("Task", task.name)
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 6b36b46..10df143 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -4,9 +4,11 @@
 from __future__ import unicode_literals
 
 import frappe, random
+from frappe.utils import flt
 from frappe.utils.make_random import add_random_children, get_random
 from erpnext.setup.utils import get_exchange_rate
 from erpnext.accounts.party import get_party_account_currency
+from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry
 
 def work():
 	frappe.set_user(frappe.db.get_global('demo_sales_user_2'))
@@ -34,6 +36,19 @@
 		for i in xrange(random.randint(1,3)):
 			make_sales_order()
 
+	if random.random() < 0.1:
+		#make payment request against Sales Order
+		sales_order_name = get_random("Sales Order", filters={"docstatus": 1})
+		if sales_order_name:
+			so = frappe.get_doc("Sales Order", sales_order_name)
+			if flt(so.per_billed) != 100:
+				payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email,
+					submit_doc=True, mute_email=True, use_dummy_message=True)
+
+				payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
+				payment_entry.posting_date = frappe.flags.current_date
+				payment_entry.submit()
+
 def make_opportunity():
 	b = frappe.get_doc({
 		"doctype": "Opportunity",
diff --git a/erpnext/docs/assets/img/accounts/budget-account.png b/erpnext/docs/assets/img/accounts/budget-account.png
new file mode 100644
index 0000000..7c5544c
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/budget-account.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/budget-variance-report.png b/erpnext/docs/assets/img/accounts/budget-variance-report.png
index c7c3677..8828981 100644
--- a/erpnext/docs/assets/img/accounts/budget-variance-report.png
+++ b/erpnext/docs/assets/img/accounts/budget-variance-report.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/budget-warning.png b/erpnext/docs/assets/img/accounts/budget-warning.png
new file mode 100644
index 0000000..c4d4ba4
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/budget-warning.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/budgeting-cost-center.png b/erpnext/docs/assets/img/accounts/budgeting-cost-center.png
new file mode 100644
index 0000000..61d0175
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/budgeting-cost-center.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/monthly-budget-distribution.png b/erpnext/docs/assets/img/accounts/monthly-budget-distribution.png
new file mode 100644
index 0000000..3cc91cc
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/monthly-budget-distribution.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/monthly-distribution.png b/erpnext/docs/assets/img/accounts/monthly-distribution.png
deleted file mode 100644
index 0791c8b..0000000
--- a/erpnext/docs/assets/img/accounts/monthly-distribution.png
+++ /dev/null
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-1.png b/erpnext/docs/assets/img/accounts/payment-entry-1.png
new file mode 100644
index 0000000..b8e49c2
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-2.gif b/erpnext/docs/assets/img/accounts/payment-entry-2.gif
new file mode 100644
index 0000000..51941ee
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-2.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-3.png b/erpnext/docs/assets/img/accounts/payment-entry-3.png
new file mode 100644
index 0000000..5df04c6
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-3.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-4.gif b/erpnext/docs/assets/img/accounts/payment-entry-4.gif
new file mode 100644
index 0000000..785c8c8
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-4.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-5.gif b/erpnext/docs/assets/img/accounts/payment-entry-5.gif
new file mode 100644
index 0000000..66513f5
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-5.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-6.png b/erpnext/docs/assets/img/accounts/payment-entry-6.png
new file mode 100644
index 0000000..90541b6
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-6.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-7.png b/erpnext/docs/assets/img/accounts/payment-entry-7.png
new file mode 100644
index 0000000..2c8c71b
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-7.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-8.png b/erpnext/docs/assets/img/accounts/payment-entry-8.png
new file mode 100644
index 0000000..9ddfade
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-8.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/payment-entry-9.png b/erpnext/docs/assets/img/accounts/payment-entry-9.png
new file mode 100644
index 0000000..2a729ed
--- /dev/null
+++ b/erpnext/docs/assets/img/accounts/payment-entry-9.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/__init__.py b/erpnext/docs/assets/img/project/timesheet/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/__init__.py
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-billable.png b/erpnext/docs/assets/img/project/timesheet/timesheet-billable.png
new file mode 100644
index 0000000..85077d1
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-billable.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-billed.png b/erpnext/docs/assets/img/project/timesheet/timesheet-billed.png
new file mode 100644
index 0000000..8848d00
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-billed.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-capacity-planning.png b/erpnext/docs/assets/img/project/timesheet/timesheet-capacity-planning.png
new file mode 100644
index 0000000..d144b12
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-capacity-planning.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-cost.png b/erpnext/docs/assets/img/project/timesheet/timesheet-cost.png
new file mode 100644
index 0000000..f82c344
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-cost.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-invoice-1.png b/erpnext/docs/assets/img/project/timesheet/timesheet-invoice-1.png
new file mode 100644
index 0000000..da73fa7
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-invoice-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-1.png b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-1.png
new file mode 100644
index 0000000..db871b8
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-2.png b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-2.png
new file mode 100644
index 0000000..bcae5e3
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-3.gif b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-3.gif
new file mode 100644
index 0000000..07092c4
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-3.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-4.png b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-4.png
new file mode 100644
index 0000000..5d214ef
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-4.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-5.png b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-5.png
new file mode 100644
index 0000000..ac97a31
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-5.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-6.png b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-6.png
new file mode 100644
index 0000000..05b0958
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-production-order-6.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-project.gif b/erpnext/docs/assets/img/project/timesheet/timesheet-project.gif
new file mode 100644
index 0000000..c04b973
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-project.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-1.png b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-1.png
new file mode 100644
index 0000000..197751a
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-2.png b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-2.png
new file mode 100644
index 0000000..cfd3871
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-3.png b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-3.png
new file mode 100644
index 0000000..ba3c26d
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-3.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-4.gif b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-4.gif
new file mode 100644
index 0000000..18a5ecb
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-4.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-5.png b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-5.png
new file mode 100644
index 0000000..3031ad0
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-slip-5.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-salary-structure.png b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-structure.png
new file mode 100644
index 0000000..50a8e18
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-salary-structure.png
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-to-invoice.gif b/erpnext/docs/assets/img/project/timesheet/timesheet-to-invoice.gif
new file mode 100644
index 0000000..03efdc2
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-to-invoice.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/project/timesheet/timesheet-total.png b/erpnext/docs/assets/img/project/timesheet/timesheet-total.png
new file mode 100644
index 0000000..a70c049
--- /dev/null
+++ b/erpnext/docs/assets/img/project/timesheet/timesheet-total.png
Binary files differ
diff --git a/erpnext/docs/user/manual/en/accounts/budgeting.md b/erpnext/docs/user/manual/en/accounts/budgeting.md
index a9f92fb..fad128c 100644
--- a/erpnext/docs/user/manual/en/accounts/budgeting.md
+++ b/erpnext/docs/user/manual/en/accounts/budgeting.md
@@ -1,22 +1,49 @@
-In ERPNext, you can set and manage budgets against a Cost Center. This is useful when, for example, you are doing online sales. You have a budget for search ads, and you want ERPNext to stop or warn you from over spending, based on that budget.
+In ERPNext, you can set and manage Budgets against a specific Account. This is useful when, for example, you are doing online sales. You have a budget for search ads, and you want ERPNext to stop or warn you from over spending, based on that budget.
 
 Budgets are also great for planning purposes. When you are making plans for the next financial year, you would typically target a revenue based on which you would set your expenses. Setting a budget will ensure that your expenses do not get out of hand, at any point, as per your plans.
 
-To allocate budget, go to:
+In ERPNext, budget against an Account is defined via Cost Center. Following are the steps to define a Budget.
 
-> Accounts > Budget and Cost Center > Budget
+###Cost Center
 
-In the Budget form, you can select a Cost Center and for that cost center you can define budgets against any Expense / Income accounts. Budgets can be defined against any Cost Center whether it is a Group / Leaf node in the Chart of Cost Centers.
+To create new Cost Center, go to:
 
-<img class="screenshot" alt="Budget" src="{{docs_base_url}}/assets/img/accounts/budget.png">
+> Accounts > Budget and Cost Center > Chart of Cost Center > Add New Cost Center
+
+<img class="screenshot" alt="Budget" src="{{docs_base_url}}/assets/img/accounts/budgeting-cost-center.png">
+
+###Budgeting
+
+####Step 1: Create a new Budget
+
+To define a Budget, go to:
+
+> Accounts > Budget and Cost Center > Budget > New
+
+####Step 2: Select Cost Center
+
+In the Budget form, select a Cost Center. Budgets can be defined against any Cost Center whether it is a Group / Leaf node in the Chart of Cost Centers. 
+
+####Step 3: Select Account
+
+In the Budgets table, select Income / Expense account for which Budget is to be defined. 
+
+<img class="screenshot" alt="Budget" src="{{docs_base_url}}/assets/img/accounts/budget-account.png">
+
+####Step 4: Monthly Distribution
 
 If you have seasonal business, you can also define a Monthly Distribution record, to distribute the budget between months. If you don't set the monthly distribution, ERPNext will calculate the budget on yearly
 basis or in equal proportion for every month.
 
-<img class="screenshot" alt="Monthly Distribution" src="{{docs_base_url}}/assets/img/accounts/monthly-distribution.png">
+<img class="screenshot" alt="Monthly Distribution" src="{{docs_base_url}}/assets/img/accounts/monthly-budget-distribution.png">
+
+####Step 5: Alert on Budget
 
 While setting budget, you can also define the actions when expenses will exceed the allocated budget for a period. You can set separate action for monthly and annual budgets. There are 3 types of actions: Stop, Warn and Ignore. If Stop, system will not allow to book expenses more than allocated budget. In Case of Warn, it will just warn the user that expenses has been exceeded from the allocated budget. And Ignore will do nothing.
 
+<img class="screenshot" alt="Monthly Distribution" src="{{docs_base_url}}/assets/img/accounts/budget-warning.png">
+
+####Budget Variance Report
 
 At any point of time, user can check Budget Variance Report to analysis the expense vs budget against a cost center.
 
diff --git a/erpnext/docs/user/manual/en/accounts/index.txt b/erpnext/docs/user/manual/en/accounts/index.txt
index fcb7441..f06bb19 100644
--- a/erpnext/docs/user/manual/en/accounts/index.txt
+++ b/erpnext/docs/user/manual/en/accounts/index.txt
@@ -3,7 +3,7 @@
 purchase-invoice
 payment-request
 chart-of-accounts
-making-payments
+payment-entry
 advance-payment-entry
 payment-request
 credit-limit
diff --git a/erpnext/docs/user/manual/en/accounts/making-payments.md b/erpnext/docs/user/manual/en/accounts/making-payments.md
deleted file mode 100644
index 2038e6f..0000000
--- a/erpnext/docs/user/manual/en/accounts/making-payments.md
+++ /dev/null
@@ -1,98 +0,0 @@
-Payments made against Sales Invoices or Purchase Invoices can be made by
-clicking on “Make Payment Entry” button on “Submitted” invoices.
-
-  1. Update the “Bank Account” (you can also set the default account in the Company master).
-  2. Update posting date.
-  3. Enter the cheque number, cheque date.
-  4. Save and Submit.
-
-<img class="screenshot" alt="Manking Payment" src="{{docs_base_url}}/assets/img/accounts/make-payment.png">
-
-Payments can also be made independent of invoices by creating a new Journal
-Voucher and selecting the type of payment.
-
-#### Incoming Payment
-
-For payments from Customers,
-
-  * Debit: Bank or Cash Account
-  * Credit: Customer
-
-> Note: Remember to add “Against Sales Invoice” or “Is Advance” as applicable.
-
-#### Outgoing Payment
-
-For payments to Suppliers,
-
-  * Debit: Supplier
-  * Credit: Bank or Cash Account
-
-### Example Payment Journal Entry
-
-<img class="screenshot" alt="Manking Payment" src="{{docs_base_url}}/assets/img/accounts/new-bank-entry.png">
-
-* * *
-
-### Reconciling Cheque Payments
-
-If you are receiving payments or making payments via cheques, the bank
-statements will not accurately match the dates of your entry, this is because
-the bank usually takes time to “clear” these payments. Also you may have
-mailed a cheque to your Supplier and it may be a few days before it is
-received and deposited by the Supplier. In ERPNext you can synchronize your
-bank statements and your Journal Entrys using the “Bank Reconciliation”
-tool.
-
-To use this, go to:
-
-> Accounts > Tools > Bank Reconciliation
-
-Select your “Bank” Account and enter the dates of your statement. Here you
-will get all the “Bank Voucher” type entries. In each of the entry on the
-right most column, update the “Clearance Date” and click on “Update”.
-
-By doing this you will be able to sync your bank statements and entries into
-the system.
-
-* * *
-
-## Managing Outstanding Payments
-
-In most cases, apart from retail sales, billing and payments are separate
-activities. There are several combinations in which these payments are done.
-These cases apply to both sales and purchases.
-
-  * They can be upfront (100% in advance).
-  * Post shipment. Either on delivery or within a few days of delivery.
-  * Part in advance and part on or post delivery.
-  * Payments can be made together for a bunch of invoices.
-  * Advances can be given together for a bunch of invoices (and can be split across invoices).
-
-ERPNext allows you to manage all these scenarios. All accounting entries (GL
-Entry) can be made against a Sales Invoice, Purchase Invoice or Journal
-Vouchers (in special cases, an invoice can be made via a Sales Invoice too).
-
-The total outstanding amount against an invoice is the sum of all the
-accounting entries that are made “against” (or are linked to) that invoice.
-This way you can combine or split payments in Journal Entrys to manage the
-scenarios.
-
-### Matching Payments to Invoices
-
-In complex scenarios, especially in the capital goods industry, sometimes
-there is no direct link between payments and invoices. You send invoices to
-your Customers and your Customer sends you block payments or payments based on
-some schedule that is not linked to your invoices.
-
-In such cases, you can use the Payment to Invoice Matching Tool.
-
-> Accounts > Tools > Payment Reconciliation
-
-In this tool, you can select an account (your Customer’s account) and click on
-“Pull Payment Entries” and it will select all un-linked Journal Entrys and
-Sales Invoices from that Customer.
-
-To cancel off some payments and invoices, select the Invoices and Journal
-Vouchers and click on “Reconcile”.
-
-{next}
diff --git a/erpnext/docs/user/manual/en/accounts/payment-entry.md b/erpnext/docs/user/manual/en/accounts/payment-entry.md
new file mode 100644
index 0000000..62dd9b4
--- /dev/null
+++ b/erpnext/docs/user/manual/en/accounts/payment-entry.md
@@ -0,0 +1,109 @@
+Payment Entry can be made against following transactions.
+
+  1. Sales Invoice.
+  2. Purchase Invoice.
+  3. Sales Order (Advance Payment)
+  4. Purchase Order (Advance Payment)
+
+####Step 1: Make Payment
+
+On submitting a document against which Payment Entry can be made, you will find Make Payment button.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-1.png">
+
+####Step 2: Mode of Payment
+
+In the Payment Entry, select Mode of Payment (eg: Bank, Cash, Wire Transfer). In the Mode of Payment master, default Account can be set. This default payment Account will fetch into Payment Entry.
+
+<img class="screenshot" alt="Making Paymentt" src="{{docs_base_url}}/assets/img/accounts/payment-entry-2.gif">
+
+####Step 3: Payment Amount
+
+Enter actual payment amount received from the Customer or paid to the Supplier.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-3.png">
+
+####Step 4: Allocate Amount
+
+If creating Payment Entry for the Customer, Payment Amount will be allocated against Sales Invoice.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-4.gif">
+
+On the same lines, when creating Payment Entry for a Supplier, Payment Amount will be allocated against Purchase Invoice.
+
+You Entry can be created directly from `Account > Payment Entry > New`. In the new entry, on selection of the Party (Customer/Supplier), all the outstanding Invoices and open Orders will be fetched for party. The Payment Amount will be auto-allocated, preferably against invoice.
+
+####Step 5: Deductions
+
+When making payment entry, there could be some difference in the actual payment amount and the invoice outstanding. This difference could be due to rounding error, or change in the currency exchange rate. You can set an Account here where this difference amount will be booked.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-5.gif">
+
+####Step 6: Submit
+
+Save and Submit Payment Entry. On submission, outstanding will be updated in the Invoices. 
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-8.png">
+
+If payment entry was created against Sales Order or Purchase Order, field Advance Paid will be updated in them. when creating Payment invoice against those transactions, Payment Entry will auto-update in that Invoice, so that you can allocate invoice amount against advance payment entry.
+
+For incoming payment, accounts posting will be done as following.
+
+  * Debit: Bank or Cash Account
+  * Credit: Customer (Debtor)
+
+For outgoing payment:
+
+  * Debit: Supplier (Creditor)
+  * Credit: Bank or Cash Account
+
+###Multi Currency Payment Entry
+
+ERPNext allows you maintain accounts and invoicing in the [multiple currency]({{docs_base_url}}/user/manual/en/accounts/multi-currency-accounting.html). If invoice is made in the party currency, Currency Exchange Rate between companies base currency and party currency is also entered in the invoice. When creating Payment Entry against that invoice, you will again have to mention the Currency Exchange Rate at the time of payment.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-6.png">
+
+Since Currency Exchange Rate is fluctuating all the time, it can lead to difference in the payment amount against invoice total. This difference amount can be booked in the Currency Exchange Gain/Loss Amount.
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-7.png">
+
+Payments can also be made independent of invoices by creating a new Payment Entry.
+
+###Internal Intransfer
+
+Following internal transfers can be managed from the Payment Entry.
+
+1. Bank - Cash
+2. Cash - Bank
+3. Cash - Cash
+4. Bank - Bank
+
+<img class="screenshot" alt="Making Payment" src="{{docs_base_url}}/assets/img/accounts/payment-entry-9.png">
+
+###Difference between Payment Entry and Journal Entry?
+
+ 1. Journal Entry requires understanding of which Account will get Debited or Credited. In the Payment Entry, it is managed in the backend, hence simpler for the User.
+ 2. Payment Entry is more efficient in managing payment in the foreign currency.
+ 3. Journal Entry can still be used for:
+	- Updating opening balance in an Accounts.
+	- Fixed Asset Depreciation entry.
+	- For adjusting Credit Note against Sales Invoice and Debit Note against Purchase Invoice, incase there is no payment happening at all.
+
+* * *
+
+## Managing Outstanding Payments
+
+In most cases, apart from retail sales, billing and payments are separate activities. There are several combinations in which these payments are done. These cases apply to both sales and purchases.
+
+  * They can be upfront (100% in advance).
+  * Post shipment. Either on delivery or within a few days of delivery.
+  * Part in advance and part on or post delivery.
+  * Payments can be made together for a bunch of invoices.
+  * Advances can be given together for a bunch of invoices (and can be split across invoices).
+
+ERPNext allows you to manage all these scenarios. All accounting entries (GL Entry) can be made against a Sales Invoice, Purchase Invoice or Payment Entry of advance payment (in special cases, an invoice can be made via a Sales Invoice too).
+
+The total outstanding amount against an invoice is the sum of all the accounting entries that are made “against” (or are linked to) that invoice. This way you can combine or split payments in Payment Entry to manage the
+scenarios.
+
+{next}
diff --git a/erpnext/docs/user/manual/en/accounts/tools/bank-reconciliation.md b/erpnext/docs/user/manual/en/accounts/tools/bank-reconciliation.md
index f2afe76..8df8201 100644
--- a/erpnext/docs/user/manual/en/accounts/tools/bank-reconciliation.md
+++ b/erpnext/docs/user/manual/en/accounts/tools/bank-reconciliation.md
@@ -1,36 +1,33 @@
 ### Bank Reconciliation Statement
 
-A Bank Reconciliation is a process that explains the difference between the
-bank balance shown in an organisation's bank statement, as supplied by the
-bank, and the corresponding amount shown in the organisation's own accounting
-records at a particular point in time.  
+If you are receiving payments or making payments via cheques, the bank statements will not accurately match the dates of your entry, this is because the bank usually takes time to “clear” these payments. Also you may have
+mailed a cheque to your Supplier and it may be a few days before it is received and deposited by the Supplier. In ERPNext you can synchronise your bank statements and your Journal Entrys using the “Bank Reconciliation”
+tool.
 
-Such differences may occur, for example, because a cheque or a list of cheques
-issued by the organisation has not been presented to the bank, a banking
-transaction, such as a credit received, or a charge made by the bank, has not
-yet been recorded in the organisations books, or either the bank or the
-organisation itself has made an error.
+The Bank Reconciliation Report provide the difference between the bank balance shown in an organisation's bank statement, as provided by the ban against amount shown in the companies Chart of Accounts.
 
-The Bank Reconciliation statement in ERPNext comes in the form of a report.
-
-#### Figure 1: Bank Reconciliation Statement
+####Bank Reconciliation Statement
 
 ![]({{docs_base_url}}/assets/old_images/erpnext/bank-reconciliation-2.png)  
 
-  
+In the report, check whether the field 'Balance as per bank' matches the Bank Account Statement. If it is matching, it means that Clearance Date is correctly updated for all the bank entries. If there is a mismatch, Its because of bank entries for which Cleanrane Date is not yet updated.
 
-When you get the report, check whether the field 'Balance as per bank' matches
-the Bank Account Statement. If there is a match then all the clearance dates
-are updated. If there is a mismatch then check clearance dates and journal
-entries.
+To add clearance entries go to:
 
-To add clearance entries go to Accounts > Tools > Bank Reconciliation
+> Accounts > Tools > Bank Reconciliation
 
-### Bank Reconciliation Tool
+###Bank Reconciliation Tool
 
-The Bank Reconciliation tool in ERPNext, helps add clearance dates to the
-account statements. To Reconcile cheque payments go to Accounts and click on
-Bank Reconciliation.  
+o use this, go to:
+
+> Accounts > Tools > Bank Reconciliation
+
+Select your “Bank” Account and enter the dates of your statement. Here you
+will get all the “Bank Voucher” type entries. In each of the entry on the
+right most column, update the “Clearance Date” and click on “Update”.
+
+By doing this you will be able to sync your bank statements and entries into
+the system.
 
 __Step 1:__ Select the Bank Account against which you intend to reconcile. For
 example; HDFC Bank, ICICI Bank, or Citibank etc.
@@ -43,8 +40,6 @@
 
 __Step 4:__ Click on the JV from the table and update clearance date.
 
-#### Figure 2: Bank Reconciliation Tool
-
 <img class="screenshot" alt="Bank Reconciliation" src="{{docs_base_url}}/assets/img/accounts/bank-reconciliation.png">
 
 __Step 5:__ Click on the button 'Update Clearance Date'.
diff --git a/erpnext/docs/user/manual/en/accounts/tools/payment-reconciliation.md b/erpnext/docs/user/manual/en/accounts/tools/payment-reconciliation.md
index c719623..bac6f65 100644
--- a/erpnext/docs/user/manual/en/accounts/tools/payment-reconciliation.md
+++ b/erpnext/docs/user/manual/en/accounts/tools/payment-reconciliation.md
@@ -1,24 +1,21 @@
-Reconciliation is an accounting process used to compare two sets of records to
-ensure the figures are in agreement and are accurate. It is the key process
-used to determine whether the money leaving an account matches the amount
-spent, ensuring the two values are balanced at the end of the recording
-period. In Payment Reconciliation, the invoices are matched against the
-payments made to the bank. Thus if you have many payments which are not
-reconciled with their respective invoices, you can use the payment
-reconciliation tool.
+In complex scenarios, especially in the capital goods industry, sometimes there is no direct link between payments and invoices. You send invoices to your Customers and your Customer sends you block payments or payments based on some schedule that is not linked to your invoices.
 
-To use Payment Reconciliation Tool go to,
+In such cases, you can use the Payment to Invoice Matching Tool.
 
-Accounts > Tools > Payment Reconciliation
+> Accounts > Tools > Payment Reconciliation
+
+In this tool, you can select an account (your Customer’s account) and click on “Pull Payment Entries” and it will select all un-linked Payment Entry and Sales Invoices from that Customer.
+
+To cancel off some payments and invoices, select the Invoices and Journal Vouchers and click on “Reconcile”.
 
 <img class="screenshot" alt="Payment Reconciliation" src="{{docs_base_url}}/assets/img/accounts/payment-reconcile-tool.png">
 
 __Step 1:__ Select the Account against whom the payments need to be reconciled.
 
 __Step 2:__ Mention the Voucher Type, whether it is Purchase Invoice, Sales
-Invoice or Journal Entry.
+Invoice or Payment Entry.
 
-__Step 3:__ Select the Voucher Number and click on 'Get Unreconcilled Entries'.  
+__Step 3:__ Select the Voucher Number and click on 'Get Unreconciled Entries'.  
 
 * All the payment entries will be pulled into a table below.
 
diff --git a/erpnext/docs/user/manual/en/projects/index.txt b/erpnext/docs/user/manual/en/projects/index.txt
index f2bae77..2f450ac 100644
--- a/erpnext/docs/user/manual/en/projects/index.txt
+++ b/erpnext/docs/user/manual/en/projects/index.txt
@@ -1,7 +1,7 @@
 tasks
 project
-time-log
 time-log-batch
 activity-type
 activity-cost
 articles
+timesheet
diff --git a/erpnext/docs/user/manual/en/projects/time-log.md b/erpnext/docs/user/manual/en/projects/time-log.md
deleted file mode 100644
index 5d4c4a3..0000000
--- a/erpnext/docs/user/manual/en/projects/time-log.md
+++ /dev/null
@@ -1,49 +0,0 @@
-Time Logs are a way to track time worked.
-They can be used to track the following
-
-* Billable work to Customers
-* Production Order Operations
-* Tasks
-* Project
-* Internal References
-
-<img class="screenshot" alt="Time Log" src="{{docs_base_url}}/assets/img/project/time_log.png">
-
-###Creating Time Logs
-
-1. To create a new Time Log, you can go to 
-> Projects > Time Log > new Time Log
-
-2. You can also create a new Time Log via Calendar
-
-To create Time Logs via Calender, go to Time Log and select Calendar.
-
-<img class="screenshot" alt="Time Log - View Calender" src="{{docs_base_url}}/assets/img/project/time_log_view_calendar.png">
-
-* To create a Time Log for multiple days, click and drag the cursor across days.
-
-<img class="screenshot" alt="Time Log - Drag Calender" src="{{docs_base_url}}/assets/img/project/time_log_calendar_day.gif">
-
-* You can also create Time Logs from 'week' and 'day' view of the calender.
-
-<img class="screenshot" alt="Time Log - Drag Calender" src="{{docs_base_url}}/assets/img/project/time_log_calendar_week.gif">
-
-* Time Logs for Manufacturing processes needs to be created from the Production Order. 
-* To create more Time Logs against Operations select the respective operation and click on the 'Make Time Log' button.
-
-###Billing using Time Logs
-
-* If you wish to bill against a Time Log you need to select the 'Billable' option.
-
-* In the costing section, the system will pull up the Costing & Billing rate from [Activity Cost]({{docs_base_url}}/user/manual/en/projects/activity-cost.html) 
-	based on the Employee and Activity Type specified.
-
-* The system shall then calculate the Costing and Billing amount based on the Hours mentioned in the Time Log.
-
-* If 'Billable' is not selected, the system shall display the 'Billing Amount' as 0.
-
-<img class="screenshot" alt="Time Log - Costing" src="{{docs_base_url}}/assets/img/project/time_log_costing.png">
-
-* After submitting the Time Log, you need to create [Time Log batch]({{docs_base_url}}/user/manual/en/projects/time-log-batch.html) to further bill the Time Log.
-
-{next}
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/__init__.py b/erpnext/docs/user/manual/en/projects/timesheet/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/__init__.py
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/index.md b/erpnext/docs/user/manual/en/projects/timesheet/index.md
new file mode 100644
index 0000000..7a80ab7
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/index.md
@@ -0,0 +1,12 @@
+Timesheet can be used for track actual hours worked. It can be used for multiple purposes like:
+
+* Billable work to Customers
+* Production Order Operations
+* Creating Salary Slip based on hours worked.
+* Tasks
+* Project
+* Internal References
+
+### Topics
+
+{index}
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/index.txt b/erpnext/docs/user/manual/en/projects/timesheet/index.txt
new file mode 100644
index 0000000..47d5ea1
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/index.txt
@@ -0,0 +1,3 @@
+salary-slip-from-timesheet
+sales-invoice-from-timesheet
+timesheet-against-production-order
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/salary-slip-from-timesheet.md b/erpnext/docs/user/manual/en/projects/timesheet/salary-slip-from-timesheet.md
new file mode 100644
index 0000000..32faf03
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/salary-slip-from-timesheet.md
@@ -0,0 +1,47 @@
+#Salary Slip from Timesheet
+
+If salary / wages for your employees are calculated based on number of hours worked, you can use Timesheet to track actual hours worked, and for creating Salary Slip.
+
+####Employee creates Timesheet
+
+To track actual hours employee has worked for, create Timesheet for each Employee. We suggest you to create Timesheet based on a payment period. For example, if you paying employee on a weekly bases, create one Timesheet for an Employee for one week. However, you can create multiple Timesheets, and create one Salary Slip for the multiple Timesheets.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-slip-1.png">
+
+####Salary Structure for the Employee
+
+In the Salary Structure of the Employee, check field "Salary Slip Based on Timesheet". On checking this field, you see fields Salary Component and Hour Rate. Amount for that Salary Component (say Basic) will be calculated based on:
+
+<div class=well> Total Timesheet Hours *  Hour Rate </div>
+
+Amount directly for other Salary Components (eg: House Rent Allowance, Phone Allowance) can be define directly. When creating Salary Slip, Amount for these Salary Component will be fetched as it is.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-slip-2.png">
+
+####Create Salary Slip from Timesheet
+
+To create Salary Slip against Timesheet, open Timesheet and click on "Salary Slip".
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-slip-3.png">
+
+In the Salary Slip, Timesheet ID will be updated. You can select more Timesheet to be paid via this Salary Slip. Based on the Timesheets selected, Total Working Hours will be calculated.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-slip-4.gif">
+
+Hour Rate will be fetched from the Salary Structure of an Employee. Based on Total Working Hours and Hour Rate, Amount will be calculated for the Salary Component is to be calculated based on actual hours worked.
+
+####Save and Submit Salary Slip
+
+On Submission of Salary Slip, Timesheet's status will be updated to "Payslip".
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-slip-5.png">
+
+<div class=well> 
+
+Creating Salary Slip based on Timesheet will allow you to manage payment for the overtime.
+	<ol>
+		<li>Employee created Timesheet for the overtime.</li>
+		<li>In the Salary Structure of an Employee, set Overtime as a Salary Component to be calculated based on hourly bases.</li>
+		<li>When creating Salary Structure for an Employee, pull Timesheet when overtime details are tracked.</li>
+	</ol>
+</div>
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/sales-invoice-from-timesheet.md b/erpnext/docs/user/manual/en/projects/timesheet/sales-invoice-from-timesheet.md
new file mode 100644
index 0000000..383a881
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/sales-invoice-from-timesheet.md
@@ -0,0 +1,68 @@
+#Sales Invoice from Timesheet
+
+Customer can be invoiced based on total no. of hours your Employees has worked for that Customer. Timesheet can be used to track actual no. of hours Employee has worked. For example, in the IT services domain, clients are billed based on man-hour bases, where per hour billing cost is pre-determined.s
+
+###Timesheet
+
+####Step 1: Create new Timesheet
+
+To create new Timesheet, go to:
+
+`Project > Timesheet > New`
+
+#### Step 2: Select Employee
+
+In the Employee field, only ones having ative Salary Structure will be selectable. Further in the Salary Structure , is created for the E on the actual hours worked, Employee can create Timesheet. To be able to create Sales Invoice against this Timesheet, ensure `Billable` field is checked.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-salary-structure.png">
+
+#### Step 3:Activity Type
+
+Employee will have to select an Activity Type (like planning, site visit, repairing etc. ). Costing and Billing Rate for each Activity can be different for each Employee. These cost can be tracked in the Activity Cost. On selection of Activity Type, Activity Cost is fetched from that Employee. Based on total Activity Cost and total no. of hours, Total Billing Amount (to the Customer) is calculated.
+
+To learn more on how to setup Activity Type and Activity Cost, click [here]({{docs_base_url}}/user/manual/en/projects/articles/project-costing).
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-cost.png">
+
+#### Step 4: Enter Actual Time
+
+In the Timesheet Details table, enter actual hours an Employee has worked for. One Timesheet can be used for multiple days as well.
+
+To be able to create Sales Invoice from the Time Sheet, ensure 'Is Billable' field is checked.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project//timesheet/timesheet-billable.png">
+
+Based on the actual hours worked and Activity Cost of an Employee, Total Billing Amount will be calculated for Timesheet.
+
+#### Step 5: Save and Submit
+
+After submitting Timesheet, you will find buttons to create Sales Invoice and Salary Slip against this Timesheet.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets//img/project/timesheet/timesheet-total.png">
+
+###Create Sales Invoice from Timesheet
+
+#### Submitted Timesheet
+
+In the Timesheet, if "Is Billable" is checked, you will find option to create Sales Invoice against it.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-invoice-1.png">
+
+####Sales Invoice
+
+Sales Invoice has dedicated table for the Timesheet table where Timesheet details will be updated. You can select more Timesheets in this table.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-to-invoice.gif">
+
+
+####Select Customer and Item
+
+Select Customer to be billed. Select an Item, and enter rate as the billing amount.
+
+####Save
+
+After enter all required details in the Sales Invoice, Save and Submit it.
+
+On submitting Sales Invoice, status of the Timesheets linked to the Sales Invoice will be updated as Billed.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-billed.png">
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-production-order.md b/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-production-order.md
new file mode 100644
index 0000000..6e108b3
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-production-order.md
@@ -0,0 +1,39 @@
+#Timesheet based on Production Order
+
+Creating Timesheet for Production Order helps in capacity planning for the Workstations. Also it helps in tracking actual time consumed the Workstation for completing specific operation.
+
+When a Production Order is submitted, based on the Planned Start Date and the availability of the Workstations, system schedules all operations by creating Timesheet.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-capacity-planning.png">
+
+Let's assume we are manufacturing a mobile phone. As per the Bill of Material, time required for the assembly of components could be one hour. However the actual time taken for it's completion could be more than planned. The actual time tracking provides actual operation cost, hence helps in determining accurate valuation of the manufacturing item.
+
+####Production Order
+
+As per the Bill of Materials of manufacturing item, following are the Operations and Workstation through which raw-material items are processed.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-1.png">
+
+On submission on Production Order, Timesheet will be created automatically.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-2.png">
+
+####Time Sheet created from Production Order
+
+In the Timesheet, unique row will be added for each Operation - Workstation. This allows operator/supervisor at the workstation to enter actual From Time and To Time taken for each Operation.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-3.gif">
+
+After enter From Time and To Time for all the Operations, Total Hours will be calculated.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-6.png">
+
+With updating actual time, you can also enter "Completed Qty". If all the items are not processed in the same Timesheet, you can create another Timesheet from the Production Order.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-4.png">
+
+####Save and Submit Timesheet
+
+On the submission of Timesheet, Total Hours is calculated. Also, in the Production Order, for each Operation, actual Start and End Time is updated.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-production-order-5.png">
diff --git a/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-project.md b/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-project.md
new file mode 100644
index 0000000..7460a4b
--- /dev/null
+++ b/erpnext/docs/user/manual/en/projects/timesheet/timesheet-against-project.md
@@ -0,0 +1,17 @@
+#Timesheet against Project and Task
+
+Timesheets can be tracked against Project and Tasks so that you can get reports on how much time was spent on each Task or Project.
+
+<img class="screenshot" alt="Sales Invoice" src="{{docs_base_url}}/assets/img/project/timesheet/timesheet-project.gif">
+
+####Billable Timesheet
+
+To bill Customer based on Timesheet, check "Is Billable" in the Timesheet created against Project and Task. To learn more about billing Customer from Timesheet, click [here]({{docs_base_url}}/user/manual/en/projects/timesheet/sales-invoice-from-timesheet.html).
+
+####Project Costing
+
+When creating Timesheet, Employee will have to select an Activity Type. For each Activity Type, you can create an Activity Cost master. In the Activity Cost, Billing Rate and Costing rate is defined for each Employee. 
+
+In the Timesheet, costing will be done based on Activity Cost multiplied with number of hours. Based the Timesheet Cost, total costing will be doen for the Task and Project as well.
+
+To learn about setup of Activity Type and Activity Cost, click [here]({{docs_base_url}}/user/manual/en/projects/articles/project-costing).
\ No newline at end of file
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index fd188bc..82d23de 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -158,6 +158,9 @@
 
 	"Website Settings": {
 		"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
+	},
+	"Payment Entry": {
+		"on_submit": "erpnext.accounts.doctype.payment_request.payment_request.make_status_as_paid"
 	}
 }
 
diff --git a/erpnext/hr/doctype/employment_type/employment_type.json b/erpnext/hr/doctype/employment_type/employment_type.json
index 5bd58d4..3b9604d 100644
--- a/erpnext/hr/doctype/employment_type/employment_type.json
+++ b/erpnext/hr/doctype/employment_type/employment_type.json
@@ -3,11 +3,13 @@
  "allow_import": 1, 
  "allow_rename": 1, 
  "autoname": "field:employee_type_name", 
+ "beta": 0, 
  "creation": "2013-01-10 16:34:14", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Setup", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -17,6 +19,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Employment Type", 
@@ -26,6 +29,7 @@
    "oldfieldtype": "Data", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -38,13 +42,14 @@
  "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": "2015-11-16 06:29:46.733350", 
+ "modified": "2016-07-22 05:34:43.238512", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employment Type", 
@@ -91,6 +96,9 @@
    "write": 1
   }
  ], 
+ "quick_entry": 1, 
  "read_only": 0, 
- "read_only_onload": 0
+ "read_only_onload": 0, 
+ "sort_order": "DESC", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/update_home_page.py b/erpnext/patches/v7_0/update_home_page.py
index 604d7d4..7bc7a2e 100644
--- a/erpnext/patches/v7_0/update_home_page.py
+++ b/erpnext/patches/v7_0/update_home_page.py
@@ -5,6 +5,8 @@
 	frappe.reload_doc('portal', 'doctype', 'homepage_featured_product')
 	frappe.reload_doc('portal', 'doctype', 'homepage')
 	frappe.reload_doc('portal', 'doctype', 'products_settings')
+	frappe.reload_doctype('Item')
+	frappe.reload_doctype('Item Group')
 
 	website_settings = frappe.get_doc('Website Settings', 'Website Settings')
 	if frappe.db.exists('Web Page', website_settings.home_page):
diff --git a/erpnext/schools/doctype/course/course.json b/erpnext/schools/doctype/course/course.json
index f3d82e6..ab73dcb 100644
--- a/erpnext/schools/doctype/course/course.json
+++ b/erpnext/schools/doctype/course/course.json
@@ -9,6 +9,7 @@
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -64,6 +65,55 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "column_break_3", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "course_abbreviation", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Course Abbreviation", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "department", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -90,6 +140,30 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "section_break_6", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "course_intro", 
    "fieldtype": "Text Editor", 
    "hidden": 0, 
@@ -123,7 +197,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-18 10:30:50.243271",
+ "modified": "2016-07-22 06:02:14.586594", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Course", 
diff --git a/erpnext/schools/doctype/program/program.json b/erpnext/schools/doctype/program/program.json
index 8041f61..279430d 100644
--- a/erpnext/schools/doctype/program/program.json
+++ b/erpnext/schools/doctype/program/program.json
@@ -9,6 +9,7 @@
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -64,6 +65,31 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "program_abbreviation", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Program Abbreviation", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -216,6 +242,7 @@
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
@@ -223,7 +250,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-18 10:30:50.243271",
+ "modified": "2016-07-22 05:35:14.470843", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Program", 
diff --git a/erpnext/schools/doctype/student_batch/__init__.py b/erpnext/schools/doctype/student_batch/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch/__init__.py
diff --git a/erpnext/schools/doctype/student_batch/student_batch.js b/erpnext/schools/doctype/student_batch/student_batch.js
new file mode 100644
index 0000000..73d4faa
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch/student_batch.js
@@ -0,0 +1,10 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Student Batch', {
+	refresh: function(frm) {
+
+	}
+});
+
+cur_frm.add_fetch("student", "title", "student_name");
diff --git a/erpnext/schools/doctype/student_batch/student_batch.json b/erpnext/schools/doctype/student_batch/student_batch.json
new file mode 100644
index 0000000..a806ae3
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch/student_batch.json
@@ -0,0 +1,237 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "", 
+ "beta": 0, 
+ "creation": "2016-07-21 15:49:53.776461", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "student_batch_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Student Batch Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "academic_year", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Academic Year", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Academic Year", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "program", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Program", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Program", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "academic_term", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Academic Term", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Academic Term", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "section_break_8", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "students", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Students", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Batch Student", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2016-07-22 09:19:51.141234", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Batch", 
+ "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": "Academics User", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "title_field": "", 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_batch/student_batch.py b/erpnext/schools/doctype/student_batch/student_batch.py
new file mode 100644
index 0000000..7c7568d
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch/student_batch.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+from erpnext.schools.utils import validate_duplicate_student
+import frappe
+
+class StudentBatch(Document):
+	def validate(self):
+		validate_duplicate_student(self.students)
+		prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation")
+		if not prog_abb:
+			prog_abb = self.program
+		self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_batch/test_student_batch.py b/erpnext/schools/doctype/student_batch/test_student_batch.py
new file mode 100644
index 0000000..55796ee
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch/test_student_batch.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+# test_records = frappe.get_test_records('Student Batch')
+
+class TestStudentBatch(unittest.TestCase):
+	pass
diff --git a/erpnext/schools/doctype/student_batch_student/__init__.py b/erpnext/schools/doctype/student_batch_student/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch_student/__init__.py
diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.json b/erpnext/schools/doctype/student_batch_student/student_batch_student.json
new file mode 100644
index 0000000..c9b1b01
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.json
@@ -0,0 +1,113 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-07-22 03:27:20.120023", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "student", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Student", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "student_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Student Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 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-22 03:27:52.913126", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Batch Student", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.py b/erpnext/schools/doctype/student_batch_student/student_batch_student.py
new file mode 100644
index 0000000..542f3c4
--- /dev/null
+++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, 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 StudentBatchStudent(Document):
+	pass
diff --git a/erpnext/schools/doctype/student_group/student_group.json b/erpnext/schools/doctype/student_group/student_group.json
index 38a7747..b2c1157 100644
--- a/erpnext/schools/doctype/student_group/student_group.json
+++ b/erpnext/schools/doctype/student_group/student_group.json
@@ -2,33 +2,37 @@
  "allow_copy": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
- "autoname": "field:group_name", 
+ "autoname": "", 
+ "beta": 0, 
  "creation": "2015-09-07 12:55:52.072792", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Document", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "group_name", 
-   "fieldtype": "Data", 
+   "fieldname": "student_batch", 
+   "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Group Name", 
+   "label": "Student Batch", 
    "length": 0, 
    "no_copy": 0, 
+   "options": "Student Batch", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
@@ -41,6 +45,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Academic Term", 
@@ -66,6 +71,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Academic Year", 
@@ -91,6 +97,7 @@
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -114,6 +121,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Program", 
@@ -139,6 +147,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Course", 
@@ -165,6 +174,7 @@
    "fieldtype": "Int", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Max Strength", 
@@ -190,6 +200,7 @@
    "fieldtype": "Section Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Students", 
@@ -214,6 +225,7 @@
    "fieldtype": "Table", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Students", 
@@ -239,6 +251,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Amended From", 
@@ -259,6 +272,7 @@
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
@@ -266,7 +280,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-18 10:30:50.243271",
+ "modified": "2016-07-22 06:12:10.092544", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Group", 
@@ -314,11 +328,12 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "search_fields": "program, course", 
  "sort_field": "modified", 
  "sort_order": "DESC", 
- "title_field": "group_name", 
- "version": 0
+ "title_field": "", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_group/student_group.py b/erpnext/schools/doctype/student_group/student_group.py
index 0acbed9..3cd9bfb 100644
--- a/erpnext/schools/doctype/student_group/student_group.py
+++ b/erpnext/schools/doctype/student_group/student_group.py
@@ -6,12 +6,32 @@
 import frappe
 from frappe.model.document import Document
 from frappe import _
+from erpnext.schools.utils import validate_duplicate_student
 
 class StudentGroup(Document):
 	def validate(self):
+		self.set_name()
 		self.validate_strength()
 		self.validate_student_name()
-		
+		validate_duplicate_student(self.students)
+	
+	def set_name(self):
+		self.name = frappe.db.get_value("Course", self.course, "course_abbreviation")
+		if not self.name:
+			self.name = self.course
+		if self.student_batch:
+			self.name += "-" + self.student_batch
+		else:
+			prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation")
+			if not prog_abb:
+				prog_abb = self.program
+			if prog_abb:
+				self.name += "-" + prog_abb
+			if self.academic_year:
+				self.name += "-" + self.academic_year
+		if self.academic_term:
+			self.name += "-" + self.academic_term
+
 	def validate_strength(self):
 		if self.max_strength and len(self.students) > self.max_strength:
 			frappe.throw(_("""Cannot enroll more than {0} students for this student group.""").format(self.max_strength))
@@ -19,3 +39,5 @@
 	def validate_student_name(self):
 		for d in self.students:
 			d.student_name = frappe.db.get_value("Student", d.student, "title")
+	
+	
\ No newline at end of file
diff --git a/erpnext/schools/utils.py b/erpnext/schools/utils.py
index c7e92c2..3adbae4 100644
--- a/erpnext/schools/utils.py
+++ b/erpnext/schools/utils.py
@@ -42,3 +42,12 @@
 		}, as_dict=True)
 
 	return existing[0] if existing else None
+	
+def validate_duplicate_student(students):
+	unique_students= []
+	for stud in students:
+		if stud.student in unique_students:
+			frappe.throw(_("Student {0} - {1} appears Multiple times in row {2} & {3}")
+				.format(stud.student, stud.student_name, unique_students.index(stud.student)+1, stud.idx))
+		else:
+			unique_students.append(stud.student)
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 66f6b71..3699595 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -3,11 +3,13 @@
  "allow_import": 1, 
  "allow_rename": 0, 
  "autoname": "naming_series:", 
+ "beta": 0, 
  "creation": "2013-06-18 12:39:59", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Document", 
+ "editable_grid": 1, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -716,6 +718,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "currency", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Currency", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "currency", 
+   "oldfieldtype": "Select", 
+   "options": "Currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0, 
+   "width": "100px"
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "description": "Rate at which customer's currency is converted to company's base currency", 
    "fieldname": "conversion_rate", 
    "fieldtype": "Float", 
@@ -745,34 +775,6 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "currency", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Currency", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "currency", 
-   "oldfieldtype": "Select", 
-   "options": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0, 
-   "width": "100px"
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
    "fieldname": "column_break2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -2989,13 +2991,14 @@
  "hide_toolbar": 0, 
  "icon": "icon-file-text", 
  "idx": 105, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-04-14 12:34:16.220066", 
+ "modified": "2016-07-21 17:24:25.306923", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Sales Order", 
@@ -3122,6 +3125,7 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 1, 
  "search_fields": "status,transaction_date,customer,customer_name, territory,order_type,company", 
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 2ab40c5..e2aa274 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -11,6 +11,7 @@
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Setup", 
+ "editable_grid": 1, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -305,7 +306,7 @@
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
-   "depends_on": "eval:(doc.__islocal&&doc.is_stock_item)", 
+   "depends_on": "eval:(doc.__islocal&&doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no)", 
    "fieldname": "opening_stock", 
    "fieldtype": "Int", 
    "hidden": 0, 
@@ -331,7 +332,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:(doc.__islocal && doc.is_stock_item && doc.opening_stock)", 
+   "depends_on": "eval:(doc.__islocal && doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no && doc.opening_stock)", 
    "fieldname": "valuation_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -2307,7 +2308,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2016-07-06 17:00:45.561349", 
+ "modified": "2016-07-21 18:44:10.230372", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index de5d545..cedfb24 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -118,6 +118,9 @@
 
 	def set_opening_stock(self):
 		'''set opening stock'''
+		if not self.is_stock_item or self.has_serial_no or self.has_batch_no:
+			return
+		
 		if not self.valuation_rate:
 			frappe.throw(_("Valuation Rate is mandatory if Opening Stock entered"))
 
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 62ae091..28817cc 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -79,7 +79,7 @@
 
 				// stop
 				cur_frm.add_custom_button(__('Stop'),
-					cur_frm.cscript['Stop Material Request'], __("Status"));
+					cur_frm.cscript['Stop Material Request']);
 
 			}
 		}
@@ -102,7 +102,7 @@
 
 		if(doc.docstatus == 1 && doc.status == 'Stopped')
 			cur_frm.add_custom_button(__('Re-open'),
-				cur_frm.cscript['Unstop Material Request'], __("Status"));
+				cur_frm.cscript['Unstop Material Request']);
 
 	},
 
diff --git a/erpnext/stock/doctype/material_request/material_request_dashboard.py b/erpnext/stock/doctype/material_request/material_request_dashboard.py
index da6790d..8547df1 100644
--- a/erpnext/stock/doctype/material_request/material_request_dashboard.py
+++ b/erpnext/stock/doctype/material_request/material_request_dashboard.py
@@ -1,7 +1,6 @@
 from frappe import _
 
 data = {
-	'docstatus': 1,
 	'fieldname': 'material_request',
 	'transactions': [
 		{
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 9ed005e..e35f3d2 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -49,7 +49,7 @@
 		self.validate_batch()
 
 		self.set_actual_qty()
-		self.calculate_rate_and_amount()
+		self.calculate_rate_and_amount(update_finished_item_rate=False)
 
 	def on_submit(self):
 		self.update_stock_ledger()
@@ -237,18 +237,20 @@
 		self.set_actual_qty()
 		self.calculate_rate_and_amount()
 
-	def calculate_rate_and_amount(self, force=False):
-		self.set_basic_rate(force)
+	def calculate_rate_and_amount(self, force=False, update_finished_item_rate=True):
+		self.set_basic_rate(force, update_finished_item_rate)
 		self.distribute_additional_costs()
 		self.update_valuation_rate()
 		self.set_total_incoming_outgoing_value()
 		self.set_total_amount()
 
-	def set_basic_rate(self, force=False):
+	def set_basic_rate(self, force=False, update_finished_item_rate=True):
 		"""get stock and incoming rate on posting date"""
 		raw_material_cost = 0.0
+		fg_basic_rate = 0.0
 
 		for d in self.get('items'):
+			if d.t_warehouse: fg_basic_rate = flt(d.basic_rate)
 			args = frappe._dict({
 				"item_code": d.item_code,
 				"warehouse": d.s_warehouse or d.t_warehouse,
@@ -269,13 +271,14 @@
 				if not d.t_warehouse:
 					raw_material_cost += flt(d.basic_amount)
 
-		self.set_basic_rate_for_finished_goods(raw_material_cost)
+		number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
+		if (fg_basic_rate == 0.0 and number_of_fg_items == 1) or update_finished_item_rate:
+			self.set_basic_rate_for_finished_goods(raw_material_cost)
 
 	def set_basic_rate_for_finished_goods(self, raw_material_cost):
 		if self.purpose in ["Manufacture", "Repack"]:
-			number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
 			for d in self.get("items"):
-				if d.bom_no or (d.t_warehouse and number_of_fg_items == 1):
+				if d.bom_no or d.t_warehouse:
 					d.basic_rate = flt(raw_material_cost / flt(d.transfer_qty), d.precision("basic_rate"))
 					d.basic_amount = flt(raw_material_cost, d.precision("basic_amount"))