Skip to content

Commit

Permalink
fix: fetch logic for repay_from_salary in loan_repayment [v13] (#37136)
Browse files Browse the repository at this point in the history
fix: fetch logic for repay_from_salary in loan_repayment
  • Loading branch information
anandbaburajan committed Sep 19, 2023
1 parent 86b152f commit d4f8b05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -353,6 +350,5 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def set_missing_values(self, amounts):
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",
Expand Down

0 comments on commit d4f8b05

Please sign in to comment.