Merge branch 'develop' into feature/cierres

This commit is contained in:
Juan Pablo Vial
2025-04-11 13:35:13 -04:00
11 changed files with 230 additions and 32 deletions

View File

@ -7,8 +7,9 @@ use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Controller\API\withJson;
use Incoviba\Service;
use Incoviba\Exception\ServiceAction\Update;
use Incoviba\Repository;
use Incoviba\Service;
class Bonos extends Controller
{
@ -39,4 +40,25 @@ class Bonos extends Controller
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function edit(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
Service\Venta\BonoPie $bonoPieService, int $venta_id): ResponseInterface
{
$input = $request->getParsedBody();
$output = [
'venta_id' => $venta_id,
'input' => $input,
'bono' => null,
'success' => false,
];
try {
try {
$venta = $ventaService->getById($venta_id);
} catch (EmptyResult $exception) {
throw new Update(__CLASS__, $exception);
}
$output['bono'] = $bonoPieService->edit($venta->formaPago()->bonoPie, $input);
$output['success'] = true;
} catch (Update) {}
return $this->withJson($response, $output);
}
}