FIX: proporcion pie pagado
This commit is contained in:
@ -43,16 +43,19 @@ class Pie extends Model
|
||||
return $sum + $cuota->pago->valor($moneda);
|
||||
}, 0) * $proporcion;
|
||||
}
|
||||
protected array $pagado;
|
||||
public function pagado(string $moneda = Pago::UF): float
|
||||
{
|
||||
$proporcion = $this->proporcion();
|
||||
if ($this->asociado !== null) {
|
||||
return $this->asociado->pagado($moneda) * $proporcion;
|
||||
return $this->asociado->pagado($moneda) / $this->asociado->proporcion() * $proporcion;
|
||||
}
|
||||
|
||||
return array_reduce($this->cuotas(true), function(float $sum, Cuota $cuota) use ($moneda) {
|
||||
return $sum + $cuota->pago->valor($moneda);
|
||||
}, 0) * $proporcion;
|
||||
if (!isset($this->pagado[$moneda])) {
|
||||
$this->pagado[$moneda] = array_reduce($this->cuotas(true), function(float $sum, Cuota $cuota) use ($moneda) {
|
||||
return $sum + $cuota->pago->valor($moneda);
|
||||
}, 0);
|
||||
}
|
||||
return $this->pagado[$moneda] * $proporcion;
|
||||
}
|
||||
protected function proporcion(): float
|
||||
{
|
||||
|
Reference in New Issue
Block a user