FIX: Pie cuotas vigentes

This commit is contained in:
2023-12-22 14:15:09 -03:00
parent 0829d338a9
commit 675b3843ea
7 changed files with 12 additions and 13 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(vigentes: true)); $i ++) @for ($i = count($pie->cuotas(vigentes: true)); $i < $pie->cuotas; $i ++)
<tr> <tr>
<td>{{$i + 1}}</td> <td>{{$i + 1}}</td>
<td> <td>
@ -112,7 +112,7 @@
const index = $(event.currentTarget).data('index') const index = $(event.currentTarget).data('index')
const calendar = $(".fecha.calendar[data-index='" + index + "']") const calendar = $(".fecha.calendar[data-index='" + index + "']")
const fecha = calendar.calendar('get date') const fecha = calendar.calendar('get date')
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) { for (let i = index + 1; i < {{$pie->cuotas}}; i ++) {
setDate(i - index, $(".fecha.calendar[data-index='" + i + "']"), fecha) setDate(i - index, $(".fecha.calendar[data-index='" + i + "']"), fecha)
} }
}) })
@ -120,7 +120,7 @@
$('.copy.banco').click(event => { $('.copy.banco').click(event => {
const index = $(event.currentTarget).data('index') const index = $(event.currentTarget).data('index')
const banco = $(".banco.dropdown[data-index='" + index + "']").dropdown('get value') const banco = $(".banco.dropdown[data-index='" + index + "']").dropdown('get value')
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) { for (let i = index + 1; i < {{$pie->cuotas}}; i ++) {
$(".banco.dropdown[data-index='" + i + "']").dropdown('set selected', banco) $(".banco.dropdown[data-index='" + i + "']").dropdown('set selected', banco)
} }
}) })
@ -133,7 +133,7 @@
$('.copy.valor').click(event => { $('.copy.valor').click(event => {
const index = $(event.currentTarget).data('index') const index = $(event.currentTarget).data('index')
const valor = $("[name='valor" + index + "']").val() const valor = $("[name='valor" + index + "']").val()
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) { for (let i = index + 1; i < {{$pie->cuotas}}; i ++) {
$("[name='valor" + i + "']").val(valor) $("[name='valor" + i + "']").val(valor)
} }
}) })

View File

@ -14,7 +14,7 @@
<td class="right aligned">Cuotas</td> <td class="right aligned">Cuotas</td>
<td> <td>
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas"> <a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
{{count($pie->cuotas(true))}}/{{$pie->cuotas}} <span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
</a> </a>
@if (count($pie->cuotas()) < $pie->cuotas) @if (count($pie->cuotas()) < $pie->cuotas)
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add"> <a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">

View File

@ -20,7 +20,6 @@ class Pies
'input' => $body, 'input' => $body,
'edited' => false 'edited' => false
]; ];
error_log(var_export($output,true).PHP_EOL,3,'/logs/pies');
try { try {
$pie = $pieService->getById($pie_id); $pie = $pieService->getById($pie_id);
$pieService->edit($pie, (array) $body); $pieService->edit($pie, (array) $body);

View File

@ -83,13 +83,14 @@ class Cuotas
}); });
return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos')); return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos'));
} }
public function doAdd(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, int $pie_id): ResponseInterface public function doAdd(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
Repository\Venta $ventaRepository, int $pie_id): ResponseInterface
{ {
$body = $request->getParsedBody(); $body = $request->getParsedBody();
$pie = $pieService->getById($pie_id); $pie = $pieService->getById($pie_id);
$venta = $ventaRepository->fetchByPie($pie_id); $venta = $ventaRepository->fetchByPie($pie_id);
$total = $pie->cuotas - count($pie->cuotas()); $start = count($pie->cuotas(vigentes: true));
$start = count($pie->cuotas()); $total = $pie->cuotas;
for ($i = $start; $i < $total; $i ++) { for ($i = $start; $i < $total; $i ++) {
$data = [ $data = [
'pie' => $pie->id, 'pie' => $pie->id,

View File

@ -27,9 +27,9 @@ class Cuota extends Model
'valor' => $this->valor, 'valor' => $this->valor,
'estado' => $this->estado ?? false, 'estado' => $this->estado ?? false,
'banco' => $this->banco, 'banco' => $this->banco,
'fecha_pago' => $this->fechaPago->format('Y-m-d H:i:s') ?? '', 'fecha_pago' => $this->fechaPago?->format('Y-m-d H:i:s') ?? '',
'abonado' => $this->abonado ?? false, 'abonado' => $this->abonado ?? false,
'fecha_abonado' => $this->fechaAbonado->format('Y-m-d H:i:s') ?? '', 'fecha_abonado' => $this->fechaAbonado?->format('Y-m-d H:i:s') ?? '',
'uf' => $this->uf ?? 1, 'uf' => $this->uf ?? 1,
'pago' => $this->pago ?? '', 'pago' => $this->pago ?? '',
'numero' => $this->numero ?? '' 'numero' => $this->numero ?? ''

View File

@ -29,7 +29,7 @@ class Pie extends Model
}); });
} }
return array_filter($this->cuotasArray, function(Cuota $cuota) { return array_filter($this->cuotasArray, function(Cuota $cuota) {
return $cuota->pago->currentEstado->tipoEstadoPago->active === 1; return $cuota->pago->currentEstado->tipoEstadoPago->activo or $cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'devuelto';
}); });
} }

View File

@ -400,7 +400,6 @@ class Venta
$pago = $venta->resciliacion(); $pago = $venta->resciliacion();
$this->pagoService->delete($pago); $this->pagoService->delete($pago);
$estado = $venta->currentEstado(); $estado = $venta->currentEstado();
error_log(var_export($estado,true));
$this->estadoVentaRepository->remove($estado); $this->estadoVentaRepository->remove($estado);
$this->ventaRepository->edit($venta, ['resciliacion' => null]); $this->ventaRepository->edit($venta, ['resciliacion' => null]);
return true; return true;