Fecha cuota
This commit is contained in:
@ -13,6 +13,19 @@ class Pagos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function get(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'pago' => null
|
||||
];
|
||||
try {
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Pago $pagoRepository, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
@ -31,33 +44,41 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Pago $pagoService, Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'depositado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['depositado'] = $pagoService->depositar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'abonado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['abonado'] = $pagoService->abonar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
$output['input']['fecha'] = $fecha->format('d-m-Y');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
|
Reference in New Issue
Block a user