Skip to content

Commit

Permalink
fix: fetch logic for repay_from_salary in loan_repayment [v14] (#37135)
Browse files Browse the repository at this point in the history
* fix: fetch logic for repay_from_salary in loan_repayment

* chore: only fetch repay_from_salary if field exists
  • Loading branch information
anandbaburajan committed Sep 19, 2023
1 parent 29ff0ce commit 480a0ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def set_missing_values(self, amounts):
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",
Expand Down

0 comments on commit 480a0ca

Please sign in to comment.