Listado de Movimientos
This commit is contained in:
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||||
|
|
||||||
|
$app->group('/movimientos', function($app) {
|
||||||
|
$app->post('/segment', [Movimientos::class, 'segment']);
|
||||||
|
$app->get('[/]', Movimientos::class);
|
||||||
|
});
|
||||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||||
});
|
});
|
||||||
|
4
app/resources/routes/contabilidad/movimientos.php
Normal file
4
app/resources/routes/contabilidad/movimientos.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Contabilidad\Movimientos;
|
||||||
|
|
||||||
|
$app->get('/movimientos', Movimientos::class);
|
160
app/resources/views/contabilidad/movimientos.blade.php
Normal file
160
app/resources/views/contabilidad/movimientos.blade.php
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
@extends('layout.base')
|
||||||
|
|
||||||
|
@section('page_content')
|
||||||
|
<div class="ui container">
|
||||||
|
<h1 class="ui header">Movimientos Contables</h1>
|
||||||
|
</div>
|
||||||
|
<table id="tabla_movimientos" class="ui table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Sociedad</th>
|
||||||
|
<th>Banco - Cuenta</th>
|
||||||
|
<th>Fecha</th>
|
||||||
|
<th>ISO Fecha</th>
|
||||||
|
<th class="right aligned">Valor</th>
|
||||||
|
<th>Valor</th>
|
||||||
|
<th>Centro de Costo</th>
|
||||||
|
<th>Glosa</th>
|
||||||
|
<th>Detalle</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="movimientos"></tbody>
|
||||||
|
</table>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@include('layout.head.styles.datatables')
|
||||||
|
@include('layout.head.styles.datatables.searchbuilder')
|
||||||
|
@include('layout.head.styles.datatables.buttons')
|
||||||
|
|
||||||
|
@include('layout.body.scripts.datatables')
|
||||||
|
@include('layout.body.scripts.datatables.searchbuilder')
|
||||||
|
@include('layout.body.scripts.datatables.buttons')
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
function getData(table_id, from, amount) {
|
||||||
|
const url = '{{$urls->api}}/contabilidad/movimientos'
|
||||||
|
const movimientos = []
|
||||||
|
return fetchAPI(url).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.json().then(json => {
|
||||||
|
if (json.movimientos.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const formatter = new Intl.NumberFormat('es-CL')
|
||||||
|
const dateFormatter = new Intl.DateTimeFormat('es-CL', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
||||||
|
json.movimientos.forEach(movimiento => {
|
||||||
|
const fecha = new Date(movimiento.fecha)
|
||||||
|
const valor = movimiento.abono - movimiento.cargo
|
||||||
|
movimientos.push([
|
||||||
|
movimiento.cuenta.inmobiliaria.razon,
|
||||||
|
movimiento.cuenta.banco.nombre + ' - ' + movimiento.cuenta.cuenta,
|
||||||
|
dateFormatter.format(fecha),
|
||||||
|
fecha.toISOString(),
|
||||||
|
formatter.format(valor),
|
||||||
|
valor,
|
||||||
|
(movimiento.detalles) ? movimiento.detalles.centro_costo.id + ' - ' + movimiento.detalles.centro_costo.descripcion : '',
|
||||||
|
movimiento.glosa,
|
||||||
|
(movimiento.detalles) ? movimiento.detalles.detalle : ''
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}).then(() => {
|
||||||
|
const table = new DataTable(table_id, {
|
||||||
|
columnDefs: [
|
||||||
|
{targets: 3, visible: false},
|
||||||
|
{targets: 4, className: 'dt-right'},
|
||||||
|
{targets: 5, visible: false}
|
||||||
|
],
|
||||||
|
order: [[3, 'asc']],
|
||||||
|
language: {
|
||||||
|
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||||
|
infoEmpty: 'No hay cuotas ingresadas',
|
||||||
|
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||||
|
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||||
|
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||||
|
search: 'Buscar: ',
|
||||||
|
searchBuilder: {
|
||||||
|
add: 'Filtrar',
|
||||||
|
condition: 'Comparador',
|
||||||
|
clearAll: 'Resetear',
|
||||||
|
delete: 'Eliminar',
|
||||||
|
deleteTitle: 'Eliminar Titulo',
|
||||||
|
data: 'Columna',
|
||||||
|
left: 'Izquierda',
|
||||||
|
leftTitle: 'Titulo Izquierdo',
|
||||||
|
logicAnd: 'Y',
|
||||||
|
logicOr: 'O',
|
||||||
|
right: 'Derecha',
|
||||||
|
rightTitle: 'Titulo Derecho',
|
||||||
|
title: {
|
||||||
|
0: 'Filtros',
|
||||||
|
_: 'Filtros (%d)'
|
||||||
|
},
|
||||||
|
value: 'Opciones',
|
||||||
|
valueJoiner: 'y'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
top1: {
|
||||||
|
searchBuilder: {
|
||||||
|
columns: [0, 1, 2, 4, 6, 7, 8]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
top1End: {
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
extend: 'excelHtml5',
|
||||||
|
className: 'green',
|
||||||
|
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||||
|
title: 'Movimientos Contables',
|
||||||
|
download: 'open',
|
||||||
|
exportOptions: {
|
||||||
|
columns: [0, 1, 2, 5, 6, 7, 8]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: movimientos,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function updateTable(table, from, amount) {
|
||||||
|
const url = '{{$urls->api}}/contabilidad/movimientos'
|
||||||
|
return fetchAPI(url).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.json().then(json => {
|
||||||
|
if (json.movimientos.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
table.clear()
|
||||||
|
const formatter = new Intl.NumberFormat('es-CL')
|
||||||
|
const dateFormatter = new Intl.DateTimeFormat('es-CL', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
||||||
|
json.movimientos.forEach(movimiento => {
|
||||||
|
const fecha = new Date(movimiento.fecha)
|
||||||
|
table.row.add([
|
||||||
|
movimiento.cuenta.inmobiliaria.razon,
|
||||||
|
movimiento.cuenta.banco.nombre + ' - ' + movimiento.cuenta.cuenta,
|
||||||
|
dateFormatter.format(fecha),
|
||||||
|
fecha.toISOString(),
|
||||||
|
formatter.format(movimiento.abono - movimiento.cargo),
|
||||||
|
(movimiento.detalles) ? movimiento.detalles.centro_costo.id + ' - ' + movimiento.detalles.centro_costo.descripcion : '',
|
||||||
|
movimiento.glosa,
|
||||||
|
(movimiento.detalles) ? movimiento.detalles.detalle : ''
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}).then(() => {
|
||||||
|
table.draw()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$(document).ready(() => {
|
||||||
|
getData('#tabla_movimientos', 0, 100)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -18,5 +18,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
||||||
<a class="item" href="{{$urls->base}}/contabilidad/depositos">Depósitos a Plazo</a>
|
<a class="item" href="{{$urls->base}}/contabilidad/depositos">Depósitos a Plazo</a>
|
||||||
|
<a class="item" href="{{$urls->base}}/contabilidad/movimientos">Movimientos</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
{{--<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/jquery.dataTables.min.js"></script>--}}
|
<script type="text/javascript" src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script>
|
||||||
<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/dataTables.min.js"></script>
|
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.semanticui.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.semanticui.min.js"></script>
|
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/dataTables.buttons.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/dataTables.buttons.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.semanticui.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.semanticui.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.colVis.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.colVis.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.html5.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.html5.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.print.min.js"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
@push('page_scripts')
|
||||||
|
<script src="https://cdn.datatables.net/datetime/1.5.2/js/dataTables.dateTime.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/dataTables.searchBuilder.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/searchBuilder.semanticui.js"></script>
|
||||||
|
@endpush
|
@ -1,3 +1,3 @@
|
|||||||
@push('page_styles')
|
@push('page_styles')
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.semanticui.min.css" />
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
@push('page_styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.5.2/css/dataTables.dateTime.min.css" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.7.0/css/searchBuilder.dataTables.min.css" />
|
||||||
|
@endpush
|
@ -47,4 +47,43 @@ class Movimientos extends Ideal\Controller
|
|||||||
} catch (EmptyResult) {}
|
} catch (EmptyResult) {}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Movimiento $movimientoService): ResponseInterface
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'movimientos' => []
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$movimientos = $movimientoService->getAll();
|
||||||
|
$output['movimientos'] = json_decode(json_encode($movimientos), JSON_OBJECT_AS_ARRAY);
|
||||||
|
foreach ($output['movimientos'] as $i => &$arrayMovimiento) {
|
||||||
|
$arrayMovimiento['cuenta'] = json_decode(json_encode($movimientos[$i]->cuenta), JSON_OBJECT_AS_ARRAY);
|
||||||
|
$arrayMovimiento['cuenta']['inmobiliaria'] = json_decode(json_encode($movimientos[$i]->cuenta->inmobiliaria), JSON_OBJECT_AS_ARRAY);
|
||||||
|
if ($arrayMovimiento['detalles'] !== null) {
|
||||||
|
$arrayMovimiento['detalles']['centro_costo'] = $movimientos[$i]->getDetalles()->centroCosto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (EmptyResult) {}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
|
public function segment(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Contabilidad\Movimiento $movimientoService): ResponseInterface
|
||||||
|
{
|
||||||
|
$input = $request->getParsedBody();
|
||||||
|
$output = [
|
||||||
|
'input' => $input,
|
||||||
|
'movimientos' => []
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$movimientos = $movimientoService->getAmountStartingFrom($input['from'], $input['amount']);
|
||||||
|
$output['movimientos'] = json_decode(json_encode($movimientos), JSON_OBJECT_AS_ARRAY);
|
||||||
|
foreach ($output['movimientos'] as $i => &$arrayMovimiento) {
|
||||||
|
$arrayMovimiento['cuenta'] = json_decode(json_encode($movimientos[$i]->cuenta), JSON_OBJECT_AS_ARRAY);
|
||||||
|
$arrayMovimiento['cuenta']['inmobiliaria'] = json_decode(json_encode($movimientos[$i]->cuenta->inmobiliaria), JSON_OBJECT_AS_ARRAY);
|
||||||
|
if ($arrayMovimiento['detalles'] !== null) {
|
||||||
|
$arrayMovimiento['detalles']['centro_costo'] = $movimientos[$i]->getDetalles()->centroCosto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (EmptyResult) {}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
15
app/src/Controller/Contabilidad/Movimientos.php
Normal file
15
app/src/Controller/Contabilidad/Movimientos.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Controller\Contabilidad;
|
||||||
|
|
||||||
|
use Incoviba\Common\Alias\View;
|
||||||
|
use Incoviba\Common\Ideal\Controller;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
|
class Movimientos extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view): ResponseInterface
|
||||||
|
{
|
||||||
|
return $view->render($response, 'contabilidad.movimientos');
|
||||||
|
}
|
||||||
|
}
|
@ -70,4 +70,12 @@ class Movimiento extends Ideal\Repository
|
|||||||
->where('cuenta_id = ? AND fecha = ? AND cargo = ? AND abono = ? AND saldo = ?');
|
->where('cuenta_id = ? AND fecha = ? AND cargo = ? AND abono = ? AND saldo = ?');
|
||||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $cargo, $abono, $saldo]);
|
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $cargo, $abono, $saldo]);
|
||||||
}
|
}
|
||||||
|
public function fetchAmountStartingFrom(int $start, int $amount): array
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select()
|
||||||
|
->from($this->getTable())
|
||||||
|
->limit($amount, $start);
|
||||||
|
return $this->fetchMany($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,18 @@ class Movimiento extends Service
|
|||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAll(null|string|array $ordering = null): array
|
||||||
|
{
|
||||||
|
return array_map([$this, 'process'], $this->movimientoRepository->fetchAll($ordering));
|
||||||
|
}
|
||||||
public function getById(int $movimiento_id): Model\Contabilidad\Movimiento
|
public function getById(int $movimiento_id): Model\Contabilidad\Movimiento
|
||||||
{
|
{
|
||||||
return $this->process($this->movimientoRepository->fetchById($movimiento_id));
|
return $this->process($this->movimientoRepository->fetchById($movimiento_id));
|
||||||
}
|
}
|
||||||
|
public function getAmountStartingFrom(int $start, int $amount): array
|
||||||
|
{
|
||||||
|
return array_map([$this, 'process'], $this->movimientoRepository->fetchAmountStartingFrom($start, $amount));
|
||||||
|
}
|
||||||
public function setDetalles(Model\Contabilidad\Movimiento $movimiento, array $data): Model\Contabilidad\Movimiento
|
public function setDetalles(Model\Contabilidad\Movimiento $movimiento, array $data): Model\Contabilidad\Movimiento
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user