Merge branch 'develop' into remove-party-status
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 20f5e54..d916789 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.2.17'
+__version__ = '7.2.18'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index c98e77f..fc261a5 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -86,9 +86,9 @@
 			};
 		});
 
-		me.frm.set_query("party_type", "accounts", function(doc, cdt, cdn) {
-			return {
-				filters: {"name": ["in", ["Customer", "Supplier"]]}
+		me.frm.set_query("party_type", "accounts", function() {
+			return{
+				query: "erpnext.setup.doctype.party_type.party_type.get_party_type"
 			}
 		});
 
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index a176680..a13cc7d 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -9,6 +9,7 @@
 from erpnext.accounts.utils import get_balance_on, get_account_currency
 from erpnext.setup.utils import get_company_currency
 from erpnext.accounts.party import get_party_account
+from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount
 
 class JournalEntry(AccountsController):
 	def __init__(self, arg1, arg2=None):
@@ -375,7 +376,7 @@
 		bank_amount = party_amount = total_amount = 0.0
 		currency = bank_account_currency = party_account_currency = pay_to_recd_from= None
 		for d in self.get('accounts'):
-			if d.party_type and d.party:
+			if d.party_type in ['Customer', 'Supplier'] and d.party:
 				if not pay_to_recd_from:
 					pay_to_recd_from = frappe.db.get_value(d.party_type, d.party,
 						"customer_name" if d.party_type=="Customer" else "supplier_name")
@@ -503,11 +504,9 @@
 
 	def update_expense_claim(self):
 		for d in self.accounts:
-			if d.reference_type=="Expense Claim":
-				amt = frappe.db.sql("""select sum(debit) as amt from `tabJournal Entry Account`
-					where reference_type = "Expense Claim" and
-					reference_name = %s and docstatus = 1""", d.reference_name ,as_dict=1)[0].amt
-				frappe.db.set_value("Expense Claim", d.reference_name , "total_amount_reimbursed", amt)
+			if d.reference_type=="Expense Claim" and d.party:
+				doc = frappe.get_doc("Expense Claim", d.reference_name)
+				update_reimbursed_amount(doc)
 
 	def validate_expense_claim(self):
 		for d in self.accounts:
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index d3dbd31..6528c8f 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -26,6 +26,12 @@
 			}
 		});
 
+		frm.set_query("party_type", function() {
+			return{
+				query: "erpnext.setup.doctype.party_type.party_type.get_party_type"
+			}
+		});
+
 		frm.set_query("paid_to", function() {
 			var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) ?
 	 			["Bank", "Cash"] : party_account_type;
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json
index dafa67a..98fa445 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.json
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json
@@ -123,7 +123,7 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
-  }, 
+  },    
   {
    "allow_on_submit": 0, 
    "bold": 1, 
@@ -247,7 +247,7 @@
    "columns": 0, 
    "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)", 
    "fieldname": "party_type", 
-   "fieldtype": "Select", 
+   "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -257,7 +257,7 @@
    "label": "Party Type", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Customer\nSupplier", 
+   "options": "DocType", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 1, 
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
index 6a951a0..272e474 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
@@ -6,12 +6,10 @@
 erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.extend({
 	onload: function() {
 		var me = this
-		this.frm.set_query('party_type', function() {
-			return {
-				filters: {
-					"name": ["in", ["Customer", "Supplier"]]
-				}
-			};
+		this.frm.set_query("party_type", function() {
+			return{
+				query: "erpnext.setup.doctype.party_type.party_type.get_party_type"
+			}
 		});
 
 		this.frm.set_query('receivable_payable_account', function() {
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index bd54776..070dbeb 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -30,6 +30,7 @@
 		'doc': doc,
 		'default_customer': pos_profile.get('customer'),
 		'items': get_items_list(pos_profile),
+		'item_groups': get_item_group(pos_profile),
 		'customers': get_customers_list(pos_profile),
 		'serial_no_data': get_serial_no_data(pos_profile, doc.company),
 		'batch_no_data': get_batch_no_data(),
@@ -140,6 +141,15 @@
 			disabled = 0 and has_variants = 0 and is_sales_item = 1 and {cond}
 		""".format(cond=cond), tuple(item_groups), as_dict=1)
 
+def get_item_group(pos_profile):
+	if pos_profile.get('item_groups'):
+		item_groups = []
+		for d in pos_profile.get('item_groups'):
+			item_groups.extend(get_child_nodes('Item Group', d.item_group))
+		return item_groups
+	else:
+		return frappe.db.sql_list("""Select name from `tabItem Group` order by name""")
+
 def get_customers_list(pos_profile):
 	cond = "1=1"
 	customer_groups = []
@@ -276,11 +286,33 @@
 		customer_doc = frappe.new_doc('Customer')
 		customer_doc.customer_name = doc.get('customer')
 		customer_doc.customer_type = 'Company'
-		customer_doc.customer_group = doc.get('customer_group')
-		customer_doc.territory = doc.get('territory')
+		customer_doc.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group')
+		customer_doc.territory = frappe.db.get_single_value('Selling Settings', 'territory')
+		customer_doc.flags.ignore_mandatory = True
 		customer_doc.save(ignore_permissions = True)
 		frappe.db.commit()
 		doc['customer'] = customer_doc.name
+		if doc.get('contact_details'):
+			args = json.loads(doc.get("contact_details"))
+			make_address(doc, args, customer_doc.name)
+
+def make_address(doc, args, customer):
+	if args.get("address_line1"):
+		address = frappe.new_doc('Address')
+		address.address_line1 = args.get('address_line1')
+		address.address_line2 = args.get('address_line2')
+		address.city = args.get('city')
+		address.state = args.get('state')
+		address.zip_code = args.get('zip_code')
+		address.email_id = args.get('email_id')
+		address.flags.ignore_mandatory = True
+		address.country = frappe.db.get_value('Company', doc.get('company'), 'country')
+		address.append('links',{
+			'link_doctype': 'Customer',
+			'link_name': customer
+		})
+		address.save(ignore_permissions = True)
+		frappe.db.commit()
 
 def validate_item(doc):
 	for item in doc.get('items'):
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 7ade318..f026cb0 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -28,7 +28,7 @@
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "fa fa-user", 
+   "options": "icon-user", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -232,7 +232,7 @@
    "in_standard_filter": 0, 
    "label": "Offline POS Name", 
    "length": 0, 
-   "no_copy": 0, 
+   "no_copy": 1, 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -1035,7 +1035,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-shopping-cart", 
+   "options": "icon-shopping-cart", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1122,7 +1122,7 @@
    "label": "Packing List", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "fa fa-suitcase", 
+   "options": "icon-suitcase", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -1462,7 +1462,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-money", 
+   "options": "icon-money", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1941,7 +1941,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-money", 
+   "options": "icon-money", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -2238,7 +2238,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-money", 
+   "options": "icon-money", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -2327,7 +2327,7 @@
    "label": "Payments", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "fa fa-money", 
+   "options": "icon-money", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -3252,7 +3252,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-file-text", 
+   "options": "icon-file-text", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -3515,7 +3515,7 @@
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "fa fa-group", 
+   "options": "icon-group", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -3720,7 +3720,7 @@
    "label": "Recurring", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "fa fa-time", 
+   "options": "icon-time", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -4173,7 +4173,7 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
- "icon": "fa fa-file-text", 
+ "icon": "icon-file-text", 
  "idx": 181, 
  "image_view": 0, 
  "in_create": 0, 
@@ -4282,5 +4282,6 @@
  "sort_order": "DESC", 
  "timeline_field": "customer", 
  "title_field": "title", 
+ "track_changes": 1, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 13abe14..ed54ab4 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -1,7 +1,7 @@
 frappe.provide("erpnext.pos");
 {% include "erpnext/public/js/controllers/taxes_and_totals.js" %}
 
-frappe.pages['pos'].on_page_load = function(wrapper) {
+frappe.pages['pos'].on_page_load = function (wrapper) {
 	var page = frappe.ui.make_app_page({
 		parent: wrapper,
 		title: __('Point of Sale'),
@@ -11,15 +11,15 @@
 	wrapper.pos = new erpnext.pos.PointOfSale(wrapper)
 }
 
-frappe.pages['pos'].refresh = function(wrapper) {
+frappe.pages['pos'].refresh = function (wrapper) {
 	window.onbeforeunload = function () {
 		return wrapper.pos.beforeunload()
 	}
 }
 
-
 erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
-	init: function(wrapper){
+	init: function (wrapper) {
+		this.page_len = 20;
 		this.page = wrapper.page;
 		this.wrapper = $(wrapper).find('.page-content');
 		this.set_indicator();
@@ -28,13 +28,13 @@
 		this.si_docs = this.get_doc_from_localstorage();
 	},
 
-	beforeunload: function(e){
-		if(this.connection_status == false && frappe.get_route()[0] == "pos"){
+	beforeunload: function (e) {
+		if (this.connection_status == false && frappe.get_route()[0] == "pos") {
 			e = e || window.event;
 
 			// For IE and Firefox prior to version 4
 			if (e) {
-			    e.returnValue = __("You are in offline mode. You will not be able to reload until you have network.");
+				e.returnValue = __("You are in offline mode. You will not be able to reload until you have network.");
 				return
 			}
 
@@ -43,23 +43,23 @@
 		}
 	},
 
-	check_internet_connection: function(){
+	check_internet_connection: function () {
 		var me = this;
 		//Check Internet connection after every 30 seconds
-		setInterval(function(){
+		setInterval(function () {
 			me.set_indicator();
 		}, 5000)
 	},
 
-	set_indicator: function(){
+	set_indicator: function () {
 		var me = this;
 		// navigator.onLine
 		this.connection_status = false;
 		this.page.set_indicator(__("Offline"), "grey")
 		frappe.call({
-			method:"frappe.handler.ping",
-			callback: function(r){
-				if(r.message){
+			method: "frappe.handler.ping",
+			callback: function (r) {
+				if (r.message) {
 					me.connection_status = true;
 					me.page.set_indicator(__("Online"), "green")
 				}
@@ -67,27 +67,23 @@
 		})
 	},
 
-	onload: function(){
+	onload: function () {
 		var me = this;
-		this.get_data_from_server(function(){
+		this.get_data_from_server(function () {
 			me.create_new();
 		});
 	},
 
-	make_menu_list: function(){
+	make_menu_list: function () {
 		var me = this;
 
-		this.page.add_menu_item(__("New Sales Invoice"), function() {
+		this.page.add_menu_item(__("New Sales Invoice"), function () {
 			me.save_previous_entry();
 			me.create_new();
 		})
 
-		this.page.add_menu_item(__("View Offline Records"), function(){
-			me.show_unsync_invoice_list();
-		});
-
-		this.page.add_menu_item(__("Sync Master Data"), function(){
-			me.get_data_from_server(function(){
+		this.page.add_menu_item(__("Sync Master Data"), function () {
+			me.get_data_from_server(function () {
 				me.load_data(false);
 				me.make_customer();
 				me.make_item_list();
@@ -95,83 +91,29 @@
 			})
 		});
 
-		this.page.add_menu_item(__("Sync Offline Invoices"), function(){
+		this.page.add_menu_item(__("Sync Offline Invoices"), function () {
 			me.sync_sales_invoice()
 		});
 
-		this.page.add_menu_item(__("POS Profile"), function() {
+		this.page.add_menu_item(__("POS Profile"), function () {
 			frappe.set_route('List', 'POS Profile');
 		});
 	},
 
-	show_unsync_invoice_list: function(){
-		var me = this;
-		this.si_docs = this.get_doc_from_localstorage();
-		this.list_dialog = new frappe.ui.Dialog({
-			title: 'Invoice List'
-		});
-
-		this.list_dialog.show();
-		this.list_body = this.list_dialog.body;
-		if(me.pos_profile_data["allow_delete"]) {
-			this.list_dialog.set_primary_action(__("Delete"), function() {
-				frappe.confirm(__("Delete permanently?"), function () {
-					me.delete_records();
-				})
-			}).addClass("btn-danger");
-			this.toggle_primary_action();
-		}
-
-		if(this.si_docs.length > 0){
-			me.render_offline_data();
-			me.dialog_actions()
-		}else{
-			$(this.list_body).append(repl('<div class="media-heading">%(message)s</div>', {'message': __("All records are synced.")}))
-		}
-	},
-
-	render_offline_data: function() {
+	dialog_actions: function () {
 		var me = this;
 
-		this.removed_items = [];
-		$(this.list_body).empty();
-
-		$(this.list_body).append('<div class="row list-row list-row-head pos-invoice-list">\
-				<div class="col-xs-1"><input class="list-select-all" type="checkbox"></div>\
-				<div class="col-xs-3">Customer</div>\
-				<div class="col-xs-2 text-left">Status</div>\
-				<div class="col-xs-3 text-right">Paid Amount</div>\
-				<div class="col-xs-3 text-right">Grand Total</div>\
-		</div>')
-
-		$.each(this.si_docs, function(index, data){
-			for(key in data) {
-				$(frappe.render_template("pos_invoice_list", {
-					sr: index + 1,
-					name: key,
-					customer: data[key].customer,
-					paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
-					grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
-					data: me.get_doctype_status(data[key])
-				})).appendTo($(me.list_body));
-			}
-		})
-	},
-
-	dialog_actions: function() {
-		var me = this;
-
-		$(this.list_body).find('.list-column').click(function() {
+		$(this.list_body).find('.list-column').click(function () {
 			me.name = $(this).parents().attr('invoice-name')
 			me.edit_record();
 		})
 
-		$(this.list_body).find('.list-select-all').click(function() {
+		$(this.list_body).find('.list-select-all').click(function () {
 			me.removed_items = [];
 			$(me.list_body).find('.list-delete').prop("checked", $(this).is(":checked"))
-			if($(this).is(":checked")) {
-				$.each(me.si_docs, function(index, data){
-					for(key in data) {
+			if ($(this).is(":checked")) {
+				$.each(me.si_docs, function (index, data) {
+					for (key in data) {
 						me.removed_items.push(key)
 					}
 				})
@@ -180,9 +122,9 @@
 			me.toggle_primary_action();
 		})
 
-		$(this.list_body).find('.list-delete').click(function() {
+		$(this.list_body).find('.list-delete').click(function () {
 			me.name = $(this).parent().parent().attr('invoice-name');
-			if($(this).is(":checked")) {
+			if ($(this).is(":checked")) {
 				me.removed_items.push(me.name);
 			} else {
 				me.removed_items.pop(me.name)
@@ -192,101 +134,103 @@
 		})
 	},
 
-	edit_record: function() {
+	edit_record: function () {
 		var me = this;
 
 		doc_data = this.get_invoice_doc(this.si_docs);
-		if(doc_data){
+		if (doc_data) {
 			this.frm.doc = doc_data[0][this.name];
 			this.set_missing_values();
 			this.refresh(false);
 			this.disable_input_field();
-			this.list_dialog.hide();
+			this.list_dialog && this.list_dialog.hide();
 		}
 	},
 
-	delete_records: function() {
+	delete_records: function () {
 		var me = this;
 		this.remove_doc_from_localstorage()
 		this.update_localstorage();
-		this.render_offline_data();
 		this.dialog_actions();
 		this.toggle_primary_action();
 	},
 
-	toggle_primary_action: function() {
+	toggle_primary_action: function () {
 		var me = this;
-		if(this.removed_items && this.removed_items.length > 0) {
-			$(this.list_dialog.wrapper).find('.btn-danger').show();
+		if(this.frm.doc.allow_delete) {
+			if (this.removed_items && this.removed_items.length > 0) {
+				$(this.wrapper).find('.btn-danger').show();
+			} else {
+				$(this.wrapper).find('.btn-danger').hide();
+			}
+		}
+	},
+
+	get_doctype_status: function (doc) {
+		if (doc.docstatus == 0) {
+			return { status: "Draft", indicator: "red" }
+		} else if (doc.outstanding_amount == 0) {
+			return { status: "Paid", indicator: "green" }
 		} else {
-			$(this.list_dialog.wrapper).find('.btn-danger').hide();
+			return { status: "Submitted", indicator: "blue" }
 		}
 	},
 
-	get_doctype_status: function(doc){
-		if(doc.docstatus == 0) {
-			return {status: "Draft", indicator: "red"}
-		}else if(doc.outstanding_amount == 0) {
-			return {status: "Paid", indicator: "green"}
-		}else {
-			return {status: "Submitted", indicator: "blue"}
-		}
-	},
-
-	set_missing_values: function(){
+	set_missing_values: function () {
 		var me = this;
 		doc = JSON.parse(localStorage.getItem('doc'))
-		if(this.frm.doc.payments.length == 0){
+		if (this.frm.doc.payments.length == 0) {
 			this.frm.doc.payments = doc.payments;
 			this.calculate_outstanding_amount();
 		}
 
-		if(this.frm.doc.customer){
+		if (this.frm.doc.customer) {
 			this.party_field.$input.val(this.frm.doc.customer);
 		}
 
-		if(!this.frm.doc.write_off_account){
+		if (!this.frm.doc.write_off_account) {
 			this.frm.doc.write_off_account = doc.write_off_account
 		}
 
-		if(!this.frm.doc.account_for_change_amount){
+		if (!this.frm.doc.account_for_change_amount) {
 			this.frm.doc.account_for_change_amount = doc.account_for_change_amount
 		}
 	},
 
-	get_invoice_doc: function(si_docs){
+	get_invoice_doc: function (si_docs) {
 		var me = this;
 		this.si_docs = this.get_doc_from_localstorage();
 
-		return $.grep(this.si_docs, function(data){
-			for(key in data){
+		return $.grep(this.si_docs, function (data) {
+			for (key in data) {
 				return key == me.name
 			}
 		})
 	},
 
-	get_data_from_server: function(callback){
+	get_data_from_server: function (callback) {
 		var me = this;
 		frappe.call({
 			method: "erpnext.accounts.doctype.sales_invoice.pos.get_pos_data",
 			freeze: true,
 			freeze_message: __("Master data syncing, it might take some time"),
-			callback: function(r){
+			callback: function (r) {
 				me.init_master_data(r)
 				localStorage.setItem('doc', JSON.stringify(r.message.doc));
 				me.set_interval_for_si_sync();
 				me.check_internet_connection();
-				if(callback){
+				if (callback) {
 					callback();
 				}
 			}
 		})
 	},
 
-	init_master_data: function(r){
+	init_master_data: function (r) {
 		var me = this;
 		this.meta = r.message.meta;
 		this.item_data = r.message.items;
+		this.item_groups = r.message.item_groups;
 		this.customers = r.message.customers;
 		this.serial_no_data = r.message.serial_no_data;
 		this.batch_no_data = r.message.batch_no_data;
@@ -301,48 +245,51 @@
 		this.letter_head = (this.pos_profile_data.length > 0) ? frappe.boot.letter_heads[this.pos_profile_data[letter_head]] : {};
 	},
 
-	save_previous_entry : function(){
-		if(this.frm.doc.docstatus < 1 && this.frm.doc.items.length > 0){
-			this.create_invoice()
+	save_previous_entry: function () {
+		if (this.frm.doc.docstatus < 1 && this.frm.doc.items.length > 0) {
+			this.create_invoice();
 		}
 	},
 
-	create_new: function(){
+	create_new: function () {
 		var me = this;
 		this.frm = {}
-		this.name = '';
+		this.name = null;
 		this.load_data(true);
 		this.setup();
 	},
 
-	load_data: function(load_doc){
+	load_data: function (load_doc) {
 		var me = this;
 
 		this.items = this.item_data;
 		this.actual_qty_dict = {};
 
-		if(load_doc) {
-			this.frm.doc =  JSON.parse(localStorage.getItem('doc'));
+		if (load_doc) {
+			this.frm.doc = JSON.parse(localStorage.getItem('doc'));
 		}
 
-		$.each(this.meta, function(i, data){
+		$.each(this.meta, function (i, data) {
 			frappe.meta.sync(data)
 			locals["DocType"][data.name] = data;
 		})
 
-		this.print_template_data = frappe.render_template("print_template", {content: this.print_template,
-			title:"POS", base_url: frappe.urllib.get_base_url(), print_css: frappe.boot.print_css,
-			print_settings: this.print_settings, header: this.letter_head.header, footer: this.letter_head.footer})
+		this.print_template_data = frappe.render_template("print_template", {
+			content: this.print_template,
+			title: "POS", base_url: frappe.urllib.get_base_url(), print_css: frappe.boot.print_css,
+			print_settings: this.print_settings, header: this.letter_head.header, footer: this.letter_head.footer
+		})
 	},
 
-	setup: function(){
+	setup: function () {
+		this.frm.doc.allow_delete = this.pos_profile_data["allow_delete"];
 		this.wrapper.html(frappe.render_template("pos", this.frm.doc));
 		this.set_transaction_defaults("Customer");
 		this.make();
 		this.set_primary_action();
 	},
 
-	set_transaction_defaults: function(party) {
+	set_transaction_defaults: function (party) {
 		var me = this;
 		this.party = party;
 		this.price_list = (party == "Customer" ?
@@ -351,34 +298,54 @@
 		this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
 	},
 
-	make: function() {
+	make: function () {
 		this.make_search();
+		this.make_list_customers();
 		this.make_customer();
 		this.make_item_list();
 		this.make_discount_field()
 	},
 
-	make_search: function() {
+	make_search: function () {
 		var me = this;
-		this.search = frappe.ui.form.make_control({
+		this.serach_item = frappe.ui.form.make_control({
 			df: {
 				"fieldtype": "Data",
 				"label": "Item",
 				"fieldname": "pos_item",
 				"placeholder": __("Search Item")
 			},
-			parent: this.wrapper.find(".search-area"),
+			parent: this.wrapper.find(".search-item"),
 			only_input: true,
 		});
 
-		this.search.make_input();
-		this.search.$input.on("keyup", function() {
-			setTimeout(function() {
+		this.serach_item.make_input();
+		this.serach_item.$input.on("keyup", function () {
+			setTimeout(function () {
 				me.items = me.get_items();
 				me.make_item_list();
 			}, 1000);
 		});
 
+		this.search_item_group = frappe.ui.form.make_control({
+			df: {
+				"fieldtype": "Select",
+				"options": me.item_groups,
+				"label": __("Item Group"),
+				"fieldname": "item_group",
+				"placeholder": __("Item Group")
+			},
+			parent: this.wrapper.find(".search-item-group"),
+			only_input: true,
+		});
+
+		this.search_item_group.make_input();
+		this.search_item_group.$input.on("change", function () {
+			me.page_len = 20;
+			me.items = me.get_items();
+			me.make_item_list();
+		});
+
 		this.party_field = frappe.ui.form.make_control({
 			df: {
 				"fieldtype": "Data",
@@ -392,21 +359,139 @@
 		});
 
 		this.party_field.make_input();
-		this.set_focus()
+		setTimeout(this.set_focus.bind(this), 500);
+
+		this.wrapper.find(".btn-more").on("click", function() {
+			me.page_len += 20;
+			me.items = me.get_items();
+			me.make_item_list();
+		})
 	},
 
-	set_focus: function(){
-		if(this.default_customer){
-			this.search.$input.focus();
-		}else{
+	make_list_customers: function () {
+		var me = this;
+		this.list_customers_btn = this.wrapper.find('.list-customers-btn');
+		this.add_customer_btn = this.wrapper.find('.add-customer-btn');
+		this.pos_bill = this.wrapper.find('.pos-bill').hide();
+		this.list_customers = this.wrapper.find('.list-customers');
+
+		this.list_customers_btn.on('click', function () {
+			$(this).toggleClass("view_customer");
+			if($(this).hasClass("view_customer")) {
+				me.render_list_customers();
+				me.bind_delete_event()
+				me.party_field.$input.attr('disabled', true);
+				me.list_customers.show();
+				me.pos_bill.hide();
+			} else {
+				if(me.frm.doc.docstatus == 0) {
+					me.party_field.$input.attr('disabled', false);
+				}
+				me.pos_bill.show();
+				me.list_customers.hide()
+			}
+		});
+		this.add_customer_btn.on('click', function() {
+			me.save_previous_entry();
+			me.create_new();
+			me.refresh();
+			me.set_focus();
+		});
+	},
+
+	render_list_customers: function () {
+		var me = this;
+
+		this.removed_items = [];
+		this.list_customers.empty();
+		this.si_docs = this.get_doc_from_localstorage();
+
+		if (!this.si_docs.length) {
+			this.list_customers.append(
+				'<div style="padding: 12px; margin-left:-12px;">' + __("No offline records.") + '</div>'
+			)
+			return;
+		}
+		var html = '<div class="row list-row list-row-head pos-invoice-list">\
+			<div class="col-xs-1"><input class="list-select-all" type="checkbox"></div>\
+			<div class="col-xs-3">Customer</div>\
+			<div class="col-xs-2 text-left">Status</div>\
+			<div class="col-xs-3 text-right">Paid Amount</div>\
+			<div class="col-xs-3 text-right">Grand Total</div>\
+		</div>';
+		this.si_docs.forEach(function (data, i) {
+			for (key in data) {
+				html += frappe.render_template("pos_invoice_list", {
+					sr: i + 1,
+					name: key,
+					customer: data[key].customer,
+					paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
+					grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
+					data: me.get_doctype_status(data[key])
+				});
+			}
+		});
+		this.list_customers.append(html);
+
+		this.list_customers.find('.list-column').click(function () {
+			me.list_customers.hide();
+			me.list_customers_btn.toggleClass("view_customer");
+			me.pos_bill.show();
+			me.list_customers_btn.show();
+			me.name = $(this).parents().attr('invoice-name')
+			me.edit_record();
+		})
+
+		//actions
+		$(this.wrapper).find('.list-select-all').click(function () {
+			me.list_customers.find('.list-delete').prop("checked", $(this).is(":checked"))
+			me.removed_items = [];
+			if ($(this).is(":checked")) {
+				$.each(me.si_docs, function (index, data) {
+					for (key in data) {
+						me.removed_items.push(key)
+					}
+				});
+			}
+
+			me.toggle_primary_action();
+		});
+
+		$(this.wrapper).find('.list-delete').click(function () {
+			me.name = $(this).parent().parent().attr('invoice-name');
+			if ($(this).is(":checked")) {
+				me.removed_items.push(me.name);
+			} else {
+				me.removed_items.pop(me.name)
+			}
+
+			me.toggle_primary_action();
+		});
+	},
+
+	bind_delete_event: function() {
+		var me = this;
+
+		$(this.wrapper).find('.btn-danger').click(function(){
+			frappe.confirm(__("Delete permanently?"), function () {
+				me.delete_records();
+				me.render_list_customers();
+			})
+		})
+	},
+
+	set_focus: function () {
+		if (this.default_customer || this.frm.doc.customer) {
+			this.serach_item.$input.focus();
+		} else {
 			this.party_field.$input.focus();
 		}
 	},
 
-	make_customer: function() {
+	make_customer: function () {
 		var me = this;
 
-		if(this.default_customer && !this.frm.doc.customer){
+		if (this.default_customer && !this.frm.doc.customer) {
 			this.party_field.$input.val(this.default_customer);
 			this.frm.doc.customer = this.default_customer;
 		}
@@ -417,14 +502,14 @@
 				maxItems: 99,
 				autoFirst: true,
 				list: [],
-				filter: function(item, input) {
+				filter: function (item, input) {
 					var value = item.value.toLowerCase();
-					if(value.indexOf('is_action') !== -1 ||
+					if (value.indexOf('is_action') !== -1 ||
 						value.indexOf(input) !== -1) {
 						return true;
 					}
 				},
-				item: function(item, input) {
+				item: function (item, input) {
 					var d = item;
 					var html = "<span>" + __(d.label || d.value) + "</span>";
 					return $('<li></li>')
@@ -433,7 +518,7 @@
 						.get(0);
 				}
 			});
-		var items = this.customers.map(function(c) {
+		var customers = this.customers.map(function (c) {
 			return {
 				label: c.name,
 				value: c.name,
@@ -441,44 +526,47 @@
 				territory: c.territory
 			}
 		});
-		items.push({
+
+		customers.push({
 			label: "<span class='text-primary link-option'>"
-				+ "<i class='fa fa-plus' style='margin-right: 5px;'></i> "
-				+ __("Create a new Customer")
-				+ "</span>",
+			+ "<i class='fa fa-plus' style='margin-right: 5px;'></i> "
+			+ __("Create a new Customer")
+			+ "</span>",
 			value: 'is_action',
 			action: me.new_customer
 		});
-		this.party_field.awesomeplete.list = items;
+		this.party_field.awesomeplete.list = customers;
 
 		this.party_field.$input
-			.on('input', function(e) {
-				me.party_field.awesomeplete.list = items;
+			.on('input', function (e) {
+				me.party_field.awesomeplete.list = customers;
 			})
-			.on('awesomplete-select', function(e) {
-				var item = me.party_field.awesomeplete
+			.on('awesomplete-select', function (e) {
+				var customer = me.party_field.awesomeplete
 					.get_item(e.originalEvent.text.value);
-				if(!item) return;
-				if(item.action) {
-					item.action.apply(me);
+				if (!customer) return;
+				// create customer link
+				if (customer.action) {
+					customer.action.apply(me);
 					return;
 				}
-				me.update_customer_data(item);
+				me.update_customer_data(customer);
 				me.refresh();
+				me.set_focus();
 			})
-			.on('change', function(e) {
-				if(!e.originalEvent.text) {
+			.on('change', function (e) {
+				if (!e.originalEvent.text) {
 					me.frm.doc.customer = $(this).val();
 				}
 			})
-			.on('focus', function(e) {
+			.on('focus', function (e) {
 				$(e.target).val('').trigger('input');
 			})
-			.on("awesomplete-selectcomplete", function(e) {
+			.on("awesomplete-selectcomplete", function (e) {
 				var item = me.party_field.awesomeplete
 					.get_item(e.originalEvent.text.value);
 				// clear text input if item is action
-				if(item.action) {
+				if (item.action) {
 					$(this).val("");
 				}
 			});
@@ -486,45 +574,119 @@
 
 	new_customer: function () {
 		var me = this;
-		if(!this.connection_status) return;
-		frappe.ui.form.quick_entry('Customer', function (doc) {
-			me.customers.push(doc);
-			me.party_field.$input.val(doc.name);
-			me.update_customer_data(doc);
+		if (!this.connection_status) return;
+
+		this.customer_doc = new frappe.ui.Dialog({
+			'title': 'Customer',
+			fields: [
+				{
+					"label": __("Full Name"),
+					"fieldname": "full_name",
+					"fieldtype": "Data",
+					"reqd": 1
+				},
+				{
+					"fieldtype": "Section Break"
+				},
+				{
+					"label": __("Email Id"),
+					"fieldname": "email_id",
+					"fieldtype": "Data"
+				},
+				{
+					"fieldtype": "Column Break"
+				},
+				{
+					"label": __("Contact Number"),
+					"fieldname": "contact_no",
+					"fieldtype": "Data"
+				},
+				{
+					"fieldtype": "Section Break"
+				},
+				{
+					"label": __("Address Line 1"),
+					"fieldname": "address_line1",
+					"fieldtype": "Data"
+				},
+				{
+					"label": __("Address Line 2"),
+					"fieldname": "address_line2",
+					"fieldtype": "Data"
+				},
+				{
+					"fieldtype": "Column Break"
+				},
+				{
+					"label": __("City"),
+					"fieldname": "city",
+					"fieldtype": "Data"
+				},
+				{
+					"label": __("State"),
+					"fieldname": "state",
+					"fieldtype": "Data"
+				},
+				{
+					"label": __("ZIP Code"),
+					"fieldname": "zip_code",
+					"fieldtype": "Data"
+				}
+			]
 		})
+
+		this.customer_doc.show()
+
+		this.customer_doc.set_primary_action(__("Save"), function () {
+			me.make_offline_customer();
+			me.pos_bill.show();
+		});
 	},
 
-	update_customer_data: function(doc) {
+	make_offline_customer: function() {
+		this.frm.doc.customer = this.customer_doc.get_values().full_name;
+		this.frm.doc.contact_details = JSON.stringify(this.customer_doc.get_values());
+		this.party_field.$input.val(this.frm.doc.customer);
+		this.customers.push({
+			name: this.frm.doc.customer,
+			customer_name: this.frm.doc.customer
+		});
+
+		this.customer_doc.hide()
+	},
+
+	update_customer_data: function (doc) {
 		var me = this;
 		this.frm.doc.customer = doc.label || doc.name;
 		this.frm.doc.customer_name = doc.customer_name;
 		this.frm.doc.customer_group = doc.customer_group;
 		this.frm.doc.territory = doc.territory;
+		this.pos_bill.show();
 	},
 
-	get_customers: function(key){
+	get_customers: function (key) {
 		var me = this;
 		key = key.toLowerCase().trim()
 		var re = new RegExp('%', 'g');
 		var reg = new RegExp(key.replace(re, '\\w*\\s*[a-zA-Z0-9]*'))
 
-		if(key){
-			return $.grep(this.customers, function(data) {
-				if(reg.test(data.name.toLowerCase())
+		if (key) {
+			return $.grep(this.customers, function (data) {
+				if (reg.test(data.name.toLowerCase())
 					|| reg.test(data.customer_name.toLowerCase())
-					|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
+					|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))) {
 					return data
 				}
 			})
-		}else{
-			customers = this.customers.sort(function(a,b){ return a.idx < b.idx })
+		} else {
+			customers = this.customers.sort(function (a, b) { return a.idx < b.idx })
 			return customers.slice(0, 20)
 		}
 	},
 
-	make_item_list: function() {
+	make_item_list: function () {
 		var me = this;
-		if(!this.price_list) {
+		if (!this.price_list) {
 			msgprint(__("Price List not found or disabled"));
 			return;
 		}
@@ -536,11 +698,11 @@
 
 		if (this.items.length > 0) {
 			$.each(this.items, function(index, obj) {
-				if(index < 30){
+				if(index < me.page_len){
 					$(frappe.render_template("pos_item", {
 						item_code: obj.name,
 						item_price: format_currency(me.price_list_data[obj.name], me.frm.doc.currency),
-						item_name: obj.name===obj.item_name ? "" : obj.item_name,
+						item_name: obj.name === obj.item_name ? "" : obj.item_name,
 						item_image: obj.image ? "url('" + obj.image + "')" : null,
 						color: frappe.get_palette(obj.item_name),
 						abbr: frappe.get_abbr(obj.item_name)
@@ -548,143 +710,173 @@
 				}
 			});
 		} else {
-			$("<h4>Searching record not found.</h4>").appendTo($wrap)
+			$("<p class='text-muted small' style='padding-left: 10px'>"
+				+__("Not items found")+"</p>").appendTo($wrap)
 		}
 
-		if(this.items.length == 1
-			&& this.search.$input.val()) {
-			this.search.$input.val("");
+		if (this.items.length == 1
+			&& this.serach_item.$input.val()) {
+			this.serach_item.$input.val("");
 			this.add_to_cart();
 		}
 
 		// if form is local then allow this function
-		$(me.wrapper).find("div.pos-item").on("click", function() {
+		$(me.wrapper).find("div.pos-item").on("click", function () {
+			if(me.list_customers_btn.hasClass("view_customer")) return;
+
 			me.customer_validate();
-			if(me.frm.doc.docstatus==0) {
+			if (me.frm.doc.docstatus == 0) {
 				me.items = me.get_items($(this).attr("data-item-code"))
 				me.add_to_cart();
 			}
 		});
 	},
 
-	get_items: function(item_code){
+	get_items: function (item_code) {
 		// To search item as per the key enter
 
 		var me = this;
 		this.item_serial_no = {};
 		this.item_batch_no = {};
 
-		if(item_code){
-			return $.grep(this.item_data, function(item){
-				if(item.item_code == item_code ){
+		if (item_code) {
+			return $.grep(this.item_data, function (item) {
+				if (item.item_code == item_code) {
 					return true
 				}
 			})
 		}
 
-		key =  this.search.$input.val().toLowerCase().replace(/[&\/\\#,+()\[\]$~.'":*?<>{}]/g,'\\$&');
+		this.items_list = this.apply_category();
+
+		key = this.serach_item.$input.val().toLowerCase().replace(/[&\/\\#,+()\[\]$~.'":*?<>{}]/g, '\\$&');
 		var re = new RegExp('%', 'g');
 		var reg = new RegExp(key.replace(re, '[\\w*\\s*[a-zA-Z0-9]*]*'))
 		search_status = true
 
-		if(key){
-			return $.grep(this.item_data, function(item){
-				if(search_status){
-					if(in_list(me.batch_no_data[item.item_code], me.search.$input.val())){
+		if (key) {
+			return $.grep(this.items_list, function (item) {
+				if (search_status) {
+					if (in_list(me.batch_no_data[item.item_code], me.serach_item.$input.val())) {
 						search_status = false;
-						return me.item_batch_no[item.item_code] = me.search.$input.val()
-					} else if( me.serial_no_data[item.item_code]
-						&& in_list(Object.keys(me.serial_no_data[item.item_code]), me.search.$input.val())) {
+						return me.item_batch_no[item.item_code] = me.serach_item.$input.val()
+					} else if (me.serial_no_data[item.item_code]
+						&& in_list(Object.keys(me.serial_no_data[item.item_code]), me.serach_item.$input.val())) {
 						search_status = false;
-						me.item_serial_no[item.item_code] = [me.search.$input.val(), me.serial_no_data[item.item_code][me.search.$input.val()]]
+						me.item_serial_no[item.item_code] = [me.serach_item.$input.val(), me.serial_no_data[item.item_code][me.serach_item.$input.val()]]
 						return true
-					} else if(item.barcode == me.search.$input.val()) {
+					} else if (item.barcode == me.serach_item.$input.val()) {
 						search_status = false;
-						return item.barcode == me.search.$input.val();
-					} else if(reg.test(item.item_code.toLowerCase()) || reg.test(item.description.toLowerCase()) ||
-					reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase()) ){
+						return item.barcode == me.serach_item.$input.val();
+					} else if (reg.test(item.item_code.toLowerCase()) || reg.test(item.description.toLowerCase()) ||
+						reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase())) {
 						return true
 					}
 				}
 			})
-		}else{
-			return this.item_data;
+		} else {
+			return this.items_list;
 		}
 	},
 
-	bind_qty_event: function() {
+	apply_category: function() {
+		var me = this;
+		category = this.search_item_group.$input.val();
+
+		if(category == 'All Item Groups') {
+			return this.item_data
+		} else {
+			return this.item_data.filter(function(element, index, array){
+				return element.item_group == category;
+			});
+		}
+	},
+
+	bind_qty_event: function () {
 		var me = this;
 
-		$(this.wrapper).find(".pos-item-qty").on("change", function(){
+		$(this.wrapper).find(".pos-item-qty").on("change", function () {
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
 			var qty = $(this).val();
 			me.update_qty(item_code, qty)
 		})
 
-		$(this.wrapper).find("[data-action='increase-qty']").on("click", function(){
+		$(this.wrapper).find("[data-action='increase-qty']").on("click", function () {
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
 			var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1;
 			me.update_qty(item_code, qty)
 		})
 
-		$(this.wrapper).find("[data-action='decrease-qty']").on("click", function(){
+		$(this.wrapper).find("[data-action='decrease-qty']").on("click", function () {
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
 			var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
 			me.update_qty(item_code, qty)
 		})
-	},
 
-	update_qty: function(item_code, qty) {
-		var me = this;
-		this.items = this.get_items(item_code);
-		this.validate_serial_no()
-		this.update_qty_rate_against_item_code(item_code, "qty", qty);
-	},
-
-	update_rate: function() {
-		var me = this;
-
-		$(this.wrapper).find(".pos-item-rate").on("change", function(){
+		$(this.wrapper).find(".pos-item-discount").on("change", function () {
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
-			me.update_qty_rate_against_item_code(item_code, "rate", $(this).val());
+			var discount = $(this).val();
+			me.update_discount(item_code, discount)
 		})
 	},
 
-	update_qty_rate_against_item_code: function(item_code, field, value){
+	update_qty: function (item_code, qty) {
 		var me = this;
-		if(value < 0){
+		this.items = this.get_items(item_code);
+		this.validate_serial_no()
+		this.set_item_details(item_code, "qty", qty);
+	},
+
+	update_discount: function(item_code, discount) {
+		var me = this;
+		this.items = this.get_items(item_code);
+		this.set_item_details(item_code, "discount_percentage", discount);
+	},
+
+	update_rate: function () {
+		var me = this;
+
+		$(this.wrapper).find(".pos-item-rate").on("change", function () {
+			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
+			me.set_item_details(item_code, "rate", $(this).val());
+		})
+	},
+
+	set_item_details: function (item_code, field, value) {
+		var me = this;
+		if (value < 0) {
 			frappe.throw(__("Enter value must be positive"));
 		}
 
 		this.remove_item = []
-		$.each(this.frm.doc["items"] || [], function(i, d) {
-			if(d.serial_no && field == 'qty'){
-				me.validate_serial_no_qty(d, item_code, field, value)
-			}
-
+		$.each(this.frm.doc["items"] || [], function (i, d) {
 			if (d.item_code == item_code) {
+				if (d.serial_no && field == 'qty') {
+					me.validate_serial_no_qty(d, item_code, field, value)
+				}
+
 				d[field] = flt(value);
 				d.amount = flt(d.rate) * flt(d.qty);
-				if(d.qty==0){
+				if (d.qty == 0) {
 					me.remove_item.push(d.idx)
 				}
 			}
 		});
 
-		if(field == 'qty'){
+		if (field == 'qty') {
 			this.remove_zero_qty_item();
 		}
 
 		this.update_paid_amount_status(false)
 	},
 
-	remove_zero_qty_item: function(){
+	remove_zero_qty_item: function () {
 		var me = this;
 		idx = 0
 		this.items = []
 		idx = 0
-		$.each(this.frm.doc["items"] || [], function(i, d) {
-			if(!in_list(me.remove_item, d.idx)){
+		$.each(this.frm.doc["items"] || [], function (i, d) {
+			if (!in_list(me.remove_item, d.idx)) {
 				d.idx = idx;
 				me.items.push(d);
 				idx++;
@@ -694,23 +886,23 @@
 		this.frm.doc["items"] = this.items;
 	},
 
-	make_discount_field: function(){
+	make_discount_field: function () {
 		var me = this;
 
-		this.wrapper.find('input.discount-percentage').on("change", function() {
+		this.wrapper.find('input.discount-percentage').on("change", function () {
 			me.frm.doc.additional_discount_percentage = flt($(this).val(), precision("additional_discount_percentage"));
 			total = me.frm.doc.grand_total
 
-			if(me.frm.doc.apply_discount_on == 'Net Total'){
+			if (me.frm.doc.apply_discount_on == 'Net Total') {
 				total = me.frm.doc.net_total
 			}
 
-			me.frm.doc.discount_amount = flt(total*flt(me.frm.doc.additional_discount_percentage) / 100, precision("discount_amount"));
+			me.frm.doc.discount_amount = flt(total * flt(me.frm.doc.additional_discount_percentage) / 100, precision("discount_amount"));
 			me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount)
 			me.refresh();
 		});
 
-		this.wrapper.find('input.discount-amount').on("change", function() {
+		this.wrapper.find('input.discount-amount').on("change", function () {
 			me.frm.doc.discount_amount = flt($(this).val(), precision("discount_amount"));
 			me.frm.doc.additional_discount_percentage = 0.0;
 			me.wrapper.find('input.discount-percentage').val(0);
@@ -718,14 +910,14 @@
 		});
 	},
 
-	customer_validate: function(){
+	customer_validate: function () {
 		var me = this;
-		if(!this.frm.doc.customer){
+		if (!this.frm.doc.customer) {
 			frappe.throw(__("Please select customer"))
 		}
 	},
 
-	add_to_cart: function() {
+	add_to_cart: function () {
 		var me = this;
 		var caught = false;
 		var no_of_items = me.wrapper.find(".pos-bill-item").length;
@@ -736,17 +928,17 @@
 		this.validate_warehouse();
 
 		if (no_of_items != 0) {
-			$.each(this.frm.doc["items"] || [], function(i, d) {
+			$.each(this.frm.doc["items"] || [], function (i, d) {
 				if (d.item_code == me.items[0].item_code) {
 					caught = true;
 					d.qty += 1;
 					d.amount = flt(d.rate) * flt(d.qty);
-					if(me.item_serial_no[d.item_code]){
+					if (me.item_serial_no[d.item_code]) {
 						d.serial_no += '\n' + me.item_serial_no[d.item_code][0]
 						d.warehouse = me.item_serial_no[d.item_code][1]
 					}
 
-					if(me.item_batch_no.length){
+					if (me.item_batch_no.length) {
 						d.batch_no = me.item_batch_no[d.item_code]
 					}
 				}
@@ -760,7 +952,7 @@
 		this.update_paid_amount_status(false)
 	},
 
-	add_new_item_to_grid: function() {
+	add_new_item_to_grid: function () {
 		var me = this;
 		this.child = frappe.model.add_child(this.frm.doc, this.frm.doc.doctype + " Item", "items");
 		this.child.item_code = this.items[0].item_code;
@@ -772,7 +964,7 @@
 		this.child.cost_center = this.pos_profile_data['cost_center'] || this.items[0].cost_center;
 		this.child.income_account = this.pos_profile_data['income_account'] || this.items[0].income_account;
 		this.child.warehouse = (this.item_serial_no[this.child.item_code]
-			? this.item_serial_no[this.child.item_code][1] : (this.pos_profile_data['warehouse'] || this.items[0].default_warehouse) );
+			? this.item_serial_no[this.child.item_code][1] : (this.pos_profile_data['warehouse'] || this.items[0].default_warehouse));
 		this.child.price_list_rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9);
 		this.child.rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9);
 		this.child.actual_qty = me.get_actual_qty(this.items[0]);
@@ -783,15 +975,15 @@
 		this.child.item_tax_rate = JSON.stringify(this.tax_data[this.child.item_code]);
 	},
 
-	update_paid_amount_status: function(update_paid_amount){
-		if(this.name){
+	update_paid_amount_status: function (update_paid_amount) {
+		if (this.name) {
 			update_paid_amount = update_paid_amount ? false : true;
 		}
 
 		this.refresh(update_paid_amount);
 	},
 
-	refresh: function(update_paid_amount) {
+	refresh: function (update_paid_amount) {
 		var me = this;
 		this.refresh_fields(update_paid_amount);
 		this.bind_qty_event();
@@ -799,7 +991,7 @@
 		this.set_primary_action();
 	},
 
-	refresh_fields: function(update_paid_amount) {
+	refresh_fields: function (update_paid_amount) {
 		this.apply_pricing_rule();
 		this.discount_amount_applied = false;
 		this._calculate_taxes_and_totals();
@@ -810,40 +1002,45 @@
 		this.set_totals();
 	},
 
-	get_company_currency: function() {
+	get_company_currency: function () {
 		return erpnext.get_currency(this.frm.doc.company);
 	},
 
-	show_item_wise_taxes: function(){
+	show_item_wise_taxes: function () {
 		return null;
 	},
 
-	show_items_in_item_cart: function() {
+	show_items_in_item_cart: function () {
 		var me = this;
 		var $items = this.wrapper.find(".items").empty();
-		$.each(this.frm.doc.items|| [], function(i, d) {
+		$.each(this.frm.doc.items || [], function (i, d) {
 			$(frappe.render_template("pos_bill_item", {
 				item_code: d.item_code,
-				item_name: (d.item_name===d.item_code || !d.item_name) ? "" : ("<br>" + d.item_name),
+				item_name: (d.item_name === d.item_code || !d.item_name) ? "" : ("<br>" + d.item_name),
 				qty: d.qty,
-				actual_qty: me.actual_qty_dict[d.item_code] || 0,
+				discount_percentage: d.discount_percentage || 0.0,
+				actual_qty: me.actual_qty_dict[d.item_code] || 0.0,
 				projected_qty: d.projected_qty,
 				rate: format_number(d.rate, me.frm.doc.currency),
-				enabled: me.pos_profile_data["allow_user_to_edit_rate"] ? true: false,
+				enabled: me.pos_profile_data["allow_user_to_edit_rate"] ? true : false,
 				amount: format_currency(d.amount, me.frm.doc.currency)
 			})).appendTo($items);
 		});
 
-		this.wrapper.find("input.pos-item-qty").on("focus", function() {
+		this.wrapper.find("input.pos-item-qty").on("focus", function () {
 			$(this).select();
 		});
 
-		this.wrapper.find("input.pos-item-rate").on("focus", function() {
+		this.wrapper.find("input.pos-item-discount").on("focus", function () {
+			$(this).select();
+		});
+
+		this.wrapper.find("input.pos-item-rate").on("focus", function () {
 			$(this).select();
 		});
 	},
 
-	set_taxes: function(){
+	set_taxes: function () {
 		var me = this;
 		me.frm.doc.total_taxes_and_charges = 0.0
 
@@ -852,7 +1049,7 @@
 			.find(".tax-area").toggleClass("hide", (taxes && taxes.length) ? false : true)
 			.find(".tax-table").empty();
 
-		$.each(taxes, function(i, d) {
+		$.each(taxes, function (i, d) {
 			if (d.tax_amount && cint(d.included_in_print_rate) == 0) {
 				$(frappe.render_template("pos_tax_row", {
 					description: d.description,
@@ -863,104 +1060,106 @@
 		});
 	},
 
-	set_totals: function() {
+	set_totals: function () {
 		var me = this;
 		this.wrapper.find(".net-total").text(format_currency(me.frm.doc.total, me.frm.doc.currency));
 		this.wrapper.find(".grand-total").text(format_currency(me.frm.doc.grand_total, me.frm.doc.currency));
 	},
 
-	set_primary_action: function() {
+	set_primary_action: function () {
 		var me = this;
 
-		if (this.frm.doc.docstatus==0) {
-			this.page.set_primary_action(__("Pay"), function() {
+		if (this.frm.doc.docstatus == 0) {
+			this.page.set_primary_action(__("Pay"), function () {
 				me.validate();
 				me.update_paid_amount_status(true);
 				me.create_invoice();
 				me.make_payment();
-			}, "octicon octfa fa-credit-card");
-		}else if(this.frm.doc.docstatus == 1) {
-			this.page.set_primary_action(__("Print"), function() {
+			}, "fa fa-credit-card");
+		} else if (this.frm.doc.docstatus == 1) {
+			this.page.set_primary_action(__("Print"), function () {
 				html = frappe.render(me.print_template_data, me.frm.doc)
 				me.print_document(html)
 			})
-		}else {
+		} else {
 			this.page.clear_primary_action()
 		}
 
-		this.page.set_secondary_action(__("New"), function() {
-			me.save_previous_entry();
-			me.create_new();
-		}, "octicon octfa fa-plus").addClass("btn-primary");
+		// this.page.set_secondary_action(__("New"), function () {
+		// 	me.save_previous_entry();
+		// 	me.create_new();
+		// }, "fa fa-plus").addClass("btn-primary");
 	},
 
-	print_dialog: function(){
+	print_dialog: function () {
 		var me = this;
 
 		msgprint = frappe.msgprint(format('<a class="btn btn-primary print_doc" \
 			style="margin-right: 5px;">{0}</a>\
 			<a class="btn btn-default new_doc">{1}</a>', [
-			__('Print'), __('New')
-		]));
+				__('Print'), __('New')
+			]));
 
-		$('.print_doc').click(function(){
+		$('.print_doc').click(function () {
 			html = frappe.render(me.print_template_data, me.frm.doc)
 			me.print_document(html)
 		})
 
-		$('.new_doc').click(function(){
+		$('.new_doc').click(function () {
 			msgprint.hide()
 			me.create_new();
 		})
 	},
 
-	print_document: function(html){
+	print_document: function (html) {
 		var w = window.open();
 		w.document.write(html);
 		w.document.close();
-		setTimeout(function(){
+		setTimeout(function () {
 			w.print();
 			w.close();
 		}, 1000)
 	},
 
-	submit_invoice: function(){
+	submit_invoice: function () {
 		var me = this;
 		this.change_status();
-		if(this.frm.doc.docstatus == 1){
+		if (this.frm.doc.docstatus == 1) {
 			this.print_dialog()
 		}
 	},
 
-	change_status: function(){
-		if(this.frm.doc.docstatus == 0){
+	change_status: function () {
+		if (this.frm.doc.docstatus == 0) {
 			this.frm.doc.docstatus = 1;
 			this.update_invoice();
 			this.disable_input_field();
 		}
 	},
 
-	disable_input_field: function(){
+	disable_input_field: function () {
 		var pointer_events = 'inherit'
 		$(this.wrapper).find('input').attr("disabled", false);
+		$(this.wrapper).find('select').attr("disabled", false);
 
-		if(this.frm.doc.docstatus == 1){
+		if (this.frm.doc.docstatus == 1) {
 			pointer_events = 'none';
 			$(this.wrapper).find('input').attr("disabled", true);
+			$(this.wrapper).find('select').attr("disabled", true);
 		}
 
-		$(this.wrapper).find('.pos-bill-wrapper').css('pointer-events', pointer_events);
+		$(this.wrapper).find('.pos-bill').css('pointer-events', pointer_events);
 		$(this.wrapper).find('.pos-items-section').css('pointer-events', pointer_events);
 		this.set_primary_action();
 	},
 
-	create_invoice: function(){
+	create_invoice: function () {
 		var me = this;
 		var invoice_data = {}
 		this.si_docs = this.get_doc_from_localstorage();
-		if(this.name){
+		if (this.name) {
 			this.update_invoice()
-		}else{
+		} else {
 			this.name = $.now();
 			this.frm.doc.offline_pos_name = this.name;
 			this.frm.doc.posting_date = frappe.datetime.get_today();
@@ -970,14 +1169,15 @@
 			this.update_localstorage();
 			this.set_primary_action();
 		}
+		return invoice_data;
 	},
 
-	update_invoice: function(){
+	update_invoice: function () {
 		var me = this;
 		this.si_docs = this.get_doc_from_localstorage();
-		$.each(this.si_docs, function(index, data){
-			for(key in data){
-				if(key == me.name){
+		$.each(this.si_docs, function (index, data) {
+			for (key in data) {
+				if (key == me.name) {
 					me.si_docs[index][key] = me.frm.doc;
 					me.update_localstorage();
 				}
@@ -985,41 +1185,41 @@
 		})
 	},
 
-	update_localstorage: function(){
-		try{
+	update_localstorage: function () {
+		try {
 			localStorage.setItem('sales_invoice_doc', JSON.stringify(this.si_docs));
-		}catch(e){
+		} catch (e) {
 			frappe.throw(__("LocalStorage is full , did not save"))
 		}
 	},
 
-	get_doc_from_localstorage: function(){
-		try{
+	get_doc_from_localstorage: function () {
+		try {
 			return JSON.parse(localStorage.getItem('sales_invoice_doc')) || [];
-		}catch(e){
+		} catch (e) {
 			return []
 		}
 	},
 
-	set_interval_for_si_sync: function(){
+	set_interval_for_si_sync: function () {
 		var me = this;
-		setInterval(function(){
+		setInterval(function () {
 			me.sync_sales_invoice()
 		}, 60000)
 	},
 
-	sync_sales_invoice: function(){
+	sync_sales_invoice: function () {
 		var me = this;
 		this.si_docs = this.get_submitted_invoice();
 
-		if(this.si_docs.length){
+		if (this.si_docs.length) {
 			frappe.call({
 				method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice",
 				args: {
 					doc_list: me.si_docs
 				},
-				callback: function(r){
-					if(r.message){
+				callback: function (r) {
+					if (r.message) {
 						me.removed_items = r.message;
 						me.remove_doc_from_localstorage();
 					}
@@ -1028,14 +1228,14 @@
 		}
 	},
 
-	get_submitted_invoice: function(){
+	get_submitted_invoice: function () {
 		var invoices = [];
 		var index = 1;
 		docs = this.get_doc_from_localstorage();
-		if(docs){
-			invoices = $.map(docs, function(data){
-				for(key in data){
-					if(data[key].docstatus == 1 && index < 50){
+		if (docs) {
+			invoices = $.map(docs, function (data) {
+				for (key in data) {
+					if (data[key].docstatus == 1 && index < 50) {
 						index++
 						data[key].docstatus = 0;
 						return data
@@ -1047,14 +1247,14 @@
 		return invoices
 	},
 
-	remove_doc_from_localstorage: function(){
+	remove_doc_from_localstorage: function () {
 		var me = this;
 		this.si_docs = this.get_doc_from_localstorage();
 		this.new_si_docs = [];
-		if(this.removed_items){
-			$.each(this.si_docs, function(index, data){
-				for(key in data){
-					if(!in_list(me.removed_items, key)){
+		if (this.removed_items) {
+			$.each(this.si_docs, function (index, data) {
+				for (key in data) {
+					if (!in_list(me.removed_items, key)) {
 						me.new_si_docs.push(data);
 					}
 				}
@@ -1064,44 +1264,44 @@
 		}
 	},
 
-	validate: function(){
+	validate: function () {
 		var me = this;
 		this.customer_validate();
 		this.item_validate();
 		this.validate_mode_of_payments();
 	},
 
-	item_validate: function(){
-		if(this.frm.doc.items.length == 0){
+	item_validate: function () {
+		if (this.frm.doc.items.length == 0) {
 			frappe.throw(__("Select items to save the invoice"))
 		}
 	},
 
-	validate_mode_of_payments: function(){
-		if (this.frm.doc.payments.length === 0){
+	validate_mode_of_payments: function () {
+		if (this.frm.doc.payments.length === 0) {
 			frappe.throw(__("Payment Mode is not configured. Please check, whether account has been set on Mode of Payments or on POS Profile."))
 		}
 	},
 
-	validate_serial_no: function(){
+	validate_serial_no: function () {
 		var me = this;
 		var item_code = serial_no = '';
-		for (key in this.item_serial_no){
+		for (key in this.item_serial_no) {
 			item_code = key;
 			serial_no = me.item_serial_no[key][0];
 		}
 
-		if(this.items[0].has_serial_no && serial_no == ""){
+		if (this.items[0].has_serial_no && serial_no == "") {
 			this.refresh();
 			frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
 				'item': this.items[0].item_code
 			})))
 		}
 
-		if(item_code && serial_no){
-			$.each(this.frm.doc.items, function(index, data){
-				if(data.item_code == item_code){
-					if(in_list(data.serial_no.split('\n'), serial_no)){
+		if (item_code && serial_no) {
+			$.each(this.frm.doc.items, function (index, data) {
+				if (data.item_code == item_code) {
+					if (in_list(data.serial_no.split('\n'), serial_no)) {
 						frappe.throw(__(repl("Serial no %(serial_no)s is already taken", {
 							'serial_no': serial_no
 						})))
@@ -1111,7 +1311,7 @@
 		}
 	},
 
-	validate_serial_no_qty: function(args, item_code, field, value){
+	validate_serial_no_qty: function (args, item_code, field, value) {
 		var me = this;
 		if (args.item_code == item_code && args.serial_no
 			&& field == 'qty' && cint(value) != value) {
@@ -1120,7 +1320,7 @@
 			frappe.throw(__("Serial no item cannot be a fraction"))
 		}
 
-		if(args.item_code == item_code && args.serial_no && args.serial_no.split('\n').length != cint(value)){
+		if (args.item_code == item_code && args.serial_no && args.serial_no.split('\n').length != cint(value)) {
 			args.qty = 0.0;
 			args.serial_no = ''
 			this.refresh();
@@ -1130,42 +1330,44 @@
 		}
 	},
 
-	mandatory_batch_no: function(){
+	mandatory_batch_no: function () {
 		var me = this;
-		if(this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]){
+		if (this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]) {
 			frappe.throw(__(repl("Error: Batch no is mandatory for item %(item)s", {
 				'item': this.items[0].item_code
 			})))
 		}
 	},
 
-	apply_pricing_rule: function(){
+	apply_pricing_rule: function () {
 		var me = this;
-		$.each(this.frm.doc["items"], function(n, item) {
+		$.each(this.frm.doc["items"], function (n, item) {
 			pricing_rule = me.get_pricing_rule(item)
 			me.validate_pricing_rule(pricing_rule)
-			if(pricing_rule.length){
+			if (pricing_rule.length) {
+				item.pricing_rule = pricing_rule[0].name;
 				item.margin_type = pricing_rule[0].margin_type;
 				item.price_list_rate = pricing_rule[0].price || item.price_list_rate;
 				item.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
 				item.discount_percentage = pricing_rule[0].discount_percentage || 0.0;
-				me.apply_pricing_rule_on_item(item)
-			} else if(item.discount_percentage > 0 || item.margin_rate_or_amount > 0) {
+			} else if ((item.discount_percentage > 0 || item.margin_rate_or_amount > 0) && item.pricing_rule) {
 				item.margin_rate_or_amount = 0.0;
 				item.discount_percentage = 0.0;
-				me.apply_pricing_rule_on_item(item)
+				item.pricing_rule = null;
 			}
+
+			me.apply_pricing_rule_on_item(item)
 		})
 	},
 
-	get_pricing_rule: function(item){
+	get_pricing_rule: function (item) {
 		var me = this;
-		return $.grep(this.pricing_rules, function(data){
-			if(item.qty >= data.min_qty && (item.qty <= (data.max_qty ? data.max_qty : item.qty)) ){
-				if(data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group)) {
-					if(in_list(['Customer', 'Customer Group', 'Territory', 'Campaign'], data.applicable_for)){
+		return $.grep(this.pricing_rules, function (data) {
+			if (item.qty >= data.min_qty && (item.qty <= (data.max_qty ? data.max_qty : item.qty))) {
+				if (data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group)) {
+					if (in_list(['Customer', 'Customer Group', 'Territory', 'Campaign'], data.applicable_for)) {
 						return me.validate_condition(data)
-					}else{
+					} else {
 						return true
 					}
 				}
@@ -1173,15 +1375,15 @@
 		})
 	},
 
-	validate_condition: function(data){
+	validate_condition: function (data) {
 		//This method check condition based on applicable for
 		condition = this.get_mapper_for_pricing_rule(data)[data.applicable_for]
-		if(in_list(condition[1], condition[0])){
+		if (in_list(condition[1], condition[0])) {
 			return true
 		}
 	},
 
-	get_mapper_for_pricing_rule: function(data){
+	get_mapper_for_pricing_rule: function (data) {
 		return {
 			'Customer': [data.customer, [this.frm.doc.customer]],
 			'Customer Group': [data.customer_group, [this.frm.doc.customer_group, 'All Customer Groups']],
@@ -1190,32 +1392,32 @@
 		}
 	},
 
-	validate_pricing_rule: function(pricing_rule){
+	validate_pricing_rule: function (pricing_rule) {
 		//This method validate duplicate pricing rule
 		var pricing_rule_name = '';
 		var priority = 0;
 		var pricing_rule_list = [];
 		var priority_list = []
 
-		if(pricing_rule.length > 1){
+		if (pricing_rule.length > 1) {
 
-			$.each(pricing_rule, function(index, data){
+			$.each(pricing_rule, function (index, data) {
 				pricing_rule_name += data.name + ','
 				priority_list.push(data.priority)
-				if(priority <= data.priority){
+				if (priority <= data.priority) {
 					priority = data.priority
 					pricing_rule_list.push(data)
 				}
 			})
 
 			count = 0
-			$.each(priority_list, function(index, value){
-				if(value == priority){
+			$.each(priority_list, function (index, value) {
+				if (value == priority) {
 					count++
 				}
 			})
 
-			if(priority == 0 || count > 1){
+			if (priority == 0 || count > 1) {
 				frappe.throw(__(repl("Multiple Price Rules exists with same criteria, please resolve conflict by assigning priority. Price Rules: %(pricing_rule)s", {
 					'pricing_rule': pricing_rule_name
 				})))
@@ -1225,17 +1427,17 @@
 		}
 	},
 
-	validate_warehouse: function(){
-		if(this.items[0].is_stock_item && !this.items[0].default_warehouse && !this.pos_profile_data['warehouse']){
+	validate_warehouse: function () {
+		if (this.items[0].is_stock_item && !this.items[0].default_warehouse && !this.pos_profile_data['warehouse']) {
 			frappe.throw(__("Default warehouse is required for selected item"))
 		}
 	},
 
-	get_actual_qty: function(item) {
+	get_actual_qty: function (item) {
 		this.actual_qty = 0.0;
 
 		var warehouse = this.pos_profile_data['warehouse'] || item.default_warehouse;
-		if(warehouse && this.bin_data[item.item_code]) {
+		if (warehouse && this.bin_data[item.item_code]) {
 			this.actual_qty = this.bin_data[item.item_code][warehouse] || 0;
 			this.actual_qty_dict[item.item_code] = this.actual_qty
 		}
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 471da9e..a8d166e 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -171,13 +171,13 @@
 		account = frappe.db.get_value("Party Account",
 			{"parenttype": party_type, "parent": party, "company": company}, "account")
 
-		if not account:
+		if not account and party_type in ['Customer', 'Supplier']:
 			party_group_doctype = "Customer Group" if party_type=="Customer" else "Supplier Type"
 			group = frappe.db.get_value(party_type, party, scrub(party_group_doctype))
 			account = frappe.db.get_value("Party Account",
 				{"parenttype": party_group_doctype, "parent": group, "company": company}, "account")
 
-		if not account:
+		if not account and party_type in ['Customer', 'Supplier']:
 			default_account_name = "default_receivable_account" \
 				if party_type=="Customer" else "default_payable_account"
 			account = frappe.db.get_value("Company", company, default_account_name)
@@ -249,7 +249,7 @@
 		if existing_gle_currency and party_account_currency != existing_gle_currency:
 			frappe.throw(_("Accounting entries have already been made in currency {0} for company {1}. Please select a receivable or payable account with currency {0}.").format(existing_gle_currency, account.company))
 
-		if doc.default_currency and party_account_currency and company_default_currency:
+		if doc.get("default_currency") and party_account_currency and company_default_currency:
 			if doc.default_currency != party_account_currency and doc.default_currency != company_default_currency:
 				frappe.throw(_("Billing currency must be equal to either default comapany's currency or party account currency"))
 
@@ -337,13 +337,18 @@
 
 def validate_party_frozen_disabled(party_type, party_name):
 	if party_type and party_name:
-		party = frappe.db.get_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True)
-		if party.disabled:
-			frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled)
-		elif party.is_frozen:
-			frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier')
-			if not frozen_accounts_modifier in frappe.get_roles():
-				frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen)
+		if party_type in ("Customer", "Supplier"):
+			party = frappe.db.get_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True)
+			if party.disabled:
+				frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled)
+			elif party.get("is_frozen"):
+				frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier')
+				if not frozen_accounts_modifier in frappe.get_roles():
+					frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen)
+
+		elif party_type == "Employee":
+			if frappe.db.get_value("Employee", party_name, "status") == "Left":
+				frappe.msgprint(_("{0} {1} is not active").format(party_type, party_name), PartyDisabled, alert=True)
 
 def get_timeline_data(doctype, name):
 	'''returns timeline data for the past one year'''
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js
index ab7ad49..a422871 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.js
+++ b/erpnext/accounts/report/general_ledger/general_ledger.js
@@ -59,8 +59,8 @@
 		{
 			"fieldname":"party_type",
 			"label": __("Party Type"),
-			"fieldtype": "Select",
-			"options": ["", "Customer", "Supplier"],
+			"fieldtype": "Link",
+			"options": "Party Type",
 			"default": ""
 		},
 		{
diff --git a/erpnext/schools/doctype/announcement/__init__.py b/erpnext/accounts/report/unpaid_expense_claim/__init__.py
similarity index 100%
copy from erpnext/schools/doctype/announcement/__init__.py
copy to erpnext/accounts/report/unpaid_expense_claim/__init__.py
diff --git a/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.js b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.js
new file mode 100644
index 0000000..811414a
--- /dev/null
+++ b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.js
@@ -0,0 +1,12 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.query_reports["Unpaid Expense Claim"] = {
+	"filters": [
+		{
+			"fieldname":"employee",
+			"label": __("Employee"),
+			"fieldtype": "Link"
+		}
+	]
+}
diff --git a/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.json b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.json
new file mode 100644
index 0000000..a1087c0
--- /dev/null
+++ b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.json
@@ -0,0 +1,18 @@
+{
+ "add_total_row": 0, 
+ "apply_user_permissions": 1, 
+ "creation": "2017-01-04 16:26:18.309717", 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "modified": "2017-01-04 16:26:18.309717", 
+ "modified_by": "Administrator", 
+ "module": "Accounts", 
+ "name": "Unpaid Expense Claim", 
+ "owner": "Administrator", 
+ "ref_doctype": "Expense Claim", 
+ "report_name": "Unpaid Expense Claim", 
+ "report_type": "Script Report"
+}
\ No newline at end of file
diff --git a/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py
new file mode 100644
index 0000000..eee620b
--- /dev/null
+++ b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+
+def execute(filters=None):
+	columns, data = [], []
+	columns = get_columns()
+	data = get_unclaimed_expese_claims(filters)
+	return columns, data
+
+def get_columns():
+	return [_("Employee") + ":Link/Employee:120", _("Employee Name") + "::120",_("Expense Claim") + ":Link/Expense Claim:120",
+		_("Sanctioned Amount") + ":Currency:120", _("Paid Amount") + ":Currency:120", _("Outstanding Amount") + ":Currency:150"]
+
+def get_unclaimed_expese_claims(filters):
+	cond = "1=1"
+	if filters.get("employee"):
+		cond = "ec.employee = %(employee)s"
+
+	return frappe.db.sql(""" 
+		select
+			ec.employee, ec.employee_name, ec.name, ec.total_sanctioned_amount, ec.total_amount_reimbursed,
+			sum(gle.credit_in_account_currency - gle.debit_in_account_currency) as outstanding_amt
+		from 
+			`tabExpense Claim` ec, `tabGL Entry` gle
+		where
+			gle.against_voucher_type = "Expense Claim" and gle.against_voucher = ec.name
+			and gle.party is not null and ec.docstatus = 1 and ec.is_paid = 0 and {cond} group by ec.name
+		having
+			outstanding_amt > 0
+	""".format(cond=cond), filters, as_list=1)
diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py
index 3a18a27..0a969ed 100644
--- a/erpnext/config/hr.py
+++ b/erpnext/config/hr.py
@@ -146,6 +146,11 @@
 					"name": "Appraisal Template",
 					"description": _("Template for performance appraisals.")
 				},
+				{
+					"type": "page",
+					"name": "team-updates",
+					"label": _("Team Updates")
+				},
 			]
 		},
 
@@ -166,7 +171,7 @@
 				},
 			]
 		},
-		
+
 		{
 			"label": _("Fleet Management"),
 			"items": [
@@ -180,7 +185,7 @@
 				},
 			]
 		},
-		
+
 
 		{
 			"label": _("Setup"),
@@ -266,6 +271,26 @@
 			]
 		},
 		{
+			"label": _("Employee Loan Management"),
+			"icon": "icon-list",
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Loan Type",
+					"description": _("Define various loan types")
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Loan Application",
+					"description": _("Employee Loan Application")
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Loan"
+				},
+			]
+		},
+		{
 			"label": _("Help"),
 			"icon": "fa fa-facetime-video",
 			"items": [
diff --git a/erpnext/config/schools.py b/erpnext/config/schools.py
index 903f54b..a4c5744 100644
--- a/erpnext/config/schools.py
+++ b/erpnext/config/schools.py
@@ -160,23 +160,6 @@
 			]
 		},
 		{
-			"label": _("LMS"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Announcement"
-				},
-				{
-					"type": "doctype",
-					"name": "Topic"
-				},
-				{
-					"type": "doctype",
-					"name": "Discussion"
-				}
-			]
-		},
-		{
 			"label": _("Setup"),
 			"items": [
 				{
diff --git a/erpnext/config/stock.py b/erpnext/config/stock.py
index 14e7999..a98c40e 100644
--- a/erpnext/config/stock.py
+++ b/erpnext/config/stock.py
@@ -50,6 +50,11 @@
 					"doctype": "Item",
 				},
 				{
+					"type": "page",
+					"name": "stock-balance",
+					"label": _("Stock Summary")
+				},
+				{
 					"type": "report",
 					"is_query_report": True,
 					"name": "Stock Ageing",
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 032fd66..c489008 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -93,8 +93,10 @@
 			sle.voucher_type, sle.voucher_no)
 		sle.stock_value = flt(sle.qty_after_transaction) * flt(sle.valuation_rate)
 		sle.stock_value_difference = sle.stock_value
-		sle.doctype="Stock Ledger Entry"
-		frappe.get_doc(sle).db_update()
+		if sle.name:
+			frappe.db.sql(""" update `tabStock Ledger Entry` set stock_value = %(stock_value)s,
+				valuation_rate = %(valuation_rate)s, stock_value_difference = %(stock_value_difference)s 
+				where name = %(name)s""", (sle))
 
 	def validate_negative_stock(self, sle):
 		if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
@@ -148,7 +150,7 @@
 
 	def get_stock_ledger_details(self):
 		stock_ledger = {}
-		for sle in frappe.db.sql("""select warehouse, stock_value_difference,
+		for sle in frappe.db.sql("""select name, warehouse, stock_value_difference,
 			voucher_detail_no, item_code, posting_date, posting_time, actual_qty, qty_after_transaction
 			from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
 			(self.doctype, self.name), as_dict=True):
diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py
index e18a123..2536602 100644
--- a/erpnext/demo/user/hr.py
+++ b/erpnext/demo/user/hr.py
@@ -6,6 +6,7 @@
 from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
 from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
 from frappe.utils.make_random import get_random
+from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account
 from erpnext.hr.doctype.expense_claim.expense_claim import get_expense_approver, make_bank_entry
 from erpnext.hr.doctype.leave_application.leave_application import (get_leave_balance_on,
 	OverlapError, AttendanceAlreadyMarkedError)
@@ -50,6 +51,7 @@
 		expense_claim.extend('expenses', get_expenses())
 		expense_claim.employee = get_random("Employee")
 		expense_claim.company = frappe.flags.company
+		expense_claim.payable_account = get_payable_account(expense_claim.company)
 		expense_claim.posting_date = frappe.flags.current_date
 		expense_claim.exp_approver = filter((lambda x: x[0] != 'Administrator'), get_expense_approver(None, '', None, 0, 20, None))[0][0]
 		expense_claim.insert()
diff --git a/erpnext/docs/assets/img/accounts/offline-records.png b/erpnext/docs/assets/img/accounts/offline-records.png
index 78bb730..a73f696 100644
--- a/erpnext/docs/assets/img/accounts/offline-records.png
+++ b/erpnext/docs/assets/img/accounts/offline-records.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/pos-customer.png b/erpnext/docs/assets/img/accounts/pos-customer.png
index ffb058a..c3cbb8a 100644
--- a/erpnext/docs/assets/img/accounts/pos-customer.png
+++ b/erpnext/docs/assets/img/accounts/pos-customer.png
Binary files differ
diff --git a/erpnext/docs/assets/img/accounts/pos-item.png b/erpnext/docs/assets/img/accounts/pos-item.png
index 321e8dc..14bd371 100644
--- a/erpnext/docs/assets/img/accounts/pos-item.png
+++ b/erpnext/docs/assets/img/accounts/pos-item.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee-loan-application.png b/erpnext/docs/assets/img/human-resources/employee-loan-application.png
new file mode 100644
index 0000000..317de4f
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/employee-loan-application.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee-loan.png b/erpnext/docs/assets/img/human-resources/employee-loan.png
new file mode 100644
index 0000000..19f3181
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/employee-loan.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/employee_account.png b/erpnext/docs/assets/img/human-resources/employee_account.png
new file mode 100644
index 0000000..a9a6066
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/employee_account.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/expense_claim.png b/erpnext/docs/assets/img/human-resources/expense_claim.png
index ddca100..9647d3d 100644
--- a/erpnext/docs/assets/img/human-resources/expense_claim.png
+++ b/erpnext/docs/assets/img/human-resources/expense_claim.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/expense_claim_book.png b/erpnext/docs/assets/img/human-resources/expense_claim_book.png
new file mode 100644
index 0000000..4b81604
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/expense_claim_book.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/loan-repayment-salary-slip.png b/erpnext/docs/assets/img/human-resources/loan-repayment-salary-slip.png
new file mode 100644
index 0000000..4e5f340
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/loan-repayment-salary-slip.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/loan-type.png b/erpnext/docs/assets/img/human-resources/loan-type.png
new file mode 100644
index 0000000..9146b89
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/loan-type.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/payment.png b/erpnext/docs/assets/img/human-resources/payment.png
new file mode 100644
index 0000000..f6b6e5d
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/payment.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/payment_entry.png b/erpnext/docs/assets/img/human-resources/payment_entry.png
new file mode 100644
index 0000000..a499ccf
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/payment_entry.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/repayment-info.png b/erpnext/docs/assets/img/human-resources/repayment-info.png
new file mode 100644
index 0000000..5b8bdf7
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/repayment-info.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/repayment-schedule.png b/erpnext/docs/assets/img/human-resources/repayment-schedule.png
new file mode 100644
index 0000000..f2ddf02
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/repayment-schedule.png
Binary files differ
diff --git a/erpnext/docs/assets/img/human-resources/unclaimed_expense_claims.png b/erpnext/docs/assets/img/human-resources/unclaimed_expense_claims.png
new file mode 100644
index 0000000..1581bb7
--- /dev/null
+++ b/erpnext/docs/assets/img/human-resources/unclaimed_expense_claims.png
Binary files differ
diff --git a/erpnext/docs/user/manual/en/human-resources/employee-loan-management.md b/erpnext/docs/user/manual/en/human-resources/employee-loan-management.md
new file mode 100644
index 0000000..b76a226
--- /dev/null
+++ b/erpnext/docs/user/manual/en/human-resources/employee-loan-management.md
@@ -0,0 +1,56 @@
+# Employee Loan Management
+This module enables companies which provides employee loans to define and manage employee loans.
+Employees can request loans, which are then reviewed and approved. For the approved loans, 
+repayment schedule for the entire loan cycle can be generated and automatic deduction from salary can also be set up. 
+
+### Loan Type
+To create a new Loan Type go to:
+
+> Human Resources > Employee Loan Management > Loan Type > New Loan Type
+
+Configure Loan limit and Rate of interest.
+
+<img class="screenshot" alt="Loan Type" src="{{docs_base_url}}/assets/img/human-resources/loan-type.png">
+
+### Employee Loan Application
+
+Employee can apply for loan by going to:
+
+> Human Resources > Employee Loan Management > Employee Loan Application > New Employee Loan Application
+
+<img class="screenshot" alt="Employee Loan Application" src="{{docs_base_url}}/assets/img/human-resources/employee-loan-application.png">
+
+#### In the Employee Loan Application,
+
+  * Enter Employee details and Loan details
+  * Select the repayment method, and based on your selection enter Repayment Period in Months or repayment Amount
+  
+On save, Employee can see Repayment Information and make changes if required before submitting.
+
+<img class="screenshot" alt="Employee Loan Application" src="{{docs_base_url}}/assets/img/human-resources/repayment-info.png">
+
+### Employee Loan
+
+Once the Loan is approved, Manager can create Employee Loan record for the Employee.
+
+> Human Resources > Employee Loan Management > Employee Loan > New Employee Loan
+
+<img class="screenshot" alt="Employee Loan Application" src="{{docs_base_url}}/assets/img/human-resources/employee-loan.png">
+
+#### In the Employee Loan,
+
+ * Enter Employee and Loan Application
+ * Check "Repay from Salary" if the loan repayment will be deducted from the salary
+ * Enter Disbursement Date and Account Info
+ * As soon as you hit save, the repayment schedule is generated.
+ 
+<img class="screenshot" alt="repayment Schedule" src="{{docs_base_url}}/assets/img/human-resources/repayment-schedule.png">
+
+#### Loan repayment deduction from Salary
+
+To auto deduct the Loan repayment from Salary, check "Repay from Salary" in Employee Loan. It will appear as Loan repayment in Salary Slip.
+
+<img class="screenshot" alt="Salary Slip" src="{{docs_base_url}}/assets/img/human-resources/loan-repayment-salary-slip.png">
+
+
+ 
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/human-resources/expense-claim.md b/erpnext/docs/user/manual/en/human-resources/expense-claim.md
index da3b2ee..1d4996d 100644
--- a/erpnext/docs/user/manual/en/human-resources/expense-claim.md
+++ b/erpnext/docs/user/manual/en/human-resources/expense-claim.md
@@ -9,6 +9,10 @@
 Set the Employee ID, date and the list of expenses that are to be claimed and
 “Submit” the record.
 
+### Set Account for Employee
+Set employee's expense account on the employee form, system books an expense amount of an employee under this account.
+<img class="screenshot" alt="Expense Claim" src="{{docs_base_url}}/assets/img/human-resources/employee_account.png">
+
 ### Approving Expenses
 
 Approver for the Expense Claim is selected by an Employee himself. Users to whom `Expense Approver` role is assigned will shown in the Expense Claim Approver field.
@@ -18,11 +22,25 @@
 Expense Claim Approver can update the “Sanctioned Amounts” against Claimed Amount of an Employee. If submitting, Approval Status should be submitted to Approved or Rejected. If Approved, then Expense Claim gets submitted. If rejected, then Expen
 Comments can be added in the Comments section explaining why the claim was approved or rejected.
 
-### Booking the Expense and Reimbursement
+### Booking the Expense
 
-The approved Expense Claim must then be converted into a Journal Entry and a
-payment must be made. Note: This amount should not be clubbed with Salary
-because the amount will then be taxable to the Employee.
+On submission of Expense Claim, system books an expense against the expense account and the employee account
+<img class="screenshot" alt="Expense Claim" src="{{docs_base_url}}/assets/img/human-resources/expense_claim_book.png">
+
+User can view unpaid expense claim using report "Unclaimed Expense Claims"
+<img class="screenshot" alt="Expense Claim" src="{{docs_base_url}}/assets/img/human-resources/unclaimed_expense_claims.png">
+
+### Payment for Expense Claim
+
+To make payment against the expense claim, user has to click on Make > Bank Entry
+#### Expense Claim
+<img class="screenshot" alt="Expense Claim" src="{{docs_base_url}}/assets/img/human-resources/payment.png">
+
+#### Payment Entry
+<img class="screenshot" alt="Expense Claim" src="{{docs_base_url}}/assets/img/human-resources/payment_entry.png">
+
+
+Note: This amount should not be clubbed with Salary because the amount will then be taxable to the Employee.
 
 ### Linking with Task & Project
 
diff --git a/erpnext/docs/user/manual/en/human-resources/index.txt b/erpnext/docs/user/manual/en/human-resources/index.txt
index f91edfa..673efdb 100644
--- a/erpnext/docs/user/manual/en/human-resources/index.txt
+++ b/erpnext/docs/user/manual/en/human-resources/index.txt
@@ -15,4 +15,5 @@
 human-resource-setup
 daily-work-summary
 fleet-management
+employee-loan-management
 articles
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 8705e98..14ea74b 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -107,7 +107,6 @@
 	{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
 	{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"},
 	{"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"},
-	{"title": _("Announcements"), "route": "/announcement", "reference_doctype": "Announcement"},
 	{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}
 ]
 
@@ -122,8 +121,7 @@
 	"Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Supplier Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission",
-	"Issue": "erpnext.support.doctype.issue.issue.has_website_permission",
-	"Discussion": "erpnext.schools.web_form.discussion.discussion.has_website_permission"
+	"Issue": "erpnext.support.doctype.issue.issue.has_website_permission"
 }
 
 dump_report_map = "erpnext.startup.report_data_map.data_map"
diff --git a/erpnext/schools/doctype/discussion/__init__.py b/erpnext/hr/doctype/employee_loan/__init__.py
similarity index 100%
rename from erpnext/schools/doctype/discussion/__init__.py
rename to erpnext/hr/doctype/employee_loan/__init__.py
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.js b/erpnext/hr/doctype/employee_loan/employee_loan.js
new file mode 100644
index 0000000..a03dbda
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.js
@@ -0,0 +1,88 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Employee Loan', {
+	onload: function(frm) {
+		frm.set_query("employee_loan_application", function() {
+			return {
+				"filters": {
+					"employee": frm.doc.employee,
+					"docstatus": 1,
+					"status": "Approved"
+				}
+			};
+		});
+
+		$.each(["payment_account", "employee_loan_account"], function(i, field) {
+			frm.set_query(field, function() {
+				return {
+					"filters": {
+						"company": frm.doc.company,
+						"root_type": "Asset",
+						"is_group": 0
+					}
+				};
+			});
+		})
+	},
+
+	mode_of_payment: function(frm){
+		frappe.call({
+			method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
+			args: {
+				"mode_of_payment": frm.doc.mode_of_payment,
+				"company": frm.doc.company
+			},
+			callback: function(r, rt) {
+				if(r.message) {
+					frm.set_value("payment_account", r.message.account);
+				}
+			}
+		});
+	},
+
+	refresh: function(frm) {
+		frm.trigger("toggle_fields");
+
+		if(frm.doc.docstatus==1) {
+			frm.add_custom_button(__('Ledger'), function() {
+				frappe.route_options = {
+					"voucher_no": frm.doc.name,
+					"from_date": frm.doc.posting_date,
+					"to_date": frm.doc.posting_date,
+					"company": frm.doc.company,
+					group_by_voucher: 0
+				};
+				frappe.set_route("query-report", "General Ledger");
+			}, "fa fa-table");
+		}
+	},
+
+	employee_loan_application: function(frm) {
+		return frm.call({
+			method: "erpnext.hr.doctype.employee_loan.employee_loan.get_employee_loan_application",
+			args: {
+				"employee_loan_application": frm.doc.employee_loan_application
+			},
+			callback: function(r){
+				if(!r.exc && r.message) {
+					frm.set_value("loan_type", r.message.loan_type);
+					frm.set_value("loan_amount", r.message.loan_amount);
+					frm.set_value("repayment_method", r.message.repayment_method);
+					frm.set_value("monthly_repayment_amount", r.message.repayment_amount);
+					frm.set_value("repayment_periods", r.message.repayment_periods);
+					frm.set_value("rate_of_interest", r.message.rate_of_interest);
+				}
+			}
+		})
+	},
+
+	repayment_method: function(frm) {
+		frm.trigger("toggle_fields")
+	},
+
+	toggle_fields: function(frm) {
+		frm.toggle_enable("monthly_repayment_amount", frm.doc.repayment_method=="Repay Fixed Amount per Period")
+		frm.toggle_enable("repayment_periods", frm.doc.repayment_method=="Repay Over Number of Periods")
+	}
+});
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.json b/erpnext/hr/doctype/employee_loan/employee_loan.json
new file mode 100644
index 0000000..560515f
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.json
@@ -0,0 +1,892 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 1, 
+ "allow_rename": 0, 
+ "autoname": "ELN.####", 
+ "beta": 0, 
+ "creation": "2016-12-02 10:11:49.673604", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Document", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_name", 
+   "fieldtype": "Read Only", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "employee.employee_name", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_loan_application", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee Loan Application", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee Loan Application", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "loan_type", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Loan Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Loan Type", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_3", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "fieldname": "posting_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Posting Date", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 1, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Company", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 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": "status", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Status", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Loan Unpaid\nLoan Paid\nEMI in progress\nLoan Repaid", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "repay_from_salary", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repay from Salary", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_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, 
+   "in_standard_filter": 0, 
+   "label": "Loan Details", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "loan_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "fieldname": "rate_of_interest", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Rate of Interest (%) / Year", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "loan_type.rate_of_interest", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "disbursement_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Disbursement Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_11", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Repay Over Number of Periods", 
+   "fieldname": "repayment_method", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Method", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nRepay Fixed Amount per Period\nRepay Over Number of Periods", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "depends_on": "", 
+   "fieldname": "repayment_periods", 
+   "fieldtype": "Int", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Period in Months", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "depends_on": "", 
+   "fieldname": "monthly_repayment_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "account_info", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Account Info", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "mode_of_payment", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Mode of Payment", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Mode of Payment", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "payment_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Payment Account", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Account", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_9", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_loan_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee Loan Account", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Account", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_15", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Schedule", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "repayment_schedule", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Schedule", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Repayment Schedule", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_17", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Totals", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "fieldname": "total_payment", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Total Payment", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_19", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "fieldname": "total_interest_payable", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Total Interest Payable", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "amended_from", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Amended From", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Employee Loan", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 1, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-01-17 07:13:10.704520", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "Employee Loan", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 1, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "is_custom": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "HR Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 1, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "search_fields": "posting_date", 
+ "sort_field": "creation", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.py b/erpnext/hr/doctype/employee_loan/employee_loan.py
new file mode 100644
index 0000000..4d7a9f3
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.py
@@ -0,0 +1,128 @@
+# -*- 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, math
+import erpnext
+from frappe import _
+from frappe.utils import flt, rounded, add_months, nowdate
+from erpnext.controllers.accounts_controller import AccountsController
+from erpnext.accounts.general_ledger import make_gl_entries
+
+class EmployeeLoan(AccountsController):
+	def validate(self):
+		check_repayment_method(self.repayment_method, self.loan_amount, self.monthly_repayment_amount, self.repayment_periods)
+		if not self.company:
+			self.company = erpnext.get_default_company()
+		if not self.posting_date:
+			self.posting_date = nowdate()
+		if self.loan_type and not self.rate_of_interest:
+			self.rate_of_interest = frappe.db.get_value("Loan Type", self.loan_type, "rate_of_interest")
+		if self.repayment_method == "Repay Over Number of Periods":
+			self.monthly_repayment_amount = get_monthly_repayment_amount(self.repayment_method, self.loan_amount, self.rate_of_interest, self.repayment_periods)
+
+		self.make_repayment_schedule()
+		self.set_repayment_period()
+		self.calculate_totals()
+
+	def on_submit(self):
+		self.make_gl_entries()
+
+	def on_cancel(self):
+		self.make_gl_entries()
+
+	def make_gl_entries(self):
+		gl_entries = []
+		# Gl entries for employee loan account
+		gl_entries.append(
+			self.get_gl_dict({
+				"account": self.employee_loan_account,
+				"party_type": "Employee",
+				"party": self.employee,
+				"debit": self.loan_amount,
+				"debit_in_account_currency": self.loan_amount
+			})
+		)
+		# Gl entries for payment account
+		gl_entries.append(
+			self.get_gl_dict({
+				"account": self.payment_account,
+				"credit": self.loan_amount,
+				"credit_in_account_currency": self.loan_amount
+			})
+		)
+		make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
+
+	def make_repayment_schedule(self):
+		self.repayment_schedule = []
+		payment_date = self.disbursement_date
+		balance_amount = self.loan_amount
+
+		while(balance_amount > 0):
+			interest_amount = rounded(balance_amount * flt(self.rate_of_interest) / (12*100))
+			principal_amount = self.monthly_repayment_amount - interest_amount
+			balance_amount = rounded(balance_amount + interest_amount - self.monthly_repayment_amount)
+
+			if balance_amount < 0:
+				principal_amount += balance_amount
+				balance_amount = 0.0
+
+			total_payment = principal_amount + interest_amount
+
+			self.append("repayment_schedule", {
+				"payment_date": payment_date,
+				"principal_amount": principal_amount,
+				"interest_amount": interest_amount,
+				"total_payment": total_payment,
+				"balance_loan_amount": balance_amount
+			})
+
+			next_payment_date = add_months(payment_date, 1)
+			payment_date = next_payment_date
+
+	def set_repayment_period(self):
+		if self.repayment_method == "Repay Fixed Amount per Period":
+			repayment_periods = len(self.repayment_schedule)
+
+			self.repayment_periods = repayment_periods
+
+	def calculate_totals(self):
+		self.total_payment = 0
+		self.total_interest_payable = 0
+		for data in self.repayment_schedule:
+			self.total_payment += data.total_payment
+			self.total_interest_payable +=data.interest_amount
+
+	def update_status(self):
+		if self.disbursement_date:
+			self.status = "Loan Paid"
+		if len(self.repayment_schedule)>0:
+			self.status = "repayment in progress"
+	
+def check_repayment_method(repayment_method, loan_amount, monthly_repayment_amount, repayment_periods):
+	if repayment_method == "Repay Over Number of Periods" and not repayment_periods:
+		frappe.throw(_("Please enter Repayment Periods"))
+		
+	if repayment_method == "Repay Fixed Amount per Period":
+		if not monthly_repayment_amount:
+			frappe.throw(_("Please enter repayment Amount"))
+		if monthly_repayment_amount > loan_amount:
+			frappe.throw(_("Monthly Repayment Amount cannot be greater than Loan Amount"))
+
+def get_monthly_repayment_amount(repayment_method, loan_amount, rate_of_interest, repayment_periods):
+	if repayment_method == "Repay Over Number of Periods":
+		if rate_of_interest:
+			monthly_interest_rate = flt(rate_of_interest) / (12 *100)
+			monthly_repayment_amount = math.ceil((loan_amount * monthly_interest_rate *
+				(1 + monthly_interest_rate)**repayment_periods) \
+				/ ((1 + monthly_interest_rate)**repayment_periods - 1))
+	else:
+		monthly_repayment_amount = math.ceil(flt(loan_amount) / repayment_periods)
+	return monthly_repayment_amount
+
+@frappe.whitelist()
+def get_employee_loan_application(employee_loan_application):
+	employee_loan = frappe.get_doc("Employee Loan Application", employee_loan_application)
+	if employee_loan:
+		return employee_loan
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_loan/test_employee_loan.py b/erpnext/hr/doctype/employee_loan/test_employee_loan.py
new file mode 100644
index 0000000..c1c6ba2
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan/test_employee_loan.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import erpnext
+import unittest
+from frappe.utils import nowdate
+from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
+
+class TestEmployeeLoan(unittest.TestCase):
+	def setUp(self):
+		create_loan_type("Personal Loan", 500000, 8.4)
+		self.employee = make_employee("robert_loan@loan.com")
+		create_employee_loan(self.employee, "Personal Loan", 280000, "Repay Over Number of Periods", 20)
+	
+	def test_employee_loan(self):
+		employee_loan = frappe.get_doc("Employee Loan", {"employee":self.employee})
+		self.assertEquals(employee_loan.monthly_repayment_amount, 15052)
+		self.assertEquals(employee_loan.total_interest_payable, 21034)
+		self.assertEquals(employee_loan.total_payment, 301034)
+
+		schedule = employee_loan.repayment_schedule
+
+		self.assertEquals(len(schedule), 20)
+
+		for idx, principal_amount, interest_amount, balance_loan_amount in [[3, 13369, 1683, 227079], [19, 14941, 105, 0], [17, 14740, 312, 29785]]:
+			self.assertEquals(schedule[idx].principal_amount, principal_amount)
+			self.assertEquals(schedule[idx].interest_amount, interest_amount)
+			self.assertEquals(schedule[idx].balance_loan_amount, balance_loan_amount)
+
+		employee_loan.repayment_method = "Repay Fixed Amount per Period"
+		employee_loan.monthly_repayment_amount = 14000
+		employee_loan.save()
+
+		self.assertEquals(len(employee_loan.repayment_schedule), 22)
+		self.assertEquals(employee_loan.total_interest_payable, 22712)
+		self.assertEquals(employee_loan.total_payment, 302712)
+
+
+def create_loan_type(loan_name, maximum_loan_amount, rate_of_interest):
+	if not frappe.db.get_value("Loan Type", loan_name):
+		frappe.get_doc({
+			"doctype": "Loan Type",
+			"loan_name": loan_name,
+			"maximum_loan_amount": maximum_loan_amount,
+			"rate_of_interest": rate_of_interest
+		}).insert()
+
+def	create_employee_loan(employee, loan_type, loan_amount, repayment_method, repayment_periods):
+	if not frappe.db.get_value("Employee Loan", {"employee":employee}):
+		employee_loan = frappe.new_doc("Employee Loan")
+		employee_loan.update({
+				"employee": employee,
+				"loan_type": loan_type,
+				"loan_amount": loan_amount,
+				"repayment_method": repayment_method,
+				"repayment_periods": repayment_periods,
+				"disbursement_date": nowdate(),
+				"mode_of_payment": frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name'),
+				"payment_account": frappe.db.get_value('Account', {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name"),
+				"employee_loan_account": frappe.db.get_value('Account', {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name")
+			})
+		employee_loan.insert()
+		return employee_loan
+	else:
+		return frappe.get_doc("Employee Loan", {"employee":employee})
\ No newline at end of file
diff --git a/erpnext/schools/doctype/discussion/__init__.py b/erpnext/hr/doctype/employee_loan_application/__init__.py
similarity index 100%
copy from erpnext/schools/doctype/discussion/__init__.py
copy to erpnext/hr/doctype/employee_loan_application/__init__.py
diff --git a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.js b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.js
new file mode 100644
index 0000000..6958bea
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Employee Loan Application', {
+	refresh: function(frm) {
+		frm.trigger("toggle_fields")
+	},
+	repayment_method: function(frm) {
+		frm.trigger("toggle_fields")
+	},
+
+	toggle_fields: function(frm) {
+		frm.toggle_enable("repayment_amount", frm.doc.repayment_method=="Repay Fixed Amount per Period")
+		frm.toggle_enable("repayment_periods", frm.doc.repayment_method=="Repay Over Number of Periods")
+	}
+});
diff --git a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.json b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.json
new file mode 100644
index 0000000..e30dc5a
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.json
@@ -0,0 +1,681 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "ELA/.#####", 
+ "beta": 0, 
+ "creation": "2016-12-02 12:35:56.046811", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Today", 
+   "fieldname": "posting_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Posting Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Employee", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "employee_name", 
+   "fieldtype": "Read Only", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 1, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employee Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "employee.employee_name", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "status", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Status", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Open\nApproved\nRejected", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Company", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_4", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Info", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "loan_type", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Loan Type", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "loan_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "required_by_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Required by Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_7", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Reason", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "repayment_info", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Info", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "repayment_method", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Method", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nRepay Fixed Amount per Period\nRepay Over Number of Periods", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "rate_of_interest", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Rate of Interest", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "loan_type.rate_of_interest", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "total_payable_interest", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Total Payable Interest", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_11", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "repayment_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "repayment_periods", 
+   "fieldtype": "Int", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Repayment Period in Months", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "total_payable_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Total Payable Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "amended_from", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Amended From", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Employee Loan Application", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 1, 
+ "issingle": 0, 
+ "istable": 0, 
+ "max_attachments": 0, 
+ "modified": "2017-01-09 12:02:36.562577", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "Employee Loan Application", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 1, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "is_custom": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "HR Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 1, 
+   "write": 1
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "is_custom": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Employee", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 1, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "search_fields": "employee, employee_name, loan_type, loan_amount", 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "timeline_field": "employee", 
+ "title_field": "employee_name", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py
new file mode 100644
index 0000000..15dbd4e
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py
@@ -0,0 +1,34 @@
+# -*- 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, math
+from frappe import _
+from frappe.utils import flt
+from frappe.model.document import Document
+
+from erpnext.hr.doctype.employee_loan.employee_loan import get_monthly_repayment_amount, check_repayment_method
+
+class EmployeeLoanApplication(Document):
+	def validate(self):
+		check_repayment_method(self.repayment_method, self.loan_amount, self.repayment_amount, self.repayment_periods)
+		self.validate_loan_amount()
+		self.get_repayment_details()
+
+	def validate_loan_amount(self):
+		maximum_loan_limit = frappe.db.get_value('Loan Type', self.loan_type, 'maximum_loan_amount')
+		if self.loan_amount > maximum_loan_limit:
+			frappe.throw(_("Loan Amount cannot exceed Maximum Loan Amount of {0}").format(maximum_loan_limit))
+
+	def get_repayment_details(self):
+		if self.repayment_method == "Repay Over Number of Periods":
+			self.repayment_amount = get_monthly_repayment_amount(self.repayment_method, self.loan_amount, self.rate_of_interest, self.repayment_periods)
+
+		if self.repayment_method == "Repay Fixed Amount per Period":
+			monthly_interest_rate = flt(self.rate_of_interest) / (12 *100)
+			self.repayment_periods = math.ceil((math.log(self.repayment_amount) - math.log(self.repayment_amount - \
+									(self.loan_amount*monthly_interest_rate)))/(math.log(1+monthly_interest_rate)))
+
+		self.total_payable_amount = self.repayment_amount * self.repayment_periods
+		self.total_payable_interest = self.total_payable_amount - self.loan_amount
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py b/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py
new file mode 100644
index 0000000..1d157d6
--- /dev/null
+++ b/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
+
+class TestEmployeeLoanApplication(unittest.TestCase):
+	def setUp(self):
+		self.create_loan_type()
+		self.employee = make_employee("kate_loan@loan.com")
+		self.create_loan_application()
+
+	def create_loan_type(self):
+		if not frappe.db.get_value("Loan Type", "Home Loan"):
+			frappe.get_doc({
+				"doctype": "Loan Type",
+				"loan_name": "Home Loan",
+				"maximum_loan_amount": 500000,
+				"rate_of_interest": 9.2
+			}).insert()
+
+	def create_loan_application(self):
+		if not frappe.db.get_value("Employee Loan Application", {"employee":self.employee}, "name"):
+			loan_application = frappe.new_doc("Employee Loan Application")
+			loan_application.update({
+				"employee": self.employee,
+				"loan_type": "Home Loan",
+				"rate_of_interest": 9.2,
+				"loan_amount": 250000,
+				"repayment_method": "Repay Over Number of Periods",
+				"repayment_periods": 24
+			})
+			loan_application.insert()
+	
+
+	def test_loan_totals(self):
+		loan_application = frappe.get_doc("Employee Loan Application", {"employee":self.employee})
+		self.assertEquals(loan_application.repayment_amount, 11445)
+		self.assertEquals(loan_application.total_payable_interest, 24680)
+		self.assertEquals(loan_application.total_payable_amount, 274680)
+
+		loan_application.repayment_method = "Repay Fixed Amount per Period"
+		loan_application.repayment_amount = 15000
+		loan_application.save()
+
+		self.assertEquals(loan_application.repayment_periods, 18)
+		self.assertEquals(loan_application.total_payable_interest, 20000)
+		self.assertEquals(loan_application.total_payable_amount, 270000)
\ No newline at end of file
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index 8b3c451..7d19051 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -158,6 +158,21 @@
 	}
 }
 
+frappe.ui.form.on("Expense Claim", {
+	refresh: function(frm) {
+		if(frm.doc.docstatus == 1) {
+			frm.add_custom_button(__('Accounting Ledger'), function() {
+				frappe.route_options = {
+					voucher_no: frm.doc.name,
+					company: frm.doc.company,
+					group_by_voucher: false
+				};
+				frappe.set_route("query-report", "General Ledger");
+			}, __("View"));
+		}
+	}
+})
+
 frappe.ui.form.on("Expense Claim Detail", {
 	claim_amount: function(frm, cdt, cdn) {
 		var child = locals[cdt][cdn];
@@ -176,6 +191,47 @@
 	}
 })
 
+frappe.ui.form.on("Expense Claim",{
+	setup: function(frm) {
+		frm.trigger("set_query_for_cost_center")
+		frm.trigger("set_query_for_payable_account")
+		frm.add_fetch("company", "cost_center", "cost_center");
+		frm.add_fetch("company", "default_payable_account", "payable_account");
+	},
+
+	refresh: function(frm) {
+		frm.trigger("toggle_fields")
+	},
+
+	set_query_for_cost_center: function(frm) {
+		frm.fields_dict["cost_center"].get_query = function() {
+			return {
+				filters: {
+					"company": frm.doc.company
+				}
+			}
+		}
+	},
+
+	set_query_for_payable_account: function(frm) {
+		frm.fields_dict["payable_account"].get_query = function() {
+			return {
+				filters: {
+					"root_type": "Liability",
+					"account_type": "Payable"
+				}
+			}
+		}
+	},
+
+	is_paid: function(frm) {
+		frm.trigger("toggle_fields")
+	},
+
+	toggle_fields: function(frm) {
+		frm.toggle_reqd("mode_of_payment", frm.doc.is_paid)
+	}
+});
 
 frappe.ui.form.on("Expense Claim", "employee_name", function(frm) {
 	erpnext.expense_claim.set_title(frm);
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.json b/erpnext/hr/doctype/expense_claim/expense_claim.json
index 67132bf..f517b91 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.json
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.json
@@ -46,6 +46,34 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "is_paid", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Paid", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "default": "Draft", 
    "depends_on": "eval:!doc.__islocal", 
    "fieldname": "approval_status", 
@@ -55,7 +83,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "Approval Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -86,7 +114,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "Approver", 
    "length": 0, 
    "no_copy": 0, 
@@ -175,7 +203,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Total Sanctioned Amount", 
    "length": 0, 
@@ -322,7 +350,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "From Employee", 
    "length": 0, 
    "no_copy": 0, 
@@ -375,36 +403,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 1, 
-   "in_list_view": 0, 
-   "in_standard_filter": 1, 
-   "label": "Company", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "company", 
-   "oldfieldtype": "Link", 
-   "options": "Company", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 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": "vehicle_log", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -434,90 +432,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "cb1", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "total_amount_reimbursed", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Total Amount Reimbursed", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "remark", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Remark", 
-   "length": 0, 
-   "no_copy": 1, 
-   "oldfieldname": "remark", 
-   "oldfieldtype": "Small Text", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "project", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -572,6 +486,90 @@
    "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "cb1", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "total_amount_reimbursed", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Total Amount Reimbursed", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "remark", 
+   "fieldtype": "Small Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Remark", 
+   "length": 0, 
+   "no_copy": 1, 
+   "oldfieldname": "remark", 
+   "oldfieldtype": "Small Text", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 1, 
    "bold": 0, 
    "collapsible": 0, 
@@ -613,7 +611,7 @@
    "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Employees Email Address", 
+   "label": "Employees Email Id", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldname": "email_id", 
@@ -634,6 +632,238 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "accounting_details", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Accounting Details", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 1, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Company", 
+   "length": 0, 
+   "no_copy": 0, 
+   "oldfieldname": "company", 
+   "oldfieldtype": "Link", 
+   "options": "Company", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 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, 
+   "depends_on": "is_paid", 
+   "fieldname": "mode_of_payment", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Mode of Payment", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Mode of Payment", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_24", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "payable_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Payable Account", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Account", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "cost_center", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Employees Email Address", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Cost Center", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 1, 
+   "columns": 0, 
+   "fieldname": "more_details", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "More Details", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "Draft", 
+   "fieldname": "status", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 1, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Status", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Draft\nPaid\nUnpaid\nSubmitted\nCancelled", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -663,7 +893,7 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
- "icon": "fa fa-money", 
+ "icon": "icon-money", 
  "idx": 1, 
  "image_view": 0, 
  "in_create": 0, 
@@ -673,10 +903,11 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-11-07 05:52:48.548201", 
+ "modified": "2017-01-19 18:15:35.968292", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Expense Claim", 
+ "name_case": "Title Case", 
  "owner": "harshada@webnotestech.com", 
  "permissions": [
   {
@@ -689,7 +920,6 @@
    "export": 1, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -710,7 +940,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -732,7 +961,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -754,7 +982,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -775,5 +1002,6 @@
  "sort_order": "DESC", 
  "timeline_field": "employee", 
  "title_field": "title", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index efdee97..957753a 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -4,13 +4,17 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
-from frappe.utils import get_fullname, flt
+from frappe.utils import get_fullname, flt, cstr
 from frappe.model.document import Document
 from erpnext.hr.utils import set_employee_name
+from erpnext.accounts.party import get_party_account
+from erpnext.accounts.general_ledger import make_gl_entries
+from erpnext.accounts.doctype.sales_invoice.sales_invoice import get_bank_cash_account
+from erpnext.controllers.accounts_controller import AccountsController
 
 class InvalidExpenseApproverError(frappe.ValidationError): pass
 
-class ExpenseClaim(Document):
+class ExpenseClaim(AccountsController):
 	def get_feed(self):
 		return _("{0}: From {0} for {1}").format(self.approval_status,
 			self.employee_name, self.total_claimed_amount)
@@ -21,16 +25,53 @@
 		self.calculate_total_amount()
 		set_employee_name(self)
 		self.set_expense_account()
+		self.set_payable_account()
+		self.set_cost_center()
+		self.set_status()
 		if self.task and not self.project:
 			self.project = frappe.db.get_value("Task", self.task, "project")
 
+	def set_status(self):
+		self.status = {
+			"0": "Draft",
+			"1": "Submitted",
+			"2": "Cancelled"
+		}[cstr(self.docstatus or 0)]
+
+		if self.total_sanctioned_amount == self.total_amount_reimbursed and self.docstatus == 1:
+			self.status = "Paid"
+		elif self.docstatus == 1:
+			self.status = "Unpaid"
+
+	def set_payable_account(self):
+		if not self.payable_account and not self.is_paid:
+			self.payable_account = frappe.db.get_value("Company", self.company, "default_payable_account")
+
+	def set_cost_center(self):
+		if not self.cost_center:
+			self.cost_center = frappe.db.get_value('Company', self.company, 'cost_center')
+
 	def on_submit(self):
 		if self.approval_status=="Draft":
 			frappe.throw(_("""Approval Status must be 'Approved' or 'Rejected'"""))
+
 		self.update_task_and_project()
+		self.make_gl_entries()
+
+		if self.is_paid:
+			update_reimbursed_amount(self)
+
+		self.set_status()
 
 	def on_cancel(self):
 		self.update_task_and_project()
+		if self.payable_account:
+			self.make_gl_entries(cancel=True)
+
+		if self.is_paid:
+			update_reimbursed_amount(self)
+
+		self.set_status()
 
 	def update_task_and_project(self):
 		if self.task:
@@ -38,6 +79,79 @@
 		elif self.project:
 			frappe.get_doc("Project", self.project).update_project()
 
+	def make_gl_entries(self, cancel = False):
+		if flt(self.total_sanctioned_amount) > 0:
+			gl_entries = self.get_gl_entries()
+			make_gl_entries(gl_entries, cancel)
+
+	def get_gl_entries(self):
+		gl_entry = []
+		self.validate_account_details()
+		
+		# payable entry
+		gl_entry.append(
+			self.get_gl_dict({
+				"account": self.payable_account,
+				"credit": self.total_sanctioned_amount,
+				"credit_in_account_currency": self.total_sanctioned_amount,
+				"against": ",".join([d.default_account for d in self.expenses]),
+				"party_type": "Employee",
+				"party": self.employee,
+				"against_voucher_type": self.doctype,
+				"against_voucher": self.name
+			})
+		)
+
+		# expense entries
+		for data in self.expenses:
+			gl_entry.append(
+				self.get_gl_dict({
+					"account": data.default_account,
+					"debit": data.sanctioned_amount,
+					"debit_in_account_currency": data.sanctioned_amount,
+					"against": self.employee,
+					"cost_center": self.cost_center
+				})
+			)
+
+		if self.is_paid:
+			# payment entry
+			payment_account = get_bank_cash_account(self.mode_of_payment, self.company).get("account")
+			gl_entry.append(
+				self.get_gl_dict({
+					"account": payment_account,
+					"credit": self.total_sanctioned_amount,
+					"credit_in_account_currency": self.total_sanctioned_amount,
+					"against": self.employee
+				})
+			)
+
+			gl_entry.append(
+				self.get_gl_dict({
+					"account": self.payable_account,
+					"party_type": "Employee",
+					"party": self.employee,
+					"against": payment_account,
+					"debit": self.total_sanctioned_amount,
+					"debit_in_account_currency": self.total_sanctioned_amount,
+					"against_voucher": self.name,
+					"against_voucher_type": self.doctype,
+				})
+			)
+
+		return gl_entry
+
+	def validate_account_details(self):
+		if not self.cost_center:
+			frappe.throw(_("Cost center is required to book an expense claim"))
+
+		if not self.payable_account:
+			frappe.throw(_("Please set default payable account in the employee {0}").format(self.employee))
+
+		if self.is_paid:
+			if not self.mode_of_payment:
+				frappe.throw(_("Mode of payment is required to make a payment").format(self.employee))
+
 	def calculate_total_amount(self):
 		self.total_claimed_amount = 0
 		self.total_sanctioned_amount = 0
@@ -64,7 +178,18 @@
 		for expense in self.expenses:
 			if not expense.default_account:
 				expense.default_account = get_expense_claim_account(expense.expense_type, self.company)["account"]
-		
+
+def update_reimbursed_amount(doc):
+	amt = frappe.db.sql("""select ifnull(sum(debit_in_account_currency), 0) as amt 
+		from `tabGL Entry` where against_voucher_type = 'Expense Claim' and against_voucher = %s
+		and party = %s """, (doc.name, doc.employee) ,as_dict=1)[0].amt
+
+	doc.total_amount_reimbursed = amt
+	frappe.db.set_value("Expense Claim", doc.name , "total_amount_reimbursed", amt)
+
+	doc.set_status()
+	frappe.db.set_value("Expense Claim", doc.name , "status", doc.status)
+
 @frappe.whitelist()
 def get_expense_approver(doctype, txt, searchfield, start, page_len, filters):
 	return frappe.db.sql("""
@@ -80,23 +205,26 @@
 
 	expense_claim = frappe.get_doc("Expense Claim", docname)
 	default_bank_cash_account = get_default_bank_cash_account(expense_claim.company, "Bank")
+	if not default_bank_cash_account:
+		default_bank_cash_account = get_default_bank_cash_account(expense_claim.company, "Cash")
 
 	je = frappe.new_doc("Journal Entry")
 	je.voucher_type = 'Bank Entry'
 	je.company = expense_claim.company
 	je.remark = 'Payment against Expense Claim: ' + docname;
 
-	for expense in expense_claim.expenses:
-		je.append("accounts", {
-			"account": expense.default_account,
-			"debit_in_account_currency": expense.sanctioned_amount,
-			"reference_type": "Expense Claim",
-			"reference_name": expense_claim.name
-		})
+	je.append("accounts", {
+		"account": expense_claim.payable_account,
+		"debit_in_account_currency": flt(expense_claim.total_sanctioned_amount - expense_claim.total_amount_reimbursed),
+		"reference_type": "Expense Claim",
+		"party_type": "Employee",
+		"party": expense_claim.employee,
+		"reference_name": expense_claim.name
+	})
 
 	je.append("accounts", {
 		"account": default_bank_cash_account.account,
-		"credit_in_account_currency": expense_claim.total_sanctioned_amount,
+		"credit_in_account_currency": flt(expense_claim.total_sanctioned_amount - expense_claim.total_amount_reimbursed),
 		"reference_type": "Expense Claim",
 		"reference_name": expense_claim.name,
 		"balance": default_bank_cash_account.balance,
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim_list.js b/erpnext/hr/doctype/expense_claim/expense_claim_list.js
index 54073ed..7cff8e2 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim_list.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim_list.js
@@ -2,7 +2,10 @@
 	add_fields: ["approval_status", "total_claimed_amount", "docstatus"],
 	filters:[["approval_status","!=", "Rejected"]],
 	get_indicator: function(doc) {
-		return [__(doc.approval_status), frappe.utils.guess_colour(doc.approval_status),
-			"approval_status,=," + doc.approval_status];
+		if(doc.status == "Paid") {
+			return [__("Paid"), "green", "status,=,'Paid'"];
+		} else {
+			return [__("Unpaid"), "orange"];
+		}
 	}
 };
diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
index 59d686e..20df7be 100644
--- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
@@ -4,6 +4,8 @@
 
 import frappe
 import unittest
+from frappe.utils import random_string, nowdate
+from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
 
 test_records = frappe.get_test_records('Expense Claim')
 
@@ -11,8 +13,6 @@
 	def test_total_expense_claim_for_project(self):
 		frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
 		frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
-		frappe.db.sql("""delete from `tabExpense Claim`""")
-		frappe.db.sql("""delete from `tabExpense Claim Detail`""")
 
 		frappe.get_doc({
 			"project_name": "_Test Project 1",
@@ -22,15 +22,17 @@
 		}).save()
 
 		task_name = frappe.db.get_value("Task", {"project": "_Test Project 1"})
+		payable_account = get_payable_account("Wind Power LLC")
 
 		expense_claim = frappe.get_doc({
 			 "doctype": "Expense Claim",
 			 "employee": "_T-Employee-0001",
+			 "payable_account": payable_account,
 			 "approval_status": "Approved",
 			 "project": "_Test Project 1",
 			 "task": task_name,
 			 "expenses":
-			 	[{ "expense_type": "Food", "default_account": "Entertainment Expenses - _TC", "claim_amount": 300, "sanctioned_amount": 200 }]
+			 	[{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "claim_amount": 300, "sanctioned_amount": 200 }]
 		})
 		expense_claim.submit()
 
@@ -44,7 +46,7 @@
 			 "project": "_Test Project 1",
 			 "task": task_name,
 			 "expenses":
-			 	[{ "expense_type": "Food", "default_account": "Entertainment Expenses - _TC", "claim_amount": 600, "sanctioned_amount": 500 }]
+			 	[{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "claim_amount": 600, "sanctioned_amount": 500 }]
 		})
 		expense_claim2.submit()
 
@@ -52,6 +54,64 @@
 		self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
 
 		expense_claim2.cancel()
+		frappe.delete_doc("Expenses Claim", expense_claim2.name)
 
 		self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
 		self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
+		
+	def test_expense_claim_status(self):
+		payable_account = get_payable_account("Wind Power LLC")
+		expense_claim = frappe.get_doc({
+			 "doctype": "Expense Claim",
+			 "employee": "_T-Employee-0001",
+			 "payable_account": payable_account,
+			 "approval_status": "Approved",
+			 "expenses":
+			 	[{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "claim_amount": 300, "sanctioned_amount": 200 }]
+		})
+		expense_claim.submit()
+
+		je_dict = make_bank_entry(expense_claim.name)
+		je = frappe.get_doc(je_dict)
+		je.posting_date = nowdate()
+		je.cheque_no = random_string(5)
+		je.cheque_date = nowdate()
+		je.submit()
+
+		expense_claim = frappe.get_doc("Expense Claim", expense_claim.name)
+		self.assertEqual(expense_claim.status, "Paid")
+		
+		je.cancel()
+		expense_claim = frappe.get_doc("Expense Claim", expense_claim.name)
+		self.assertEqual(expense_claim.status, "Unpaid")
+
+	def test_expense_claim_gl_entry(self):
+		payable_account = get_payable_account("Wind Power LLC")
+		expense_claim = frappe.get_doc({
+			 "doctype": "Expense Claim",
+			 "employee": "_T-Employee-0001",
+			 "payable_account": payable_account,
+			 "approval_status": "Approved",
+			 "expenses":
+			 	[{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "claim_amount": 300, "sanctioned_amount": 200 }]
+		})
+		expense_claim.submit()
+		
+		gl_entries = frappe.db.sql("""select account, debit, credit
+			from `tabGL Entry` where voucher_type='Expense Claim' and voucher_no=%s
+			order by account asc""", expense_claim.name, as_dict=1)
+
+		self.assertTrue(gl_entries)
+
+		expected_values = dict((d[0], d) for d in [
+			[payable_account, 0.0, 200.0],
+			["Travel Expenses - WP", 200.0, 0.0]
+		])
+
+		for gle in gl_entries:
+			self.assertEquals(expected_values[gle.account][0], gle.account)
+			self.assertEquals(expected_values[gle.account][1], gle.debit)
+			self.assertEquals(expected_values[gle.account][2], gle.credit)
+
+def get_payable_account(company):
+	return frappe.db.get_value('Company', company, 'default_payable_account')
diff --git a/erpnext/schools/doctype/topic/__init__.py b/erpnext/hr/doctype/loan_type/__init__.py
similarity index 100%
rename from erpnext/schools/doctype/topic/__init__.py
rename to erpnext/hr/doctype/loan_type/__init__.py
diff --git a/erpnext/hr/doctype/loan_type/loan_type.js b/erpnext/hr/doctype/loan_type/loan_type.js
new file mode 100644
index 0000000..72f5775
--- /dev/null
+++ b/erpnext/hr/doctype/loan_type/loan_type.js
@@ -0,0 +1,7 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Loan Type', {
+	refresh: function(frm) {
+	}
+});
diff --git a/erpnext/hr/doctype/loan_type/loan_type.json b/erpnext/hr/doctype/loan_type/loan_type.json
new file mode 100644
index 0000000..f9441ea
--- /dev/null
+++ b/erpnext/hr/doctype/loan_type/loan_type.json
@@ -0,0 +1,230 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:loan_name", 
+ "beta": 0, 
+ "creation": "2016-12-02 10:41:40.732843", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "loan_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "maximum_loan_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Maximum Loan Amount", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "rate_of_interest", 
+   "fieldtype": "Percent", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Rate of Interest (%) Yearly", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "default": "", 
+   "fieldname": "disabled", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Disabled", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "description", 
+   "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Description", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "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-12-29 15:54:17.716285", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "Loan Type", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "is_custom": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "HR Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }
+ ], 
+ "quick_entry": 0, 
+ "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/hr/doctype/loan_type/loan_type.py b/erpnext/hr/doctype/loan_type/loan_type.py
new file mode 100644
index 0000000..2714e20
--- /dev/null
+++ b/erpnext/hr/doctype/loan_type/loan_type.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 LoanType(Document):
+	pass
diff --git a/erpnext/hr/doctype/loan_type/test_loan_type.py b/erpnext/hr/doctype/loan_type/test_loan_type.py
new file mode 100644
index 0000000..078e11e
--- /dev/null
+++ b/erpnext/hr/doctype/loan_type/test_loan_type.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('Loan Type')
+
+class TestLoanType(unittest.TestCase):
+	pass
diff --git a/erpnext/schools/doctype/announcement/__init__.py b/erpnext/hr/doctype/repayment_schedule/__init__.py
similarity index 100%
copy from erpnext/schools/doctype/announcement/__init__.py
copy to erpnext/hr/doctype/repayment_schedule/__init__.py
diff --git a/erpnext/hr/doctype/repayment_schedule/repayment_schedule.json b/erpnext/hr/doctype/repayment_schedule/repayment_schedule.json
new file mode 100644
index 0000000..3a0dfd3
--- /dev/null
+++ b/erpnext/hr/doctype/repayment_schedule/repayment_schedule.json
@@ -0,0 +1,179 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2016-12-20 15:32:25.078334", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "payment_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Payment Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "principal_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Principal Amount", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "interest_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Interest Amount", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "total_payment", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Total Payment", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 2, 
+   "fieldname": "balance_loan_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Balance Loan Amount", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
+ "idx": 0, 
+ "image_view": 0, 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 1, 
+ "max_attachments": 0, 
+ "modified": "2017-01-09 12:00:10.818772", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "Repayment Schedule", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/repayment_schedule/repayment_schedule.py b/erpnext/hr/doctype/repayment_schedule/repayment_schedule.py
new file mode 100644
index 0000000..8abee5e
--- /dev/null
+++ b/erpnext/hr/doctype/repayment_schedule/repayment_schedule.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 RepaymentSchedule(Document):
+	pass
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js
index 8b0dd16..0262259 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.js
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.js
@@ -110,6 +110,7 @@
 	calculate_earning_total(doc, dt, dn, true);
 	calculate_ded_total(doc, dt, dn, true);
 	calculate_net_pay(doc, dt, dn);
+	refresh_many(['amount','gross_pay', 'rounded_total', 'net_pay', 'loan_repayment']);
 };
 
 // Calculate earning total
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index e558d73..7d5dbe9 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -1266,7 +1266,35 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "description": "Gross Pay + Arrear Amount +Encashment Amount - Total Deduction", 
+   "fieldname": "loan_repayment", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Loan Repayment", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Gross Pay + Arrear Amount + Encashment Amount - Total Deduction - Loan Repayment", 
    "fieldname": "net_pay", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -1362,7 +1390,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-14 08:26:31.400930", 
+ "modified": "2017-01-09 12:37:03.802501", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Slip", 
@@ -1413,7 +1441,7 @@
   }, 
   {
    "amend": 0, 
-   "apply_user_permissions": 0, 
+   "apply_user_permissions": 1, 
    "cancel": 0, 
    "create": 0, 
    "delete": 0, 
@@ -1430,6 +1458,7 @@
    "set_user_permissions": 0, 
    "share": 0, 
    "submit": 0, 
+   "user_permission_doctypes": "[\"Employee\"]", 
    "write": 0
   }
  ], 
@@ -1440,5 +1469,6 @@
  "sort_order": "DESC", 
  "timeline_field": "employee", 
  "title_field": "employee_name", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index eeec6e8..5ff1248 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -89,8 +89,8 @@
 		    frappe.throw(_("Name error: {0}".format(err)))
 		except SyntaxError as err:
 		    frappe.throw(_("Syntax error in formula or condition: {0}".format(err)))
-		except:
-		    frappe.throw(_("Error in formula or condition"))
+		except Exception, e:
+		    frappe.throw(_("Error in formula or condition: {0}".format(e)))
 		    raise
 
 	def get_data_for_eval(self):
@@ -99,7 +99,7 @@
 
 		for d in self._salary_structure_doc.employees:
 			if d.employee == self.employee:
-				data.base, data.variable = d.base, d.variable
+				data.update(frappe.get_doc("Salary Structure Employee", {"employee": self.employee}).as_dict())
 
 		data.update(frappe.get_doc("Employee", self.employee).as_dict())
 		data.update(self.as_dict())
@@ -108,7 +108,6 @@
 		salary_components = frappe.get_all("Salary Component", fields=["salary_component_abbr"])
 		for salary_component in salary_components:
 			data[salary_component.salary_component_abbr] = 0
-
 		return data
 
 
@@ -329,11 +328,21 @@
 
 		self.sum_components('earnings', 'gross_pay')
 		self.sum_components('deductions', 'total_deduction')
+		
+		self.set_loan_repayment()
 
-		self.net_pay = flt(self.gross_pay) - flt(self.total_deduction)
+		self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.loan_repayment))
 		self.rounded_total = rounded(self.net_pay,
 			self.precision("net_pay") if disable_rounded_total else 0)
 
+	def set_loan_repayment(self):
+		employee_loan = frappe.db.sql("""select sum(total_payment) as loan_repayment from `tabRepayment Schedule`
+						where payment_date between %s and %s and parent in (select name from `tabEmployee Loan`
+						where employee = %s and repay_from_salary = 1 and docstatus = 1)""",
+						(self.start_date, self.end_date, self.employee), as_dict=True)
+		if employee_loan:
+			self.loan_repayment = employee_loan[0].loan_repayment
+
 	def on_submit(self):
 		if self.net_pay < 0:
 			frappe.throw(_("Net Pay cannot be less than 0"))
diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
index 3d119c3..9999f1e 100644
--- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
@@ -7,7 +7,7 @@
 import erpnext
 import calendar
 from erpnext.accounts.utils import get_fiscal_year
-from frappe.utils import getdate, nowdate, add_days
+from frappe.utils import getdate, nowdate, add_days, flt
 from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
 from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account
 from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details
@@ -24,7 +24,6 @@
 
 		frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
 
-
 	def tearDown(self):
 		frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
 		frappe.set_user("Administrator")
@@ -40,12 +39,12 @@
 
 		self.assertEquals(ss.total_working_days, no_of_days[0])
 		self.assertEquals(ss.payment_days, no_of_days[0])
-		self.assertEquals(ss.earnings[0].amount, 5000)
+		self.assertEquals(ss.earnings[0].amount, 25000)
 		self.assertEquals(ss.earnings[1].amount, 3000)
 		self.assertEquals(ss.deductions[0].amount, 5000)
-		self.assertEquals(ss.deductions[1].amount, 2500)
-		self.assertEquals(ss.gross_pay, 10500)
-		self.assertEquals(ss.net_pay, 3000)
+		self.assertEquals(ss.deductions[1].amount, 5000)
+		self.assertEquals(ss.gross_pay, 40500)
+		self.assertEquals(ss.net_pay, 29918)
 
 	def test_salary_slip_with_holidays_excluded(self):
 		no_of_days = self.get_no_of_days()
@@ -58,13 +57,13 @@
 
 		self.assertEquals(ss.total_working_days, no_of_days[0] - no_of_days[1])
 		self.assertEquals(ss.payment_days, no_of_days[0] - no_of_days[1])
-		self.assertEquals(ss.earnings[0].amount, 5000)
-		self.assertEquals(ss.earnings[0].default_amount, 5000)
+		self.assertEquals(ss.earnings[0].amount, 25000)
+		self.assertEquals(ss.earnings[0].default_amount, 25000)
 		self.assertEquals(ss.earnings[1].amount, 3000)
 		self.assertEquals(ss.deductions[0].amount, 5000)
-		self.assertEquals(ss.deductions[1].amount, 2500)
-		self.assertEquals(ss.gross_pay, 10500)
-		self.assertEquals(ss.net_pay, 3000)
+		self.assertEquals(ss.deductions[1].amount, 5000)
+		self.assertEquals(ss.gross_pay, 40500)
+		self.assertEquals(ss.net_pay, 29918)
 
 	def test_payment_days(self):
 		no_of_days = self.get_no_of_days()
@@ -130,9 +129,23 @@
 		ss = frappe.get_doc("Salary Slip",
 			self.make_employee_salary_slip("test_employee@salary.com", "Monthly"))
 		ss.submit()
+
 		email_queue = frappe.db.sql("""select name from `tabEmail Queue`""")
 		self.assertTrue(email_queue)
 
+	def test_loan_repayment_salary_slip(self):
+		from erpnext.hr.doctype.employee_loan.test_employee_loan import create_loan_type, create_employee_loan
+		employee = self.make_employee("test_employee@salary.com")
+		create_loan_type("Car Loan", 500000, 6.4)
+		employee_loan = create_employee_loan(employee, "Car Loan", 11000, "Repay Over Number of Periods", 20)
+		employee_loan.repay_from_salary = 1
+		employee_loan.submit()
+		ss = frappe.get_doc("Salary Slip",
+			self.make_employee_salary_slip("test_employee@salary.com", "Monthly"))
+		ss.submit()
+		self.assertEquals(ss.loan_repayment, 582)
+		self.assertEquals(ss.net_pay, (flt(ss.gross_pay) - (flt(ss.total_deduction) + flt(ss.loan_repayment))))
+
 	def test_payroll_frequency(self):
 		fiscal_year = get_fiscal_year(nowdate(), company="_Test Company")[0]
 		month = "%02d" % getdate(nowdate()).month
@@ -167,7 +180,7 @@
 			}).insert()
 
 		if not frappe.db.get_value("Employee", {"user_id": user}):
-			frappe.get_doc({
+			employee = frappe.get_doc({
 				"doctype": "Employee",
 				"naming_series": "EMP-",
 				"employee_name": user,
@@ -183,6 +196,9 @@
 				"status": "Active",
 				"employment_type": "Intern"
 			}).insert()
+			return employee.name
+		else:
+			return frappe.get_value("Employee", {"employee_name":user}, "name")
 
 	def make_holiday_list(self):
 		fiscal_year = get_fiscal_year(nowdate(), company="_Test Company")
@@ -278,7 +294,7 @@
 
 def get_employee_details(employee):
 	return [{"employee": employee,
-			"base": 25000,
+			"base": 50000,
 			"variable": 5000
 			}
 		]
@@ -289,14 +305,14 @@
 					"salary_component": 'Basic Salary',
 					"abbr":'BS',
 					"condition": 'base > 10000',
-					"formula": 'base*.2',
+					"formula": 'base*.5',
 					"idx": 1
 				},
 				{
 					"salary_component": 'Basic Salary',
 					"abbr":'BS',
 					"condition": 'base < 10000',
-					"formula": 'base*.1',
+					"formula": 'base*.2',
 					"idx": 2
 				},
 				{
@@ -320,13 +336,13 @@
 					"salary_component": 'Professional Tax',
 					"abbr":'PT',
 					"condition": 'base > 10000',
-					"formula": 'base*.2',
+					"formula": 'base*.1',
 					"idx": 1
 				},
 				{
 					"salary_component": 'TDS',
 					"abbr":'T',
-					"formula": 'base*.5',
+					"formula": 'base*.1',
 					"idx": 2
 				},
 				{
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.json b/erpnext/hr/doctype/salary_structure/salary_structure.json
index ca59ded..b34cff1 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.json
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.json
@@ -21,7 +21,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -48,7 +47,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Company", 
@@ -76,7 +74,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Letter Head", 
@@ -107,7 +104,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Payroll Frequency", 
@@ -136,7 +132,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -164,7 +159,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 1, 
    "in_standard_filter": 1, 
    "label": "Is Active", 
@@ -195,7 +189,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Is Default", 
@@ -224,7 +217,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "From Date", 
@@ -253,7 +245,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "To Date", 
@@ -282,7 +273,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -310,7 +300,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Employees", 
@@ -339,7 +328,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
@@ -368,7 +356,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Salary Slip Based on Timesheet", 
@@ -396,7 +383,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -425,7 +411,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Salary Component", 
@@ -455,7 +440,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Hour Rate", 
@@ -485,7 +469,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
@@ -515,7 +498,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Earning", 
@@ -546,7 +528,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Earnings", 
@@ -576,7 +557,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Deduction", 
@@ -606,7 +586,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Deductions", 
@@ -637,7 +616,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -664,7 +642,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -691,7 +668,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Earning", 
@@ -721,7 +697,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Deduction", 
@@ -751,7 +726,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Net Pay", 
@@ -779,7 +753,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Account", 
@@ -807,7 +780,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Mode of Payment", 
@@ -836,7 +808,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -863,7 +834,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Payment Account", 
@@ -894,7 +864,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-01-11 02:02:10.848614", 
+ "modified": "2017-02-02 01:23:49.179497", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Structure", 
@@ -910,7 +880,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -928,10 +897,9 @@
    "create": 1, 
    "delete": 1, 
    "email": 1, 
-   "export": 0, 
+   "export": 1, 
    "if_owner": 0, 
-   "import": 0, 
-   "is_custom": 0, 
+   "import": 1, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -950,5 +918,6 @@
  "sort_order": "DESC", 
  "timeline_field": "", 
  "title_field": "", 
+ "track_changes": 0, 
  "track_seen": 0
-}
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 13622c3..0e2dd1b 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -4,8 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.utils import cstr, flt, getdate, cint
-from frappe.model.naming import make_autoname
+from frappe.utils import flt, cint
 from frappe import _
 from frappe.model.mapper import get_mapped_doc
 from frappe.model.document import Document
@@ -15,7 +14,6 @@
 	
 	def validate(self):
 		self.validate_amount()
-		self.validate_joining_date()
 		for e in self.get('employees'):
 			set_employee_name(e)
 
@@ -29,12 +27,6 @@
 	def validate_amount(self):
 		if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet:
 			frappe.throw(_("Net pay cannot be negative"))
-
-	def validate_joining_date(self):
-		for e in self.get('employees'):
-			joining_date = getdate(frappe.db.get_value("Employee", e.employee, "date_of_joining"))
-			if getdate(self.from_date) < joining_date:
-				frappe.throw(_("From Date in Salary Structure cannot be lesser than Employee Joining Date."))
 				
 
 @frappe.whitelist()
@@ -42,6 +34,7 @@
 	def postprocess(source, target):
 		if employee:
 			target.employee = employee
+			target.employee_name = frappe.get_value("Employee",employee, "employee_name")
 		target.run_method('process_salary_structure')
 
 	doc = get_mapped_doc("Salary Structure", source_name, {
diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
index fe88d9a..36e50d3 100644
--- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
@@ -19,8 +19,8 @@
 		frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Structure Test Holiday List")
 		make_earning_salary_component(["Basic Salary", "Allowance", "HRA"])
 		make_deduction_salary_component(["Professional Tax", "TDS"])
-		self.make_employee("test_employee@salary.com")
-		self.make_employee("test_employee_2@salary.com")
+		make_employee("test_employee@salary.com")
+		make_employee("test_employee_2@salary.com")
 		
 	def make_holiday_list(self):
 		if not frappe.db.get_value("Holiday List", "Salary Structure Test Holiday List"):
@@ -33,37 +33,6 @@
 			}).insert()	
 			holiday_list.get_weekly_off_dates()
 			holiday_list.save()
-	
-	def make_employee(self, user):
-		if not frappe.db.get_value("User", user):
-			frappe.get_doc({
-				"doctype": "User",
-				"email": user,
-				"first_name": user,
-				"new_password": "password",
-				"user_roles": [{"doctype": "UserRole", "role": "Employee"}]
-			}).insert()
-			
-
-		if not frappe.db.get_value("Employee", {"user_id": user}):
-			emp = frappe.get_doc({
-				"doctype": "Employee",
-				"naming_series": "EMP-",
-				"employee_name": user,
-				"company": erpnext.get_default_company(),
-				"user_id": user,
-				"date_of_birth": "1990-05-08",
-				"date_of_joining": "2013-01-01",
-				"relieving_date": "",
-				"department": frappe.get_all("Department", fields="name")[0].name,
-				"gender": "Female",
-				"company_email": user,
-				"status": "Active",
-				"employment_type": "Intern"
-			}).insert()
-			return emp.name
-		else:
-			return frappe.get_value("Employee", {"employee_name":user}, "name")
 		
 	def test_amount_totals(self):
 		sal_slip = frappe.get_value("Salary Slip", {"employee_name":"test_employee@salary.com"})
@@ -76,6 +45,36 @@
 			self.assertEquals(sal_slip.get("total_deduction"), 7500)
 			self.assertEquals(sal_slip.get("net_pay"), 7500)
 			
+def make_employee(user):
+	if not frappe.db.get_value("User", user):
+		frappe.get_doc({
+			"doctype": "User",
+			"email": user,
+			"first_name": user,
+			"new_password": "password",
+			"user_roles": [{"doctype": "UserRole", "role": "Employee"}]
+		}).insert()
+		
+
+	if not frappe.db.get_value("Employee", {"user_id": user}):
+		emp = frappe.get_doc({
+			"doctype": "Employee",
+			"naming_series": "EMP-",
+			"employee_name": user,
+			"company": erpnext.get_default_company(),
+			"user_id": user,
+			"date_of_birth": "1990-05-08",
+			"date_of_joining": "2013-01-01",
+			"relieving_date": "",
+			"department": frappe.get_all("Department", fields="name")[0].name,
+			"gender": "Female",
+			"company_email": user,
+			"status": "Active",
+			"employment_type": "Intern"
+		}).insert()
+		return emp.name
+	else:
+		return frappe.get_value("Employee", {"employee_name":user}, "name")			
 		
 def make_salary_slip_from_salary_structure(employee):
 	sal_struct = make_salary_structure('Salary Structure Sample')
diff --git a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
index aae33e3..f5ac764 100644
--- a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
+++ b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
@@ -15,13 +15,14 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "employee", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Employee", 
    "length": 0, 
    "no_copy": 0, 
@@ -31,6 +32,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -41,21 +43,24 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "employee_name", 
-   "fieldtype": "Data", 
+   "fieldtype": "Read Only", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Employee Name", 
    "length": 0, 
    "no_copy": 0, 
+   "options": "employee.employee_name", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 1, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
@@ -66,13 +71,14 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "base", 
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Base", 
    "length": 0, 
    "no_copy": 0, 
@@ -81,6 +87,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -91,13 +98,14 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "variable", 
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Variable", 
    "length": 0, 
    "no_copy": 0, 
@@ -106,6 +114,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
@@ -123,7 +132,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-08-11 12:18:14.526977", 
+ "modified": "2017-02-02 02:06:33.809285", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Structure Employee", 
@@ -135,5 +144,6 @@
  "read_only_onload": 0, 
  "sort_field": "modified", 
  "sort_order": "DESC", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/topic/__init__.py b/erpnext/hr/page/team_updates/__init__.py
similarity index 100%
copy from erpnext/schools/doctype/topic/__init__.py
copy to erpnext/hr/page/team_updates/__init__.py
diff --git a/erpnext/hr/page/team_updates/team_update_row.html b/erpnext/hr/page/team_updates/team_update_row.html
new file mode 100644
index 0000000..e3adcb8
--- /dev/null
+++ b/erpnext/hr/page/team_updates/team_update_row.html
@@ -0,0 +1,15 @@
+<div class="row activity-row" data-creation="{%= creation.split(" ")[0] + " 00:00:00" %}">
+	<div class="col-xs-3 text-right activity-date"><span class="{%= date_class %}">
+		{%= date_sep || "" %}</span></div>
+	<div class="col-xs-9 activity-message"
+		title="{%= by %} / {%= dateutil.str_to_user(creation) %}">
+		<div class="row">
+			<div class="col-xs-2 col-sm-1">
+				{{ avatar }}
+			</div>
+			<div class="col-xs-10 col-sm-11 small content">
+				{{ content }}
+			</div>
+		</div>
+	</div>
+</div>
diff --git a/erpnext/hr/page/team_updates/team_updates.css b/erpnext/hr/page/team_updates/team_updates.css
new file mode 100644
index 0000000..d37e782
--- /dev/null
+++ b/erpnext/hr/page/team_updates/team_updates.css
@@ -0,0 +1,57 @@
+.date-indicator {
+    background:none;
+    font-size:12px;
+    vertical-align:middle;
+    font-weight:bold;
+    color:#6c7680;
+}
+.date-indicator::after {
+    margin:0 -4px 0 12px;
+    content:'';
+    display:inline-block;
+    height:8px;
+    width:8px;
+    border-radius:8px;
+	background: #d1d8dd;
+}
+
+.date-indicator.blue {
+	color: #5e64ff;
+}
+
+.date-indicator.blue::after {
+	background: #5e64ff;
+}
+
+.activity-row {
+}
+
+.activity-message {
+	border-left: 1px solid #d1d8dd;
+}
+
+.activity-message .row {
+	padding: 15px;
+	margin-right: 0px;
+	border-bottom: 1px solid #d1d8dd;
+}
+
+.activity-row:last-child .activity-message .row {
+	border-bottom: none;
+}
+
+.activity-row .content {
+	padding-left: 0px;
+	padding-right: 30px;
+}
+
+.activity-date {
+	padding: 15px;
+	padding-right: 0px;
+	z-index: 1;
+}
+
+.for-more {
+	border-top: 1px solid #d1d8dd;
+	padding: 10px;
+}
diff --git a/erpnext/hr/page/team_updates/team_updates.js b/erpnext/hr/page/team_updates/team_updates.js
new file mode 100644
index 0000000..e701b5f
--- /dev/null
+++ b/erpnext/hr/page/team_updates/team_updates.js
@@ -0,0 +1,79 @@
+frappe.pages['team-updates'].on_page_load = function(wrapper) {
+	var page = frappe.ui.make_app_page({
+		parent: wrapper,
+		title: __('Team Updates'),
+		single_column: true
+	});
+
+	frappe.team_updates.make(page);
+	frappe.team_updates.run();
+
+	if(frappe.model.can_read('Daily Work Summary Settings')) {
+		page.add_menu_item(__('Daily Work Summary Settings'), function() {
+			frappe.set_route('Form', 'Daily Work Summary Settings');
+		});
+	}
+}
+
+frappe.team_updates = {
+	start: 0,
+	make: function(page) {
+		var me = frappe.team_updates;
+		me.page = page;
+		me.body = $('<div></div>').appendTo(me.page.main);
+		me.more = $('<div class="for-more"><button class="btn btn-sm btn-default btn-more">'
+			+ __("More") + '</button></div>').appendTo(me.page.main)
+			.find('.btn-more').on('click', function() {
+				me.start += 40;
+				me.run();
+			});
+	},
+	run: function() {
+		var me = frappe.team_updates;
+		frappe.call({
+			method: 'erpnext.hr.page.team_updates.team_updates.get_data',
+			args: {
+				start: me.start
+			},
+			callback: function(r) {
+				if(r.message) {
+					r.message.forEach(function(d) {
+						me.add_row(d);
+					});
+				} else {
+					frappe.show_alert({message:__('No more updates'), indicator:'darkgrey'});
+					me.more.parent().addClass('hidden');
+				}
+			}
+		});
+	},
+	add_row: function(data) {
+		var me = frappe.team_updates;
+
+		data.by = frappe.user.full_name(data.sender);
+		data.avatar = frappe.avatar(data.sender);
+		data.when = comment_when(data.creation);
+
+		var date = dateutil.str_to_obj(data.creation);
+		var last = me.last_feed_date;
+
+		if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) {
+			var diff = dateutil.get_day_diff(dateutil.get_today(), dateutil.obj_to_str(date));
+			if(diff < 1) {
+				pdate = 'Today';
+			} else if(diff < 2) {
+				pdate = 'Yesterday';
+			} else {
+				pdate = dateutil.global_date_format(date);
+			}
+			data.date_sep = pdate;
+			data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator";
+		} else {
+			data.date_sep = null;
+			data.date_class = "";
+		}
+		me.last_feed_date = date;
+
+		$(frappe.render_template('team_update_row', data)).appendTo(me.body)
+	}
+}
\ No newline at end of file
diff --git a/erpnext/hr/page/team_updates/team_updates.json b/erpnext/hr/page/team_updates/team_updates.json
new file mode 100644
index 0000000..167c67f
--- /dev/null
+++ b/erpnext/hr/page/team_updates/team_updates.json
@@ -0,0 +1,25 @@
+{
+ "content": null, 
+ "creation": "2017-01-31 11:02:31.614045", 
+ "docstatus": 0, 
+ "doctype": "Page", 
+ "idx": 0, 
+ "modified": "2017-01-31 11:25:01.983200", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "team-updates", 
+ "owner": "Administrator", 
+ "page_name": "team-updates", 
+ "roles": [
+  {
+   "role": "Employee"
+  }, 
+  {
+   "role": "System Manager"
+  }
+ ], 
+ "script": null, 
+ "standard": "Yes", 
+ "style": null, 
+ "title": "Team Updates"
+}
\ No newline at end of file
diff --git a/erpnext/hr/page/team_updates/team_updates.py b/erpnext/hr/page/team_updates/team_updates.py
new file mode 100644
index 0000000..5b90f6f
--- /dev/null
+++ b/erpnext/hr/page/team_updates/team_updates.py
@@ -0,0 +1,21 @@
+from __future__ import unicode_literals
+
+import frappe
+from email_reply_parser import EmailReplyParser
+from markdown2 import markdown
+
+@frappe.whitelist()
+def get_data(start=0):
+	#frappe.only_for('Employee', 'System Manager')
+	data = frappe.get_all('Communication',
+		fields=('content', 'text_content', 'sender', 'creation'),
+		filters=dict(reference_doctype='Daily Work Summary'),
+		order_by='creation desc', limit=40, start=start)
+
+	for d in data:
+		d.sender_name = frappe.db.get_value("Employee", {"user_id": d.sender},
+			"employee_name") or d.sender
+		if d.text_content:
+			d.content = markdown(EmailReplyParser.parse_reply(d.text_content))
+
+	return data
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index c2c9b64..51018d3 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -21,7 +21,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 1, 
    "in_standard_filter": 1, 
    "label": "Item", 
@@ -51,7 +50,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Item Name", 
@@ -81,7 +79,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Quantity", 
@@ -110,7 +107,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -137,7 +133,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Is Active", 
@@ -167,7 +162,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Is Default", 
@@ -197,7 +191,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "With Operations", 
@@ -224,7 +217,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Rate Of Materials Based On", 
@@ -253,7 +245,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Price List", 
@@ -281,7 +272,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
@@ -309,7 +299,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Currency", 
@@ -338,7 +327,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -365,7 +353,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Conversion Rate", 
@@ -395,7 +382,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Operations", 
@@ -423,7 +409,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Operations", 
@@ -453,7 +438,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Materials", 
@@ -481,7 +465,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Items", 
@@ -511,7 +494,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Scrap", 
@@ -539,7 +521,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Scrap Items", 
@@ -568,7 +549,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Costing", 
@@ -596,7 +576,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Operating Cost", 
@@ -624,7 +603,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Raw Material Cost", 
@@ -652,7 +630,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Scrap Material Cost", 
@@ -681,7 +658,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -707,7 +683,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Operating Cost (Company Currency)", 
@@ -736,7 +711,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Raw Material Cost(Company Currency)", 
@@ -765,7 +739,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Scrap Material Cost(Company Currency)", 
@@ -794,7 +767,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -821,7 +793,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Total Cost", 
@@ -849,7 +820,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -876,7 +846,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Cost(Company Currency)", 
@@ -905,7 +874,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
@@ -932,7 +900,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Project", 
@@ -962,7 +929,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Company", 
@@ -991,7 +957,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 1, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Amended From", 
@@ -1019,7 +984,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1045,7 +1009,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Item UOM", 
@@ -1073,7 +1036,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1100,7 +1062,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Item Description", 
@@ -1127,7 +1088,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1154,7 +1114,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Image", 
@@ -1182,7 +1141,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Image View", 
@@ -1212,7 +1170,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Materials Required (Exploded)", 
@@ -1239,7 +1196,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Exploded_items", 
@@ -1271,8 +1227,8 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-21 17:06:49.349654", 
- "modified_by": "rohit@erpnext.com", 
+ "modified": "2017-02-01 14:27:17.949390", 
+ "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "BOM", 
  "owner": "Administrator", 
@@ -1287,7 +1243,6 @@
    "export": 1, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -1308,7 +1263,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -1329,7 +1283,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -1347,5 +1300,6 @@
  "search_fields": "item", 
  "sort_field": "modified", 
  "sort_order": "DESC", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index f4fed6e..8102057 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -500,10 +500,15 @@
 @frappe.whitelist()
 def get_children():
 	if frappe.form_dict.parent:
-		return frappe.db.sql("""select item_code,
-			bom_no as value, qty,
-			if(ifnull(bom_no, "")!="", 1, 0) as expandable
-			from `tabBOM Item`
-			where parent=%s
-			order by idx
+		return frappe.db.sql("""select
+			bom_item.item_code,
+			bom_item.bom_no as value,
+			bom_item.qty,
+			if(ifnull(bom_item.bom_no, "")!="", 1, 0) as expandable,
+			item.image,
+			item.description
+			from `tabBOM Item` bom_item, tabItem item
+			where bom_item.parent=%s
+			and bom_item.item_code = item.name
+			order by bom_item.idx
 			""", frappe.form_dict.parent, as_dict=True)
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom_item_preview.html b/erpnext/manufacturing/doctype/bom/bom_item_preview.html
new file mode 100644
index 0000000..9db19a0
--- /dev/null
+++ b/erpnext/manufacturing/doctype/bom/bom_item_preview.html
@@ -0,0 +1,21 @@
+<div style="padding: 15px;">
+	{% if data.image %}
+	<img class="responsive" src={{ data.image }}>
+	<hr style="margin: 15px -15px;">
+	{% endif %}
+	<h4>
+		{{ __("Description") }}
+	</h4>
+	<div style="padding-top: 10px;">
+		{{ data.description }}
+	</div>
+	<hr style="margin: 15px -15px;">
+	<p>
+		{% if data.value %}
+		<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="#Form/BOM/{{ data.value }}">
+			{{ __("Open BOM {0}", [data.value.bold()]) }}</a>
+		{% endif %}
+		<a class="btn btn-default btn-xs" href="#Form/Item/{{ data.item_code }}">
+			{{ __("Open Item {0}", [data.item_code.bold()]) }}</a>
+	</p>
+</div>
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom_tree.js b/erpnext/manufacturing/doctype/bom/bom_tree.js
index f6a205f..09fe037 100644
--- a/erpnext/manufacturing/doctype/bom/bom_tree.js
+++ b/erpnext/manufacturing/doctype/bom/bom_tree.js
@@ -20,14 +20,14 @@
 		}
 	},
 	toolbar: [
-		{toggle_btn: true},
+		{ toggle_btn: true },
 		{
 			label:__("Edit"),
 			condition: function(node) {
 				return node.expandable;
 			},
 			click: function(node) {
-				
+
 				frappe.set_route("Form", "BOM", node.data.value);
 			}
 		}
@@ -40,5 +40,6 @@
 			},
 			condition: 'frappe.boot.user.can_create.indexOf("BOM") !== -1'
 		}
-	]
+	],
+	view_template: 'bom_item_preview'
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/production_order/production_order_calendar.js b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
index 2832494..47cac28 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
@@ -7,7 +7,10 @@
 		"end": "planned_end_date",
 		"id": "name",
 		"title": "name",
-		"allDay": "allDay"
+		"allDay": "allDay",
+		"progress": function(data) {
+			return flt(data.produced_qty) / data.qty * 100;
+		}
 	},
 	gantt: true,
 	get_css_class: function(data) {
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 87c070e..9494fbd 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -369,3 +369,4 @@
 erpnext.patches.v7_2.set_null_value_to_fields
 erpnext.patches.v7_2.update_guardian_name_in_student_master
 erpnext.patches.v7_2.update_abbr_in_salary_slips
+erpnext.patches.v7_2.update_party_type
diff --git a/erpnext/patches/v7_0/set_portal_settings.py b/erpnext/patches/v7_0/set_portal_settings.py
index f7ee205..54a17dc 100644
--- a/erpnext/patches/v7_0/set_portal_settings.py
+++ b/erpnext/patches/v7_0/set_portal_settings.py
@@ -8,7 +8,7 @@
 
 def execute():
 	frappe.reload_doctype('Role')
-	for dt in ("assessment", "announcement", "course", "fees"):
+	for dt in ("assessment", "course", "fees"):
 		frappe.reload_doc("schools", "doctype", dt)
 
 	frappe.reload_doc('website', 'doctype', 'portal_menu_item')
diff --git a/erpnext/patches/v7_2/__init__.py b/erpnext/patches/v7_2/__init__.py
index e69de29..baffc48 100644
--- a/erpnext/patches/v7_2/__init__.py
+++ b/erpnext/patches/v7_2/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/patches/v7_2/update_assessment_modules.py b/erpnext/patches/v7_2/update_assessment_modules.py
index 2ea9f6e..ac04294 100644
--- a/erpnext/patches/v7_2/update_assessment_modules.py
+++ b/erpnext/patches/v7_2/update_assessment_modules.py
@@ -20,7 +20,8 @@
 	frappe.reload_doc("schools", "doctype", "evaluation_criteria")
 
 
-	for assessment in frappe.get_all("Assessment Plan", fields=["name", "grading_scale"]):
+	for assessment in frappe.get_all("Assessment Plan", fields=["name", "grading_scale"], filters = [["docstatus", "!=", 2 ]]):
+		print assessment
 		for stud_result in frappe.db.sql("select * from `tabAssessment Result` where parent= %s", assessment.name, as_dict=True):
 			if stud_result.result:
 				assessment_result = frappe.new_doc("Assessment Result")
@@ -30,6 +31,7 @@
 				assessment_result.grading_scale = assessment.grading_scale
 				assessment_result.total_score = stud_result.result
 				assessment_result.flags.ignore_validate = True
+				assessment_result.flags.ignore_mandatory = True
 				assessment_result.save()
 	
 	frappe.db.sql("""delete from `tabAssessment Result` where parent != '' or parent is not null""")
\ No newline at end of file
diff --git a/erpnext/patches/v7_2/update_party_type.py b/erpnext/patches/v7_2/update_party_type.py
new file mode 100644
index 0000000..147f5a3
--- /dev/null
+++ b/erpnext/patches/v7_2/update_party_type.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doc('setup', 'doctype', 'party_type')
+	make_party_type()
+
+def make_party_type():
+	for party_type in ["Customer", "Supplier", "Employee"]:
+		if not frappe.db.get_value("Party Type", party_type):
+			doc = frappe.new_doc("Party Type")
+			doc.party_type = party_type
+			doc.save(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/projects/doctype/task/task_calendar.js b/erpnext/projects/doctype/task/task_calendar.js
index f8fc3d3..d7468a5 100644
--- a/erpnext/projects/doctype/task/task_calendar.js
+++ b/erpnext/projects/doctype/task/task_calendar.js
@@ -7,7 +7,8 @@
 		"end": "exp_end_date",
 		"id": "name",
 		"title": "subject",
-		"allDay": "allDay"
+		"allDay": "allDay",
+		"progress": "progress"
 	},
 	gantt: true,
 	filters: [
diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css
index 7f85de9..cfe9f63 100644
--- a/erpnext/public/css/erpnext.css
+++ b/erpnext/public/css/erpnext.css
@@ -67,7 +67,6 @@
 .pos-toolbar,
 .pos-bill-toolbar {
   padding: 10px 0px;
-  border-bottom: 1px solid #d1d8dd;
   height: 51px;
 }
 .pos-item-toolbar .form-group {
@@ -79,6 +78,7 @@
   margin-right: -1px;
 }
 .pos-bill {
+  border-top: 1px solid #d1d8dd;
   margin-left: -15px;
   margin-right: -15px;
 }
@@ -171,6 +171,9 @@
 .payment-toolbar {
   padding-right: 30px;
 }
+.list-row-head.pos-invoice-list {
+  border-top: 1px solid #d1d8dd;
+}
 body[data-route="pos"] .modal-dialog {
   width: 750px;
 }
diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html
index 9d0ab60..44e42d7 100644
--- a/erpnext/public/js/pos/pos.html
+++ b/erpnext/public/js/pos/pos.html
@@ -1,14 +1,26 @@
 <div class="pos">
     <div class="row">
-    	<div class="col-sm-5 pos-bill-wrapper">
-            <div class="pos-bill-toolbar row">
-                <div class="party-area col-xs-12"></div>
+    	<div class="col-sm-6 pos-bill-wrapper">
+            <div class="pos-bill-toolbar" style="display: flex;">
+                <div class="party-area" style="flex: 1;"></div>
+				<button class="btn btn-default list-customers-btn" style="margin: 0 5px 0 15px;">
+					<i class="fa fa-list"></i>
+				</button>
+				<button class="btn btn-default add-customer-btn">
+					<i class="fa fa-plus"></i>
+				</button>
+				{% if (allow_delete) { %}
+					<button class="btn btn-default btn-danger" style="margin: 0 5px 0 5px;display:none">
+						<i class="octicon octicon-trashcan"></i>
+					</button>
+				{% } %}
             </div>
     		<div class="pos-bill">
     			<div class="item-cart">
                     <div class="row pos-bill-row pos-bill-header">
-                        <div class="col-xs-5"><h6>{%= __("Item") %}</h6></div>
-                        <div class="col-xs-4"><h6 class="text-right">{%= __("Quantity") %}</h6></div>
+                        <div class="col-xs-4"><h6>{%= __("Item") %}</h6></div>
+                        <div class="col-xs-3"><h6 class="text-right">{%= __("Quantity") %}</h6></div>
+						<div class="col-xs-2"><h6 class="text-right">{%= __("Discount") %}</h6></div>
                         <div class="col-xs-3"><h6 class="text-right">{%= __("Rate") %}</h6></div>
                     </div>
                     <div class="items"></div>
@@ -48,18 +60,27 @@
                     </div>
     			</div>
     		</div>
+			<div class="list-customers">
+
+			</div>
     	</div>
-    	<div class="col-sm-7 pos-items-section">
+    	<div class="col-sm-6 pos-items-section">
 			<div class="row pos-item-area">
 
 			</div>
 			<span id="customer-results" style="color:#68a;"></span>
             <div class="row pos-item-toolbar">
-            	<div class="search-area col-xs-12"></div>
+				<div class="search-item-group col-xs-5"></div>
+				<div class="search-item col-xs-7"></div>
             </div>
-    		<div class="item-list-area">
+    		<div class="item-list-area" style="auto">
 				<div class="app-listing item-list"></ul>
     		</div>
     	</div>
+		<div class="row">
+			<div class="text-right list-paging-area">
+				<button class="btn btn-default btn-more btn-sm" style="margin:5px 20px">{{ __("More") }}</button>
+			</div>
+		</div>
     </div>
 </div>
diff --git a/erpnext/public/js/pos/pos_bill_item.html b/erpnext/public/js/pos/pos_bill_item.html
index f5d1a76..1a1f1e2 100644
--- a/erpnext/public/js/pos/pos_bill_item.html
+++ b/erpnext/public/js/pos/pos_bill_item.html
@@ -1,25 +1,30 @@
 <div class="row pos-bill-row pos-bill-item" data-item-code="{%= item_code %}">
-    <div class="col-xs-5"><h6>{%= item_code || "" %}{%= item_name || "" %}</h6></div>
-    <div class="col-xs-4">
+    <div class="col-xs-4"><h6>{%= item_code || "" %}{%= __(item_name) || "" %}</h6></div>
+    <div class="col-xs-3">
         <div class="row pos-qty-row">
             <div class="col-xs-2 text-center pos-qty-btn" data-action="decrease-qty"><i class="fa fa-minus text-muted" style="font-size:12px"></i></div>
             <div class="col-xs-8">
 				<div>
-                    <input type="text" value="{%= qty %}" class="form-control input-sm pos-item-qty text-right">
+                    <input type="tel" value="{%= qty %}" class="form-control   pos-item-qty text-right">
                 </div>
                 {% if(actual_qty != null) { %}
                 <div style="margin-top: 5px;" class="text-muted small text-right">
-                    <span title="{%= __("In Stock") %}">{%= actual_qty || 0 %}<span>
+                    {%= __("In Stock: ") %} <span>{%= actual_qty || 0.0 %}</span>
                 </div>
                 {% } %}
             </div>
             <div class="col-xs-2 text-center pos-qty-btn" data-action="increase-qty"><i class="fa fa-plus text-muted" style="font-size:12px"></i></div>
         </div>
     </div>
+    <div class="col-xs-2 text-right">
+		<div class="row input-sm">
+            <input type="tel" value="{%= discount_percentage %}" class="form-control text-right pos-item-discount">
+        </div>
+    </div>
     <div class="col-xs-3 text-right">
         <div class="text-muted" style="margin-top: 5px;">
 			{% if(enabled) { %}
-				<input type="text" value="{%= rate %}" class="form-control input-sm pos-item-rate text-right">
+				<input type="tel" value="{%= rate %}" class="form-control input-sm pos-item-rate text-right">
 			{% } else { %}
 				<h6>{%= format_currency(rate) %}</h6>
 			{% } %}
diff --git a/erpnext/public/less/erpnext.less b/erpnext/public/less/erpnext.less
index 790a031..495e618 100644
--- a/erpnext/public/less/erpnext.less
+++ b/erpnext/public/less/erpnext.less
@@ -82,7 +82,7 @@
 
 .pos-toolbar, .pos-bill-toolbar {
 	padding: 10px 0px;
-	border-bottom: 1px solid #d1d8dd;
+	// border-bottom: 1px solid #d1d8dd;
 	height: 51px;
 }
 
@@ -97,6 +97,7 @@
 }
 
 .pos-bill {
+	border-top: 1px solid @border-color;
 	margin-left: -15px;
 	margin-right: -15px;
 }
@@ -213,6 +214,10 @@
 	padding-right: 30px;
 }
 
+.list-row-head.pos-invoice-list {
+	border-top: 1px solid @border-color;
+}
+
 body[data-route="pos"] .modal-dialog {
 	width: 750px;
 
diff --git a/erpnext/schools/doctype/announcement/announcement.js b/erpnext/schools/doctype/announcement/announcement.js
deleted file mode 100644
index 5b1d1c0..0000000
--- a/erpnext/schools/doctype/announcement/announcement.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2016, Frappe and contributors
-// For license information, please see license.txt
-
-frappe.ui.form.on('Announcement', {
-	onload: function(frm) {
-		frm.add_fetch('instructor', 'instructor_name' , 'posted_by');
-	}
-});
-
diff --git a/erpnext/schools/doctype/announcement/announcement.json b/erpnext/schools/doctype/announcement/announcement.json
deleted file mode 100644
index 831b71f..0000000
--- a/erpnext/schools/doctype/announcement/announcement.json
+++ /dev/null
@@ -1,315 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "autoname": "announcement.#####", 
- "beta": 0, 
- "creation": "2016-06-23 05:37:33.996289", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 0, 
- "fields": [
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "default": "", 
-   "fieldname": "receiver", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "label": "Receiver", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Student\nStudent Group\nAll Students", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "instructor", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Instructor", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Instructor", 
-   "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, 
-   "depends_on": "eval: doc.receiver == \"Student\"", 
-   "fieldname": "student", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "label": "Student", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Student", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "depends_on": "eval: doc.receiver == \"Student Group\"", 
-   "fieldname": "student_group", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "label": "Student Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Student Group", 
-   "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": "posted_by", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Posted By", 
-   "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
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "section_break_5", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "subject", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Subject", 
-   "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 Editor", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "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": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Announcement", 
-   "permlevel": 0, 
-   "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
-  }
- ], 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "in_dialog": 0, 
- "is_submittable": 1, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2016-07-21 06:30:12.825629", 
- "modified_by": "r@r.com", 
- "module": "Schools", 
- "name": "Announcement", 
- "name_case": "", 
- "owner": "demo@erpnext.com", 
- "permissions": [
-  {
-   "amend": 1, 
-   "apply_user_permissions": 0, 
-   "cancel": 1, 
-   "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": 1, 
-   "write": 1
-  }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "subject", 
- "track_seen": 1
-}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/announcement/announcement.py b/erpnext/schools/doctype/announcement/announcement.py
deleted file mode 100644
index 1a3fe75d..0000000
--- a/erpnext/schools/doctype/announcement/announcement.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe 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 _
-
-class Announcement(Document):
-	def validate(self):
-		self.validate_receiver()
-		self.set_posted_by()
-
-	def validate_receiver(self):
-		if self.receiver == "Student":
-			if not self.student:
-				frappe.throw(_("Please select a Student"))
-				self.student_group = None
-		elif self.receiver == "Student Group":
-			if not self.student_group:
-				frappe.throw(_("Please select a Student Group"))
-				self.student = None
-		else:
-			self.student_group = None
-			self.student = None
-
-	def set_posted_by(self):
-		if self.instructor:
-			self.posted_by = frappe.db.get_value("Instructor", self.instructor, "instructor_name")
-		else:
-			self.posted_by = frappe.session.user
-
-
-
-
-def get_message_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:
-		sg_list = frappe.db.sql("""select parent from `tabStudent Group Student` as sgs
-				where sgs.student = %s """,(student))
-
-		data = frappe.db.sql("""select name, receiver, subject, description, posted_by, modified,
-			student, student_group
-		    from `tabAnnouncement` as announce
-			where (announce.receiver = "Student" and announce.student = %s)
-			or (announce.receiver = "Student Group" and announce.student_group in %s)
-			or announce.receiver = "All Students"
-			and announce.docstatus = 1	
-			order by announce.idx asc limit {0} , {1}"""
-			.format(limit_start, limit_page_length), (student,sg_list), as_dict = True)
-
-		for announcement in data:
-			try:
-				num_attachments = frappe.db.sql(""" select count(file_url) from tabFile as file
-													where file.attached_to_name=%s 
-													and file.attached_to_doctype=%s""",(announcement.name,"Announcement"))
-
-			except IOError or frappe.DoesNotExistError:
-				pass
-				frappe.local.message_log.pop()
-
-			announcement.num_attachments = num_attachments[0][0]
-
-		return data
-
-def get_list_context(context=None):
-	return {
-		"show_sidebar": True,
-		'no_breadcrumbs': True,
-		"title": _("Announcements"),
-		"get_list": get_message_list,
-		"row_template": "templates/includes/announcement/announcement_row.html"
-	}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/announcement/test_announcement.py b/erpnext/schools/doctype/announcement/test_announcement.py
deleted file mode 100644
index b0200a2..0000000
--- a/erpnext/schools/doctype/announcement/test_announcement.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe and Contributors
-# See license.txt
-from __future__ import unicode_literals
-
-import frappe
-import unittest
-
-# test_records = frappe.get_test_records('Announcement')
-
-class TestAnnouncement(unittest.TestCase):
-	pass
diff --git a/erpnext/schools/doctype/assessment_plan/assessment_plan.js b/erpnext/schools/doctype/assessment_plan/assessment_plan.js
index 374b444..f11c10b 100644
--- a/erpnext/schools/doctype/assessment_plan/assessment_plan.js
+++ b/erpnext/schools/doctype/assessment_plan/assessment_plan.js
@@ -7,6 +7,17 @@
 cur_frm.add_fetch("supervisor", "instructor_name", "supervisor_name");
 
 frappe.ui.form.on("Assessment Plan", {
+        refresh: function(frm) {
+        if (!frm.doc.__islocal) {
+            frm.add_custom_button(__("Assessment Result"), function() {
+                frappe.route_options = {
+                    assessment_plan: frm.doc.name
+                }
+                frappe.set_route("Form", "Assessment Result Tool");
+            });
+        }
+    },
+
     course: function(frm) {
         if (frm.doc.course && frm.doc.maximum_assessment_score) {
             frappe.call({
diff --git a/erpnext/schools/doctype/assessment_plan/assessment_plan.py b/erpnext/schools/doctype/assessment_plan/assessment_plan.py
index aa84ae3..1b4b671 100644
--- a/erpnext/schools/doctype/assessment_plan/assessment_plan.py
+++ b/erpnext/schools/doctype/assessment_plan/assessment_plan.py
@@ -13,7 +13,7 @@
 			frappe.throw(_("Please select Student Group or Student Batch"))
 		self.validate_student_batch()
 		self.validate_overlap()
-
+		self.validate_max_score()
 
 	def validate_overlap(self):
 		"""Validates overlap for Student Group/Student Batch, Instructor, Room"""
@@ -42,4 +42,11 @@
 
 	def validate_student_batch(self):
 		if self.student_group:
-			self.student_batch = frappe.db.get_value("Student Group", self.student_group, "student_batch")
\ No newline at end of file
+			self.student_batch = frappe.db.get_value("Student Group", self.student_group, "student_batch")
+
+	def validate_max_score(self):
+		max_score = 0
+		for d in self.evaluation_criterias:
+			max_score += d.maximum_score
+		if self.maximum_assessment_score != max_score:
+			frappe.throw(_("Sum of Scores of Evaluation Criterias needs to be {0}.".format(self.maximum_assessment_score)))
\ No newline at end of file
diff --git a/erpnext/schools/doctype/discussion/discussion.js b/erpnext/schools/doctype/discussion/discussion.js
deleted file mode 100644
index df3c2b8..0000000
--- a/erpnext/schools/doctype/discussion/discussion.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2016, Frappe and contributors
-// For license information, please see license.txt
-
-frappe.ui.form.on('Discussion', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/schools/doctype/discussion/discussion.json b/erpnext/schools/doctype/discussion/discussion.json
deleted file mode 100644
index 57ebfba..0000000
--- a/erpnext/schools/doctype/discussion/discussion.json
+++ /dev/null
@@ -1,175 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_import": 1, 
- "allow_rename": 0, 
- "autoname": "Discussion.####", 
- "beta": 0, 
- "creation": "2016-06-13 07:57:38.326925", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 0, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "subject", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Subject", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "course", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Course", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Course", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "description", 
-   "fieldtype": "Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Discussion", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }
- ], 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "in_dialog": 0, 
- "is_submittable": 1, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2016-11-07 05:28:34.032169", 
- "modified_by": "Administrator", 
- "module": "Schools", 
- "name": "Discussion", 
- "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, 
-   "is_custom": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Academics User", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 1, 
-   "write": 1
-  }
- ], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "subject", 
- "track_seen": 1
-}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/discussion/discussion.py b/erpnext/schools/doctype/discussion/discussion.py
deleted file mode 100644
index 96732e3..0000000
--- a/erpnext/schools/doctype/discussion/discussion.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe and contributors
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.model.document import Document
-
-class Discussion(Document):
-	def validate(self):
-		if not self.owner== frappe.session.user:
-			frappe.throw(_("Not Permitted"))
-
-def get_discussions(doctype, txt, filters, limit_start, limit_page_length=20):
-	from frappe.www.list import get_list
-	if not filters:
-		filters = []
-		filters.append(("Discussion", "course", "=", frappe.form_dict.course))
-	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=True)
-
-def get_list_context(context=None):
-	course_name = frappe.form_dict.course
-	portal_items = [{'reference_doctype': u'Topic', 'route': u"/topic?course=" + str(course_name), 'show_always': 0L, 'title': u'Topics'},
-				{'reference_doctype': u'Discussion', 'route': u"/discussion?course=" + str(course_name), 'show_always': 0L, 'title': u'Discussions'},
-
-	]
-	sidebar_title = course_name
-	return {
-		"show_sidebar": True,
-		'no_breadcrumbs': True,
-		"get_list" : get_discussions,
-		"title": _("Discussions"),
-		"sidebar_items" : portal_items,
-		"sidebar_title" : sidebar_title,
-		"row_template": "templates/includes/discussion/discussion_row.html"
-	}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/discussion/test_discussion.py b/erpnext/schools/doctype/discussion/test_discussion.py
deleted file mode 100644
index 31799f0..0000000
--- a/erpnext/schools/doctype/discussion/test_discussion.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe and Contributors
-# See license.txt
-from __future__ import unicode_literals
-
-import frappe
-import unittest
-
-# test_records = frappe.get_test_records('Discussion')
-
-class TestDiscussion(unittest.TestCase):
-	pass
diff --git a/erpnext/schools/doctype/guardian/guardian.json b/erpnext/schools/doctype/guardian/guardian.json
index 8368f4a..6f5e25d 100644
--- a/erpnext/schools/doctype/guardian/guardian.json
+++ b/erpnext/schools/doctype/guardian/guardian.json
@@ -129,14 +129,15 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "column_break_3", 
-   "fieldtype": "Column Break", 
+   "fieldname": "date_of_birth", 
+   "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
+   "label": "Date of Birth", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -156,15 +157,14 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "date_of_birth", 
-   "fieldtype": "Date", 
+   "fieldname": "column_break_3", 
+   "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Date of Birth", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -268,61 +268,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "image", 
-   "fieldtype": "Attach Image", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Image", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_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, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "work_address", 
    "fieldtype": "Text", 
    "hidden": 0, 
@@ -351,6 +296,91 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "image", 
+   "fieldtype": "Attach Image", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Image", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "section_break_13", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Guardian Of ", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "students", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Students", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Guardian Student", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_8", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -359,6 +389,7 @@
    "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
+   "label": "Guardian Interests", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -414,7 +445,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-28 16:14:58.836437", 
+ "modified": "2017-01-31 16:47:23.436075", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Guardian", 
@@ -431,7 +462,6 @@
    "export": 1, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -449,5 +479,6 @@
  "sort_field": "modified", 
  "sort_order": "DESC", 
  "title_field": "guardian_name", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/guardian/guardian.py b/erpnext/schools/doctype/guardian/guardian.py
index 1388cfe..38597f0 100644
--- a/erpnext/schools/doctype/guardian/guardian.py
+++ b/erpnext/schools/doctype/guardian/guardian.py
@@ -7,4 +7,22 @@
 from frappe.model.document import Document
 
 class Guardian(Document):
-	pass
+	def __setup__(self):
+		self.onload()
+
+	def onload(self):
+		"""Load Students for quick view"""
+		self.load_students()
+
+	def load_students(self):
+		"""Load `students` from the database"""
+		self.students = []
+		students = frappe.get_all("Student Guardian", filters={"guardian":self.name}, fields=["parent"])
+		for student in students:
+			self.append("students", {
+				"student":student.parent,
+				"student_name": frappe.db.get_value("Student", student.parent, "title")
+			})
+
+	def validate(self):
+		self.students = []
\ No newline at end of file
diff --git a/erpnext/schools/doctype/announcement/__init__.py b/erpnext/schools/doctype/guardian_student/__init__.py
similarity index 100%
rename from erpnext/schools/doctype/announcement/__init__.py
rename to erpnext/schools/doctype/guardian_student/__init__.py
diff --git a/erpnext/schools/doctype/guardian_student/guardian_student.json b/erpnext/schools/doctype/guardian_student/guardian_student.json
new file mode 100644
index 0000000..948ed70
--- /dev/null
+++ b/erpnext/schools/doctype/guardian_student/guardian_student.json
@@ -0,0 +1,123 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "beta": 0, 
+ "creation": "2017-01-31 11:53:21.580099", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Student", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_2", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_name", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Student Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 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": "2017-01-31 16:40:26.551040", 
+ "modified_by": "Administrator", 
+ "module": "Schools", 
+ "name": "Guardian Student", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [], 
+ "quick_entry": 1, 
+ "read_only": 0, 
+ "read_only_onload": 0, 
+ "sort_field": "modified", 
+ "sort_order": "DESC", 
+ "track_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/guardian_student/guardian_student.py b/erpnext/schools/doctype/guardian_student/guardian_student.py
new file mode 100644
index 0000000..bf6f5c1
--- /dev/null
+++ b/erpnext/schools/doctype/guardian_student/guardian_student.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class GuardianStudent(Document):
+	pass
diff --git a/erpnext/schools/doctype/topic/test_topic.py b/erpnext/schools/doctype/topic/test_topic.py
deleted file mode 100644
index 1d2974e..0000000
--- a/erpnext/schools/doctype/topic/test_topic.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe and Contributors
-# See license.txt
-from __future__ import unicode_literals
-
-import frappe
-import unittest
-
-# test_records = frappe.get_test_records('Topic')
-
-class TestTopic(unittest.TestCase):
-	pass
diff --git a/erpnext/schools/doctype/topic/topic.js b/erpnext/schools/doctype/topic/topic.js
deleted file mode 100644
index bd9379d..0000000
--- a/erpnext/schools/doctype/topic/topic.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2016, Frappe and contributors
-// For license information, please see license.txt
-
-frappe.ui.form.on('Topic', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/schools/doctype/topic/topic.json b/erpnext/schools/doctype/topic/topic.json
deleted file mode 100644
index 0a69f88..0000000
--- a/erpnext/schools/doctype/topic/topic.json
+++ /dev/null
@@ -1,175 +0,0 @@
-{
- "allow_copy": 0, 
- "allow_import": 0, 
- "allow_rename": 1, 
- "autoname": "Topic.####", 
- "beta": 0, 
- "creation": "2016-06-28 07:06:38.749398", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 0, 
- "engine": "InnoDB", 
- "fields": [
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "course", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Course", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Course", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "topic_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Topic Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "introduction", 
-   "fieldtype": "Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Introduction", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "content", 
-   "fieldtype": "Text Editor", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Content", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }
- ], 
- "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-11-07 05:29:20.531725", 
- "modified_by": "Administrator", 
- "module": "Schools", 
- "name": "Topic", 
- "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, 
-   "is_custom": 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": "course", 
- "track_seen": 0
-}
\ No newline at end of file
diff --git a/erpnext/schools/doctype/topic/topic.py b/erpnext/schools/doctype/topic/topic.py
deleted file mode 100644
index 5dba561..0000000
--- a/erpnext/schools/doctype/topic/topic.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe 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 _
-
-class Topic(Document):
-	pass
-
-def get_topic_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:
-		data = frappe. db.sql('''select name, course, modified,topic_name, introduction, content from `tabTopic` as topic
-								where topic.course = %s 
-								order by idx asc limit {0} , {1}'''.format(limit_start, limit_page_length),filters.course,as_dict = True)
-		
-		for topic in data:
-			try:
-				num_attachments = frappe.db.sql(""" select count(file_url) from tabFile as file
-													where file.attached_to_name=%s 
-													and file.attached_to_doctype=%s""",(topic.name,"Topic"))
-
-			except IOError or frappe.DoesNotExistError:
-				pass
-				frappe.local.message_log.pop()
-
-			topic.num_attachments = num_attachments[0][0]
-
-		return data
-
-def get_list_context(context=None):
-	course = frappe.get_doc('Course', frappe.form_dict.course)
-	portal_items = [{'reference_doctype': u'Topic', 'route': u"/topic?course=" + str(course.name), 'show_always': 0L, 'title': u'Topics'},
-				{'reference_doctype': u'Discussion', 'route': u"/discussion?course=" + str(course.name), 'show_always': 0L, 'title': u'Discussions'},
-
-	]
-	return {
-		"show_sidebar": True,
-		"title": _("Topic"),
-		'no_breadcrumbs': True,
-		"sidebar_items" : portal_items,
-		"sidebar_title" : course.name,
-		"get_list": get_topic_list,
-		"row_template": "templates/includes/topic/topic_row.html"
-	}
\ No newline at end of file
diff --git a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
index cd2c82c..01cee58 100644
--- a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
+++ b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
@@ -61,7 +61,7 @@
 	students_with_leave_application = get_students_with_leave_application(from_date, to_date, students_list)
 	for d in attendance_list:
 		att_map.setdefault(d.student, frappe._dict()).setdefault(d.date, "")
-		if students_with_leave_application and d.student in students_with_leave_application.get(d.date,[]):
+		if students_with_leave_application and d.student in students_with_leave_application.get(d.date):
 			att_map[d.student][d.date] = "Present"
 		else:
 			att_map[d.student][d.date] = d.status
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index f22e63e..5dd8ceb 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -4,6 +4,17 @@
 frappe.provide("erpnext.company");
 
 frappe.ui.form.on("Company", {
+	setup: function(frm) {
+		frm.fields_dict['default_payable_account'].get_query = function() {
+			return{
+				filters: {
+					"root_type": "Liability",
+					"account_type": "Payable"
+				}
+			}
+		}
+	},
+
 	onload: function(frm) {
 		erpnext.company.setup_queries(frm);
 	},
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 32ad8eb..93f02f8 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -153,6 +153,8 @@
 			self.db_set("default_income_account", frappe.db.get_value("Account",
 				{"account_name": _("Sales"), "company": self.name}))
 
+		if not self.default_payable_account:
+			self.db_set("default_payable_account", self.default_payable_account)
 
 	def _set_default_account(self, fieldname, account_type):
 		if self.get(fieldname):
diff --git a/erpnext/schools/doctype/topic/__init__.py b/erpnext/setup/doctype/party_type/__init__.py
similarity index 100%
copy from erpnext/schools/doctype/topic/__init__.py
copy to erpnext/setup/doctype/party_type/__init__.py
diff --git a/erpnext/setup/doctype/party_type/party_type.js b/erpnext/setup/doctype/party_type/party_type.js
new file mode 100644
index 0000000..7a96dc5
--- /dev/null
+++ b/erpnext/setup/doctype/party_type/party_type.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2016, Frappe Technologies and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Party Type', {
+	setup: function(frm) {
+		frm.fields_dict["party_type"].get_query = function(frm) {
+			return {
+				filters: {
+					"istable": 0,
+					"is_submittable": 0
+				}
+			}
+		}
+	}
+});
diff --git a/erpnext/setup/doctype/party_type/party_type.json b/erpnext/setup/doctype/party_type/party_type.json
new file mode 100644
index 0000000..f49e7b3
--- /dev/null
+++ b/erpnext/setup/doctype/party_type/party_type.json
@@ -0,0 +1,130 @@
+{
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
+ "autoname": "field:party_type", 
+ "beta": 0, 
+ "creation": "2016-12-26 11:26:51.508286", 
+ "custom": 0, 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "", 
+ "editable_grid": 1, 
+ "engine": "InnoDB", 
+ "fields": [
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "party_type", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Party Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "DocType", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }
+ ], 
+ "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": "2017-01-19 17:55:33.428335", 
+ "modified_by": "Administrator", 
+ "module": "Setup", 
+ "name": "Party Type", 
+ "name_case": "", 
+ "owner": "Administrator", 
+ "permissions": [
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "System Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Accounts User", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Accounts Manager", 
+   "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_changes": 1, 
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/party_type/party_type.py b/erpnext/setup/doctype/party_type/party_type.py
new file mode 100644
index 0000000..74db037
--- /dev/null
+++ b/erpnext/setup/doctype/party_type/party_type.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2015, Frappe Technologies and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class PartyType(Document):
+	pass
+
+@frappe.whitelist()
+def get_party_type(doctype, txt, searchfield, start, page_len, filters):
+	return frappe.db.sql("""select name from `tabParty Type`
+			where `{key}` LIKE %(txt)s
+			order by name limit %(start)s, %(page_len)s"""
+			.format(key=searchfield), {
+				'txt': "%%%s%%" % frappe.db.escape(txt),
+				'start': start, 'page_len': page_len
+			})
diff --git a/erpnext/setup/doctype/party_type/test_party_type.py b/erpnext/setup/doctype/party_type/test_party_type.py
new file mode 100644
index 0000000..079fe2f
--- /dev/null
+++ b/erpnext/setup/doctype/party_type/test_party_type.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('Party Type')
+
+class TestPartyType(unittest.TestCase):
+	pass
diff --git a/erpnext/setup/setup_wizard/install_fixtures.py b/erpnext/setup/setup_wizard/install_fixtures.py
index 1589b3b..5e08203 100644
--- a/erpnext/setup/setup_wizard/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/install_fixtures.py
@@ -171,6 +171,10 @@
 		{'doctype': "Email Account", "email_id": "support@example.com", "append_to": "Issue"},
 		{'doctype': "Email Account", "email_id": "jobs@example.com", "append_to": "Job Applicant"},
 
+		{'doctype': "Party Type", "party_type": "Customer"},
+		{'doctype': "Party Type", "party_type": "Supplier"},
+		{'doctype': "Party Type", "party_type": "Employee"},
+
 		{"doctype": "Offer Term", "offer_term": _("Date of Joining")},
 		{"doctype": "Offer Term", "offer_term": _("Annual Salary")},
 		{"doctype": "Offer Term", "offer_term": _("Probationary Period")},
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 316d35b..5748a93 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -2713,7 +2713,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2017-01-18 17:43:20.262925", 
+ "modified": "2017-01-30 17:25:46.211995", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
@@ -2729,7 +2729,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 1, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -2750,7 +2749,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -2771,7 +2769,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -2792,7 +2789,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -2813,7 +2809,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -2834,7 +2829,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -2855,7 +2849,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -2876,7 +2869,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -2895,5 +2887,6 @@
  "sort_field": "idx desc, modified desc", 
  "sort_order": "DESC", 
  "title_field": "item_name", 
+ "track_changes": 1, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index ba303bb..a7480e8 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -117,6 +117,10 @@
 					if buying_rate:
 						row.valuation_rate = buying_rate
 
+					else:
+						# get valuation rate from Item
+						row.valuation_rate = frappe.get_value('Item', row.item_code, 'valuation_rate')
+
 		# throw all validation messages
 		if self.validation_messages:
 			for msg in self.validation_messages:
diff --git a/erpnext/templates/pages/announcements.html b/erpnext/templates/pages/announcements.html
deleted file mode 100644
index d6e0d73..0000000
--- a/erpnext/templates/pages/announcements.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% extends "templates/web.html" %}
-
-{% block header %}
-	<h1> {{doc.subject}} </h1>
-{% endblock %}
-
-{% block page_content %}
-
-<p class="post-description"> {{doc.description}} </p>
-<p class="post-by text-muted small">
-	{% for file in attached_files%}
-		<a href="{{file.file_url}}" target="_new">{{file.file_name}}</a>
-		<br>
-	{% endfor %}
-	<br>
-	<i>{{ doc.posted_by }}</i>
-	<i class="blog-dot"></i> {{ frappe.format_date(doc.modified) }}
-</p>
-
-{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/announcements.py b/erpnext/templates/pages/announcements.py
deleted file mode 100644
index 4a61fc8..0000000
--- a/erpnext/templates/pages/announcements.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def get_context(context):
-	announcement = frappe.get_doc('Announcement', frappe.form_dict.announcement)
-	context.no_cache = 1
-	context.show_sidebar = True
-	announcement.has_permission('read')
-	context.doc = announcement
-	attachments = frappe.db.sql("""select file_url, file_name from tabFile as file
-								where file.attached_to_name=%s """,(announcement.name), as_dict = True)
-
-	context.attached_files = attachments
-
-
diff --git a/erpnext/templates/pages/courses.py b/erpnext/templates/pages/courses.py
index 5b1410e..c80d8e7 100644
--- a/erpnext/templates/pages/courses.py
+++ b/erpnext/templates/pages/courses.py
@@ -15,14 +15,6 @@
 	course = frappe.get_doc('Course', frappe.form_dict.course)
 	course.has_permission('read')
 	context.doc = course
-	portal_items = [{'reference_doctype': u'Topic', 'route': u"/topic?course=" + str(course.name), 'show_always': 0L, 'title': u'Topics'},
-				{'reference_doctype': u'Discussion', 'route': u"/discussion?course=" + str(course.name), 'show_always': 0L, 'title': u'Discussions'},
-
-	]
-
-	context.sidebar_items = portal_items
-
 	context.sidebar_title = sidebar_title
-
 	context.intro = course.course_intro
 
diff --git a/erpnext/templates/pages/discussions.html b/erpnext/templates/pages/discussions.html
deleted file mode 100644
index 28eb01f..0000000
--- a/erpnext/templates/pages/discussions.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "templates/web.html" %}
-
-{% block header %}
-	<h2> {{doc.subject}} </h2>
-	<p> {{doc.description}} </p>
-	<p class="text-muted small">Started by: {{doc.owner}} </p>
-{% endblock %}
-
-{% block page_content %}
-
-<div>
-	{% include 'templates/includes/comments/comments.html' %}
-</div>
-
-{% endblock %}
diff --git a/erpnext/templates/pages/discussions.py b/erpnext/templates/pages/discussions.py
deleted file mode 100644
index 22a1bef..0000000
--- a/erpnext/templates/pages/discussions.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.website.utils import get_comment_list
-
-def get_context(context):
-	context.doc = frappe.get_doc('Discussion', frappe.form_dict.discussion)
-	portal_items = [{'reference_doctype': u'Topic', 'route': u"/topic?course=" + str(context.doc.course), 'show_always': 0L, 'title': u'Topics'},
-				{'reference_doctype': u'Discussion', 'route': u"/discussion?course=" + str(context.doc.course), 'show_always': 0L, 'title': u'Discussions'},
-
-	]
-	context.show_sidebar = True
-	context.sidebar_items = portal_items
-	context.no_cache = 1
-	context.doc.has_permission('read')
-	context.sidebar_title = context.doc.course
-	context.reference_doctype = "Discussion"
-	context.reference_name = context.doc.name
-	context.comment_list = get_comment_list(context.doc.doctype,context.doc.name)
\ No newline at end of file
diff --git a/erpnext/templates/pages/topics.html b/erpnext/templates/pages/topics.html
deleted file mode 100644
index 94d7a17..0000000
--- a/erpnext/templates/pages/topics.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{% extends "templates/web.html" %}
-
-
-{% block header %}
-	<h2> {{ doc.introduction }} </h1>
-{% endblock %}
-
-{% block page_content %}
-
-<p class="post-description"> {{ doc.content }} </p>
-
-{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/topics.py b/erpnext/templates/pages/topics.py
deleted file mode 100644
index 8a55b64..0000000
--- a/erpnext/templates/pages/topics.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-
-def get_context(context):
-	topic = frappe.get_doc('Topic', frappe.form_dict.topic)
-	context.no_cache = 1
-	context.show_sidebar = True
-	context.doc = topic
-	attachments = frappe.db.sql("""select file_url, file_name from tabFile as file
-								where file.attached_to_name=%s """,(topic.name), as_dict = True)
-
-	context.attached_files = attachments