Merge pull request #21546 from deepeshgarg007/loan_closure_fixes

fix: Loan Closure without loan interest accrual
This commit is contained in:
Deepesh Garg 2020-05-01 15:49:56 +05:30 committed by GitHub
commit 0f8150f8de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -37,7 +37,7 @@
"idx": 0, "idx": 0,
"is_standard": 1, "is_standard": 1,
"label": "Loan Management", "label": "Loan Management",
"modified": "2020-04-01 11:28:51.380509", "modified": "2020-04-02 11:28:51.380509",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Loan Management", "module": "Loan Management",
"name": "Loan Management", "name": "Loan Management",

View File

@ -7,17 +7,17 @@
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"against_loan", "against_loan",
"disbursement_date",
"posting_date", "posting_date",
"applicant_type",
"column_break_4", "column_break_4",
"company", "company",
"applicant_type",
"applicant", "applicant",
"section_break_7", "section_break_7",
"disbursement_date",
"column_break_8",
"disbursed_amount", "disbursed_amount",
"accounting_dimensions_section", "accounting_dimensions_section",
"cost_center", "cost_center",
"section_break_13",
"customer_details_section", "customer_details_section",
"bank_account", "bank_account",
"amended_from" "amended_from"
@ -66,6 +66,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"collapsible": 1,
"fieldname": "accounting_dimensions_section", "fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Accounting Dimensions" "label": "Accounting Dimensions"
@ -89,12 +90,8 @@
}, },
{ {
"fieldname": "section_break_7", "fieldname": "section_break_7",
"fieldtype": "Section Break" "fieldtype": "Section Break",
}, "label": "Disbursement Details"
{
"collapsible": 1,
"fieldname": "section_break_13",
"fieldtype": "Section Break"
}, },
{ {
"fieldname": "customer_details_section", "fieldname": "customer_details_section",
@ -114,11 +111,15 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Bank Account", "label": "Bank Account",
"options": "Bank Account" "options": "Bank Account"
},
{
"fieldname": "column_break_8",
"fieldtype": "Column Break"
} }
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-04-09 14:44:28.527271", "modified": "2020-04-29 05:20:41.629911",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Loan Management", "module": "Loan Management",
"name": "Loan Disbursement", "name": "Loan Disbursement",

View File

@ -106,6 +106,7 @@ class LoanRepayment(AccountsController):
def allocate_amounts(self, paid_entries): def allocate_amounts(self, paid_entries):
self.set('repayment_details', []) self.set('repayment_details', [])
self.principal_amount_paid = 0 self.principal_amount_paid = 0
interest_paid = 0
if self.amount_paid - self.penalty_amount > 0 and paid_entries: if self.amount_paid - self.penalty_amount > 0 and paid_entries:
interest_paid = self.amount_paid - self.penalty_amount interest_paid = self.amount_paid - self.penalty_amount
@ -286,7 +287,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 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: 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 payable_principal_amount = pending_principal_amount
per_day_interest = (payable_principal_amount * (loan_type_details.rate_of_interest / 100))/365 per_day_interest = (payable_principal_amount * (loan_type_details.rate_of_interest / 100))/365
total_pending_interest += (pending_days * per_day_interest) total_pending_interest += (pending_days * per_day_interest)