From a0b846fb88f09591546682f70fe2dfa4ecee6b79 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 9 Aug 2018 15:51:38 +0530 Subject: [PATCH] [Minor] Added condition for get_bank_cash_account (#15112) --- .../hr/doctype/employee_loan/employee_loan.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.js b/erpnext/hr/doctype/employee_loan/employee_loan.js index 1f38105c4d..e089e29911 100644 --- a/erpnext/hr/doctype/employee_loan/employee_loan.js +++ b/erpnext/hr/doctype/employee_loan/employee_loan.js @@ -71,19 +71,22 @@ frappe.ui.form.on('Employee Loan', { } }) }, + 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); + if (frm.doc.mode_of_payment && frm.doc.company) { + 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); + } } - } - }); + }); + } }, employee_loan_application: function (frm) {