fix: Only submitted Loan security pledges should be approved

This commit is contained in:
Deepesh Garg 2020-09-07 23:22:21 +05:30
parent 8e4ae0af56
commit 03b0ad4f98
2 changed files with 7 additions and 6 deletions

View File

@ -240,15 +240,19 @@ def unpledge_security(loan=None, loan_security_pledge=None, as_dict=0, save=0, s
unpledge_request = create_loan_security_unpledge(security_map, pledge_doc.loan, unpledge_request = create_loan_security_unpledge(security_map, pledge_doc.loan,
pledge_doc.company, pledge_doc.applicant_type, pledge_doc.applicant) pledge_doc.company, pledge_doc.applicant_type, pledge_doc.applicant)
if approve:
unpledge_request.status = 'Approved'
if save: if save:
unpledge_request.save() unpledge_request.save()
if submit: if submit:
unpledge_request.submit() unpledge_request.submit()
if approve:
if unpledge_request.docstatus == 1:
unpledge_request.status = 'Approved'
unpledge_request.save()
else:
frappe.throw(_('Only submittted unpledge requests can be approved'))
if as_dict: if as_dict:
return unpledge_request return unpledge_request
else: else:

View File

@ -20,9 +20,6 @@ class LoanSecurityUnpledge(Document):
self.update_loan_status(cancel=1) self.update_loan_status(cancel=1)
self.db_set('status', 'Requested') self.db_set('status', 'Requested')
def on_submit(self):
self.approve()
def validate_duplicate_securities(self): def validate_duplicate_securities(self):
security_list = [] security_list = []
for d in self.securities: for d in self.securities: