From c79e6dd4af547f96d7b6e7d35005b77500fc106c Mon Sep 17 00:00:00 2001 From: houssine Date: Wed, 2 Dec 2020 15:04:28 +0100 Subject: [PATCH] [IMP] add field that contains only the loan due amount(w/ the interest) --- easy_my_coop_loan/models/interest_line.py | 6 +++++- easy_my_coop_loan/models/loan_issue_line.py | 5 +++++ easy_my_coop_loan/views/loan_interest_lines_view.xml | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/easy_my_coop_loan/models/interest_line.py b/easy_my_coop_loan/models/interest_line.py index 17915bf..d5a2514 100644 --- a/easy_my_coop_loan/models/interest_line.py +++ b/easy_my_coop_loan/models/interest_line.py @@ -72,8 +72,12 @@ class LoanInterestLine(models.Model): currency_field="company_currency_id", readonly=True, ) + due_loan_amount = fields.Monetary( + string="Due loan amount", + currency_field="company_currency_id" + ) due_amount = fields.Monetary( - string="Due amount", + string="Total due amount", currency_field="company_currency_id" ) due_date = fields.Date(string="Due date") diff --git a/easy_my_coop_loan/models/loan_issue_line.py b/easy_my_coop_loan/models/loan_issue_line.py index ba38330..24e46b4 100644 --- a/easy_my_coop_loan/models/loan_issue_line.py +++ b/easy_my_coop_loan/models/loan_issue_line.py @@ -207,6 +207,8 @@ class LoanIssueLine(models.Model): for year in range(1, loan_term + 1): interest = accrued_amount * rate due_amount = 0 + due_loan_amount = 0 + if loan_issue.capital_payment == "end": if year == loan_term: due_amount = line.amount @@ -214,6 +216,8 @@ class LoanIssueLine(models.Model): due_amount = line.amount * (loan_term / 100) accrued_amount -= due_amount + due_loan_amount = due_amount + if loan_issue.interest_payment == "end": accrued_interest += interest accrued_amount += interest @@ -238,6 +242,7 @@ class LoanIssueLine(models.Model): accrued_net_interest += net_interest accrued_taxes += taxes_amount vals["due_date"] = due_date + vals["due_loan_amount"] = due_loan_amount vals["due_amount"] = due_amount vals["interest"] = interest vals["net_interest"] = net_interest diff --git a/easy_my_coop_loan/views/loan_interest_lines_view.xml b/easy_my_coop_loan/views/loan_interest_lines_view.xml index e0d5e26..a83817c 100644 --- a/easy_my_coop_loan/views/loan_interest_lines_view.xml +++ b/easy_my_coop_loan/views/loan_interest_lines_view.xml @@ -19,6 +19,7 @@ + @@ -41,6 +42,7 @@ +