FIX: Cuotas vigentes

This commit is contained in:
2023-12-22 13:17:03 -03:00
parent 8492d1df2b
commit 20b2bdc6c6
2 changed files with 9 additions and 4 deletions

View File

@ -23,7 +23,7 @@
</tr>
</thead>
<tbody id="cuotas">
@for ($i = count($pie->cuotas()); $i < $pie->cuotas - count($pie->cuotas()); $i ++)
@for ($i = count($pie->cuotas()); $i < $pie->cuotas - count($pie->cuotas(vigentes: true)); $i ++)
<tr>
<td>{{$i + 1}}</td>
<td>

View File

@ -15,18 +15,23 @@ class Pie extends Model
public ?Pago $reajuste;
public array $cuotasArray;
public function cuotas(bool $pagadas = false): array
public function cuotas(bool $pagadas = false, bool $vigentes = false): array
{
if ($this->asociado !== null) {
return $this->asociado->cuotas($pagadas);
}
if (!$pagadas) {
if (!$pagadas and !$vigentes) {
return $this->cuotasArray;
}
if ($pagadas) {
return array_filter($this->cuotasArray, function(Cuota $cuota) {
return $cuota->pago->currentEstado->tipoEstadoPago->descripcion !== 'no pagado';
});
}
return array_filter($this->cuotasArray, function(Cuota $cuota) {
return $cuota->pago->currentEstado->tipoEstadoPago->active === 1;
});
}
public function pagado(string $moneda = Pago::UF): float
{