Test Failed
Push — master ( 0837c7...124efb )
by Francisco Manzano
04:08
created

econopy.loans.FrenchLoan.quota()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
"""Prestamos 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
32
    # def calcula_tabla_amortizacion(self):
33
    #     self.capital_vivo.append(self.principal)
34
    #     self.cuotas_interes.append(0)
35
    #     self.cuotas_amortizacion.append(0)
36
    #     self.total_amortizado.append(0)
37
    #     for periodo in range(1, self.periodos+1):
38
    #         interes = self.capital_vivo[periodo-1]*self.interes
39
    #         amortizado = self.cuota - interes
40
    #         self.cuotas_interes.append(interes)
41
    #         self.cuotas_amortizacion.append(amortizado)
42
    #         self.capital_vivo.append(
43
    #             self.capital_vivo[periodo-1]-amortizado)
44
    #         self.total_amortizado.append(
45
    #             self.total_amortizado[periodo-1]+amortizado)
46