fix: Loan Security unpledge on loan cancel
This commit is contained in:
parent
8c13fded17
commit
66967c6d45
@ -11,6 +11,9 @@ frappe.ui.form.on('Loan', {
|
||||
}
|
||||
},
|
||||
onload: function (frm) {
|
||||
// Ignore loan security pledge on cancel of loan
|
||||
frm.ignore_doctypes_on_cancel_all = ["Loan Security Pledge"];
|
||||
|
||||
frm.set_query("loan_application", function () {
|
||||
return {
|
||||
"filters": {
|
||||
|
@ -138,9 +138,12 @@ class Loan(AccountsController):
|
||||
})
|
||||
|
||||
def unlink_loan_security_pledge(self):
|
||||
frappe.db.sql("""UPDATE `tabLoan Security Pledge` SET
|
||||
loan = '', status = 'Unpledged'
|
||||
where name = %s """, (self.loan_security_pledge))
|
||||
pledges = frappe.get_all('Loan Security Pledge', fields=['name'], filters={'loan': self.name})
|
||||
pledge_list = [d.name for d in pledges]
|
||||
if pledge_list:
|
||||
frappe.db.sql("""UPDATE `tabLoan Security Pledge` SET
|
||||
loan = '', status = 'Unpledged'
|
||||
where name in (%s) """ % (', '.join(['%s']*len(pledge_list))), tuple(pledge_list))
|
||||
|
||||
def update_total_amount_paid(doc):
|
||||
total_amount_paid = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user