Files
oficial/app/src/Controller/API/Ventas/Creditos.php

32 lines
1020 B
PHP
Raw Normal View History

2024-02-15 18:57:56 -03:00
<?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);
}
}