Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -3,6 +3,7 @@ namespace Incoviba\Controller\Ventas;
use DateTimeImmutable;
use DateInterval;
use Incoviba\Common\Implement\Exception\EmptyResult;
use IntlDateFormatter;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@ -44,16 +45,19 @@ class Cuotas
}
return $view->render($response, 'ventas.cuotas.pendientes', compact('cuotas_pendientes'));
}
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Ventas\Pago $pagoService): ResponseInterface
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Venta\Pago $pagoService): ResponseInterface
{
$body = $request->getBody();
$json = json_decode($body->getContents());
$cuota_id = $json->cuota_id;
$cuota = $cuotaRepository->fetchById($cuota_id);
$output = [
'cuota_id' => $cuota_id,
'depositada' => $pagoService->depositar($cuota->pago)
'depositada' => false
];
try{
$cuota = $cuotaRepository->fetchById($cuota_id);
$output['depositada'] = $pagoService->depositar($cuota->pago);
} catch (EmptyResult) {}
$response->getBody()->write(json_encode($output));
return $response->withHeader('Content-Type', 'application/json');
}