32 lines
1020 B
PHP
32 lines
1020 B
PHP
<?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);
|
|
}
|
|
}
|