Merge pull request #3670 from neilLasrado/expense-claim
Default Expense Account added to Expense Claim Type.
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index b556172..a56929d 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -19,10 +19,13 @@
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 @@
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 c6123ee..9522d94 100644
--- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json
+++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json
@@ -35,6 +35,18 @@
"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",
"permlevel": 0,
@@ -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 fc7e604..0b0d304 100644
--- a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json
+++ b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json
@@ -18,6 +18,14 @@
"search_index": 0
},
{
+ "fieldname": "default_account",
+ "fieldtype": "Link",
+ "label": "Default Account",
+ "options": "Account",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description",
@@ -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
}