-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprestamo.class.php
59 lines (55 loc) · 1.8 KB
/
prestamo.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace BCO;
require_once("cuota.class.php");
use BCO\Cuota;
class Prestamo{
private $_capital;
private $_periodos;
private $_tasa;
private $_valorFuturo;
private $_cuotanivelada;
private $_cuotas;
public function __construct($capital, $periodos, $tasa)
{
$this->_capital = $capital;
$this->_periodos = $periodos;
$this->_tasa = $tasa;
}
public function calcularPrestamo()
{
$this->_valorFuturo = $this->_capital * pow((1 + ($this->_tasa/12)), $this->_periodos);
$this->_cuotanivelada = round($this->_valorFuturo / $this->_periodos, 4);
$saldo = $this->_capital;
for ($i = 1 ; $i<= $this->_periodos; $i ++) {
$tmpCuota = new Cuota($i, $this->_cuotanivelada, $saldo, $this->_tasa);
$this->_cuotas[] = $tmpCuota;
$saldo = $tmpCuota->getSaldoFinal();
}
}
public function getCuotas(){
return $this->_cuotas;
}
public function exportWithAdapter(&$fnAdaptador) {
$arrObjeto = array(
"capital" => $this->_capital,
"periodos" => $this->_periodos,
"tasa" => $this->_tasa,
"valorFuturo" => $this->_valorFuturo,
"cuotanivelada" => $this->_cuotanivelada,
"cuotas" => array()
);
foreach ($this->_cuotas as $oCuota) {
$arrObjeto["cuotas"][] = array(
"periodo" => $oCuota->getPeriodo(),
"cuota" => $oCuota->getCuota(),
"interes" => $oCuota->getInteres(),
"capital" => $oCuota->getCapital(),
"saldoFinal" => $oCuota->getSaldoFinal(),
"saldoAntes" => $oCuota->getSaldoAntes(),
"tasa" => $oCuota->getTasa()
);
}
return $fnAdaptador($arrObjeto);
}
}
?>