Skip to content

Commit a713064

Browse files
committed
fix: Get bank account on selection of payment mode in Loan
1 parent b2d9ffa commit a713064

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

erpnext/hr/doctype/loan/loan.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ frappe.ui.form.on('Loan', {
146146
'payment_date': payment.payment_date,
147147
'principal_amount': payment.principal_amount,
148148
'interest_amount': payment.interest_amount,
149-
'total_payment': payment.total_payment
149+
'total_payment': payment.total_payment
150150
});
151151
dialog.fields_dict.payments.grid.refresh();
152152
$(dialog.wrapper.find(".grid-buttons")).hide();
@@ -172,18 +172,20 @@ frappe.ui.form.on('Loan', {
172172
},
173173

174174
mode_of_payment: function (frm) {
175-
frappe.call({
176-
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
177-
args: {
178-
"mode_of_payment": frm.doc.mode_of_payment,
179-
"company": frm.doc.company
180-
},
181-
callback: function (r, rt) {
182-
if (r.message) {
183-
frm.set_value("payment_account", r.message.account);
175+
if (frm.doc.mode_of_payment && frm.doc.company) {
176+
frappe.call({
177+
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
178+
args: {
179+
"mode_of_payment": frm.doc.mode_of_payment,
180+
"company": frm.doc.company
181+
},
182+
callback: function (r, rt) {
183+
if (r.message) {
184+
frm.set_value("payment_account", r.message.account);
185+
}
184186
}
185-
}
186-
});
187+
});
188+
}
187189
},
188190

189191
loan_application: function (frm) {

0 commit comments

Comments
 (0)