Sumar cuotas.

This commit is contained in:
Juan Pablo Vial
2024-11-28 17:38:21 -03:00
parent f4b8634cb4
commit 52de72b507
3 changed files with 38 additions and 5 deletions

View File

@ -25,6 +25,9 @@ class FormaPago implements JsonSerializable
if ($this->escritura !== null) {
$sum += $this->escritura->pago->valor($moneda);
}
if (count($this->cuotasAbono) > 0) {
$sum += $this->cuotasAbono($moneda);
}
return $sum;
}
public function prometido(string $moneda = Pago::UF): float
@ -53,6 +56,15 @@ class FormaPago implements JsonSerializable
}
return $sum;
}
public function cuotasAbono(string $moneda = Pago::UF): float
{
return array_reduce($this->cuotasAbono, function($sum, $cuota) use ($moneda) {
if ($cuota->currentEstado->tipoEstadoPago->descripcion === 'abonado') {
return $sum + $cuota->pago->valor($moneda);
}
return $sum;
}, 0);
}
public function ids(): array
{
return [