fix: Loan Security unpledge on loan cancel

This commit is contained in:
Deepesh Garg 2020-10-13 18:10:51 +05:30
parent 8c13fded17
commit 66967c6d45
2 changed files with 9 additions and 3 deletions

View File

@ -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": {

View File

@ -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