fix: fetch logic for repay_from_salary in loan_repayment [v13] (#37136)

fix: fetch logic for repay_from_salary in loan_repayment
This commit is contained in:
Anand Baburajan
2023-09-19 15:18:17 +05:30
committed by GitHub
parent 86b152fe5c
commit d4f8b057e1
3 changed files with 13 additions and 7 deletions

View File

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

View File

@@ -262,8 +262,6 @@
},
{
"default": "0",
"fetch_from": "against_loan.repay_from_salary",
"fetch_if_empty": 1,
"fieldname": "repay_from_salary",
"fieldtype": "Check",
"label": "Repay From Salary"
@@ -313,11 +311,10 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2022-08-04 17:13:51.964203",
"modified": "2023-09-18 16:50:32.897005",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Repayment",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@@ -353,6 +350,5 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

View File

@@ -81,6 +81,11 @@ class LoanRepayment(AccountsController):
if amounts.get("due_date"):
self.due_date = amounts.get("due_date")
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",