Informe Tesoreria
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
@ -12,24 +13,56 @@ class DAPs extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\DAP $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
Repository\Deposito $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'daps' => []
|
||||
'depositos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($inmobiliaria_rut);
|
||||
$cuentas = $cuentaRepository->fetchByInmobiliaria($inmobiliaria->rut);
|
||||
foreach ($cuentas as $cuenta) {
|
||||
$daps = $dapRepository->fetchByCuenta($cuenta->id);
|
||||
$output['depositos'] = $dapRepository->fetchByCuenta($cuenta->id);
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'status' => false
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$cuenta = $cuentaRepository->fetchByInmobiliariaAndBanco($inmobiliaria->rut, $banco->id);
|
||||
$data = [
|
||||
'id' => $body['id'],
|
||||
'cuenta_id' => $cuenta->id,
|
||||
'capital' => $body['capital'],
|
||||
'futuro' => $body['futuro'],
|
||||
'inicio' => (new DateTimeImmutable($body['inicio']))->format('Y-m-d'),
|
||||
'termino' => (new DateTimeImmutable($body['termino']))->format('Y-m-d')
|
||||
];
|
||||
try {
|
||||
$dapRepository->fetchById($body['id']);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
$dap = $dapRepository->create($data);
|
||||
$dapRepository->save($dap);
|
||||
}
|
||||
$output['status'] = true;
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user