From 6988fbb82d84d4c6164b8fba06599ed0445c00c5 Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 13 Aug 2020 12:17:13 +0530 Subject: [PATCH 1/3] fix: Validate or Set Loan Amount first --- .../doctype/loan_application/loan_application.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_application/loan_application.py b/erpnext/loan_management/doctype/loan_application/loan_application.py index f051755f67c..4ea6f92a6a0 100644 --- a/erpnext/loan_management/doctype/loan_application/loan_application.py +++ b/erpnext/loan_management/doctype/loan_application/loan_application.py @@ -16,14 +16,15 @@ from six import string_types class LoanApplication(Document): def validate(self): + self.set_loan_amount() + self.validate_loan_amount() validate_repayment_method(self.repayment_method, self.loan_amount, self.repayment_amount, self.repayment_periods, self.is_term_loan) self.validate_loan_type() self.set_pledge_amount() - self.set_loan_amount() - self.validate_loan_amount() + self.get_repayment_details() self.check_sanctioned_amount_limit() From 8264fcd0a53c4261d8836f171f7aa055471185f0 Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 13 Aug 2020 12:47:34 +0530 Subject: [PATCH 2/3] fix: Only validate repayment if term loan --- .../doctype/loan_application/loan_application.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_application/loan_application.py b/erpnext/loan_management/doctype/loan_application/loan_application.py index 4ea6f92a6a0..93446a08bd3 100644 --- a/erpnext/loan_management/doctype/loan_application/loan_application.py +++ b/erpnext/loan_management/doctype/loan_application/loan_application.py @@ -19,8 +19,9 @@ class LoanApplication(Document): self.set_loan_amount() self.validate_loan_amount() - validate_repayment_method(self.repayment_method, self.loan_amount, self.repayment_amount, - self.repayment_periods, self.is_term_loan) + if self.is_term_loan: + validate_repayment_method(self.repayment_method, self.loan_amount, self.repayment_amount, + self.repayment_periods, self.is_term_loan) self.validate_loan_type() self.set_pledge_amount() From 1151f888baf399b7125619c2cc8b82553aef7867 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 13 Aug 2020 18:52:23 +0530 Subject: [PATCH 3/3] fix: Set pledge amount before setting loan amount --- .../doctype/loan_application/loan_application.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_application/loan_application.py b/erpnext/loan_management/doctype/loan_application/loan_application.py index 93446a08bd3..71773f14599 100644 --- a/erpnext/loan_management/doctype/loan_application/loan_application.py +++ b/erpnext/loan_management/doctype/loan_application/loan_application.py @@ -16,6 +16,7 @@ from six import string_types class LoanApplication(Document): def validate(self): + self.set_pledge_amount() self.set_loan_amount() self.validate_loan_amount() @@ -24,7 +25,6 @@ class LoanApplication(Document): self.repayment_periods, self.is_term_loan) self.validate_loan_type() - self.set_pledge_amount() self.get_repayment_details() self.check_sanctioned_amount_limit() @@ -108,7 +108,7 @@ class LoanApplication(Document): if self.is_secured_loan and self.proposed_pledges: self.maximum_loan_amount = 0 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: self.loan_amount = self.maximum_loan_amount