FIX: calculo de UF nula o 0

This commit is contained in:
Juan Pablo Vial
2025-04-03 13:37:17 -03:00
parent fd6577c984
commit 4d6a1827a3

View File

@ -24,8 +24,15 @@ class Pago extends Model
public function valor(string $moneda = Pago::UF): float
{
$uf = $this->uf ?? ($this->uf > 0.0 ? $this->uf : 1);
return $this->valor / (($moneda === Pago::UF) ? $uf : 1);
$multiplier = 1;
if ($moneda === Pago::UF) {
if ($this->uf === null or $this->uf === 0.0) {
return 0;
}
$uf = $this->uf;
$multiplier = 1 / $uf;
}
return $this->valor * $multiplier;
}
public function estado(?string $tipoEstado = null): ?EstadoPago