Merge pull request #6267 from PawanMeh/fixes_6254

[fix] #6254
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 219fbf2..5e6fc53 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -219,6 +219,12 @@
 
 	party: function(frm) {
 		if(frm.doc.payment_type && frm.doc.party_type && frm.doc.party) {
+			if(!frm.doc.posting_date) {
+				frappe.msgprint(__("Please select Posting Date before selecting Party"))
+				frm.set_value("party", "");
+				return ;
+			}
+			
 			frm.set_party_account_based_on_party = true;
 
 			return frappe.call({
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json
index 43d43ca..2057d07 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.json
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json
@@ -75,7 +75,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "label": "Payment Type", 
    "length": 0, 
    "no_copy": 0, 
@@ -1426,7 +1426,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-09-02 11:34:14.817383", 
+ "modified": "2016-09-05 11:06:18.183458", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Payment Entry", 
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry_list.js b/erpnext/accounts/doctype/payment_entry/payment_entry_list.js
deleted file mode 100644
index 81230d0..0000000
--- a/erpnext/accounts/doctype/payment_entry/payment_entry_list.js
+++ /dev/null
@@ -1,6 +0,0 @@
-frappe.listview_settings['Payment Entry'] = {
-	add_fields: ["payment_type"],
-	get_indicator: function(doc) {
-		return [__(doc.payment_type), (doc.docstatus==0 ? 'red' : 'blue'), 'status=' + doc.payment_type]
-	}
-}
diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json
index c3e0407..968ce29 100644
--- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json
+++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json
@@ -178,7 +178,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "label": "Allocated", 
    "length": 0, 
    "no_copy": 0, 
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 30d043f..84a8e82 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -6,10 +6,11 @@
 import frappe
 from frappe import _
 from frappe.model.document import Document
-from frappe.utils import flt, get_url, nowdate
+from frappe.utils import flt, nowdate, get_url
 from erpnext.accounts.party import get_party_account
 from erpnext.accounts.utils import get_account_currency
 from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, get_company_defaults
+from frappe.integration_broker.doctype.integration_service.integration_service import get_integration_controller
 
 class PaymentRequest(Document):
 	def validate(self):
@@ -25,7 +26,7 @@
 		ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
 		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 on_submit(self):
 		send_mail = True
 		self.make_communication_entry()
@@ -35,17 +36,13 @@
 			send_mail = False
 
 		if send_mail and not self.flags.mute_email:
-			self.send_payment_request()
+			self.set_payment_request_url()
 			self.send_email()
 
 	def on_cancel(self):
+		self.check_if_payment_entry_exists()
 		self.set_as_cancelled()
 
-	def get_payment_url(self):
-		""" This is blanck method to trigger hooks call from individual payment gateway app
-		which will return respective payment gateway"""
-		pass
-
 	def make_invoice(self):
 		ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
 		if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart":
@@ -54,20 +51,39 @@
 			si = si.insert(ignore_permissions=True)
 			si.submit()
 
-	def send_payment_request(self):
+	def set_payment_request_url(self):
 		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))
+			self.payment_url = self.get_payment_url()
 		
 		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 get_payment_url(self):
+		data = frappe.db.get_value(self.reference_doctype, self.reference_name,
+			["company", "customer_name"], as_dict=1)
+		
+		controller = get_integration_controller(self.payment_gateway, setup=False)
+		controller.validate_transaction_currency(self.currency)
+		
+		return controller.get_payment_url(**{
+			"amount": self.grand_total,
+			"title": data.company,
+			"description": self.subject,
+			"reference_doctype": "Payment Request",
+			"reference_docname": self.name,
+			"payer_email": self.email_to or frappe.session.user,
+			"payer_name": data.customer_name,
+			"order_id": self.name,
+			"currency": self.currency
+		})
 
 	def set_as_paid(self):
 		if frappe.session.user == "Guest":
 			frappe.set_user("Administrator")
-
+		
 		payment_entry = self.create_payment_entry()
 		self.make_invoice()
 
@@ -141,6 +157,13 @@
 
 	def set_as_cancelled(self):
 		self.db_set("status", "Cancelled")
+	
+	def check_if_payment_entry_exists(self):
+		if self.status == "Paid":
+			payment_entry = frappe.db.sql_list("""select parent from `tabPayment Entry Reference`
+				where reference_name=%s""", self.reference_name)
+			if payment_entry:
+				frappe.throw(_("Payment Entry already exists"), title=_('Error'))
 
 	def make_communication_entry(self):
 		"""Make communication entry"""
@@ -156,7 +179,33 @@
 
 	def get_payment_success_url(self):
 		return self.payment_success_url
+	
+	def on_payment_authorized(self, status=None):
+		if not status:
+			return
+		
+		shopping_cart_settings = frappe.get_doc("Shopping Cart Settings")
 
+		if status in ["Authorized", "Completed"]:
+			redirect_to = None
+			self.run_method("set_as_paid")
+
+			# if shopping cart enabled and in session
+			if (shopping_cart_settings.enabled and hasattr(frappe.local, "session")
+				and frappe.local.session.user != "Guest"):
+
+				success_url = shopping_cart_settings.payment_success_url
+				if success_url:
+					redirect_to = ({
+						"Orders": "orders",
+						"Invoices": "invoices",
+						"My Account": "me"
+					}).get(success_url, "me")
+				else:
+					redirect_to = get_url("/orders/{0}".format(self.reference_name))
+			
+			return redirect_to
+			
 @frappe.whitelist(allow_guest=True)
 def make_payment_request(**args):
 	"""Make payment request"""
@@ -201,8 +250,9 @@
 			pr.submit()
 
 	if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart":
-		generate_payment_request(pr.name)
 		frappe.db.commit()
+		frappe.local.response["type"] = "redirect"
+		frappe.local.response["location"] = pr.get_payment_url()
 
 	if not args.cart:
 		return pr
@@ -256,10 +306,6 @@
 	}
 
 @frappe.whitelist(allow_guest=True)
-def generate_payment_request(name):
-	frappe.get_doc("Payment Request", name).run_method("get_payment_url")
-
-@frappe.whitelist(allow_guest=True)
 def resend_payment_email(docname):
 	return frappe.get_doc("Payment Request", docname).send_email()
 
@@ -278,6 +324,7 @@
 			doc = frappe.get_doc("Payment Request", payment_request_name)
 			if doc.status != "Paid":
 				doc.db_set('status', 'Paid')
+				frappe.db.commit()
 
 def get_dummy_message(use_dummy_message=True):
 	return """
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 5947bde..f3ee7d0 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -614,6 +614,7 @@
 		this.child.batch_no = this.item_batch_no[this.child.item_code];
 		this.child.serial_no = (this.item_serial_no[this.child.item_code]
 			? this.item_serial_no[this.child.item_code][0] : '');
+		this.child.item_tax_rate = this.items[0].taxes;
 	},
 
 	update_paid_amount_status: function(update_paid_amount){
@@ -775,6 +776,7 @@
 			this.update_invoice()
 		}else{
 			this.name = $.now();
+			this.frm.doc.offline_pos_name = this.name;
 			this.frm.doc.posting_date = frappe.datetime.get_today();
 			this.frm.doc.posting_time = frappe.datetime.now_time();
 			invoice_data[this.name] = this.frm.doc
diff --git a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
index 605c032..773f7fc 100644
--- a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
+++ b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json
@@ -6,9 +6,9 @@
  "docstatus": 0, 
  "doctype": "Print Format", 
  "font": "Default", 
- "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ company }}<br>\n\t{{  __(\"Invoice\") }}<br>\n</p>\n<p>\n\t<b>{{ __(\"Date\") }}:</b> {{ dateutil.global_date_format(posting_date) }}<br>\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"50%\">{{ __(\"Item\") }}</b></th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Qty\") }}</th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Amount\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{% for item in items %}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_name }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ format_number(item.qty, precision(\"difference\")) }}<br>@ {{ format_currency(item.rate, currency) }}</td>\n\t\t\t<td class=\"text-right\">{{ format_currency(item.amount, currency) }}</td>\n\t\t</tr>\n\t\t{% endfor %}\n\t</tbody>\n</table>\n\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% for row in taxes %}\n\t\t{% if not row.included_in_print_rate %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t{% endfor %}\n\t\t{% if discount_amount %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ __(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n\n<hr>\n<p class=\"text-center\">{{ __(\"Thank you, please visit again.\") }}</p>", 
+ "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ company }}<br>\n\t{{  __(\"POS No : \") }}{{offline_pos_name}}<br>\n</p>\n<p>\n\t<b>{{ __(\"Date\") }}:</b> {{ dateutil.global_date_format(posting_date) }}<br>\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"50%\">{{ __(\"Item\") }}</b></th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Qty\") }}</th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ __(\"Amount\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{% for item in items %}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_name }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ format_number(item.qty, precision(\"difference\")) }}<br>@ {{ format_currency(item.rate, currency) }}</td>\n\t\t\t<td class=\"text-right\">{{ format_currency(item.amount, currency) }}</td>\n\t\t</tr>\n\t\t{% endfor %}\n\t</tbody>\n</table>\n\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% for row in taxes %}\n\t\t{% if not row.included_in_print_rate %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t{% endfor %}\n\t\t{% if discount_amount %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{% endif %}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ __(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n\n<hr>\n<p class=\"text-center\">{{ __(\"Thank you, please visit again.\") }}</p>", 
  "idx": 0, 
- "modified": "2016-08-11 07:23:04.530676", 
+ "modified": "2016-09-05 08:28:42.308782", 
  "modified_by": "Administrator", 
  "name": "Point of Sale", 
  "owner": "Administrator", 
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index 23fa762..d2626cd 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -70,7 +70,7 @@
 	if liability:
 		opening_balance -= flt(liability[0].get("opening_balance", 0))
 	if equity:
-		opening_balance -= flt(asset[0].get("opening_balance", 0))
+		opening_balance -= flt(equity[0].get("opening_balance", 0))
 
 	if opening_balance:
 		return _("Previous Financial Year is not closed")
@@ -101,4 +101,4 @@
 			'x': 'x',
 			'columns': columns
 		}
-	}
\ No newline at end of file
+	}
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 6efb288..9b28cbd 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -570,3 +570,58 @@
 				each["balance_in_account_currency"] = flt(get_balance_on(each.get("value")))
 
 	return acc
+
+def create_payment_gateway_and_account(gateway):
+	create_payment_gateway(gateway)
+	create_payment_gateway_account(gateway)
+
+def create_payment_gateway(gateway):
+	# NOTE: we don't translate Payment Gateway name because it is an internal doctype
+	if not frappe.db.exists("Payment Gateway", gateway):
+		payment_gateway = frappe.get_doc({
+			"doctype": "Payment Gateway",
+			"gateway": gateway
+		})
+		payment_gateway.insert(ignore_permissions=True)
+
+def create_payment_gateway_account(gateway):
+	from erpnext.setup.setup_wizard.setup_wizard import create_bank_account
+
+	company = frappe.db.get_value("Global Defaults", None, "default_company")
+	if not company:
+		return
+
+	# NOTE: we translate Payment Gateway account name because that is going to be used by the end user
+	bank_account = frappe.db.get_value("Account", {"account_name": _(gateway), "company": company},
+		["name", 'account_currency'], as_dict=1)
+
+	if not bank_account:
+		# check for untranslated one
+		bank_account = frappe.db.get_value("Account", {"account_name": gateway, "company": company},
+			["name", 'account_currency'], as_dict=1)
+
+	if not bank_account:
+		# try creating one
+		bank_account = create_bank_account({"company_name": company, "bank_account": _(gateway)})
+
+	if not bank_account:
+		frappe.msgprint(_("Payment Gateway Account not created, please create one manually."))
+		return
+
+	# if payment gateway account exists, return
+	if frappe.db.exists("Payment Gateway Account",
+		{"payment_gateway": gateway, "currency": bank_account.account_currency}):
+		return
+
+	try:
+		frappe.get_doc({
+			"doctype": "Payment Gateway Account",
+			"is_default": 1,
+			"payment_gateway": gateway,
+			"payment_account": bank_account.name,
+			"currency": bank_account.account_currency
+		}).insert(ignore_permissions=True)
+
+	except frappe.DuplicateEntryError:
+		# already exists, due to a reinstall?
+		pass
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index ccf7a2f..3083acb 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -138,20 +138,15 @@
 	},
 
 	qty: function(doc, cdt, cdn) {
+		var item = frappe.get_doc(cdt, cdn);
 		if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && doc.update_stock)) {
-			var item = frappe.get_doc(cdt, cdn);
 			frappe.model.round_floats_in(item, ["qty", "received_qty"]);
 			if(!(item.received_qty || item.rejected_qty) && item.qty) {
 				item.received_qty = item.qty;
 			}
 
-			if(item.qty > item.received_qty) {
-				msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "qty", item.name)),
-							__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]))
-				item.qty = item.rejected_qty = 0.0;
-			} else {
-				item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
-			}
+			frappe.model.round_floats_in(item, ["qty", "received_qty"]);
+			item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
 		}
 
 		this._super(doc, cdt, cdn);
@@ -160,26 +155,18 @@
 	},
 
 	received_qty: function(doc, cdt, cdn) {
-		var item = frappe.get_doc(cdt, cdn);
-		frappe.model.round_floats_in(item, ["qty", "received_qty"]);
-
-		item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
-		this.qty(doc, cdt, cdn);
+		this.calculate_accepted_qty(doc, cdt, cdn)
 	},
 
 	rejected_qty: function(doc, cdt, cdn) {
+		this.calculate_accepted_qty(doc, cdt, cdn)
+	},
+
+	calculate_accepted_qty: function(doc, cdt, cdn){
 		var item = frappe.get_doc(cdt, cdn);
 		frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
 
-		if(item.rejected_qty > item.received_qty) {
-			msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "rejected_qty", item.name)),
-						__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
-			item.qty = item.rejected_qty = 0.0;
-		} else {
-
-			item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
-		}
-
+		item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
 		this.qty(doc, cdt, cdn);
 	},
 
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index 1859cf5..0323c2f 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -41,10 +41,6 @@
 // for backward compatibility: combine new and previous states
 $.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm}));
 
-cur_frm.cscript.uom = function(doc, cdt, cdn) {
-	// no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation
-}
-
 cur_frm.fields_dict['items'].grid.get_field('project').get_query =
 	function(doc, cdt, cdn) {
 		return{
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index b6a3376..206dfa3 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -3,6 +3,7 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe.utils import flt
 from frappe.model.mapper import get_mapped_doc
 
 from erpnext.controllers.buying_controller import BuyingController
@@ -62,7 +63,7 @@
 		target.run_method("calculate_taxes_and_totals")
 
 	def update_item(obj, target, source_parent):
-		target.conversion_factor = 1
+		target.stock_qty = flt(obj.qty) * flt(obj.conversion_factor)
 
 	doclist = get_mapped_doc("Supplier Quotation", source_name,		{
 		"Supplier Quotation": {
@@ -76,8 +77,6 @@
 			"field_map": [
 				["name", "supplier_quotation_item"],
 				["parent", "supplier_quotation"],
-				["uom", "stock_uom"],
-				["uom", "uom"],
 				["material_request", "material_request"],
 				["material_request_item", "material_request_item"]
 			],
diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
index 2f4b390..73ebf23 100644
--- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
+++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
@@ -308,6 +308,33 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "stock_uom", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Stock UOM", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "UOM", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "price_list_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -414,6 +441,32 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "conversion_factor", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "UOM Conversion Factor", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "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
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "base_price_list_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1107,6 +1160,57 @@
    "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_44", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "stock_qty", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Qty as per Stock UOM", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1144,7 +1248,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-08-26 04:51:44.857545", 
+ "modified": "2016-09-06 02:40:11.022104", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Supplier Quotation Item", 
diff --git a/erpnext/config/schools.py b/erpnext/config/schools.py
index 5e73fce..ce0c5dc 100644
--- a/erpnext/config/schools.py
+++ b/erpnext/config/schools.py
@@ -126,6 +126,14 @@
 				},
 				{
 					"type": "doctype",
+					"name": "Student Category"
+				},
+				{
+					"type": "doctype",
+					"name": "Grading Structure"
+				},
+				{
+					"type": "doctype",
 					"name": "Instructor"
 				},
 				{
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 432d09a..8927da7 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -662,7 +662,7 @@
 			.format(order_doctype, order_condition))
 
 	reference_condition = " and (" + " or ".join(conditions) + ")" if conditions else ""
-
+	
 	journal_entries = frappe.db.sql("""
 		select
 			"Journal Entry" as reference_type, t1.name as reference_name,
@@ -674,8 +674,7 @@
 			t1.name = t2.parent and t2.account = %s
 			and t2.party_type = %s and t2.party = %s
 			and t2.is_advance = 'Yes' and t1.docstatus = 1
-			and {1} > 0
-			and (ifnull(t2.reference_name, '')='' {2})
+			and {1} > 0 {2}
 		order by t1.posting_date""".format(amount_field, dr_or_cr, reference_condition),
 		[party_account, party_type, party] + order_list, as_dict=1)
 
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 88acfb7..f7181d7 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -37,7 +37,7 @@
 			self.validate_purchase_receipt_if_update_stock()
 
 		if self.doctype=="Purchase Receipt" or (self.doctype=="Purchase Invoice" and self.update_stock):
-			self.validate_purchase_return()
+			# self.validate_purchase_return()
 			self.validate_rejected_warehouse()
 			self.validate_accepted_rejected_qty()
 
@@ -346,7 +346,7 @@
 						})
 					sl_entries.append(sle)
 
-				if flt(d.rejected_qty) > 0:
+				if flt(d.rejected_qty) != 0:
 					sl_entries.append(self.get_sl_entries(d, {
 						"warehouse": d.rejected_warehouse,
 						"actual_qty": flt(d.rejected_qty) * flt(d.conversion_factor),
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 0debe4a..6da496b 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -17,7 +17,8 @@
 				if isinstance(f[1], basestring) and f[1][0] == '!':
 					flt.append([doctype, f[0], '!=', f[1][1:]])
 				else:
-					flt.append([doctype, f[0], '=', f[1]])
+					value = frappe.db.escape(f[1]) if isinstance(f[1], basestring) else f[1]
+					flt.append([doctype, f[0], '=', value])
 
 		query = DatabaseQuery(doctype)
 		query.filters = flt
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 8d30247..ae03a35 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -53,13 +53,15 @@
 
 	valid_items = frappe._dict()
 
-	select_fields = "item_code, qty" if doc.doctype=="Purchase Invoice" \
-		else "item_code, qty, serial_no, batch_no"
+	select_fields = "item_code, qty, parenttype" if doc.doctype=="Purchase Invoice" \
+		else "item_code, qty, serial_no, batch_no, parenttype"
+
+	if doc.doctype in ['Purchase Invoice', 'Purchase Receipt']:
+		select_fields += ",rejected_qty, received_qty"
 
 	for d in frappe.db.sql("""select {0} from `tab{1} Item` where parent = %s"""
 		.format(select_fields, doc.doctype), doc.return_against, as_dict=1):
 			valid_items = get_ref_item_dict(valid_items, d)
-			
 
 	if doc.doctype in ("Delivery Note", "Sales Invoice"):
 		for d in frappe.db.sql("""select item_code, qty, serial_no, batch_no from `tabPacked Item`
@@ -73,21 +75,15 @@
 
 	items_returned = False
 	for d in doc.get("items"):
-		if flt(d.qty) < 0:
+		if flt(d.qty) < 0 or d.get('received_qty') < 0:
 			if d.item_code not in valid_items:
 				frappe.throw(_("Row # {0}: Returned Item {1} does not exists in {2} {3}")
 					.format(d.idx, d.item_code, doc.doctype, doc.return_against))
 			else:
 				ref = valid_items.get(d.item_code, frappe._dict())
-				already_returned_qty = flt(already_returned_items.get(d.item_code))
-				max_return_qty = flt(ref.qty) - already_returned_qty
+				validate_quantity(doc, d, ref, valid_items, already_returned_items)
 
-				if already_returned_qty >= ref.qty:
-					frappe.throw(_("Item {0} has already been returned").format(d.item_code), StockOverReturnError)
-				elif abs(d.qty) > max_return_qty:
-					frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
-						.format(d.idx, ref.qty, d.item_code), StockOverReturnError)
-				elif ref.batch_no and d.batch_no not in ref.batch_no:
+				if ref.batch_no and d.batch_no not in ref.batch_no:
 					frappe.throw(_("Row # {0}: Batch No must be same as {1} {2}")
 						.format(d.idx, doc.doctype, doc.return_against))
 				elif ref.serial_no:
@@ -107,18 +103,45 @@
 
 	if not items_returned:
 		frappe.throw(_("Atleast one item should be entered with negative quantity in return document"))
-		
+
+def validate_quantity(doc, args, ref, valid_items, already_returned_items):
+	fields = ['qty']
+	if doc.doctype in ['Purchase Invoice', 'Purchase Receipt']:
+		fields.extend(['received_qty', 'rejected_qty'])
+
+	already_returned_data = already_returned_items.get(args.item_code) or {}
+
+	for column in fields:
+		return_qty = flt(already_returned_data.get(column, 0)) if len(already_returned_data) > 0 else 0
+		referenced_qty = ref.get(column)
+		max_return_qty = flt(referenced_qty) - return_qty
+		label = column.replace('_', ' ').title()
+
+		if flt(args.get(column)) > 0:
+			frappe.throw(_("{0} must be negative in return document").format(label))
+		elif return_qty >= referenced_qty and flt(args.get(column)) != 0:
+			frappe.throw(_("Item {0} has already been returned").format(args.item_code), StockOverReturnError)
+		elif abs(args.get(column)) > max_return_qty:
+			frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
+				.format(args.idx, referenced_qty, args.item_code), StockOverReturnError)
+
 def get_ref_item_dict(valid_items, ref_item_row):
 	from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
 	
 	valid_items.setdefault(ref_item_row.item_code, frappe._dict({
 		"qty": 0,
+		"rejected_qty": 0,
+		"received_qty": 0,
 		"serial_no": [],
 		"batch_no": []
 	}))
 	item_dict = valid_items[ref_item_row.item_code]
 	item_dict["qty"] += ref_item_row.qty
-	
+
+	if ref_item_row.parenttype in ['Purchase Invoice', 'Purchase Receipt']:
+		item_dict["received_qty"] += ref_item_row.received_qty
+		item_dict["rejected_qty"] += ref_item_row.rejected_qty
+
 	if ref_item_row.get("serial_no"):
 		item_dict["serial_no"] += get_serial_nos(ref_item_row.serial_no)
 		
@@ -128,16 +151,30 @@
 	return valid_items
 
 def get_already_returned_items(doc):
-	return frappe._dict(frappe.db.sql("""
-		select
-			child.item_code, sum(abs(child.qty)) as qty
+	column = 'child.item_code, sum(abs(child.qty)) as qty'
+	if doc.doctype in ['Purchase Invoice', 'Purchase Receipt']:
+		column += ', sum(abs(child.rejected_qty)) as rejected_qty, sum(abs(child.received_qty)) as received_qty'
+
+	data = frappe.db.sql("""
+		select {0}
 		from
-			`tab{0} Item` child, `tab{1}` par
+			`tab{1} Item` child, `tab{2}` par
 		where
 			child.parent = par.name and par.docstatus = 1
-			and par.is_return = 1 and par.return_against = %s and child.qty < 0
+			and par.is_return = 1 and par.return_against = %s
 		group by item_code
-	""".format(doc.doctype, doc.doctype), doc.return_against))
+	""".format(column, doc.doctype, doc.doctype), doc.return_against, as_dict=1)
+
+	items = {}
+
+	for d in data:
+		items.setdefault(d.item_code, frappe._dict({
+			"qty": d.get("qty"),
+			"received_qty": d.get("received_qty"),
+			"rejected_qty": d.get("rejected_qty")
+		}))
+
+	return items
 
 def make_return_doc(doctype, source_name, target_doc=None):
 	from frappe.model.mapper import get_mapped_doc
@@ -166,12 +203,18 @@
 	def update_item(source_doc, target_doc, source_parent):
 		target_doc.qty = -1* source_doc.qty
 		if doctype == "Purchase Receipt":
-			target_doc.received_qty = -1* source_doc.qty
+			target_doc.received_qty = -1* source_doc.received_qty
+			target_doc.rejected_qty = -1* source_doc.rejected_qty
+			target_doc.qty = -1* source_doc.qty
 			target_doc.purchase_order = source_doc.purchase_order
+			target_doc.rejected_warehouse = source_doc.rejected_warehouse
 		elif doctype == "Purchase Invoice":
-			target_doc.received_qty = -1* source_doc.qty
+			target_doc.received_qty = -1* source_doc.received_qty
+			target_doc.rejected_qty = -1* source_doc.rejected_qty
+			target_doc.qty = -1* source_doc.qty
 			target_doc.purchase_order = source_doc.purchase_order
 			target_doc.purchase_receipt = source_doc.purchase_receipt
+			target_doc.rejected_warehouse = source_doc.rejected_warehouse
 			target_doc.po_detail = source_doc.po_detail
 			target_doc.pr_detail = source_doc.pr_detail
 		elif doctype == "Delivery Note":
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
index 4cbccaf..5f82967 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
@@ -58,7 +58,7 @@
 			if no_email_sp:
 				frappe.msgprint(
 					frappe._("Setting Events to {0}, since the Employee attached to the below Sales Persons does not have a User ID{1}").format(
-						self.owner, "<br>"+no_email_sp.join("<br>")
+						self.owner, "<br>" + "<br>".join(no_email_sp)
 				))
 
 			scheduled_date = frappe.db.sql("""select scheduled_date from
@@ -187,14 +187,17 @@
 			if not sr_details:
 				frappe.throw(_("Serial No {0} not found").format(serial_no))
 
-			if sr_details.warranty_expiry_date and sr_details.warranty_expiry_date>=amc_start_date:
-				throw(_("Serial No {0} is under warranty upto {1}").format(serial_no, sr_details.warranty_expiry_date))
+			if sr_details.warranty_expiry_date \
+				and getdate(sr_details.warranty_expiry_date) >= getdate(amc_start_date):
+				throw(_("Serial No {0} is under warranty upto {1}")
+					.format(serial_no, sr_details.warranty_expiry_date))
 
-			if sr_details.amc_expiry_date and sr_details.amc_expiry_date >= amc_start_date:
-				throw(_("Serial No {0} is under maintenance contract upto {1}").format(serial_no, sr_details.amc_start_date))
+			if sr_details.amc_expiry_date and getdate(sr_details.amc_expiry_date) >= getdate(amc_start_date):
+				throw(_("Serial No {0} is under maintenance contract upto {1}")
+					.format(serial_no, sr_details.amc_start_date))
 
 			if not sr_details.warehouse and sr_details.delivery_date and \
-				sr_details.delivery_date >= amc_start_date:
+				getdate(sr_details.delivery_date) >= getdate(amc_start_date):
 					throw(_("Maintenance start date can not be before delivery date for Serial No {0}")
 						.format(serial_no))
 
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 7a378a5..0706a2c 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -322,3 +322,5 @@
 erpnext.patches.v7_0.update_missing_employee_in_timesheet
 erpnext.patches.v7_0.update_status_for_timesheet
 erpnext.patches.v7_0.set_party_name_in_payment_entry
+erpnext.patches.v7_1.set_student_guardian
+erpnext.patches.v7_0.update_conversion_factor_in_supplier_quotation_item
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
index b9f02a6..16b2aec 100644
--- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
+++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
@@ -4,8 +4,10 @@
 
 def execute():
 	frappe.reload_doc('projects', 'doctype', 'timesheet')
+	if not frappe.db.table_exists("Time Log"):
+		return
 
-	for data in frappe.get_all('Time Log', fields=["*"], filters = [["docstatus", "<", "2"]]):
+	for data in frappe.db.sql("select * from `tabTime Log` where docstatus < 2", as_dict=1):
 		if data.task:
 			company = frappe.db.get_value("Task", data.task, "company")
 		elif data.production_order:
diff --git a/erpnext/patches/v7_0/migrate_mode_of_payments_v6_to_v7.py b/erpnext/patches/v7_0/migrate_mode_of_payments_v6_to_v7.py
index e2d2c89..8de92b7 100644
--- a/erpnext/patches/v7_0/migrate_mode_of_payments_v6_to_v7.py
+++ b/erpnext/patches/v7_0/migrate_mode_of_payments_v6_to_v7.py
@@ -4,17 +4,35 @@
 def execute():
 	frappe.reload_doc('accounts', 'doctype', 'sales_invoice_timesheet')
 	frappe.reload_doc('accounts', 'doctype', 'sales_invoice_payment')
-	
-	for data in frappe.db.sql("""select name, mode_of_payment, cash_bank_account, paid_amount from 
-		`tabSales Invoice` where is_pos = 1 and docstatus < 2 and cash_bank_account is not null""", as_dict=1):
+	frappe.reload_doc('accounts', 'doctype', 'mode_of_payment')
+
+	count = 0
+	for data in frappe.db.sql("""select name, mode_of_payment, cash_bank_account, paid_amount, company 
+		from `tabSales Invoice` si
+		where si.is_pos = 1 and si.docstatus < 2 
+		and si.cash_bank_account is not null and si.cash_bank_account != ''
+		and not exists(select name from `tabSales Invoice Payment` where parent=si.name)""", as_dict=1):
+		
+		if not data.mode_of_payment and not frappe.db.exists("Mode of Payment", "Cash"):
+			mop = frappe.new_doc("Mode of Payment")
+			mop.mode_of_payment = "Cash"
+			mop.type = "Cash"
+			mop.save()
+		
 		si_doc = frappe.get_doc('Sales Invoice', data.name)
-		si_doc.append('payments', {
+		row = si_doc.append('payments', {
 			'mode_of_payment': data.mode_of_payment or 'Cash',
 			'account': data.cash_bank_account,
 			'type': frappe.db.get_value('Mode of Payment', data.mode_of_payment, 'type') or 'Cash',
 			'amount': data.paid_amount
 		})
-
+		row.db_update()
+		
 		si_doc.set_paid_amount()
-		si_doc.flags.ignore_validate_update_after_submit = True
-		si_doc.save()
\ No newline at end of file
+		si_doc.db_set("paid_amount", si_doc.paid_amount)
+		si_doc.db_set("base_paid_amount", si_doc.base_paid_amount)
+		
+		count +=1
+		
+		if count % 200 == 0:
+			frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/setup_account_table_for_expense_claim_type_if_exists.py b/erpnext/patches/v7_0/setup_account_table_for_expense_claim_type_if_exists.py
index a067e71..9622490 100644
--- a/erpnext/patches/v7_0/setup_account_table_for_expense_claim_type_if_exists.py
+++ b/erpnext/patches/v7_0/setup_account_table_for_expense_claim_type_if_exists.py
@@ -9,7 +9,8 @@
 		return
 
 	for expense_claim_type in frappe.get_all("Expense Claim Type", fields=["name", "default_account"]):
-		if expense_claim_type.default_account:
+		if expense_claim_type.default_account \
+				and frappe.db.exists("Account", expense_claim_type.default_account):
 			doc = frappe.get_doc("Expense Claim Type", expense_claim_type.name)
 			doc.append("accounts", {
 				"company": frappe.db.get_value("Account", expense_claim_type.default_account, "company"),
diff --git a/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py b/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py
new file mode 100644
index 0000000..24da4b1
--- /dev/null
+++ b/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py
@@ -0,0 +1,19 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doc('buying', 'doctype', 'supplier_quotation_item')
+
+	frappe.db.sql("""update 
+			`tabSupplier Quotation Item` as sqi_t,
+			(select sqi.item_code as item_code, sqi.uom as uom, ucd.conversion_factor as conversion_factor  
+				from `tabSupplier Quotation Item` sqi left join `tabUOM Conversion Detail` ucd  
+				on ucd.uom = sqi.uom and sqi.item_code = ucd.parent) as conversion_data,
+			`tabItem` as item
+		set 
+			sqi_t.conversion_factor= ifnull(conversion_data.conversion_factor, 1), 
+			sqi_t.stock_qty = (ifnull(conversion_data.conversion_factor, 1) * sqi_t.qty), 
+			sqi_t.stock_uom = item.stock_uom  
+		where 
+			sqi_t.item_code = conversion_data.item_code and
+			sqi_t.uom = conversion_data.uom and sqi_t.item_code = item.name""")
\ No newline at end of file
diff --git a/erpnext/patches/v7_1/set_student_guardian.py b/erpnext/patches/v7_1/set_student_guardian.py
new file mode 100644
index 0000000..e64279b
--- /dev/null
+++ b/erpnext/patches/v7_1/set_student_guardian.py
@@ -0,0 +1,16 @@
+import frappe
+
+def execute():
+	if frappe.db.exists("DocType", "Guardian"):
+		frappe.reload_doc("schools", "doctype", "student")
+		frappe.reload_doc("schools", "doctype", "student_guardian")
+		frappe.reload_doc("schools", "doctype", "student_sibling")
+		if "student" not in frappe.db.get_table_columns("Guardian"):
+			return
+		guardian = frappe.get_all("Guardian", fields=["name", "student"])
+		for d in guardian:
+			if d.student:
+				student = frappe.get_doc("Student", d.student)
+				if student:
+					student.append("guardians", {"guardian": d.name})
+					student.save()
diff --git a/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py b/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
index ab0b4a1..cc854a4 100644
--- a/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
+++ b/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
@@ -12,8 +12,9 @@
 		filters["from_time"] = "00:00:00"
 		filters["to_time"] = "24:00:00"
 
-	columns = [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("From Datetime") + "::140",
-		_("To Datetime") + "::140", _("Hours") + "::70", _("Activity Type") + "::120", _("Task") + ":Link/Task:150",
+	columns = [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("Employee Name") + "::150", 
+		_("From Datetime") + "::140", _("To Datetime") + "::140", _("Hours") + "::70", 
+		_("Activity Type") + "::120", _("Task") + ":Link/Task:150",
 		_("Project") + ":Link/Project:120", _("Status") + "::70"]
 		
 	conditions = "ts.docstatus = 1"
@@ -27,7 +28,8 @@
 	return columns, data
 
 def get_data(conditions, filters):
-	time_sheet = frappe.db.sql(""" select ts.name, ts.employee, tsd.from_time, tsd.to_time, tsd.hours,
+	time_sheet = frappe.db.sql(""" select ts.name, ts.employee, ts.employee_name, 
+		tsd.from_time, tsd.to_time, tsd.hours,
 		tsd.activity_type, tsd.task, tsd.project, ts.status from `tabTimesheet Detail` tsd, 
 		`tabTimesheet` ts where ts.name = tsd.parent and %s order by ts.name"""%(conditions), filters, as_list=1)
 
diff --git a/erpnext/schools/api.py b/erpnext/schools/api.py
index 3554fe7..6011158 100644
--- a/erpnext/schools/api.py
+++ b/erpnext/schools/api.py
@@ -103,13 +103,14 @@
 		return fs
 
 @frappe.whitelist()
-def get_fee_schedule(program):
+def get_fee_schedule(program, student_category=None):
 	"""Returns Fee Schedule.
 
 	:param program: Program.
+	:param student_category: Student Category
 	"""
 	fs = frappe.get_list("Program Fee", fields=["academic_term", "fee_structure", "due_date", "amount"] ,
-		filters={"parent": program}, order_by= "idx")
+		filters={"parent": program, "student_category": student_category }, order_by= "idx")
 	return fs
 
 @frappe.whitelist()
diff --git a/erpnext/schools/doctype/academic_term/academic_term.json b/erpnext/schools/doctype/academic_term/academic_term.json
index 9d9c9e0..ca10ebf 100644
--- a/erpnext/schools/doctype/academic_term/academic_term.json
+++ b/erpnext/schools/doctype/academic_term/academic_term.json
@@ -2,7 +2,7 @@
  "allow_copy": 0, 
  "allow_import": 1, 
  "allow_rename": 1, 
- "autoname": "field:term_name", 
+ "autoname": "field:title", 
  "beta": 0, 
  "creation": "2015-09-08 17:19:19.158228", 
  "custom": 0, 
@@ -15,6 +15,32 @@
    "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": "term_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -31,6 +57,81 @@
    "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": "term_start_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Term Start Date", 
+   "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": 1, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "term_end_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Term End Date", 
+   "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": 1, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "title", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Title", 
+   "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, 
@@ -47,7 +148,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-07-25 05:24:23.032319", 
+ "modified": "2016-08-27 23:02:03.565866", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Academic Term", 
@@ -78,7 +179,8 @@
  "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
- "sort_field": "modified", 
+ "sort_field": "name", 
  "sort_order": "DESC", 
+ "title_field": "title", 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/academic_term/academic_term.py b/erpnext/schools/doctype/academic_term/academic_term.py
index 1a4526b..891feb8 100644
--- a/erpnext/schools/doctype/academic_term/academic_term.py
+++ b/erpnext/schools/doctype/academic_term/academic_term.py
@@ -4,7 +4,35 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe import msgprint, _
+from frappe.utils import get_datetime, get_datetime_str
 from frappe.model.document import Document
 
 class AcademicTerm(Document):
-	pass
+    def autoname(self):
+        self.name = self.academic_year + " ({})".format(self.term_name) if self.term_name else ""
+        
+    def validate(self):
+        #Check if entry with same academic_year and the term_name already exists
+        validate_duplication(self)
+        self.title = self.academic_year + " ({})".format(self.term_name) if self.term_name else ""
+        
+        #Check that start of academic year is earlier than end of academic year
+        if self.term_start_date and self.term_end_date and self.term_start_date > self.term_end_date:
+            frappe.throw(_("The Term End Date cannot be earlier than the Term Start Date. Please correct the dates and try again."))
+        
+        """Check that the start of the term is not before the start of the academic year and end of term is not after 
+            the end of the academic year"""
+        year = frappe.get_doc("Academic Year",self.academic_year)
+        if self.term_start_date and get_datetime_str(year.year_start_date) and (self.term_start_date < get_datetime_str(year.year_start_date)):
+            frappe.throw(_("The Term Start Date cannot be earlier than the Year Start Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
+        
+        if self.term_end_date and get_datetime_str(year.year_end_date) and (self.term_end_date > get_datetime_str(year.year_end_date)):
+            frappe.throw(_("The Term End Date cannot be later than the Year End Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
+
+
+def validate_duplication(self):
+    term = frappe.db.sql("""select name from `tabAcademic Term` where academic_year= %s and term_name= %s 
+    and docstatus<2 and name != %s""", (self.academic_year, self.term_name, self.name))
+    if term:
+        frappe.throw(_("An academic term with this 'Academic Year' {0} and 'Term Name' {1} already exists. Please modify these entries and try again.").format(self.academic_year,self.term_name))
diff --git a/erpnext/schools/doctype/academic_term/test_records.json b/erpnext/schools/doctype/academic_term/test_records.json
index 9807221..2d84383 100644
--- a/erpnext/schools/doctype/academic_term/test_records.json
+++ b/erpnext/schools/doctype/academic_term/test_records.json
@@ -1,11 +1,17 @@
 [
-	{
-		"term_name": "_Test Academic Term"
-	},
-	{
-		"term_name": "_Test Academic Term 1"
-	},
-	{
-		"term_name": "_Test Academic Term 2"
-	}
-]
\ No newline at end of file
+    {
+        "doctype": "Academic Term",
+        "academic_year": "2014-2015",
+        "term_name": "_Test Academic Term"
+    },
+    {
+        "doctype": "Academic Term",
+        "academic_year": "2014-2015",
+        "term_name": "_Test Academic Term 1"
+    },
+    {
+        "doctype": "Academic Term",
+        "academic_year": "2014-2015",
+        "term_name": "_Test Academic Term 2"
+    }
+]    
\ No newline at end of file
diff --git a/erpnext/schools/doctype/academic_year/academic_year.py b/erpnext/schools/doctype/academic_year/academic_year.py
index 4b955de..f2858a4 100644
--- a/erpnext/schools/doctype/academic_year/academic_year.py
+++ b/erpnext/schools/doctype/academic_year/academic_year.py
@@ -4,7 +4,11 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe import msgprint, _
 from frappe.model.document import Document
 
 class AcademicYear(Document):
-	pass
+    def validate(self):
+        #Check that start of academic year is earlier than end of academic year
+        if self.year_start_date and self.year_end_date and self.year_start_date > self.year_end_date:
+            frappe.throw(_("The Year End Date cannot be earlier than the Year Start Date. Please correct the dates and try again."))
diff --git a/erpnext/schools/doctype/assessment/assessment.js b/erpnext/schools/doctype/assessment/assessment.js
index 799ae7b..efadbd6 100644
--- a/erpnext/schools/doctype/assessment/assessment.js
+++ b/erpnext/schools/doctype/assessment/assessment.js
@@ -28,4 +28,24 @@
 			});
 		}
 	}
+});
+
+frappe.ui.form.on("Assessment Result" ,{
+	result : function(frm, cdt, cdn) {
+		if(frm.doc.grading_structure){
+			var assessment_result = locals[cdt][cdn];
+			frappe.call({
+				method:"erpnext.schools.doctype.assessment.assessment.get_grade",
+				args:{
+					grading_structure: frm.doc.grading_structure,
+					result: assessment_result.result
+				},
+				callback: function(r){
+					if(r.message){
+						frappe.model.set_value(cdt, cdn, 'grade', r.message);
+					}
+				}
+			});
+		}
+	}
 });
\ No newline at end of file
diff --git a/erpnext/schools/doctype/assessment/assessment.json b/erpnext/schools/doctype/assessment/assessment.json
index 30ac1ed..e978d08 100644
--- a/erpnext/schools/doctype/assessment/assessment.json
+++ b/erpnext/schools/doctype/assessment/assessment.json
@@ -91,6 +91,32 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "fieldname": "grading_structure", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Grading Structure", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Grading Structure", 
+   "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", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -506,7 +532,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-08-05 04:57:41.018614", 
+ "modified": "2016-08-27 14:18:51.852078", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Assessment", 
diff --git a/erpnext/schools/doctype/assessment/assessment.py b/erpnext/schools/doctype/assessment/assessment.py
index a23d5cc..de6a653 100644
--- a/erpnext/schools/doctype/assessment/assessment.py
+++ b/erpnext/schools/doctype/assessment/assessment.py
@@ -8,39 +8,56 @@
 from frappe import _
 
 class Assessment(Document):
-	def validate(self):
-		self.validate_overlap()
-	
-	def validate_overlap(self):
-		"""Validates overlap for Student Group, Supervisor, Room"""
+    def validate(self):
+        self.validate_overlap()
+    
+    def validate_overlap(self):
+        """Validates overlap for Student Group, Supervisor, Room"""
 
-		from erpnext.schools.utils import validate_overlap_for
+        from erpnext.schools.utils import validate_overlap_for
 
-		validate_overlap_for(self, "Assessment", "student_group")
-		validate_overlap_for(self, "Course Schedule", "student_group" )
-		
-		if self.room:
-			validate_overlap_for(self, "Assessment", "room")
-			validate_overlap_for(self, "Course Schedule", "room")
+        validate_overlap_for(self, "Assessment", "student_group")
+        validate_overlap_for(self, "Course Schedule", "student_group" )
+        
+        if self.room:
+            validate_overlap_for(self, "Assessment", "room")
+            validate_overlap_for(self, "Course Schedule", "room")
 
-		if self.supervisor:
-			validate_overlap_for(self, "Assessment", "supervisor")
-			validate_overlap_for(self, "Course Schedule", "instructor", self.supervisor)
+        if self.supervisor:
+            validate_overlap_for(self, "Assessment", "supervisor")
+            validate_overlap_for(self, "Course Schedule", "instructor", self.supervisor)
 
 def get_assessment_list(doctype, txt, filters, limit_start, limit_page_length=20):
-	user = frappe.session.user
-	student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user)
-	if student:
-		return frappe. db.sql('''select course, schedule_date, from_time, to_time, sgs.name from `tabAssessment` as assessment, 
-			`tabStudent Group Student` as sgs where assessment.student_group = sgs.parent and sgs.student = %s and assessment.docstatus=1
-			order by assessment.name asc limit {0} , {1}'''
-			.format(limit_start, limit_page_length), student, as_dict = True)
+    user = frappe.session.user
+    student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user)
+    if student:
+        return frappe. db.sql('''select course, schedule_date, from_time, to_time, sgs.name from `tabAssessment` as assessment, 
+            `tabStudent Group Student` as sgs where assessment.student_group = sgs.parent and sgs.student = %s and assessment.docstatus=1
+            order by assessment.name asc limit {0} , {1}'''
+            .format(limit_start, limit_page_length), student, as_dict = True)
 
 def get_list_context(context=None):
-	return {
-		"show_sidebar": True,
-		'no_breadcrumbs': True,
-		"title": _("Assessment Schedule"),
-		"get_list": get_assessment_list,
-		"row_template": "templates/includes/assessment/assessment_row.html"
-	}
+    return {
+        "show_sidebar": True,
+        'no_breadcrumbs': True,
+        "title": _("Assessment Schedule"),
+        "get_list": get_assessment_list,
+        "row_template": "templates/includes/assessment/assessment_row.html"
+    }
+
+@frappe.whitelist()
+def get_grade(grading_structure, result):
+    grade = frappe.db.sql("""select gi.from_score, gi.to_score, gi.grade_code, gi.grade_description 
+        from `tabGrading Structure` as gs, `tabGrade Interval` as gi 
+        where gs.name = gi.parent and gs.name = %(grading_structure)s and gi.from_score <= %(result)s 
+        and gi.to_score >= %(result)s""".format(), 
+        {
+            "grading_structure":grading_structure,
+            "result": result
+        },
+        as_dict=True)
+    
+    return grade[0].grade_code if grade else ""
+
+def validate_grade(score, grade):
+    pass
\ No newline at end of file
diff --git a/erpnext/schools/doctype/assessment_result/assessment_result.json b/erpnext/schools/doctype/assessment_result/assessment_result.json
index 19339eb..91e580d 100644
--- a/erpnext/schools/doctype/assessment_result/assessment_result.json
+++ b/erpnext/schools/doctype/assessment_result/assessment_result.json
@@ -109,6 +109,31 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "grade", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Grade", 
+   "length": 0, 
+   "no_copy": 0, 
+   "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, 
@@ -121,7 +146,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-08-01 10:37:23.571679", 
+ "modified": "2016-08-27 12:15:01.923000", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Assessment Result", 
diff --git a/erpnext/schools/doctype/course_schedule/test_course_schedule.py b/erpnext/schools/doctype/course_schedule/test_course_schedule.py
index b527303..e9fce4b 100644
--- a/erpnext/schools/doctype/course_schedule/test_course_schedule.py
+++ b/erpnext/schools/doctype/course_schedule/test_course_schedule.py
@@ -24,27 +24,27 @@
 		cs1 = make_course_schedule_test_record(simulate= True)
 		
 		cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time, 
-			student_group="TC2-TP-2014-2015-_Test Academic Term", room="RM0002", do_not_save= 1)
+			student_group="TC2-TP-2014-2015-2014-2015 (_Test Academic Term)", room="RM0002", do_not_save= 1)
 		self.assertRaises(OverlapError, cs2.save)
 
 	def test_room_conflict(self):
 		cs1 = make_course_schedule_test_record(simulate= True)
 		
 		cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time, 
-			student_group="TC2-TP-2014-2015-_Test Academic Term", instructor="_T-Instructor-00002", do_not_save= 1)
+			student_group="TC2-TP-2014-2015-2014-2015 (_Test Academic Term)", instructor="_T-Instructor-00002", do_not_save= 1)
 		self.assertRaises(OverlapError, cs2.save)
 		
 	def test_no_conflict(self):
 		cs1 = make_course_schedule_test_record(simulate= True)
 		
 		make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time, 
-			student_group="TC2-TP-2014-2015-_Test Academic Term", instructor="_T-Instructor-00002", room="RM0002")
+			student_group="TC2-TP-2014-2015-2014-2015 (_Test Academic Term)", instructor="_T-Instructor-00002", room="RM0002")
 
 def make_course_schedule_test_record(**args):
 	args = frappe._dict(args)
 
 	course_schedule = frappe.new_doc("Course Schedule")
-	course_schedule.student_group = args.student_group or "TC-TP-2014-2015-_Test Academic Term"
+	course_schedule.student_group = args.student_group or "TC-TP-2014-2015-2014-2015 (_Test Academic Term)"
 	course_schedule.course = args.course or "_Test Course"
 	course_schedule.instructor = args.instructor or "_T-Instructor-00001"
 	course_schedule.room = args.room or "RM0001"
diff --git a/erpnext/schools/doctype/fee_structure/fee_structure.json b/erpnext/schools/doctype/fee_structure/fee_structure.json
index d6c5a7f..95a2f6f 100644
--- a/erpnext/schools/doctype/fee_structure/fee_structure.json
+++ b/erpnext/schools/doctype/fee_structure/fee_structure.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "program", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -43,6 +44,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -69,6 +71,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -93,6 +96,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "academic_term", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -122,6 +126,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_category", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Student Category", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Category", 
+   "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, 
+   "columns": 0, 
    "fieldname": "section_break_4", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -146,6 +178,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "components", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -172,6 +205,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_6", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -196,6 +230,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "total_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -230,7 +265,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 08:44:07.886467", 
+ "modified": "2016-09-05 06:54:22.360035", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Fee Structure", 
diff --git a/erpnext/schools/doctype/fees/fees.js b/erpnext/schools/doctype/fees/fees.js
index 22c6d8a..7c35de4 100644
--- a/erpnext/schools/doctype/fees/fees.js
+++ b/erpnext/schools/doctype/fees/fees.js
@@ -2,6 +2,25 @@
 cur_frm.add_fetch("student", "title", "student_name");
 
 frappe.ui.form.on("Fees", {
+	
+	onload: function(frm){
+		cur_frm.set_query("academic_term",function(){
+			return{
+				"filters":{
+					"academic_year": (frm.doc.academic_year)
+				}
+			};
+		});
+		
+		cur_frm.set_query("fee_structure",function(){
+			return{
+				"filters":{
+					"academic_term": (frm.doc.academic_term)
+				}
+			};
+		});
+	},
+	
 	refresh: function(frm) {
 		if (frm.doc.docstatus === 1 && (frm.doc.total_amount > frm.doc.paid_amount)) {
 			frm.add_custom_button(__("Collect Fees"), function() {
diff --git a/erpnext/schools/doctype/fees/fees.json b/erpnext/schools/doctype/fees/fees.json
index ce911ad..a3af99b 100644
--- a/erpnext/schools/doctype/fees/fees.json
+++ b/erpnext/schools/doctype/fees/fees.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -41,32 +42,7 @@
    "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, 
+   "columns": 0, 
    "fieldname": "academic_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -93,6 +69,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 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, 
+   "columns": 0, 
    "fieldname": "fee_structure", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -119,6 +123,33 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "due_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Due Date", 
+   "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, 
+   "columns": 0, 
    "fieldname": "column_break_4", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -143,6 +174,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -168,6 +200,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -194,6 +227,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "program", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -220,6 +254,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "program_enrollment", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -246,16 +281,18 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "due_date", 
-   "fieldtype": "Date", 
+   "columns": 0, 
+   "fieldname": "student_category", 
+   "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Due Date", 
+   "label": "Student Category", 
    "length": 0, 
    "no_copy": 0, 
+   "options": "Student Category", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -271,6 +308,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -295,6 +333,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "components", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -321,6 +360,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_10", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -345,6 +385,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -370,6 +411,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_11", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -394,6 +436,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "0", 
    "fieldname": "total_amount", 
    "fieldtype": "Currency", 
@@ -420,6 +463,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "0", 
    "fieldname": "paid_amount", 
    "fieldtype": "Currency", 
@@ -446,6 +490,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "0", 
    "fieldname": "outstanding_amount", 
    "fieldtype": "Currency", 
@@ -480,7 +525,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-27 03:52:28.509757", 
+ "modified": "2016-09-05 06:56:33.012835", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Fees", 
diff --git a/erpnext/schools/doctype/grade_interval/__init__.py b/erpnext/schools/doctype/grade_interval/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/grade_interval/__init__.py
diff --git a/erpnext/schools/doctype/grade_interval/grade_interval.json b/erpnext/schools/doctype/grade_interval/grade_interval.json
new file mode 100644
index 0000000..79ef9f4
--- /dev/null
+++ b/erpnext/schools/doctype/grade_interval/grade_interval.json
@@ -0,0 +1,137 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-08-26 03:11:09.591049", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "grade_code", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Grade Code", 
+   "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": "from_score", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "From Score", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "1", 
+   "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": "to_score", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "To Score", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "1", 
+   "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": "grade_description", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Grade Description", 
+   "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
+  }
+ ], 
+ "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-08-27 15:45:04.657328", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Grade Interval", 
+ "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/grade_interval/grade_interval.py b/erpnext/schools/doctype/grade_interval/grade_interval.py
new file mode 100644
index 0000000..c8ded13
--- /dev/null
+++ b/erpnext/schools/doctype/grade_interval/grade_interval.py
@@ -0,0 +1,11 @@
+# -*- 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 GradeInterval(Document):
+    def validate(self):
+        pass
\ No newline at end of file
diff --git a/erpnext/schools/doctype/grading_structure/__init__.py b/erpnext/schools/doctype/grading_structure/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/grading_structure/__init__.py
diff --git a/erpnext/schools/doctype/grading_structure/grading_structure.js b/erpnext/schools/doctype/grading_structure/grading_structure.js
new file mode 100644
index 0000000..36f4504
--- /dev/null
+++ b/erpnext/schools/doctype/grading_structure/grading_structure.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Grading Structure', {
+	refresh: function(frm) {
+
+	}
+});
diff --git a/erpnext/schools/doctype/grading_structure/grading_structure.json b/erpnext/schools/doctype/grading_structure/grading_structure.json
new file mode 100644
index 0000000..cda6bd4
--- /dev/null
+++ b/erpnext/schools/doctype/grading_structure/grading_structure.json
@@ -0,0 +1,185 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 1, 
+ "autoname": "field:grading_system_name", 
+ "beta": 0, 
+ "creation": "2016-08-26 03:06:53.922972", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "grading_system_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Grading System 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": "description", 
+   "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Description", 
+   "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, 
+   "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": "grading_intervals_section", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Grading Intervals", 
+   "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": "grade_intervals", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Grade Intervals", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Grade Interval", 
+   "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
+  }
+ ], 
+ "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-08-27 14:20:50.709823", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Grading Structure", 
+ "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": "grading_system_name", 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/grading_structure/grading_structure.py b/erpnext/schools/doctype/grading_structure/grading_structure.py
new file mode 100644
index 0000000..1b5d6a8
--- /dev/null
+++ b/erpnext/schools/doctype/grading_structure/grading_structure.py
@@ -0,0 +1,25 @@
+# -*- 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
+from frappe import _
+from frappe.utils import cstr
+
+class GradingStructure(Document):
+    def validate(self):
+        grade_intervals = self.get("grade_intervals")
+        check_overlap(grade_intervals, self)
+
+#Check if any of the grade intervals for this grading structure overlap
+def check_overlap(grade_intervals, parent_doc):
+    for interval1 in grade_intervals:
+        for interval2 in grade_intervals:
+            if interval1.name == interval2.name:
+                pass
+            else:
+                if (interval1.from_score <= interval2.from_score and interval1.to_score >= interval2.from_score) or (interval1.from_score <= interval2.to_score and interval1.to_score >= interval2.to_score):
+                    frappe.throw(_("""The intervals for Grade Code {0} overlaps with the grade intervals for other grades. 
+                    Please check intervals {0} and {1} and try again""".format(interval1.grade_code, interval2.grade_code))) 
\ No newline at end of file
diff --git a/erpnext/schools/doctype/grading_structure/test_grading_structure.py b/erpnext/schools/doctype/grading_structure/test_grading_structure.py
new file mode 100644
index 0000000..0e36080
--- /dev/null
+++ b/erpnext/schools/doctype/grading_structure/test_grading_structure.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('Grading Structure')
+
+class TestGradingStructure(unittest.TestCase):
+	pass
diff --git a/erpnext/schools/doctype/guardian/guardian.json b/erpnext/schools/doctype/guardian/guardian.json
index 390a52f..120a884 100644
--- a/erpnext/schools/doctype/guardian/guardian.json
+++ b/erpnext/schools/doctype/guardian/guardian.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "guardian_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -40,32 +41,7 @@
    "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": 0, 
-   "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, 
+   "columns": 0, 
    "fieldname": "email_address", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -91,6 +67,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "mobile_number", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -116,6 +93,33 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "alternate_number", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Alternate Number", 
+   "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, 
+   "columns": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -140,6 +144,111 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "date_of_birth", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Date of Birth", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "education", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Education", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "occupation", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Occupation", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "designation", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Designation", 
+   "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, 
+   "columns": 0, 
    "fieldname": "image", 
    "fieldtype": "Attach Image", 
    "hidden": 1, 
@@ -165,6 +274,83 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_9", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "work_address", 
+   "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Work Address", 
+   "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, 
+   "columns": 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, 
+   "columns": 0, 
    "fieldname": "interests", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -199,7 +385,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-08-11 07:57:21.708354", 
+ "modified": "2016-09-01 14:33:26.541873", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Guardian", 
diff --git a/erpnext/schools/doctype/program/program.json b/erpnext/schools/doctype/program/program.json
index acd5a8e..ca6e1df 100644
--- a/erpnext/schools/doctype/program/program.json
+++ b/erpnext/schools/doctype/program/program.json
@@ -250,7 +250,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 01:33:56.912243", 
+ "modified": "2016-08-27 03:21:35.806511", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Program", 
diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.js b/erpnext/schools/doctype/program_enrollment/program_enrollment.js
index 038afd9..96c8f96 100644
--- a/erpnext/schools/doctype/program_enrollment/program_enrollment.js
+++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.js
@@ -9,7 +9,8 @@
 			frappe.call({
 				method: "erpnext.schools.api.get_fee_schedule",
 				args: {
-					"program": frm.doc.program
+					"program": frm.doc.program,
+					"student_category": frm.doc.student_category
 				},
 				callback: function(r) {
 					if(r.message) {
@@ -18,5 +19,27 @@
 				}
 			});
 		}
+	},
+	
+	student_category: function() {
+		frappe.ui.form.trigger("Program Enrollment", "program");
+	},
+	
+	onload: function(frm, cdt, cdn){
+		cur_frm.set_query("academic_term", "fees", function(){
+			return{
+				"filters":{
+					"academic_year": (frm.doc.academic_year)
+				}
+			};
+		});
+				
+		cur_frm.fields_dict['fees'].grid.get_field('fee_structure').get_query = function(doc, cdt, cdn) {
+			var d = locals[cdt][cdn];
+			return {
+				filters: {'academic_term': d.academic_term}
+			}
+		};
+		
 	}
 });
diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.json b/erpnext/schools/doctype/program_enrollment/program_enrollment.json
index c7c5eed..199b5e1 100644
--- a/erpnext/schools/doctype/program_enrollment/program_enrollment.json
+++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -41,6 +42,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student_name", 
    "fieldtype": "Read Only", 
    "hidden": 0, 
@@ -67,6 +69,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_category", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Student Category", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Category", 
+   "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, 
+   "columns": 0, 
    "fieldname": "column_break_4", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -91,6 +121,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "program", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -117,6 +148,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "academic_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -143,6 +175,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "Today", 
    "fieldname": "enrollment_date", 
    "fieldtype": "Date", 
@@ -169,6 +202,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -194,6 +228,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "fees", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -214,12 +249,14 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
-   "unique": 0
+   "unique": 0, 
+   "width": ""
   }, 
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -245,6 +282,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "image", 
    "fieldtype": "Attach Image", 
    "hidden": 1, 
@@ -279,7 +317,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-08-11 08:50:24.317353", 
+ "modified": "2016-09-05 06:59:18.620611", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Program Enrollment", 
diff --git a/erpnext/schools/doctype/program_enrollment_fee/program_enrollment_fee.json b/erpnext/schools/doctype/program_enrollment_fee/program_enrollment_fee.json
index 6760384..17d740e 100644
--- a/erpnext/schools/doctype/program_enrollment_fee/program_enrollment_fee.json
+++ b/erpnext/schools/doctype/program_enrollment_fee/program_enrollment_fee.json
@@ -14,6 +14,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "academic_term", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -40,6 +41,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "fee_structure", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -66,6 +68,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -90,6 +93,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "due_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -115,6 +119,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -147,7 +152,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-07-21 12:27:02.547926", 
+ "modified": "2016-09-05 07:05:20.118119", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Program Enrollment Fee", 
diff --git a/erpnext/schools/doctype/program_fee/program_fee.json b/erpnext/schools/doctype/program_fee/program_fee.json
index 6b320a0..d5d3b5f 100644
--- a/erpnext/schools/doctype/program_fee/program_fee.json
+++ b/erpnext/schools/doctype/program_fee/program_fee.json
@@ -14,6 +14,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "academic_term", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -40,13 +41,14 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "fee_structure", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "label": "Fee Structure", 
    "length": 0, 
    "no_copy": 0, 
@@ -66,6 +68,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_category", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Student Category", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Category", 
+   "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, 
+   "columns": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -90,6 +120,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "due_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -115,6 +146,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -147,7 +179,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-07-21 12:27:02.153696", 
+ "modified": "2016-09-05 07:07:39.776848", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Program Fee", 
diff --git a/erpnext/schools/doctype/student/student.json b/erpnext/schools/doctype/student/student.json
index 22b8c4e..22e229c 100644
--- a/erpnext/schools/doctype/student/student.json
+++ b/erpnext/schools/doctype/student/student.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "first_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -40,6 +41,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "middle_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -65,6 +67,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "last_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -90,6 +93,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_4", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -114,6 +118,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -140,6 +145,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student_email_id", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -165,6 +171,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_mobile_number", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Student Mobile Number", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "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, 
+   "columns": 0, 
    "default": "Today", 
    "fieldname": "joining_date", 
    "fieldtype": "Date", 
@@ -180,7 +214,7 @@
    "precision": "", 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
@@ -191,6 +225,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "image", 
    "fieldtype": "Attach Image", 
    "hidden": 1, 
@@ -216,8 +251,9 @@
   {
    "allow_on_submit": 0, 
    "bold": 0, 
-   "collapsible": 1, 
-   "collapsible_depends_on": "!doc.__islocal", 
+   "collapsible": 0, 
+   "collapsible_depends_on": "", 
+   "columns": 0, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -243,6 +279,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "date_of_birth", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -268,32 +305,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "gender", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Gender", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nMale\nFemale", 
-   "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, 
+   "columns": 0, 
    "fieldname": "blood_group", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -320,6 +332,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -344,6 +357,61 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "gender", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Gender", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nMale\nFemale", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "nationality", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Nationality", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Country", 
+   "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, 
+   "columns": 0, 
    "fieldname": "student_applicant", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -370,14 +438,41 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "nationality", 
+   "columns": 0, 
+   "fieldname": "section_break_22", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Home Address", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "address_line_1", 
    "fieldtype": "Data", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Nationality", 
+   "label": "Address Line 1", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -395,17 +490,17 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "contact", 
-   "fieldtype": "Link", 
+   "columns": 0, 
+   "fieldname": "address_line_2", 
+   "fieldtype": "Data", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Contact", 
+   "label": "Address Line 2", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Contact", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -421,6 +516,217 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "pincode", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Pincode", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "column_break_20", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "city", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "City", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "state", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "State", 
+   "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": 1, 
+   "columns": 0, 
+   "fieldname": "section_break_18", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Guardian Details", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "guardians", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Guardians", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Guardian", 
+   "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": 1, 
+   "columns": 0, 
+   "fieldname": "section_break_20", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Sibling Details", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Country", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "siblings", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Siblings", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Sibling", 
+   "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, 
+   "columns": 0, 
    "default": "", 
    "fieldname": "title", 
    "fieldtype": "Data", 
@@ -456,7 +762,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 07:22:57.581638", 
+ "modified": "2016-09-08 06:29:27.702968", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student", 
diff --git a/erpnext/schools/doctype/student/student_dashboard.py b/erpnext/schools/doctype/student/student_dashboard.py
index 45a2f14..9322986 100644
--- a/erpnext/schools/doctype/student/student_dashboard.py
+++ b/erpnext/schools/doctype/student/student_dashboard.py
@@ -9,7 +9,7 @@
 			'items': ['Student Log', 'Student Group', 'Student Attendance']
 		},
 		{
-			'items': ['Program Enrollment', 'Fees', 'Assessment', 'Guardian']
+			'items': ['Program Enrollment', 'Fees', 'Assessment']
 		}
 	]
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.json b/erpnext/schools/doctype/student_applicant/student_applicant.json
index b9505a5..ae99488 100644
--- a/erpnext/schools/doctype/student_applicant/student_applicant.json
+++ b/erpnext/schools/doctype/student_applicant/student_applicant.json
@@ -15,6 +15,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "first_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -40,6 +41,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "middle_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -65,6 +67,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "last_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -90,6 +93,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "program", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -116,6 +120,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_8", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -140,6 +145,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -166,6 +172,7 @@
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "depends_on": "eval:doc.docstatus != 0", 
    "fieldname": "application_status", 
    "fieldtype": "Select", 
@@ -193,6 +200,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "Today", 
    "fieldname": "application_date", 
    "fieldtype": "Date", 
@@ -220,6 +228,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "academic_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -246,6 +255,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "image", 
    "fieldtype": "Attach Image", 
    "hidden": 1, 
@@ -270,8 +280,9 @@
   {
    "allow_on_submit": 0, 
    "bold": 0, 
-   "collapsible": 1, 
-   "collapsible_depends_on": "eval: doc.__islocal == 1", 
+   "collapsible": 0, 
+   "collapsible_depends_on": "", 
+   "columns": 0, 
    "fieldname": "section_break_4", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -297,156 +308,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "mother_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Mother's 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": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "mother_email_id", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Mother's / Guardian 1 Email ID", 
-   "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": "father_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Father's 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": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "father_email_id", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Father's/ Guardian 2 Email ID", 
-   "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": "contact", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Contact", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Contact", 
-   "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_12", 
-   "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, 
+   "columns": 0, 
    "fieldname": "date_of_birth", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -472,6 +334,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "gender", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -498,6 +361,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "blood_group", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -524,14 +388,14 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "nationality", 
-   "fieldtype": "Data", 
+   "columns": 0, 
+   "fieldname": "column_break_12", 
+   "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Nationality", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -549,6 +413,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "student_email_id", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -574,6 +439,372 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_mobile_number", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Student Mobile Number", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "nationality", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Nationality", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Country", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "home_address", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Home Address", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "address_line_1", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Address Line 1", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "address_line_2", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Address Line 2", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "pincode", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Pincode", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "column_break_23", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "city", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "City", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "state", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "State", 
+   "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": 1, 
+   "columns": 0, 
+   "fieldname": "section_break_20", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Guardian Details", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "guardians", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Guardians", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Guardian", 
+   "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": 1, 
+   "columns": 0, 
+   "fieldname": "section_break_21", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Sibling Details", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "siblings", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Siblings", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Sibling", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "section_break_23", 
+   "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, 
+   "columns": 0, 
    "fieldname": "title", 
    "fieldtype": "Data", 
    "hidden": 1, 
@@ -599,6 +830,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -633,7 +865,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 01:24:27.384647", 
+ "modified": "2016-09-08 06:40:54.242322", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Applicant", 
diff --git a/erpnext/schools/doctype/student_batch/student_batch.js b/erpnext/schools/doctype/student_batch/student_batch.js
index 73d4faa..931e41b 100644
--- a/erpnext/schools/doctype/student_batch/student_batch.js
+++ b/erpnext/schools/doctype/student_batch/student_batch.js
@@ -4,7 +4,18 @@
 frappe.ui.form.on('Student Batch', {
 	refresh: function(frm) {
 
+	},
+	
+	onload: function(frm){
+		cur_frm.set_query("academic_term",function(){
+			return{
+				"filters":{
+					"academic_year": (frm.doc.academic_year)
+				}
+			};
+		});
 	}
+	
 });
 
 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
index a806ae3..fa7e6b5 100644
--- a/erpnext/schools/doctype/student_batch/student_batch.json
+++ b/erpnext/schools/doctype/student_batch/student_batch.json
@@ -199,7 +199,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-07-22 09:19:51.141234", 
+ "modified": "2016-08-24 05:32:00.585277", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Batch", 
diff --git a/erpnext/schools/doctype/student_batch/student_batch.py b/erpnext/schools/doctype/student_batch/student_batch.py
index 107ef93..ec2dc79 100644
--- a/erpnext/schools/doctype/student_batch/student_batch.py
+++ b/erpnext/schools/doctype/student_batch/student_batch.py
@@ -8,12 +8,12 @@
 import frappe
 
 class StudentBatch(Document):
-	def autoname(self):
-		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
-	
-	def validate(self):
-		validate_duplicate_student(self.students)
-		
\ No newline at end of file
+    def autoname(self):
+        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
+        
+    def validate(self):
+        validate_duplicate_student(self.students)
+        
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_category/__init__.py b/erpnext/schools/doctype/student_category/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/__init__.py
diff --git a/erpnext/schools/doctype/student_category/student_category.js b/erpnext/schools/doctype/student_category/student_category.js
new file mode 100644
index 0000000..3a264d1
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/student_category.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Student Category', {
+	refresh: function(frm) {
+
+	}
+});
diff --git a/erpnext/schools/doctype/student_category/student_category.json b/erpnext/schools/doctype/student_category/student_category.json
new file mode 100644
index 0000000..03ec0d1
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/student_category.json
@@ -0,0 +1,85 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:category", 
+ "beta": 0, 
+ "creation": "2016-09-05 06:28:33.679415", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "category", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Category", 
+   "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
+  }
+ ], 
+ "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-09-05 06:28:33.679415", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Category", 
+ "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", 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_category/student_category.py b/erpnext/schools/doctype/student_category/student_category.py
new file mode 100644
index 0000000..bd3a835
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/student_category.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 StudentCategory(Document):
+	pass
diff --git a/erpnext/schools/doctype/student_category/test_student_category.py b/erpnext/schools/doctype/student_category/test_student_category.py
new file mode 100644
index 0000000..756cab8
--- /dev/null
+++ b/erpnext/schools/doctype/student_category/test_student_category.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 Category')
+
+class TestStudentCategory(unittest.TestCase):
+	pass
diff --git a/erpnext/schools/doctype/student_group/student_group.js b/erpnext/schools/doctype/student_group/student_group.js
index eed3342..784f557 100644
--- a/erpnext/schools/doctype/student_group/student_group.js
+++ b/erpnext/schools/doctype/student_group/student_group.js
@@ -16,4 +16,19 @@
 			frappe.set_route("List", "Assessment");
 		});
 	}
-});
\ No newline at end of file
+});
+
+frappe.ui.form.on("Student Group", "onload", function(frm){
+	cur_frm.set_query("academic_term",function(){
+		return{
+			"filters":{
+				"academic_year": (frm.doc.academic_year)
+			}
+		};
+	});
+});
+
+//If Student Batch is entered, deduce program, academic_year and academic term from it
+cur_frm.add_fetch("student_batch", "program", "program");
+cur_frm.add_fetch("student_batch", "academic_term", "academic_term");
+cur_frm.add_fetch("student_batch", "academic_year", "academic_year");
diff --git a/erpnext/schools/doctype/student_group/student_group.json b/erpnext/schools/doctype/student_group/student_group.json
index e4b4ea3..a0584e3 100644
--- a/erpnext/schools/doctype/student_group/student_group.json
+++ b/erpnext/schools/doctype/student_group/student_group.json
@@ -41,17 +41,17 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "academic_term", 
+   "fieldname": "academic_year", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
-   "label": "Academic Term", 
+   "label": "Academic Year", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Academic Term", 
+   "options": "Academic Year", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -67,17 +67,17 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "academic_year", 
+   "fieldname": "academic_term", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
-   "label": "Academic Year", 
+   "label": "Academic Term", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Academic Year", 
+   "options": "Academic Term", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -280,7 +280,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 06:23:43.903111", 
+ "modified": "2016-08-24 05:21:05.058875", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Group", 
diff --git a/erpnext/schools/doctype/student_group/test_records.json b/erpnext/schools/doctype/student_group/test_records.json
index a14f670..27cd181 100644
--- a/erpnext/schools/doctype/student_group/test_records.json
+++ b/erpnext/schools/doctype/student_group/test_records.json
@@ -3,12 +3,12 @@
 		"program": "_Test Program",
 		"course": "_Test Course",
 		"academic_year": "2014-2015",
-		"academic_term": "_Test Academic Term"
+		"academic_term": "2014-2015 (_Test Academic Term)"
 	},
 	{
 		"program": "_Test Program",
 		"course": "_Test Course 2",
 		"academic_year": "2014-2015",
-		"academic_term": "_Test Academic Term"
+		"academic_term": "2014-2015 (_Test Academic Term)"
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
index 056574c..9c796bb 100644
--- a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
+++ b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
@@ -20,4 +20,14 @@
 			}
 		}
 	})
+});
+
+frappe.ui.form.on("Student Group Creation Tool", "onload", function(frm){
+	cur_frm.set_query("academic_term",function(){
+		return{
+			"filters":{
+				"academic_year": (frm.doc.academic_year)
+			}
+		};
+	});
 });
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_guardian/__init__.py b/erpnext/schools/doctype/student_guardian/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_guardian/__init__.py
diff --git a/erpnext/schools/doctype/student_guardian/student_guardian.json b/erpnext/schools/doctype/student_guardian/student_guardian.json
new file mode 100644
index 0000000..d8e50c9
--- /dev/null
+++ b/erpnext/schools/doctype/student_guardian/student_guardian.json
@@ -0,0 +1,91 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-09-01 14:28:39.174471", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "guardian", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Guardian", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Guardian", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "relation", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Relation", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nMother\nFather\nOthers", 
+   "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": 1, 
+ "max_attachments": 0, 
+ "modified": "2016-09-01 14:39:03.576590", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Guardian", 
+ "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_guardian/student_guardian.py b/erpnext/schools/doctype/student_guardian/student_guardian.py
new file mode 100644
index 0000000..04445bc
--- /dev/null
+++ b/erpnext/schools/doctype/student_guardian/student_guardian.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 StudentGuardian(Document):
+	pass
diff --git a/erpnext/schools/doctype/student_sibling/__init__.py b/erpnext/schools/doctype/student_sibling/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_sibling/__init__.py
diff --git a/erpnext/schools/doctype/student_sibling/student_sibling.json b/erpnext/schools/doctype/student_sibling/student_sibling.json
new file mode 100644
index 0000000..b07b958
--- /dev/null
+++ b/erpnext/schools/doctype/student_sibling/student_sibling.json
@@ -0,0 +1,117 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-09-01 14:41:23.824083", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "name1", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "gender", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Gender", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nMale\nFemale", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "date_of_birth", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Date of Birth", 
+   "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
+  }
+ ], 
+ "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-09-01 14:43:53.473391", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Sibling", 
+ "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_sibling/student_sibling.py b/erpnext/schools/doctype/student_sibling/student_sibling.py
new file mode 100644
index 0000000..4adc3f3
--- /dev/null
+++ b/erpnext/schools/doctype/student_sibling/student_sibling.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 StudentSibling(Document):
+	pass
diff --git a/erpnext/schools/doctype/student_siblings/__init__.py b/erpnext/schools/doctype/student_siblings/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/schools/doctype/student_siblings/__init__.py
diff --git a/erpnext/schools/doctype/student_siblings/student_siblings.json b/erpnext/schools/doctype/student_siblings/student_siblings.json
new file mode 100644
index 0000000..4f1ed02
--- /dev/null
+++ b/erpnext/schools/doctype/student_siblings/student_siblings.json
@@ -0,0 +1,117 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-09-01 14:41:23.824083", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "name1", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "gender", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Gender", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nMale\nFemale", 
+   "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, 
+   "columns": 0, 
+   "fieldname": "date_of_birth", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Date of Birth", 
+   "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
+  }
+ ], 
+ "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-09-01 14:41:23.824083", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Student Siblings", 
+ "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_siblings/student_siblings.py b/erpnext/schools/doctype/student_siblings/student_siblings.py
new file mode 100644
index 0000000..4e20d84
--- /dev/null
+++ b/erpnext/schools/doctype/student_siblings/student_siblings.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 StudentSiblings(Document):
+	pass
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index 191f169..945dfb1 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -15,538 +15,541 @@
 from erpnext.setup.setup_wizard.domainify import setup_domain
 
 def setup_complete(args=None):
-	if frappe.db.sql("select name from tabCompany"):
-		frappe.throw(_("Setup Already Complete!!"))
+    if frappe.db.sql("select name from tabCompany"):
+        frappe.throw(_("Setup Already Complete!!"))
 
-	install_fixtures.install(args.get("country"))
+    install_fixtures.install(args.get("country"))
 
-	create_price_lists(args)
-	create_fiscal_year_and_company(args)
-	create_users(args)
-	set_defaults(args)
-	create_territories()
-	create_feed_and_todo()
-	create_email_digest()
-	create_letter_head(args)
-	create_taxes(args)
-	create_items(args)
-	create_customers(args)
-	create_suppliers(args)
+    create_price_lists(args)
+    create_fiscal_year_and_company(args)
+    create_users(args)
+    set_defaults(args)
+    create_territories()
+    create_feed_and_todo()
+    create_email_digest()
+    create_letter_head(args)
+    create_taxes(args)
+    create_items(args)
+    create_customers(args)
+    create_suppliers(args)
 
-	if args.domain.lower() == 'education':
-		create_academic_term()
-		create_academic_year()
-		create_program(args)
-		create_course(args)
-		create_instructor(args)
-		create_room(args)
+    if args.domain.lower() == 'education':
+        create_academic_year()
+        create_academic_term()
+        create_program(args)
+        create_course(args)
+        create_instructor(args)
+        create_room(args)
 
-	if args.get('setup_website'):
-		website_maker(args)
+    if args.get('setup_website'):
+        website_maker(args)
 
-	create_logo(args)
+    create_logo(args)
 
-	frappe.local.message_log = []
-	setup_domain(args.get('domain'))
+    frappe.local.message_log = []
+    setup_domain(args.get('domain'))
 
-	frappe.db.commit()
-	login_as_first_user(args)
+    frappe.db.commit()
+    login_as_first_user(args)
 
-	frappe.db.commit()
-	frappe.clear_cache()
+    frappe.db.commit()
+    frappe.clear_cache()
 
-	if args.get("add_sample_data"):
-		try:
-			make_sample_data()
-			frappe.clear_cache()
-		except:
-			# clear message
-			if frappe.message_log:
-				frappe.message_log.pop()
+    if args.get("add_sample_data"):
+        try:
+            make_sample_data()
+            frappe.clear_cache()
+        except:
+            # clear message
+            if frappe.message_log:
+                frappe.message_log.pop()
 
-			pass
+            pass
 
 def create_fiscal_year_and_company(args):
-	if (args.get('fy_start_date')):
-		curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
-		frappe.get_doc({
-		"doctype":"Fiscal Year",
-		'year': curr_fiscal_year,
-		'year_start_date': args.get('fy_start_date'),
-		'year_end_date': args.get('fy_end_date'),
-		}).insert()
-		args["curr_fiscal_year"] = curr_fiscal_year
+    if (args.get('fy_start_date')):
+        curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
+        frappe.get_doc({
+        "doctype":"Fiscal Year",
+        'year': curr_fiscal_year,
+        'year_start_date': args.get('fy_start_date'),
+        'year_end_date': args.get('fy_end_date'),
+        }).insert()
+        args["curr_fiscal_year"] = curr_fiscal_year
 
-	# Company
-	if (args.get('company_name')):
-		frappe.get_doc({
-			"doctype":"Company",
-			'company_name':args.get('company_name').strip(),
-			'abbr':args.get('company_abbr'),
-			'default_currency':args.get('currency'),
-			'country': args.get('country'),
-			'chart_of_accounts': args.get(('chart_of_accounts')),
-			'domain': args.get('domain')
-		}).insert()
+    # Company
+    if (args.get('company_name')):
+        frappe.get_doc({
+            "doctype":"Company",
+            'company_name':args.get('company_name').strip(),
+            'abbr':args.get('company_abbr'),
+            'default_currency':args.get('currency'),
+            'country': args.get('country'),
+            'chart_of_accounts': args.get(('chart_of_accounts')),
+            'domain': args.get('domain')
+        }).insert()
 
-		#Enable shopping cart
-		enable_shopping_cart(args)
+        #Enable shopping cart
+        enable_shopping_cart(args)
 
-		# Bank Account
-		create_bank_account(args)
+        # Bank Account
+        create_bank_account(args)
 
 def enable_shopping_cart(args):
-	frappe.get_doc({
-		"doctype": "Shopping Cart Settings",
-		"enabled": 1,
-		'company': args.get('company_name').strip(),
-		'price_list': frappe.db.get_value("Price List", {"selling": 1}),
-		'default_customer_group': _("Individual"),
-		'quotation_series': "QTN-",
-	}).insert()
+    frappe.get_doc({
+        "doctype": "Shopping Cart Settings",
+        "enabled": 1,
+        'company': args.get('company_name').strip(),
+        'price_list': frappe.db.get_value("Price List", {"selling": 1}),
+        'default_customer_group': _("Individual"),
+        'quotation_series': "QTN-",
+    }).insert()
 
 def create_bank_account(args):
-	if args.get("bank_account"):
-		company_name = args.get('company_name').strip()
-		bank_account_group =  frappe.db.get_value("Account",
-			{"account_type": "Bank", "is_group": 1, "root_type": "Asset",
-				"company": company_name})
-		if bank_account_group:
-			bank_account = frappe.get_doc({
-				"doctype": "Account",
-				'account_name': args.get("bank_account"),
-				'parent_account': bank_account_group,
-				'is_group':0,
-				'company': company_name,
-				"account_type": "Bank",
-			})
-			try:
-				return bank_account.insert()
-			except RootNotEditable:
-				frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
-			except frappe.DuplicateEntryError:
-				# bank account same as a CoA entry
-				pass
+    if args.get("bank_account"):
+        company_name = args.get('company_name').strip()
+        bank_account_group =  frappe.db.get_value("Account",
+            {"account_type": "Bank", "is_group": 1, "root_type": "Asset",
+                "company": company_name})
+        if bank_account_group:
+            bank_account = frappe.get_doc({
+                "doctype": "Account",
+                'account_name': args.get("bank_account"),
+                'parent_account': bank_account_group,
+                'is_group':0,
+                'company': company_name,
+                "account_type": "Bank",
+            })
+            try:
+                return bank_account.insert()
+            except RootNotEditable:
+                frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
+            except frappe.DuplicateEntryError:
+                # bank account same as a CoA entry
+                pass
 
 def create_price_lists(args):
-	for pl_type, pl_name in (("Selling", _("Standard Selling")), ("Buying", _("Standard Buying"))):
-		frappe.get_doc({
-			"doctype": "Price List",
-			"price_list_name": pl_name,
-			"enabled": 1,
-			"buying": 1 if pl_type == "Buying" else 0,
-			"selling": 1 if pl_type == "Selling" else 0,
-			"currency": args["currency"]
-		}).insert()
+    for pl_type, pl_name in (("Selling", _("Standard Selling")), ("Buying", _("Standard Buying"))):
+        frappe.get_doc({
+            "doctype": "Price List",
+            "price_list_name": pl_name,
+            "enabled": 1,
+            "buying": 1 if pl_type == "Buying" else 0,
+            "selling": 1 if pl_type == "Selling" else 0,
+            "currency": args["currency"]
+        }).insert()
 
 def set_defaults(args):
-	# enable default currency
-	frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
+    # enable default currency
+    frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
 
-	global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
-	global_defaults.update({
-		'current_fiscal_year': args.curr_fiscal_year,
-		'default_currency': args.get('currency'),
-		'default_company':args.get('company_name').strip(),
-		"country": args.get("country"),
-	})
+    global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
+    global_defaults.update({
+        'current_fiscal_year': args.curr_fiscal_year,
+        'default_currency': args.get('currency'),
+        'default_company':args.get('company_name').strip(),
+        "country": args.get("country"),
+    })
 
-	global_defaults.save()
+    global_defaults.save()
 
-	frappe.db.set_value("System Settings", None, "email_footer_address", args.get("company"))
+    frappe.db.set_value("System Settings", None, "email_footer_address", args.get("company"))
 
-	accounts_settings = frappe.get_doc("Accounts Settings")
-	accounts_settings.auto_accounting_for_stock = 1
-	accounts_settings.save()
+    accounts_settings = frappe.get_doc("Accounts Settings")
+    accounts_settings.auto_accounting_for_stock = 1
+    accounts_settings.save()
 
-	stock_settings = frappe.get_doc("Stock Settings")
-	stock_settings.item_naming_by = "Item Code"
-	stock_settings.valuation_method = "FIFO"
-	stock_settings.default_warehouse = frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')})
-	stock_settings.stock_uom = _("Nos")
-	stock_settings.auto_indent = 1
-	stock_settings.auto_insert_price_list_rate_if_missing = 1
-	stock_settings.automatically_set_serial_nos_based_on_fifo = 1
-	stock_settings.save()
+    stock_settings = frappe.get_doc("Stock Settings")
+    stock_settings.item_naming_by = "Item Code"
+    stock_settings.valuation_method = "FIFO"
+    stock_settings.default_warehouse = frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')})
+    stock_settings.stock_uom = _("Nos")
+    stock_settings.auto_indent = 1
+    stock_settings.auto_insert_price_list_rate_if_missing = 1
+    stock_settings.automatically_set_serial_nos_based_on_fifo = 1
+    stock_settings.save()
 
-	selling_settings = frappe.get_doc("Selling Settings")
-	selling_settings.cust_master_name = "Customer Name"
-	selling_settings.so_required = "No"
-	selling_settings.dn_required = "No"
-	selling_settings.save()
+    selling_settings = frappe.get_doc("Selling Settings")
+    selling_settings.cust_master_name = "Customer Name"
+    selling_settings.so_required = "No"
+    selling_settings.dn_required = "No"
+    selling_settings.save()
 
-	buying_settings = frappe.get_doc("Buying Settings")
-	buying_settings.supp_master_name = "Supplier Name"
-	buying_settings.po_required = "No"
-	buying_settings.pr_required = "No"
-	buying_settings.maintain_same_rate = 1
-	buying_settings.save()
+    buying_settings = frappe.get_doc("Buying Settings")
+    buying_settings.supp_master_name = "Supplier Name"
+    buying_settings.po_required = "No"
+    buying_settings.pr_required = "No"
+    buying_settings.maintain_same_rate = 1
+    buying_settings.save()
 
-	notification_control = frappe.get_doc("Notification Control")
-	notification_control.quotation = 1
-	notification_control.sales_invoice = 1
-	notification_control.purchase_order = 1
-	notification_control.save()
+    notification_control = frappe.get_doc("Notification Control")
+    notification_control.quotation = 1
+    notification_control.sales_invoice = 1
+    notification_control.purchase_order = 1
+    notification_control.save()
 
-	hr_settings = frappe.get_doc("HR Settings")
-	hr_settings.emp_created_by = "Naming Series"
-	hr_settings.save()
+    hr_settings = frappe.get_doc("HR Settings")
+    hr_settings.emp_created_by = "Naming Series"
+    hr_settings.save()
 
 def create_feed_and_todo():
-	"""update Activity feed and create todo for creation of item, customer, vendor"""
-	add_info_comment(**{
-		"subject": _("ERPNext Setup Complete!")
-	})
+    """update Activity feed and create todo for creation of item, customer, vendor"""
+    add_info_comment(**{
+        "subject": _("ERPNext Setup Complete!")
+    })
 
 def create_email_digest():
-	from frappe.utils.user import get_system_managers
-	system_managers = get_system_managers(only_name=True)
-	if not system_managers:
-		return
+    from frappe.utils.user import get_system_managers
+    system_managers = get_system_managers(only_name=True)
+    if not system_managers:
+        return
 
-	companies = frappe.db.sql_list("select name FROM `tabCompany`")
-	for company in companies:
-		if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
-			edigest = frappe.get_doc({
-				"doctype": "Email Digest",
-				"name": "Default Weekly Digest - " + company,
-				"company": company,
-				"frequency": "Weekly",
-				"recipient_list": "\n".join(system_managers)
-			})
+    companies = frappe.db.sql_list("select name FROM `tabCompany`")
+    for company in companies:
+        if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
+            edigest = frappe.get_doc({
+                "doctype": "Email Digest",
+                "name": "Default Weekly Digest - " + company,
+                "company": company,
+                "frequency": "Weekly",
+                "recipient_list": "\n".join(system_managers)
+            })
 
-			for df in edigest.meta.get("fields", {"fieldtype": "Check"}):
-				if df.fieldname != "scheduler_errors":
-					edigest.set(df.fieldname, 1)
+            for df in edigest.meta.get("fields", {"fieldtype": "Check"}):
+                if df.fieldname != "scheduler_errors":
+                    edigest.set(df.fieldname, 1)
 
-			edigest.insert()
+            edigest.insert()
 
-	# scheduler errors digest
-	if companies:
-		edigest = frappe.new_doc("Email Digest")
-		edigest.update({
-			"name": "Scheduler Errors",
-			"company": companies[0],
-			"frequency": "Daily",
-			"recipient_list": "\n".join(system_managers),
-			"scheduler_errors": 1,
-			"enabled": 1
-		})
-		edigest.insert()
+    # scheduler errors digest
+    if companies:
+        edigest = frappe.new_doc("Email Digest")
+        edigest.update({
+            "name": "Scheduler Errors",
+            "company": companies[0],
+            "frequency": "Daily",
+            "recipient_list": "\n".join(system_managers),
+            "scheduler_errors": 1,
+            "enabled": 1
+        })
+        edigest.insert()
 
 def get_fy_details(fy_start_date, fy_end_date):
-	start_year = getdate(fy_start_date).year
-	if start_year == getdate(fy_end_date).year:
-		fy = cstr(start_year)
-	else:
-		fy = cstr(start_year) + '-' + cstr(start_year + 1)
-	return fy
+    start_year = getdate(fy_start_date).year
+    if start_year == getdate(fy_end_date).year:
+        fy = cstr(start_year)
+    else:
+        fy = cstr(start_year) + '-' + cstr(start_year + 1)
+    return fy
 
 def create_taxes(args):
 
-	for i in xrange(1,6):
-		if args.get("tax_" + str(i)):
-			# replace % in case someone also enters the % symbol
-			tax_rate = cstr(args.get("tax_rate_" + str(i)) or "").replace("%", "")
+    for i in xrange(1,6):
+        if args.get("tax_" + str(i)):
+            # replace % in case someone also enters the % symbol
+            tax_rate = cstr(args.get("tax_rate_" + str(i)) or "").replace("%", "")
 
-			try:
-				tax_group = frappe.db.get_value("Account", {"company": args.get("company_name"),
-					"is_group": 1, "account_type": "Tax", "root_type": "Liability"})
-				if tax_group:
-					account = make_tax_head(args, i, tax_group, tax_rate)
-					make_sales_and_purchase_tax_templates(account)
+            try:
+                tax_group = frappe.db.get_value("Account", {"company": args.get("company_name"),
+                    "is_group": 1, "account_type": "Tax", "root_type": "Liability"})
+                if tax_group:
+                    account = make_tax_head(args, i, tax_group, tax_rate)
+                    make_sales_and_purchase_tax_templates(account)
 
-			except frappe.NameError, e:
-				if e.args[2][0]==1062:
-					pass
-				else:
-					raise
-			except RootNotEditable, e:
-				pass
+            except frappe.NameError, e:
+                if e.args[2][0]==1062:
+                    pass
+                else:
+                    raise
+            except RootNotEditable, e:
+                pass
 
 def make_tax_head(args, i, tax_group, tax_rate):
-	return frappe.get_doc({
-		"doctype":"Account",
-		"company": args.get("company_name").strip(),
-		"parent_account": tax_group,
-		"account_name": args.get("tax_" + str(i)),
-		"is_group": 0,
-		"report_type": "Balance Sheet",
-		"account_type": "Tax",
-		"tax_rate": flt(tax_rate) if tax_rate else None
-	}).insert(ignore_permissions=True)
+    return frappe.get_doc({
+        "doctype":"Account",
+        "company": args.get("company_name").strip(),
+        "parent_account": tax_group,
+        "account_name": args.get("tax_" + str(i)),
+        "is_group": 0,
+        "report_type": "Balance Sheet",
+        "account_type": "Tax",
+        "tax_rate": flt(tax_rate) if tax_rate else None
+    }).insert(ignore_permissions=True)
 
 def make_sales_and_purchase_tax_templates(account):
-	doc = {
-		"doctype": "Sales Taxes and Charges Template",
-		"title": account.name,
-		"taxes": [{
-		    "category": "Valuation and Total",
-		    "charge_type": "On Net Total",
-			"account_head": account.name,
-			"description": "{0} @ {1}".format(account.account_name, account.tax_rate),
-			"rate": account.tax_rate
-		}]
-	}
+    doc = {
+        "doctype": "Sales Taxes and Charges Template",
+        "title": account.name,
+        "taxes": [{
+            "category": "Valuation and Total",
+            "charge_type": "On Net Total",
+            "account_head": account.name,
+            "description": "{0} @ {1}".format(account.account_name, account.tax_rate),
+            "rate": account.tax_rate
+        }]
+    }
 
-	# Sales
-	frappe.get_doc(copy.deepcopy(doc)).insert()
+    # Sales
+    frappe.get_doc(copy.deepcopy(doc)).insert()
 
-	# Purchase
-	doc["doctype"] = "Purchase Taxes and Charges Template"
-	frappe.get_doc(copy.deepcopy(doc)).insert()
+    # Purchase
+    doc["doctype"] = "Purchase Taxes and Charges Template"
+    frappe.get_doc(copy.deepcopy(doc)).insert()
 
 def create_items(args):
-	for i in xrange(1,6):
-		item = args.get("item_" + str(i))
-		if item:
-			item_group = args.get("item_group_" + str(i))
-			is_sales_item = args.get("is_sales_item_" + str(i))
-			is_purchase_item = args.get("is_purchase_item_" + str(i))
-			is_stock_item = item_group!=_("Services")
-			default_warehouse = ""
-			if is_stock_item:
-				default_warehouse = frappe.db.get_value("Warehouse", filters={
-					"warehouse_name": _("Finished Goods") if is_sales_item else _("Stores"),
-					"company": args.get("company_name").strip()
-				})
+    for i in xrange(1,6):
+        item = args.get("item_" + str(i))
+        if item:
+            item_group = args.get("item_group_" + str(i))
+            is_sales_item = args.get("is_sales_item_" + str(i))
+            is_purchase_item = args.get("is_purchase_item_" + str(i))
+            is_stock_item = item_group!=_("Services")
+            default_warehouse = ""
+            if is_stock_item:
+                default_warehouse = frappe.db.get_value("Warehouse", filters={
+                    "warehouse_name": _("Finished Goods") if is_sales_item else _("Stores"),
+                    "company": args.get("company_name").strip()
+                })
 
-			try:
-				frappe.get_doc({
-					"doctype":"Item",
-					"item_code": item,
-					"item_name": item,
-					"description": item,
-					"show_in_website": 1,
-					"is_sales_item": is_sales_item,
-					"is_purchase_item": is_purchase_item,
-					"is_stock_item": is_stock_item and 1 or 0,
-					"item_group": item_group,
-					"stock_uom": args.get("item_uom_" + str(i)),
-					"default_warehouse": default_warehouse
-				}).insert()
+            try:
+                frappe.get_doc({
+                    "doctype":"Item",
+                    "item_code": item,
+                    "item_name": item,
+                    "description": item,
+                    "show_in_website": 1,
+                    "is_sales_item": is_sales_item,
+                    "is_purchase_item": is_purchase_item,
+                    "is_stock_item": is_stock_item and 1 or 0,
+                    "item_group": item_group,
+                    "stock_uom": args.get("item_uom_" + str(i)),
+                    "default_warehouse": default_warehouse
+                }).insert()
 
-				if args.get("item_img_" + str(i)):
-					item_image = args.get("item_img_" + str(i)).split(",")
-					if len(item_image)==3:
-						filename, filetype, content = item_image
-						fileurl = save_file(filename, content, "Item", item, decode=True).file_url
-						frappe.db.set_value("Item", item, "image", fileurl)
+                if args.get("item_img_" + str(i)):
+                    item_image = args.get("item_img_" + str(i)).split(",")
+                    if len(item_image)==3:
+                        filename, filetype, content = item_image
+                        fileurl = save_file(filename, content, "Item", item, decode=True).file_url
+                        frappe.db.set_value("Item", item, "image", fileurl)
 
-				if args.get("item_price_" + str(i)):
-					item_price = flt(args.get("item_price_" + str(i)))
+                if args.get("item_price_" + str(i)):
+                    item_price = flt(args.get("item_price_" + str(i)))
 
-					if is_sales_item:
-						price_list_name = frappe.db.get_value("Price List", {"selling": 1})
-						make_item_price(item, price_list_name, item_price)
+                    if is_sales_item:
+                        price_list_name = frappe.db.get_value("Price List", {"selling": 1})
+                        make_item_price(item, price_list_name, item_price)
 
-					if is_purchase_item:
-						price_list_name = frappe.db.get_value("Price List", {"buying": 1})
-						make_item_price(item, price_list_name, item_price)
+                    if is_purchase_item:
+                        price_list_name = frappe.db.get_value("Price List", {"buying": 1})
+                        make_item_price(item, price_list_name, item_price)
 
-			except frappe.NameError:
-				pass
+            except frappe.NameError:
+                pass
 
 def make_item_price(item, price_list_name, item_price):
-	frappe.get_doc({
-		"doctype": "Item Price",
-		"price_list": price_list_name,
-		"item_code": item,
-		"price_list_rate": item_price
-	}).insert()
+    frappe.get_doc({
+        "doctype": "Item Price",
+        "price_list": price_list_name,
+        "item_code": item,
+        "price_list_rate": item_price
+    }).insert()
 
 
 def create_customers(args):
-	for i in xrange(1,6):
-		customer = args.get("customer_" + str(i))
-		if customer:
-			try:
-				doc = frappe.get_doc({
-					"doctype":"Customer",
-					"customer_name": customer,
-					"customer_type": "Company",
-					"customer_group": _("Commercial"),
-					"territory": args.get("country"),
-					"company": args.get("company_name").strip()
-				}).insert()
+    for i in xrange(1,6):
+        customer = args.get("customer_" + str(i))
+        if customer:
+            try:
+                doc = frappe.get_doc({
+                    "doctype":"Customer",
+                    "customer_name": customer,
+                    "customer_type": "Company",
+                    "customer_group": _("Commercial"),
+                    "territory": args.get("country"),
+                    "company": args.get("company_name").strip()
+                }).insert()
 
-				if args.get("customer_contact_" + str(i)):
-					create_contact(args.get("customer_contact_" + str(i)),
-						"customer", doc.name)
-			except frappe.NameError:
-				pass
+                if args.get("customer_contact_" + str(i)):
+                    create_contact(args.get("customer_contact_" + str(i)),
+                        "customer", doc.name)
+            except frappe.NameError:
+                pass
 
 def create_suppliers(args):
-	for i in xrange(1,6):
-		supplier = args.get("supplier_" + str(i))
-		if supplier:
-			try:
-				doc = frappe.get_doc({
-					"doctype":"Supplier",
-					"supplier_name": supplier,
-					"supplier_type": _("Local"),
-					"company": args.get("company_name").strip()
-				}).insert()
+    for i in xrange(1,6):
+        supplier = args.get("supplier_" + str(i))
+        if supplier:
+            try:
+                doc = frappe.get_doc({
+                    "doctype":"Supplier",
+                    "supplier_name": supplier,
+                    "supplier_type": _("Local"),
+                    "company": args.get("company_name").strip()
+                }).insert()
 
-				if args.get("supplier_contact_" + str(i)):
-					create_contact(args.get("supplier_contact_" + str(i)),
-						"supplier", doc.name)
-			except frappe.NameError:
-				pass
+                if args.get("supplier_contact_" + str(i)):
+                    create_contact(args.get("supplier_contact_" + str(i)),
+                        "supplier", doc.name)
+            except frappe.NameError:
+                pass
 
 def create_contact(contact, party_type, party):
-	"""Create contact based on given contact name"""
-	contact = contact.strip().split(" ")
+    """Create contact based on given contact name"""
+    contact = contact.strip().split(" ")
 
-	frappe.get_doc({
-		"doctype":"Contact",
-		party_type: party,
-		"first_name":contact[0],
-		"last_name": len(contact) > 1 and contact[1] or ""
-	}).insert()
+    frappe.get_doc({
+        "doctype":"Contact",
+        party_type: party,
+        "first_name":contact[0],
+        "last_name": len(contact) > 1 and contact[1] or ""
+    }).insert()
 
 def create_letter_head(args):
-	if args.get("attach_letterhead"):
-		frappe.get_doc({
-			"doctype":"Letter Head",
-			"letter_head_name": _("Standard"),
-			"is_default": 1
-		}).insert()
+    if args.get("attach_letterhead"):
+        frappe.get_doc({
+            "doctype":"Letter Head",
+            "letter_head_name": _("Standard"),
+            "is_default": 1
+        }).insert()
 
-		attach_letterhead = args.get("attach_letterhead").split(",")
-		if len(attach_letterhead)==3:
-			filename, filetype, content = attach_letterhead
-			fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url
-			frappe.db.set_value("Letter Head", _("Standard"), "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
+        attach_letterhead = args.get("attach_letterhead").split(",")
+        if len(attach_letterhead)==3:
+            filename, filetype, content = attach_letterhead
+            fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url
+            frappe.db.set_value("Letter Head", _("Standard"), "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
 
 def create_logo(args):
-	if args.get("attach_logo"):
-		attach_logo = args.get("attach_logo").split(",")
-		if len(attach_logo)==3:
-			filename, filetype, content = attach_logo
-			fileurl = save_file(filename, content, "Website Settings", "Website Settings",
-				decode=True).file_url
-			frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
-				"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name").strip()))
+    if args.get("attach_logo"):
+        attach_logo = args.get("attach_logo").split(",")
+        if len(attach_logo)==3:
+            filename, filetype, content = attach_logo
+            fileurl = save_file(filename, content, "Website Settings", "Website Settings",
+                decode=True).file_url
+            frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
+                "<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name").strip()))
 
 def create_territories():
-	"""create two default territories, one for home country and one named Rest of the World"""
-	from frappe.utils.nestedset import get_root_of
-	country = frappe.db.get_default("country")
-	root_territory = get_root_of("Territory")
-	for name in (country, _("Rest Of The World")):
-		if name and not frappe.db.exists("Territory", name):
-			frappe.get_doc({
-				"doctype": "Territory",
-				"territory_name": name.replace("'", ""),
-				"parent_territory": root_territory,
-				"is_group": "No"
-			}).insert()
+    """create two default territories, one for home country and one named Rest of the World"""
+    from frappe.utils.nestedset import get_root_of
+    country = frappe.db.get_default("country")
+    root_territory = get_root_of("Territory")
+    for name in (country, _("Rest Of The World")):
+        if name and not frappe.db.exists("Territory", name):
+            frappe.get_doc({
+                "doctype": "Territory",
+                "territory_name": name.replace("'", ""),
+                "parent_territory": root_territory,
+                "is_group": "No"
+            }).insert()
 
 def login_as_first_user(args):
-	if args.get("email") and hasattr(frappe.local, "login_manager"):
-		frappe.local.login_manager.login_as(args.get("email"))
+    if args.get("email") and hasattr(frappe.local, "login_manager"):
+        frappe.local.login_manager.login_as(args.get("email"))
 
 def create_users(args):
-	if frappe.session.user == 'Administrator':
-		return
+    if frappe.session.user == 'Administrator':
+        return
 
-	# create employee for self
-	emp = frappe.get_doc({
-		"doctype": "Employee",
-		"employee_name": " ".join(filter(None, [args.get("first_name"), args.get("last_name")])),
-		"user_id": frappe.session.user,
-		"status": "Active",
-		"company": args.get("company_name")
-	})
-	emp.flags.ignore_mandatory = True
-	emp.insert(ignore_permissions = True)
+    # create employee for self
+    emp = frappe.get_doc({
+        "doctype": "Employee",
+        "employee_name": " ".join(filter(None, [args.get("first_name"), args.get("last_name")])),
+        "user_id": frappe.session.user,
+        "status": "Active",
+        "company": args.get("company_name")
+    })
+    emp.flags.ignore_mandatory = True
+    emp.insert(ignore_permissions = True)
 
-	for i in xrange(1,5):
-		email = args.get("user_email_" + str(i))
-		fullname = args.get("user_fullname_" + str(i))
-		if email:
-			if not fullname:
-				fullname = email.split("@")[0]
+    for i in xrange(1,5):
+        email = args.get("user_email_" + str(i))
+        fullname = args.get("user_fullname_" + str(i))
+        if email:
+            if not fullname:
+                fullname = email.split("@")[0]
 
-			parts = fullname.split(" ", 1)
+            parts = fullname.split(" ", 1)
 
-			user = frappe.get_doc({
-				"doctype": "User",
-				"email": email,
-				"first_name": parts[0],
-				"last_name": parts[1] if len(parts) > 1 else "",
-				"enabled": 1,
-				"user_type": "System User"
-			})
+            user = frappe.get_doc({
+                "doctype": "User",
+                "email": email,
+                "first_name": parts[0],
+                "last_name": parts[1] if len(parts) > 1 else "",
+                "enabled": 1,
+                "user_type": "System User"
+            })
 
-			# default roles
-			user.append_roles("Projects User", "Stock User", "Support Team")
+            # default roles
+            user.append_roles("Projects User", "Stock User", "Support Team")
 
-			if args.get("user_sales_" + str(i)):
-				user.append_roles("Sales User", "Sales Manager", "Accounts User")
-			if args.get("user_purchaser_" + str(i)):
-				user.append_roles("Purchase User", "Purchase Manager", "Accounts User")
-			if args.get("user_accountant_" + str(i)):
-				user.append_roles("Accounts Manager", "Accounts User")
+            if args.get("user_sales_" + str(i)):
+                user.append_roles("Sales User", "Sales Manager", "Accounts User")
+            if args.get("user_purchaser_" + str(i)):
+                user.append_roles("Purchase User", "Purchase Manager", "Accounts User")
+            if args.get("user_accountant_" + str(i)):
+                user.append_roles("Accounts Manager", "Accounts User")
 
-			user.flags.delay_emails = True
+            user.flags.delay_emails = True
 
-			if not frappe.db.get_value("User", email):
-				user.insert(ignore_permissions=True)
+            if not frappe.db.get_value("User", email):
+                user.insert(ignore_permissions=True)
 
-				# create employee
-				emp = frappe.get_doc({
-					"doctype": "Employee",
-					"employee_name": fullname,
-					"user_id": email,
-					"status": "Active",
-					"company": args.get("company_name")
-				})
-				emp.flags.ignore_mandatory = True
-				emp.insert(ignore_permissions = True)
+                # create employee
+                emp = frappe.get_doc({
+                    "doctype": "Employee",
+                    "employee_name": fullname,
+                    "user_id": email,
+                    "status": "Active",
+                    "company": args.get("company_name")
+                })
+                emp.flags.ignore_mandatory = True
+                emp.insert(ignore_permissions = True)
 
 def create_academic_term():
-	at = ["Semester 1", "Semester 2", "Semester 3"]
-	for d in at:
-		academic_term = frappe.new_doc("Academic Term")
-		academic_term.term_name = d
-		academic_term.save()
+    at = ["Semester 1", "Semester 2", "Semester 3"]
+    ay = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
+    for y in ay:
+        for t in at:
+            academic_term = frappe.new_doc("Academic Term")
+            academic_term.academic_year = y
+            academic_term.term_name = t
+            academic_term.save()
 
 def create_academic_year():
-	ac = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
-	for d in ac:
-		academic_year = frappe.new_doc("Academic Year")
-		academic_year.academic_year_name = d
-		academic_year.save()
+    ac = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
+    for d in ac:
+        academic_year = frappe.new_doc("Academic Year")
+        academic_year.academic_year_name = d
+        academic_year.save()
 
 def create_program(args):
-	for i in xrange(1,6):
-		if args.get("program_" + str(i)):
-			program = frappe.new_doc("Program")
-			program.program_name = args.get("program_" + str(i))
-			program.save()
+    for i in xrange(1,6):
+        if args.get("program_" + str(i)):
+            program = frappe.new_doc("Program")
+            program.program_name = args.get("program_" + str(i))
+            program.save()
 
 def create_course(args):
-	for i in xrange(1,6):
-		if args.get("course_" + str(i)):
-			course = frappe.new_doc("Course")
-			course.course_name = args.get("course_" + str(i))
-			course.save()
+    for i in xrange(1,6):
+        if args.get("course_" + str(i)):
+            course = frappe.new_doc("Course")
+            course.course_name = args.get("course_" + str(i))
+            course.save()
 
 def create_instructor(args):
-	for i in xrange(1,6):
-		if args.get("instructor_" + str(i)):
-			instructor = frappe.new_doc("Instructor")
-			instructor.instructor_name = args.get("instructor_" + str(i))
-			instructor.save()
+    for i in xrange(1,6):
+        if args.get("instructor_" + str(i)):
+            instructor = frappe.new_doc("Instructor")
+            instructor.instructor_name = args.get("instructor_" + str(i))
+            instructor.save()
 
 def create_room(args):
-	for i in xrange(1,6):
-		if args.get("room_" + str(i)):
-			room = frappe.new_doc("Room")
-			room.room_name = args.get("room_" + str(i))
-			room.seating_capacity = args.get("room_capacity_" + str(i))
-			room.save()
+    for i in xrange(1,6):
+        if args.get("room_" + str(i)):
+            room = frappe.new_doc("Room")
+            room.room_name = args.get("room_" + str(i))
+            room.seating_capacity = args.get("room_capacity_" + str(i))
+            room.save()
 
 
diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py
index 991114d..58a2c79 100644
--- a/erpnext/startup/notifications.py
+++ b/erpnext/startup/notifications.py
@@ -22,12 +22,21 @@
 				"docstatus": ("<", 2)
 			},
 			"Journal Entry": {"docstatus": 0},
-			"Sales Invoice": { "outstanding_amount": (">", 0), "docstatus": ("<", 2) },
-			"Purchase Invoice": {"docstatus": 0},
+			"Sales Invoice": {
+				"outstanding_amount": (">", 0), 
+				"docstatus": ("<", 2) 
+			},
+			"Purchase Invoice": {
+				"outstanding_amount": (">", 0), 
+				"docstatus": ("<", 2)
+			},
 			"Leave Application": {"status": "Open"},
 			"Expense Claim": {"approval_status": "Draft"},
 			"Job Applicant": {"status": "Open"},
-			"Delivery Note": {"docstatus": 0},
+			"Delivery Note": {
+				"status": ("not in", ("Completed", "Closed")),
+				"docstatus": ("<", 2)
+			},
 			"Stock Entry": {"docstatus": 0},
 			"Material Request": {
 				"docstatus": ("<", 2),
@@ -40,7 +49,10 @@
 				"status": ("not in", ("Completed", "Closed")),
 				"docstatus": ("<", 2)
 			},
-			"Purchase Receipt": {"docstatus": 0},
+			"Purchase Receipt": {
+				"status": ("not in", ("Completed", "Closed")),
+				"docstatus": ("<", 2)
+			},
 			"Production Order": { "status": ("in", ("Draft", "Not Started", "In Process")) },
 			"BOM": {"docstatus": 0},
 			"Timesheet": {"status": "Draft"}
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index eba9201..f961cdd 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -125,7 +125,7 @@
 		pr = make_purchase_receipt()
 		
 		return_pr = make_purchase_receipt(is_return=1, return_against=pr.name, qty=-2)
-		
+
 		# check sle
 		outgoing_rate = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Purchase Receipt", 
 			"voucher_no": return_pr.name}, "outgoing_rate")
@@ -148,7 +148,21 @@
 			self.assertEquals(expected_values[gle.account][1], gle.credit)
 		
 		set_perpetual_inventory(0)
+
+	def test_purchase_return_for_rejected_qty(self):
+		set_perpetual_inventory()
+
+		pr = make_purchase_receipt(received_qty=4, qty=2)
+
+		return_pr = make_purchase_receipt(is_return=1, return_against=pr.name, received_qty = -4, qty=-2)
+
+		actual_qty = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Purchase Receipt",
+			"voucher_no": return_pr.name, 'warehouse': return_pr.items[0].rejected_warehouse}, "actual_qty")
 		
+		self.assertEqual(actual_qty, -2)
+
+		set_perpetual_inventory(0)
+
 	def test_purchase_return_for_serialized_items(self):
 		def _check_serial_no_values(serial_no, field_values):
 			serial_no = frappe.get_doc("Serial No", serial_no)
@@ -248,17 +262,23 @@
 	pr.currency = args.currency or "INR"
 	pr.is_return = args.is_return
 	pr.return_against = args.return_against
-	
+	qty = args.qty or 5
+	received_qty = args.received_qty or qty
+	rejected_qty = args.rejected_qty or flt(received_qty) - flt(qty)
+
 	pr.append("items", {
 		"item_code": args.item or args.item_code or "_Test Item",
 		"warehouse": args.warehouse or "_Test Warehouse - _TC",
-		"qty": args.qty or 5,
-		"received_qty": args.qty or 5,
+		"qty": qty,
+		"received_qty": received_qty,
+		"rejected_qty": rejected_qty,
+		"rejected_warehouse": args.rejected_warehouse or "_Test Rejected Warehouse - _TC" if rejected_qty != 0 else "",
 		"rate": args.rate or 50,
 		"conversion_factor": 1.0,
 		"serial_no": args.serial_no,
 		"stock_uom": "_Test UOM"
 	})
+
 	if not args.do_not_save:
 		pr.insert()
 		if not args.do_not_submit:
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index a0c3adf..c70613b 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -78,10 +78,27 @@
 				}
 			});
 		}
-	}
+	},
+	set_item_code: function(doc, cdt, cdn) {
+		var d = frappe.model.get_doc(cdt, cdn);
+		if (d.barcode) {
+			frappe.call({
+				method: "erpnext.stock.get_item_details.get_item_code",
+				args: {"barcode": d.barcode },
+				callback: function(r) {
+					if (!r.exe){
+						frappe.model.set_value(cdt, cdn, "item_code", r.message);
+					}
+				}
+			});
+		}
+	}	
 });
 
 frappe.ui.form.on("Stock Reconciliation Item", {
+	barcode: function(frm, cdt, cdn) {
+		frm.events.set_item_code(frm, cdt, cdn);
+	},
 	warehouse: function(frm, cdt, cdn) {
 		frm.events.set_valuation_rate_and_qty(frm, cdt, cdn);
 	},
diff --git a/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json b/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
index e03d8a0..efd0dee 100644
--- a/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
+++ b/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
@@ -14,6 +14,32 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "barcode", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Barcode", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "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, 
    "columns": 3, 
    "fieldname": "item_code", 
    "fieldtype": "Link", 
@@ -285,7 +311,7 @@
  "istable": 1, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-08-26 02:15:26.109664", 
+ "modified": "2016-09-05 07:10:19.571562", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Reconciliation Item", 
diff --git a/patches.txt b/patches.txt
new file mode 100644
index 0000000..8f127fe
--- /dev/null
+++ b/patches.txt
@@ -0,0 +1 @@
+bench.patches.v3.deprecate_old_config