DAPs API
This commit is contained in:
36
app/src/Model/DAP.php
Normal file
36
app/src/Model/DAP.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class DAP extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public int $capital;
|
||||
public int $futuro;
|
||||
public DateTimeInterface $inicio;
|
||||
public DateTimeInterface $termino;
|
||||
|
||||
public function periodo(): int
|
||||
{
|
||||
return $this->termino->diff($this->inicio)->days;
|
||||
}
|
||||
public function interes(): float
|
||||
{
|
||||
return ($this->futuro - $this->capital) / $this->capital / $this->periodo() * 365;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'capital' => $this->capital,
|
||||
'futuro' => $this->futuro,
|
||||
'inicio' => $this->inicio->format('Y-m-d'),
|
||||
'termino' => $this->termino->format('Y-m-d'),
|
||||
'periodo' => $this->periodo(),
|
||||
'interes' => $this->interes()
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user