Implemented repository mapper, and venta show
This commit is contained in:
@ -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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user