Browse Source

[IMP] add field capital_payment and improve interest line creation

pull/134/head
houssine 4 years ago
parent
commit
8715d7a222
  1. 20
      easy_my_coop_loan/models/loan.py
  2. 1
      easy_my_coop_loan/views/loan_view.xml

20
easy_my_coop_loan/models/loan.py

@ -66,8 +66,19 @@ class LoanIssue(models.Model):
compute="_compute_subscribed_amount",
currency_field="company_currency_id",
)
capital_payment = fields.Selection(
[
("end", "End"),
("yearly", "Yearly")
],
string="Capital reimbursement"
)
interest_payment = fields.Selection(
[("end", "End"), ("yearly", "Yearly")], string="Interest payment"
[
("end", "End"),
("yearly", "Yearly")
],
string="Interest payment"
)
interest_payment_info = fields.Char(string="Yearly payment on")
loan_issue_lines = fields.One2many(
@ -173,12 +184,13 @@ class LoanIssue(models.Model):
self.write({"state": "closed"})
def get_interest_vals(self, line, vals):
interest_obj = self.env["loan.interest.line"]
list_vals = []
accrued_amount = line.amount
accrued_interest = 0
accrued_net_interest = 0
accrued_taxes = 0
loan_term = self.loan_term / 12
for year in range(1, int(loan_term) + 1):
interest = accrued_amount * (line.loan_issue_id.rate / 100)
accrued_amount += interest
@ -195,7 +207,9 @@ class LoanIssue(models.Model):
vals["accrued_net_interest"] = accrued_net_interest
vals["accrued_taxes"] = accrued_taxes
vals["name"] = year
interest_obj.create(vals)
list_vals.append(vals.copy())
self.env["loan.interest.line"].create(list_vals)
@api.multi
def compute_loan_interest(self):

1
easy_my_coop_loan/views/loan_view.xml

@ -102,6 +102,7 @@
<field name="loan_start_date"/>
<field name="term_date"/>
<field name="loan_term"/>
<field name="capital_payment" widget="selection"/>
<field name="interest_payment" widget="selection"/>
<field name="interest_payment_info"
attrs="{'invisible':[('interest_payment','not in',['end','yearly'])]}"/>

Loading…
Cancel
Save