Editar credito

This commit is contained in:
Juan Pablo Vial
2024-02-15 18:57:56 -03:00
parent 1621d6fe30
commit 51cabee824
10 changed files with 383 additions and 15 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace Incoviba\Controller\API\Ventas;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Controller\API\withJson;
use Incoviba\Service;
class Creditos extends Controller
{
use withJson;
public function edit(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
Service\Venta\Credito $creditoService, int $venta_id): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
'input' => $body,
'credito' => null,
'status' => false
];
try {
$venta = $ventaService->getById($venta_id);
$output['credito'] = $creditoService->edit($venta->formaPago()->credito, $body);
$output['status'] = true;
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
}