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> </tr>
</thead> </thead>
<tbody id="cuotas"> <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> <tr>
<td>{{$i + 1}}</td> <td>{{$i + 1}}</td>
<td> <td>

View File

@ -15,16 +15,21 @@ class Pie extends Model
public ?Pago $reajuste; public ?Pago $reajuste;
public array $cuotasArray; public array $cuotasArray;
public function cuotas(bool $pagadas = false): array public function cuotas(bool $pagadas = false, bool $vigentes = false): array
{ {
if ($this->asociado !== null) { if ($this->asociado !== null) {
return $this->asociado->cuotas($pagadas); return $this->asociado->cuotas($pagadas);
} }
if (!$pagadas) { if (!$pagadas and !$vigentes) {
return $this->cuotasArray; 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 array_filter($this->cuotasArray, function(Cuota $cuota) {
return $cuota->pago->currentEstado->tipoEstadoPago->descripcion !== 'no pagado'; return $cuota->pago->currentEstado->tipoEstadoPago->active === 1;
}); });
} }