Total Complexity | 3 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Loan module.""" |
||
2 | |||
3 | from econopy.constants import ANUAL |
||
4 | |||
5 | |||
6 | class BaseLoan: |
||
7 | |||
8 | def __init__(self, capital, periodos, interes, tipo_periodo=ANUAL): |
||
9 | self.capital = capital |
||
10 | self.periodos = periodos |
||
11 | self.tipo_periodo = tipo_periodo |
||
12 | self._interes = interes |
||
13 | self.cuotas_interes = [] |
||
14 | self.cuotas_amortizacion = [] |
||
15 | self.capital_vivo = [] |
||
16 | self.total_amortizado = [] |
||
17 | |||
18 | @property |
||
19 | def interest_rate(self): |
||
20 | return self._interes * self.tipo_periodo |
||
21 | |||
22 | |||
23 | class FrenchLoan(BaseLoan): |
||
24 | |||
25 | @property |
||
26 | def quota(self): |
||
27 | return self.capital * ( |
||
28 | self.interest_rate*( |
||
29 | 1 + self.interest_rate)**self.periodos) / (-1 + ( |
||
30 | 1 + self.interest_rate)**self.periodos) |
||
31 |