Facturacion
This commit is contained in:
62
app/src/Controller/API/CentrosCostos.php
Normal file
62
app/src/Controller/API/CentrosCostos.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'added' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->create($body);
|
||||
$centroCosto->id = $body['id'];
|
||||
$centroCostoRepository->save($centroCosto);
|
||||
$output['added'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'centro_costo_id' => $centro_costo_id,
|
||||
'input' => $body,
|
||||
'edited' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->fetchById($centro_costo_id);
|
||||
if ($body['tipo_cuenta_id'] === '') {
|
||||
$body['tipo_cuenta_id'] = null;
|
||||
}
|
||||
$centroCostoRepository->edit($centroCosto, $body);
|
||||
$output['edited'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function remove(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'centro_costo_id' => $centro_costo_id,
|
||||
'removed' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->fetchById($centro_costo_id);
|
||||
$centroCostoRepository->remove($centroCosto);
|
||||
$output['removed'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
90
app/src/Controller/API/Nubox.php
Normal file
90
app/src/Controller/API/Nubox.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\HttpResponse;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Nubox
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function token(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'token' => ''
|
||||
];
|
||||
try {
|
||||
$output['token'] = $nuboxService->getToken($inmobiliaria_rut);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function sistemas(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'sistemas' => []
|
||||
];
|
||||
try {
|
||||
$output['sistemas'] = $nuboxService->getSistemas($inmobiliaria_rut);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function libroMayor(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'libro_mayor' => []
|
||||
];
|
||||
try {
|
||||
$from = new DateTimeImmutable($body['inicio']);
|
||||
$to = new DateTimeImmutable($body['termino']);
|
||||
$output['libro_mayor'] = $nuboxService->getLibroMayor($inmobiliaria_rut, $from, $to);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function libroDiario(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'libro_diario' => []
|
||||
];
|
||||
try {
|
||||
$from = new DateTimeImmutable($body['inicio']);
|
||||
$to = new DateTimeImmutable($body['termino']);
|
||||
$output['libro_diario'] = $nuboxService->getLibroDiario($inmobiliaria_rut, $from, $to);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
32
app/src/Controller/CentrosCostos.php
Normal file
32
app/src/Controller/CentrosCostos.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Common\Alias\View;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\CentroCosto $centroCostoRepository,
|
||||
Repository\TipoCentro $tipoCentroRepository,
|
||||
Repository\CategoriaCentro $categoriaCentroRepository,
|
||||
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$tiposCentros = $tipoCentroRepository->fetchAll();
|
||||
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
|
||||
$tiposCuentas = $tipoCuentaRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
|
||||
'tiposCentros', 'categorias', 'tiposCuentas'));
|
||||
}
|
||||
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\CentroCosto $centroCostoRepository,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
|
||||
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
|
||||
}
|
||||
}
|
@ -8,14 +8,18 @@ use Incoviba\Service;
|
||||
|
||||
class Facturacion
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Proyecto $proyectoService): ResponseInterface
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Proyecto $proyectoService): ResponseInterface
|
||||
{
|
||||
$proyectos = $proyectoService->getEscriturando();
|
||||
return $view->render($response, 'ventas.facturacion', compact('proyectos'));
|
||||
}
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Service\Proyecto\Terreno $terrenoService,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.facturacion.show', compact('venta'));
|
||||
$terreno = $terrenoService->valor($venta->proyecto()->id);
|
||||
return $view->render($response, 'ventas.facturacion.show', compact('venta', 'terreno'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user