fix: Set pledge amount before setting loan amount

This commit is contained in:
Deepesh Garg 2020-08-13 18:52:23 +05:30
parent 8264fcd0a5
commit 1151f888ba

View File

@ -16,6 +16,7 @@ from six import string_types
class LoanApplication(Document): class LoanApplication(Document):
def validate(self): def validate(self):
self.set_pledge_amount()
self.set_loan_amount() self.set_loan_amount()
self.validate_loan_amount() self.validate_loan_amount()
@ -24,7 +25,6 @@ class LoanApplication(Document):
self.repayment_periods, self.is_term_loan) self.repayment_periods, self.is_term_loan)
self.validate_loan_type() self.validate_loan_type()
self.set_pledge_amount()
self.get_repayment_details() self.get_repayment_details()
self.check_sanctioned_amount_limit() self.check_sanctioned_amount_limit()
@ -108,7 +108,7 @@ class LoanApplication(Document):
if self.is_secured_loan and self.proposed_pledges: if self.is_secured_loan and self.proposed_pledges:
self.maximum_loan_amount = 0 self.maximum_loan_amount = 0
for security in self.proposed_pledges: for security in self.proposed_pledges:
self.maximum_loan_amount += security.post_haircut_amount self.maximum_loan_amount += flt(security.post_haircut_amount)
if not self.loan_amount and self.is_secured_loan and self.proposed_pledges: if not self.loan_amount and self.is_secured_loan and self.proposed_pledges:
self.loan_amount = self.maximum_loan_amount self.loan_amount = self.maximum_loan_amount