Limpieza de input de valor y filtro de datos a nivel Repo
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Model\Venta\Pago;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
@ -26,6 +28,15 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param Repository\Venta\Pago $pagoRepository
|
||||
* @param int $pago_id
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Pago $pagoRepository, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
@ -44,6 +55,16 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param Service\Venta\Pago $pagoService
|
||||
* @param Service\Format $formatService
|
||||
* @param int $pago_id
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Pago $pagoService, Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
@ -63,6 +84,16 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param Service\Venta\Pago $pagoService
|
||||
* @param Service\Format $formatService
|
||||
* @param int $pago_id
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
@ -83,6 +114,15 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param Service\Venta\Pago $pagoService
|
||||
* @param int $pago_id
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function devolver(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
@ -102,34 +142,49 @@ class Pagos
|
||||
public function para_pendientes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getPendientes();
|
||||
$pagos_pendientes = [];
|
||||
$pagos_pendientes = array_map(function(Pago $pago) {
|
||||
return [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}, $pagos);
|
||||
/*$pagos_pendientes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_pendientes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
}*/
|
||||
return $this->withJson($response, ['pagos' => $pagos_pendientes, 'total' => count($pagos_pendientes)]);
|
||||
}
|
||||
public function para_abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getDepositados();
|
||||
$pagos_depositados = [];
|
||||
$pagos_depositados = array_map(function(Pago $pago) {
|
||||
return [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}, $pagos);
|
||||
/*$pagos_depositados = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_depositados []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
}*/
|
||||
return $this->withJson($response, ['pagos' => $pagos_depositados, 'total' => count($pagos_depositados)]);
|
||||
}
|
||||
public function rebotes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getRebotes();
|
||||
$rebotes = [];
|
||||
$rebotes = array_map(function(Pago $pago) {
|
||||
return [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}, $pagos);
|
||||
/*$rebotes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$rebotes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
}*/
|
||||
return $this->withJson($response, ['pagos' => $rebotes, 'total' => count($rebotes)]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user