From feda4f9bc9c9553fdaf5f01a8427aff7db83f9b7 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 16 Jul 2015 15:44:56 +0530 Subject: [PATCH] Default Expense Account added to Expense Claim Type. Fetch account while making Bank Entry --- erpnext/hr/doctype/expense_claim/expense_claim.js | 12 ++++++++---- .../expense_claim_detail/expense_claim_detail.json | 14 +++++++++++++- .../expense_claim_type/expense_claim_type.json | 12 ++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index b556172a78..a56929d1c3 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -19,10 +19,13 @@ erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({ jv.company = cur_frm.doc.company; jv.remark = 'Payment against Expense Claim: ' + cur_frm.doc.name; jv.fiscal_year = cur_frm.doc.fiscal_year; - - var d1 = frappe.model.add_child(jv, 'Journal Entry Account', 'accounts'); - d1.debit = cur_frm.doc.total_sanctioned_amount; - d1.against_expense_claim = cur_frm.doc.name; + var expense = cur_frm.doc.expenses || []; + for(var i = 0; i < expense.length; i++){ + var d1 = frappe.model.add_child(jv, 'Journal Entry Account', 'accounts'); + d1.debit = expense[i].sanctioned_amount; + d1.account = expense[i].default_account; + d1.against_expense_claim = cur_frm.doc.name; + } // credit to bank var d1 = frappe.model.add_child(jv, 'Journal Entry Account', 'accounts'); @@ -43,6 +46,7 @@ $.extend(cur_frm.cscript, new erpnext.hr.ExpenseClaimController({frm: cur_frm})) cur_frm.add_fetch('employee', 'company', 'company'); cur_frm.add_fetch('employee','employee_name','employee_name'); +cur_frm.add_fetch('expense_type', 'default_account', 'default_account'); cur_frm.cscript.onload = function(doc,cdt,cdn) { if(!doc.approval_status) diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json index c6123eeeff..9522d94207 100644 --- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json +++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json @@ -34,6 +34,18 @@ "reqd": 1, "width": "150px" }, + { + "depends_on": "expense_type", + "fieldname": "default_account", + "fieldtype": "Link", + "hidden": 1, + "label": "Default Account", + "options": "Account", + "permlevel": 0, + "precision": "", + "read_only": 1, + "unique": 0 + }, { "fieldname": "section_break_4", "fieldtype": "Section Break", @@ -93,7 +105,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-04-08 06:18:47.539134", + "modified": "2015-07-16 06:13:32.090048", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim Detail", diff --git a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json index fc7e604dba..0b0d304644 100644 --- a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json +++ b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json @@ -17,6 +17,14 @@ "reqd": 1, "search_index": 0 }, + { + "fieldname": "default_account", + "fieldtype": "Link", + "label": "Default Account", + "options": "Account", + "permlevel": 0, + "precision": "" + }, { "fieldname": "description", "fieldtype": "Small Text", @@ -29,7 +37,7 @@ ], "icon": "icon-flag", "idx": 1, - "modified": "2015-07-13 04:46:38.897484", + "modified": "2015-07-15 08:57:23.069980", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim Type", @@ -55,7 +63,7 @@ "print": 0, "read": 1, "report": 0, - "role": "Employee", + "role": "All", "share": 0, "write": 0 }