From 4226191ec75be83690115c1398d008937d9c1693 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 30 Apr 2020 22:11:57 +0530 Subject: [PATCH 1/2] fix: Loan Closure without loan interest accrual --- .../loan_management/loan_management.json | 2 +- .../loan_disbursement/loan_disbursement.json | 21 ++++++++++--------- .../doctype/loan_repayment/loan_repayment.py | 6 +++++- 3 files changed, 17 insertions(+), 12 deletions(-) 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 691d2c1e0c..f9ea978ed6 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 2d9c45d122..c437a987eb 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 87e8a15ab4..ed1eed236d 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -286,7 +286,11 @@ def get_amounts(amounts, against_loan, posting_date, payment_type): 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) From 61363d2ceda3934224404daf3acf9d4bf23dc373 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 30 Apr 2020 22:22:44 +0530 Subject: [PATCH 2/2] fix: Initialize interest_paid as zero --- erpnext/loan_management/doctype/loan_repayment/loan_repayment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index ed1eed236d..a5ed5de30e 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 @@ class LoanRepayment(AccountsController): 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