From f5804438bb14c45b4c46bef6143fdcfa1f35d9ae Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Mon, 3 Nov 2014 12:23:55 +0530 Subject: [PATCH] Auto set default bank/cash account on select of Bank/Cash Voucher in JV --- .../doctype/journal_voucher/journal_voucher.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 9174873406..4ba4dff32f 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -213,10 +213,11 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { return; var update_jv_details = function(doc, r) { - $.each(r.message, function(i, d) { - var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries"); - jvdetail.account = d.account; - jvdetail.balance = d.balance; + var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries"); + $.each(r, function(i, d) { + var row = frappe.model.add_child(doc, "Journal Voucher Detail", "entries"); + row.account = d.account; + row.balance = d.balance; }); refresh_field("entries"); } @@ -231,7 +232,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { }, callback: function(r) { if(r.message) { - update_jv_details(doc, r); + update_jv_details(doc, [r.message]); } } }) @@ -245,7 +246,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { callback: function(r) { frappe.model.clear_table(doc, "entries"); if(r.message) { - update_jv_details(doc, r); + update_jv_details(doc, r.message); } cur_frm.set_value("is_opening", "Yes") }