Sumar cuotas.
This commit is contained in:
@ -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 [
|
||||
|
Reference in New Issue
Block a user