Merge pull request #21546 from deepeshgarg007/loan_closure_fixes
fix: Loan Closure without loan interest accrual
diff --git a/erpnext/loan_management/desk_page/loan_management/loan_management.json b/erpnext/loan_management/desk_page/loan_management/loan_management.json
index 691d2c1..f9ea978 100644
--- a/erpnext/loan_management/desk_page/loan_management/loan_management.json
+++ b/erpnext/loan_management/desk_page/loan_management/loan_management.json
@@ -37,7 +37,7 @@
"idx": 0,
"is_standard": 1,
"label": "Loan Management",
- "modified": "2020-04-01 11:28:51.380509",
+ "modified": "2020-04-02 11:28:51.380509",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Management",
diff --git a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json
index 2d9c45d..c437a98 100644
--- a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json
+++ b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json
@@ -7,17 +7,17 @@
"engine": "InnoDB",
"field_order": [
"against_loan",
- "disbursement_date",
"posting_date",
+ "applicant_type",
"column_break_4",
"company",
- "applicant_type",
"applicant",
"section_break_7",
+ "disbursement_date",
+ "column_break_8",
"disbursed_amount",
"accounting_dimensions_section",
"cost_center",
- "section_break_13",
"customer_details_section",
"bank_account",
"amended_from"
@@ -66,6 +66,7 @@
"read_only": 1
},
{
+ "collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
"label": "Accounting Dimensions"
@@ -89,12 +90,8 @@
},
{
"fieldname": "section_break_7",
- "fieldtype": "Section Break"
- },
- {
- "collapsible": 1,
- "fieldname": "section_break_13",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Disbursement Details"
},
{
"fieldname": "customer_details_section",
@@ -114,11 +111,15 @@
"fieldtype": "Link",
"label": "Bank Account",
"options": "Bank Account"
+ },
+ {
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break"
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-09 14:44:28.527271",
+ "modified": "2020-04-29 05:20:41.629911",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Disbursement",
diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
index 87e8a15..a5ed5de 100644
--- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
+++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
@@ -106,6 +106,7 @@
def allocate_amounts(self, paid_entries):
self.set('repayment_details', [])
self.principal_amount_paid = 0
+ interest_paid = 0
if self.amount_paid - self.penalty_amount > 0 and paid_entries:
interest_paid = self.amount_paid - self.penalty_amount
@@ -286,7 +287,11 @@
pending_principal_amount = against_loan_doc.total_payment - against_loan_doc.total_principal_paid - against_loan_doc.total_interest_payable
if payment_type == "Loan Closure" and not payable_principal_amount:
- pending_days = date_diff(posting_date, entry.posting_date) + 1
+ if final_due_date:
+ pending_days = date_diff(posting_date, final_due_date)
+ else:
+ pending_days = date_diff(posting_date, against_loan_doc.disbursement_date) + 1
+
payable_principal_amount = pending_principal_amount
per_day_interest = (payable_principal_amount * (loan_type_details.rate_of_interest / 100))/365
total_pending_interest += (pending_days * per_day_interest)