Browse Source

[IMP] add field that contains only the loan due amount(w/ the interest)

pull/134/head
houssine 4 years ago
parent
commit
c79e6dd4af
  1. 6
      easy_my_coop_loan/models/interest_line.py
  2. 5
      easy_my_coop_loan/models/loan_issue_line.py
  3. 2
      easy_my_coop_loan/views/loan_interest_lines_view.xml

6
easy_my_coop_loan/models/interest_line.py

@ -72,8 +72,12 @@ class LoanInterestLine(models.Model):
currency_field="company_currency_id", currency_field="company_currency_id",
readonly=True, readonly=True,
) )
due_loan_amount = fields.Monetary(
string="Due loan amount",
currency_field="company_currency_id"
)
due_amount = fields.Monetary( due_amount = fields.Monetary(
string="Due amount",
string="Total due amount",
currency_field="company_currency_id" currency_field="company_currency_id"
) )
due_date = fields.Date(string="Due date") due_date = fields.Date(string="Due date")

5
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): for year in range(1, loan_term + 1):
interest = accrued_amount * rate interest = accrued_amount * rate
due_amount = 0 due_amount = 0
due_loan_amount = 0
if loan_issue.capital_payment == "end": if loan_issue.capital_payment == "end":
if year == loan_term: if year == loan_term:
due_amount = line.amount due_amount = line.amount
@ -214,6 +216,8 @@ class LoanIssueLine(models.Model):
due_amount = line.amount * (loan_term / 100) due_amount = line.amount * (loan_term / 100)
accrued_amount -= due_amount accrued_amount -= due_amount
due_loan_amount = due_amount
if loan_issue.interest_payment == "end": if loan_issue.interest_payment == "end":
accrued_interest += interest accrued_interest += interest
accrued_amount += interest accrued_amount += interest
@ -238,6 +242,7 @@ class LoanIssueLine(models.Model):
accrued_net_interest += net_interest accrued_net_interest += net_interest
accrued_taxes += taxes_amount accrued_taxes += taxes_amount
vals["due_date"] = due_date vals["due_date"] = due_date
vals["due_loan_amount"] = due_loan_amount
vals["due_amount"] = due_amount vals["due_amount"] = due_amount
vals["interest"] = interest vals["interest"] = interest
vals["net_interest"] = net_interest vals["net_interest"] = net_interest

2
easy_my_coop_loan/views/loan_interest_lines_view.xml

@ -19,6 +19,7 @@
<field name="accrued_interest"/> <field name="accrued_interest"/>
<field name="net_interest"/> <field name="net_interest"/>
<field name="taxes_amount"/> <field name="taxes_amount"/>
<field name="due_loan_amount"/>
<field name="due_amount"/> <field name="due_amount"/>
<field name="due_date"/> <field name="due_date"/>
<field name="state"/> <field name="state"/>
@ -41,6 +42,7 @@
<field name="name"/> <field name="name"/>
<field name="amount"/> <field name="amount"/>
<field name="accrued_amount"/> <field name="accrued_amount"/>
<field name="due_loan_amount"/>
<field name="due_amount"/> <field name="due_amount"/>
<field name="due_date"/> <field name="due_date"/>
</group> </group>

Loading…
Cancel
Save