fix: fetch logic for repay_from_salary in loan_repayment [v14] (#37135)

* fix: fetch logic for repay_from_salary in loan_repayment

* chore: only fetch repay_from_salary if field exists
This commit is contained in:
Anand Baburajan
2023-09-19 15:18:35 +05:30
committed by GitHub
parent 29ff0ce286
commit 480a0ca7a8
2 changed files with 14 additions and 1 deletions

View File

@@ -6,7 +6,14 @@
frappe.ui.form.on('Loan Repayment', {
// refresh: function(frm) {
// }
// },
setup: function(frm) {
if (frappe.meta.has_field("Loan Repayment", "repay_from_salary")) {
frm.add_fetch("against_loan", "repay_from_salary", "repay_from_salary");
}
},
onload: function(frm) {
frm.set_query('against_loan', function() {
return {

View File

@@ -80,6 +80,12 @@ class LoanRepayment(AccountsController):
if amounts.get("due_date"):
self.due_date = amounts.get("due_date")
if hasattr(self, "repay_from_salary") and hasattr(self, "payroll_payable_account"):
if self.repay_from_salary and not self.payroll_payable_account:
frappe.throw(_("Please set Payroll Payable Account in Loan Repayment"))
elif not self.repay_from_salary and self.payroll_payable_account:
self.repay_from_salary = 1
def check_future_entries(self):
future_repayment_date = frappe.db.get_value(
"Loan Repayment",