1
|
|
|
"""Prestamos module.""" |
2
|
|
|
|
3
|
|
|
from econopy import rentas |
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class PrestamoFrances: |
|
|
|
|
7
|
|
|
|
8
|
|
|
cuota = 0 |
9
|
|
|
principal = 10 |
10
|
|
|
interes_anual = 0.1 |
11
|
|
|
interes = 0.01 |
12
|
|
|
periodos = 1 |
13
|
|
|
tipo_periodo = rentas.ANUAL |
14
|
|
|
cuotas_interes = [] |
15
|
|
|
cuotas_amortizacion = [] |
16
|
|
|
capital_vivo = [] |
17
|
|
|
total_amortizado = [] |
18
|
|
|
|
19
|
|
|
def calcula_interes(self): |
|
|
|
|
20
|
|
|
self.interes = self.interes_anual / self.tipo_periodo |
21
|
|
|
|
22
|
|
|
def calcula_cuota(self): |
|
|
|
|
23
|
|
|
self.calcula_interes() |
24
|
|
|
cuota = self.principal * \ |
25
|
|
|
((self.interes*(1+self.interes)**self.periodos) / |
26
|
|
|
(-1+(1+self.interes)**self.periodos)) |
27
|
|
|
self.cuota = cuota |
28
|
|
|
|
29
|
|
|
def calcula_tabla_amortizacion(self): |
|
|
|
|
30
|
|
|
self.capital_vivo.append(self.principal) |
31
|
|
|
self.cuotas_interes.append(0) |
32
|
|
|
self.cuotas_amortizacion.append(0) |
33
|
|
|
self.total_amortizado.append(0) |
34
|
|
|
for periodo in range(1, self.periodos+1): |
35
|
|
|
interes = self.capital_vivo[periodo-1]*self.interes |
36
|
|
|
amortizado = self.cuota - interes |
37
|
|
|
self.cuotas_interes.append(interes) |
38
|
|
|
self.cuotas_amortizacion.append(amortizado) |
39
|
|
|
self.capital_vivo.append( |
40
|
|
|
self.capital_vivo[periodo-1]-amortizado) |
41
|
|
|
self.total_amortizado.append( |
42
|
|
|
self.total_amortizado[periodo-1]+amortizado) |
43
|
|
|
|
44
|
|
|
def pinta_cuadro(self): |
|
|
|
|
45
|
|
|
self.calcula_cuota() |
46
|
|
|
self.calcula_tabla_amortizacion() |
47
|
|
|
|
48
|
|
|
for i in range(1, self.periodos+1): |
49
|
|
|
print("| {} | {} | {} | {} | {} |").format( |
50
|
|
|
i, round(self.cuota, 2), round( |
51
|
|
|
self.capital_vivo[i], 2), round( |
52
|
|
|
self.cuotas_interes[i], 2), round( |
53
|
|
|
self.cuotas_amortizacion[i], 2)) |
54
|
|
|
|