econopy.loans   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 22
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A FrenchLoan.quota() 0 6 1
A BaseLoan.__init__() 0 9 1
A BaseLoan.interest_rate() 0 3 1
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