feat: add grand total field
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index 6425b95..4a61963 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -112,9 +112,6 @@
 		doc.total_claimed_amount += d.amount;
 		doc.total_sanctioned_amount += d.sanctioned_amount;
 	});
-
-	refresh_field("total_claimed_amount");
-	refresh_field('total_sanctioned_amount');
 };
 
 cur_frm.cscript.calculate_total_amount = function(doc,cdt,cdn){
@@ -157,14 +154,14 @@
 				}
 			};
 		});
-		// frm.set_query("taxes", "account_head", function(doc) {
-		// 	return {
-		// 		filters: [
-		// 			['docstatus', '=', 1],
-		// 			['company', '=', doc.company]
-		// 		]
-		// 	};
-		// });
+		frm.set_query("account_head", "taxes", function(doc) {
+			return {
+				filters: [
+					['company', '=', doc.company],
+					['account_type', 'in', ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation"]]
+				]
+			};
+		});
 	},
 
 	onload: function(frm) {
@@ -205,6 +202,12 @@
 		}
 	},
 
+	calculate_grand_total: function(frm) {
+		var grand_total = flt(frm.doc.total_sanctioned_amount) + flt(frm.doc.total_taxes_and_charges) - flt(frm.doc.total_advance_amount);
+		frm.set_value("grand_total", grand_total);
+		frm.refresh_fields();
+	},
+
 	make_payment_entry: function(frm) {
 		var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
 		if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) {
@@ -319,6 +322,7 @@
 		var doc = frm.doc;
 		cur_frm.cscript.calculate_total(doc,cdt,cdn);
 		frm.trigger("get_taxes");
+		frm.trigger("calculate_grand_total");
 	}
 });
 
@@ -345,6 +349,7 @@
 						child.advance_paid = r.message[0].paid_amount;
 						child.unclaimed_amount = flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount);
 						child.allocated_amount = flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount);
+						frm.trigger('calculate_grand_total');
 						refresh_field("advances");
 					}
 				}
@@ -370,27 +375,30 @@
 		}
 	},
 
-	calculate_total: function(frm, cdt, cdn) {
+	calculate_total_tax: function(frm, cdt, cdn) {
 		var child = locals[cdt][cdn];
 		child.total = flt(frm.doc.total_sanctioned_amount) + flt(child.tax_amount);
+		frm.trigger("calculate_tax_amount", cdt, cdn);
+	},
 
-		refresh_field("taxes");
+	calculate_tax_amount: function(frm) {
+		frm.doc.total_taxes_and_charges = 0;
+		(frm.doc.taxes || []).forEach(function(d) {
+			frm.doc.total_taxes_and_charges += d.tax_amount;
+		});
+		frm.trigger("calculate_grand_total")
 	},
 
 	rate: function(frm, cdt, cdn) {
 		var child = locals[cdt][cdn];
 		if(!child.amount) {
 			child.tax_amount = flt(frm.doc.total_sanctioned_amount) * (flt(child.rate)/100);
-			refresh_field("taxes");
 		}
-		frm.trigger("calculate_total", cdt, cdn)
+		frm.trigger("calculate_total_tax", cdt, cdn)
 	},
 
 	tax_amount: function(frm, cdt, cdn) {
-		var child = locals[cdt][cdn];
-		child.rate = flt(child.tax_amount/frm.doc.total_sanctioned_amount) * 100;
-		frm.trigger("calculate_total", cdt, cdn)
-		refresh_field("taxes");
+		frm.trigger("calculate_total_tax", cdt, cdn)
 	}
 });
 
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.json b/erpnext/hr/doctype/expense_claim/expense_claim.json
index 409bdc8..7b0d494 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.json
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.json
@@ -19,10 +19,13 @@
   "sb1",
   "taxes",
   "transactions_section",
-  "total_tax_amount",
-  "total_amount_reimbursed",
   "total_sanctioned_amount",
   "total_claimed_amount",
+  "total_advance_amount",
+  "column_break_17",
+  "total_amount_reimbursed",
+  "total_taxes_and_charges",
+  "grand_total",
   "section_break_16",
   "posting_date",
   "vehicle_log",
@@ -44,8 +47,7 @@
   "status",
   "amended_from",
   "advance_payments",
-  "advances",
-  "total_advance_amount"
+  "advances"
  ],
  "fields": [
   {
@@ -122,7 +124,6 @@
   {
    "fieldname": "total_sanctioned_amount",
    "fieldtype": "Currency",
-   "in_list_view": 1,
    "label": "Total Sanctioned Amount",
    "no_copy": 1,
    "oldfieldname": "total_sanctioned_amount",
@@ -337,9 +338,21 @@
    "label": "Transactions"
   },
   {
-   "fieldname": "total_tax_amount",
+   "fieldname": "grand_total",
    "fieldtype": "Currency",
-   "label": "Total Tax Amount",
+   "in_list_view": 1,
+   "label": "Grand Total",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "total_taxes_and_charges",
+   "fieldtype": "Currency",
+   "label": "Total Taxes and Charges",
    "options": "Company:company:default_currency",
    "read_only": 1
   }
@@ -347,7 +360,7 @@
  "icon": "fa fa-money",
  "idx": 1,
  "is_submittable": 1,
- "modified": "2019-06-12 12:32:13.775009",
+ "modified": "2019-06-12 15:35:09.092603",
  "modified_by": "Administrator",
  "module": "HR",
  "name": "Expense Claim",
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index 07e7119..7f660a4 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -104,15 +104,13 @@
 		gl_entry = []
 		self.validate_account_details()
 
-		payable_amount = flt(self.net_total) - flt(self.total_advance_amount)
-
 		# payable entry
-		if payable_amount:
+		if self.grand_total:
 			gl_entry.append(
 				self.get_gl_dict({
 					"account": self.payable_account,
-					"credit": payable_amount,
-					"credit_in_account_currency": payable_amount,
+					"credit": self.grand_total,
+					"credit_in_account_currency": self.grand_total,
 					"against": ",".join([d.default_account for d in self.expenses]),
 					"party_type": "Employee",
 					"party": self.employee,
@@ -146,15 +144,16 @@
 					"against_voucher": self.name
 				})
 			)
+		self.add_tax_gl_entries(gl_entry)
 
-		if self.is_paid and payable_amount:
+		if self.is_paid and self.grand_total:
 			# 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": payable_amount,
-					"credit_in_account_currency": payable_amount,
+					"credit": self.grand_total,
+					"credit_in_account_currency": self.grand_total,
 					"against": self.employee
 				})
 			)
@@ -165,15 +164,13 @@
 					"party_type": "Employee",
 					"party": self.employee,
 					"against": payment_account,
-					"debit": payable_amount,
-					"debit_in_account_currency": payable_amount,
+					"debit": self.grand_total,
+					"debit_in_account_currency": self.grand_total,
 					"against_voucher": self.name,
 					"against_voucher_type": self.doctype,
 				})
 			)
 
-		self.add_tax_gl_entries(gl_entry)
-
 		return gl_entry
 
 	def add_tax_gl_entries(self, gl_entries):
@@ -184,11 +181,12 @@
 				self.get_gl_dict({
 					"account": tax.account_head,
 					"debit": tax.tax_amount,
+					"debit_in_account_currency": tax.tax_amount,
 					"against": self.employee,
 					"cost_center": self.cost_center,
 					"against_voucher_type": self.doctype,
 					"against_voucher": self.name
-				}, account_currency)
+				})
 			)
 
 	def validate_account_details(self):
@@ -213,13 +211,15 @@
 			self.total_sanctioned_amount += flt(d.sanctioned_amount)
 
 	def calculate_taxes(self):
+		self.total_taxes_and_charges = 0
 		for tax in self.taxes:
 			if tax.rate:
 				tax.tax_amount = flt(self.total_sanctioned_amount) * flt(tax.rate/100)
-			if tax.tax_amount:
-				tax.rate = flt(tax.tax_amount)/flt(self.total_sanctioned_amount) * 100
+
 			tax.total = flt(tax.tax_amount) + flt(self.total_sanctioned_amount)
-			self.net_total += tax.total
+			self.total_taxes_and_charges += flt(tax.tax_amount)
+
+		self.grand_total = flt(self.total_sanctioned_amount) + flt(self.total_taxes_and_charges) - flt(self.total_advance_amount)
 
 	def update_task(self):
 		task = frappe.get_doc("Task", self.task)