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:
@@ -6,7 +6,14 @@
|
|||||||
frappe.ui.form.on('Loan Repayment', {
|
frappe.ui.form.on('Loan Repayment', {
|
||||||
// refresh: function(frm) {
|
// 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) {
|
onload: function(frm) {
|
||||||
frm.set_query('against_loan', function() {
|
frm.set_query('against_loan', function() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ class LoanRepayment(AccountsController):
|
|||||||
if amounts.get("due_date"):
|
if amounts.get("due_date"):
|
||||||
self.due_date = 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):
|
def check_future_entries(self):
|
||||||
future_repayment_date = frappe.db.get_value(
|
future_repayment_date = frappe.db.get_value(
|
||||||
"Loan Repayment",
|
"Loan Repayment",
|
||||||
|
|||||||
Reference in New Issue
Block a user