FIX: Banco vacio

This commit is contained in:
Juan Pablo Vial
2024-10-01 17:33:29 -03:00
parent 933e652dac
commit c68b773cbb

View File

@ -84,7 +84,7 @@ 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, public function doAdd(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
Repository\Venta $ventaRepository, int $pie_id): ResponseInterface Repository\Venta $ventaRepository, Service\Valor $valorService, int $pie_id): ResponseInterface
{ {
$body = $request->getParsedBody(); $body = $request->getParsedBody();
$pie = $pieService->getById($pie_id); $pie = $pieService->getById($pie_id);
@ -92,12 +92,15 @@ class Cuotas
$start = count($pie->cuotas(vigentes: true)); $start = count($pie->cuotas(vigentes: true));
$total = $pie->cuotas; $total = $pie->cuotas;
for ($i = $start; $i < $total; $i ++) { for ($i = $start; $i < $total; $i ++) {
if ($body["banco{$i}"] === '') {
continue;
}
$data = [ $data = [
'pie' => $pie->id, 'pie' => $pie->id,
'fecha' => $body["fecha{$i}"], 'fecha' => $body["fecha{$i}"],
'banco' => $body["banco{$i}"], 'banco' => (int) $body["banco{$i}"],
'identificador' => $body["identificador{$i}"], 'identificador' => $body["identificador{$i}"],
'valor' => str_replace(['.', ','], ['', ''], $body["valor{$i}"]), 'valor' => $valorService->clean($body["valor{$i}"]),
'numero' => $i + 1, 'numero' => $i + 1,
]; ];
$pieService->addCuota($data); $pieService->addCuota($data);