From 23db6a8e3a1f4688f3fcb833f52bfd9a6aba3532 Mon Sep 17 00:00:00 2001 From: Jannat Patel <31363128+pateljannat@users.noreply.github.com> Date: Mon, 12 Jul 2021 13:17:27 +0530 Subject: [PATCH] fix: added company filter while fetching loans (#26296) Co-authored-by: Rucha Mahabal --- erpnext/hr/doctype/loan/loan.js | 9 +++++++++ .../hr/doctype/loan_application/loan_application.js | 11 +++++++++-- erpnext/hr/doctype/salary_slip/salary_slip.py | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/loan/loan.js b/erpnext/hr/doctype/loan/loan.js index 3f5c30c4758..97504980225 100644 --- a/erpnext/hr/doctype/loan/loan.js +++ b/erpnext/hr/doctype/loan/loan.js @@ -15,6 +15,15 @@ frappe.ui.form.on('Loan', { }; }); + frm.set_query("loan_type", function () { + return { + "filters": { + "docstatus": 1, + "company": frm.doc.company + } + }; + }); + frm.set_query("interest_income_account", function () { return { "filters": { diff --git a/erpnext/hr/doctype/loan_application/loan_application.js b/erpnext/hr/doctype/loan_application/loan_application.js index a73b62a894e..e150a220b86 100644 --- a/erpnext/hr/doctype/loan_application/loan_application.js +++ b/erpnext/hr/doctype/loan_application/loan_application.js @@ -5,8 +5,15 @@ frappe.ui.form.on('Loan Application', { refresh: function(frm) { - frm.trigger("toggle_fields") - frm.trigger("add_toolbar_buttons") + frm.trigger("toggle_fields"); + frm.trigger("add_toolbar_buttons"); + frm.set_query('loan_type', () => { + return { + filters: { + company: frm.doc.company + } + }; + }); }, repayment_method: function(frm) { frm.doc.repayment_amount = frm.doc.repayment_periods = "" diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 6e6ae4351c8..2213fa6fb57 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -869,8 +869,8 @@ class SalarySlip(TransactionBase): `tabRepayment Schedule` as rps, `tabLoan` as l where l.name = rps.parent and rps.payment_date between %s and %s and - l.repay_from_salary = 1 and l.docstatus = 1 and l.applicant = %s""", - (self.start_date, self.end_date, self.employee), as_dict=True) or [] + l.repay_from_salary = 1 and l.docstatus = 1 and l.applicant = %s and l.company = %s""", + (self.start_date, self.end_date, self.employee, self.company), as_dict=True) or [] def update_salary_slip_in_additional_salary(self): salary_slip = self.name if self.docstatus==1 else None