Compare commits
17 Commits
2.1.21
...
82647a171d
Author | SHA1 | Date | |
---|---|---|---|
82647a171d | |||
e44ab30665 | |||
19333bc338 | |||
4738dae7c8 | |||
a370ffff43 | |||
88f9e539f7 | |||
671b26f038 | |||
e133bd36cf | |||
251dbbe0f0 | |||
e1eb2c4c56 | |||
1078f4c188 | |||
38962cb9cf | |||
3cd699d2e2 | |||
d8b8787be9 | |||
62edca5335 | |||
ac6c5b7d3d | |||
5b5a0ed1f5 |
@ -1,16 +1,19 @@
|
||||
FROM php:8.2-fpm
|
||||
FROM php:8.2-cli
|
||||
|
||||
ENV TZ "America/Santiago"
|
||||
ENV TZ "${TZ}"
|
||||
ENV APP_NAME "${APP_NAME}"
|
||||
ENV API_URL "${API_URL}"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron && rm -r /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN pecl install xdebug-3.2.2 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
|
||||
WORKDIR /code/bin
|
||||
|
||||
COPY ./cli/crontab /var/spool/cron/crontabs/root
|
||||
COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root
|
||||
|
||||
CMD ["cron", "-f"]
|
||||
CMD [ "/root/entrypoint" ]
|
||||
|
@ -2,9 +2,10 @@
|
||||
namespace Incoviba\Common\Ideal\Cartola;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
abstract class Banco implements Define\Cartola\Banco
|
||||
abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
@ -14,6 +15,9 @@ abstract class Banco implements Define\Cartola\Banco
|
||||
foreach ($data as $row) {
|
||||
$r = [];
|
||||
foreach ($columns as $old => $new) {
|
||||
if (!isset($row[$old])) {
|
||||
continue;
|
||||
}
|
||||
$r[$new] = $row[$old];
|
||||
}
|
||||
$temp []= $r;
|
||||
|
@ -1,9 +1,13 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad;
|
||||
use Incoviba\Controller\API\Contabilidad\Cartolas;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->post('/procesar[/]', [Contabilidad::class, 'procesarCartola']);
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'procesar']);
|
||||
});
|
||||
$app->group('/cartola', function($app) {
|
||||
$app->post('/exportar[/]', [Contabilidad::class, 'exportarCartola']);
|
||||
$app->group('/diaria', function($app) {
|
||||
$app->post('/ayer[/]', [Cartolas::class, 'ayer']);
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'diaria']);
|
||||
});
|
||||
$app->post('/exportar[/]', [Cartolas::class, 'exportar']);
|
||||
});
|
||||
|
7
app/resources/routes/api/contabilidad/daps.php
Normal file
7
app/resources/routes/api/contabilidad/daps.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\DAPs;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->post('/add[/]', [DAPs::class, 'add']);
|
||||
$app->get('/inmobiliaria/{inmobiliaria_rut}[/]', [DAPs::class, 'inmobiliaria']);
|
||||
});
|
6
app/resources/routes/contabilidad/cartolas.php
Normal file
6
app/resources/routes/contabilidad/cartolas.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
||||
});
|
6
app/resources/routes/contabilidad/daps.php
Normal file
6
app/resources/routes/contabilidad/daps.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->get('[/]', [Contabilidad::class, 'depositos']);
|
||||
});
|
10
app/resources/routes/contabilidad/informes.php
Normal file
10
app/resources/routes/contabilidad/informes.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/informes', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'informes']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/tesoreria', function($app) {
|
||||
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
||||
});
|
323
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
323
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
@ -0,0 +1,323 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Cartola Diaria
|
||||
</h1>
|
||||
<form class="ui form" id="cartola_form">
|
||||
<div class="fields">
|
||||
<div class="six wide field">
|
||||
<label for="inmobiliaria">Sociedad</label>
|
||||
<div class="ui search selection dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria_rut" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide field">
|
||||
<label>Banco</label>
|
||||
<div class="ui selection search dropdown" id="banco">
|
||||
<input type="hidden" name="banco_id"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<label for="fecha">Fecha</label>
|
||||
<div class="ui calendar" id="fecha">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="file">Cartola</label>
|
||||
<input type="file" name="file" id="file" class="ui invisible file input" />
|
||||
<label for="file" class="ui icon button">
|
||||
<i class="file icon"></i>
|
||||
Cargar
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="ui two columns grid">
|
||||
<div class="column">
|
||||
<button class="ui icon button" id="process_button">
|
||||
<i class="file excel icon"></i>
|
||||
Procesar
|
||||
</button>
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui inline active loader" id="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui table" id="diferencia">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hoy</th>
|
||||
<th>Último Saldo</th>
|
||||
<th>Saldo Actual</th>
|
||||
<th>Diferencia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui fluid container">
|
||||
<table class="ui table" id="tabla_movimientos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha</th>
|
||||
<th>Glosa</th>
|
||||
<th>Documento</th>
|
||||
<th class="right aligned">Cargo</th>
|
||||
<th class="right aligned">Abono</th>
|
||||
<th class="right aligned">Saldo</th>
|
||||
<th>Orden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const diaria = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: 0,
|
||||
nombre: ''
|
||||
},
|
||||
fecha: '',
|
||||
movimientos: [],
|
||||
saldo: 0,
|
||||
ayer: 0
|
||||
},
|
||||
dataTableConfig: {
|
||||
order: [[6, 'asc']],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [0, 2, 3, 4, 5],
|
||||
width: '10%'
|
||||
},
|
||||
{
|
||||
targets: [1],
|
||||
width: '20%'
|
||||
},
|
||||
{
|
||||
targets: [6],
|
||||
visible: false
|
||||
}
|
||||
],
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
$(this.ids.loader).show()
|
||||
return fetchAPI(url).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.form.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {
|
||||
value: cuenta.banco.id,
|
||||
text: cuenta.banco.nombre,
|
||||
name: cuenta.banco.nombre
|
||||
}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
ayer: (inmobiliaria_rut, banco_id, fecha) => {
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/ayer'
|
||||
const body = new FormData()
|
||||
body.set('inmobiliaria_rut', inmobiliaria_rut)
|
||||
body.set('banco_id', banco_id)
|
||||
body.set('fecha', fecha.toISOString())
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
this.data.ayer = json.cartola.saldo
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
cartola: event => {
|
||||
event.preventDefault()
|
||||
const body = new FormData(document.getElementById('cartola_form'))
|
||||
const fecha = $('#fecha').calendar('get date')
|
||||
body.set('fecha', [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-'))
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/procesar'
|
||||
$(this.ids.loader).show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cartola.movimientos.length === 0) {
|
||||
return
|
||||
}
|
||||
this.data.movimientos = []
|
||||
json.cartola.movimientos.forEach((row, idx) => {
|
||||
const fecha = new Date(row.fecha)
|
||||
fecha.setDate(fecha.getDate() + 1)
|
||||
this.data.movimientos[idx] = {
|
||||
fecha: fecha,
|
||||
glosa: row.glosa,
|
||||
documento: row.documento,
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
saldo: row.saldo
|
||||
}
|
||||
})
|
||||
this.data.saldo = json.cartola.cartola.saldo
|
||||
const ayer = new Date()
|
||||
ayer.setDate(fecha.getDate() - 1)
|
||||
this.get().ayer(body.get('inmobiliaria_rut'), body.get('banco_id'), ayer)
|
||||
.then(() => {
|
||||
this.draw().diferencia()
|
||||
this.draw().cartola()
|
||||
})
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
diferencia: () => {
|
||||
const table = $(this.ids.table.diferencia)
|
||||
const tbody = table.find('tbody')
|
||||
tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(dateFormatter.format(this.data.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.data.ayer))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.data.saldo))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.data.saldo - this.data.ayer))
|
||||
)
|
||||
)
|
||||
},
|
||||
cartola: () => {
|
||||
const table = $(this.ids.table.base)
|
||||
table.DataTable().clear()
|
||||
table.DataTable().destroy()
|
||||
const tbody = $(this.ids.table.body)
|
||||
tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.movimientos.forEach((row, idx) => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(dateFormatter.format(row.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(row.glosa)
|
||||
).append(
|
||||
$('<td></td>').html(row.documento)
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').html(row.cargo === 0 ? '' : numberFormatter.format(row.cargo))
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').html(row.abono === 0 ? '' : numberFormatter.format(row.abono))
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').html(row.saldo === 0 ? '' : numberFormatter.format(row.saldo))
|
||||
).append(
|
||||
$('<td></td>').html(idx + 1)
|
||||
)
|
||||
)
|
||||
})
|
||||
table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
$(this.ids.form.inmobiliaria).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
},
|
||||
})
|
||||
$(this.ids.form.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.loader).hide()
|
||||
|
||||
calendar_date_options['initialDate'] = new Date()
|
||||
calendar_date_options['maxDate'] = calendar_date_options['initialDate']
|
||||
calendar_date_options['onChange'] = (date, text, mode) => {
|
||||
this.data.fecha = date
|
||||
}
|
||||
$(this.ids.form.fecha).calendar(calendar_date_options)
|
||||
$(this.ids.form.base).submit(this.parse().cartola)
|
||||
$(this.ids.button).click(this.parse().cartola)
|
||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
diaria.setup({
|
||||
table: {
|
||||
base: '#tabla_movimientos',
|
||||
body: '#movimientos',
|
||||
diferencia: '#diferencia'
|
||||
},
|
||||
form: {
|
||||
base: '#cartola_form',
|
||||
inmobiliaria: '#inmobiliaria',
|
||||
banco: '#banco',
|
||||
fecha: '#fecha'
|
||||
},
|
||||
button: '#process_button',
|
||||
loader: '#loader'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
235
app/resources/views/contabilidad/depositos.blade.php
Normal file
235
app/resources/views/contabilidad/depositos.blade.php
Normal file
@ -0,0 +1,235 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Depósitos a Plazo</h1>
|
||||
|
||||
<table class="ui table" id="depositos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inmobiliaria</th>
|
||||
<th>Banco</th>
|
||||
<th>N° Depósito</th>
|
||||
<th>Capital</th>
|
||||
<th>Inicio</th>
|
||||
<th>Plazo</th>
|
||||
<th>Vencimiento</th>
|
||||
<th>Monto al Vencimiento</th>
|
||||
<th>Tasa</th>
|
||||
<th>
|
||||
<button class="ui green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($depositos as $deposito)
|
||||
<tr>
|
||||
<td>{{$deposito->cuenta->inmobiliaria->razon}}</td>
|
||||
<td>{{$deposito->cuenta->banco->nombre}}</td>
|
||||
<td>{{$deposito->id}}</td>
|
||||
<td>{{$format->pesos($deposito->capital)}}</td>
|
||||
<td>{{$deposito->inicio->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->plazo()}}</td>
|
||||
<td>{{$deposito->termino->format('d-m-Y')}}</td>
|
||||
<td>{{$format->pesos($deposito->futuro)}}</td>
|
||||
<td>{{$format->percent($deposito->tasa() * 100, 4)}}</td>
|
||||
<td>
|
||||
<button class="ui red icon button remove_button" data-deposito="{{$deposito->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="add_modal">
|
||||
<div class="content">
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inmobiliaria">Inmobiliaria</label>
|
||||
<div class="ui search selection dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria_rut" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="banco">Banco</label>
|
||||
<div class="ui search selection dropdown" id="banco">
|
||||
<input type="hidden" name="banco_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="identificador">N° Depósito</label>
|
||||
<input type="text" id="identificador" name="id" />
|
||||
</div>
|
||||
<div class="three fields">
|
||||
<div class="field">
|
||||
<label for="capital">Capital</label>
|
||||
<input type="number" id="capital" name="capital" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="futuro">Monto al Vencimiento</label>
|
||||
<input type="number" id="futuro" name="futuro" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inicio">Inicio</label>
|
||||
<div class="ui calendar" id="inicio">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="inicio" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="termino">Vencimiento</label>
|
||||
<div class="ui calendar" id="termino">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="termino" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const depositos = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: 0,
|
||||
nombre: ''
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.forms.add.bancos).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
add() {
|
||||
return {
|
||||
deposito: form => {
|
||||
const url = '{{$urls->api}}/contabilidad/depositos/add'
|
||||
const body = new FormData(form)
|
||||
const inicio = $(this.ids.forms.add.inicio).calendar('get date')
|
||||
const termino = $(this.ids.forms.add.termino).calendar('get date')
|
||||
body.set('inicio', [inicio.getFullYear(), inicio.getMonth()+1, inicio.getDate()].join('-'))
|
||||
body.set('termino', [termino.getFullYear(), termino.getMonth()+1, termino.getDate()].join('-'))
|
||||
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.status) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.buttons.add).click(event => {
|
||||
$(this.ids.modals.add).modal('show')
|
||||
})
|
||||
$(this.ids.modals.add).modal({
|
||||
onApprove: $element => {
|
||||
$(this.ids.forms.add.base).submit()
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.base).submit(event => {
|
||||
event.preventDefault()
|
||||
this.add().deposito(event.currentTarget)
|
||||
return false
|
||||
})
|
||||
$(this.ids.forms.add.inmobiliarias).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.inicio).calendar(calendar_date_options)
|
||||
$(this.ids.forms.add.termino).calendar(calendar_date_options)
|
||||
|
||||
$(this.ids.table).dataTable()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
depositos.setup({
|
||||
table: '#depositos',
|
||||
buttons: {
|
||||
add: '#add_button'
|
||||
},
|
||||
modals: {
|
||||
add: '#add_modal'
|
||||
},
|
||||
forms: {
|
||||
add: {
|
||||
base: '#add_form',
|
||||
inmobiliarias: '#inmobiliaria',
|
||||
bancos: '#banco',
|
||||
inicio: '#inicio',
|
||||
termino: '#termino'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
147
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
147
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
@ -0,0 +1,147 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
||||
</div>
|
||||
<div class="ui grid">
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Informe anterior</td>
|
||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Informe actual</td>
|
||||
<td>{{$fecha->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Valor UF</td>
|
||||
<td class="right aligned">{{$format->pesos($UF->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Valor Dólar</td>
|
||||
<td class="right aligned">{{$format->pesos($USD->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui striped table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th>Banco</th>
|
||||
<th>Cuenta</th>
|
||||
<th class="right aligned">Saldo Anterior</th>
|
||||
<th class="right aligned">Saldo Actual</th>
|
||||
<th class="right aligned">Diferencia</th>
|
||||
<th class="right aligned">FFMM</th>
|
||||
<th class="right aligned">DAP</th>
|
||||
<th class="right aligned">Saldo Empresa</th>
|
||||
<th class="right aligned">Total Cuentas</th>
|
||||
<th class="right aligned">Total FFMM</th>
|
||||
<th class="right aligned">Total DAP</th>
|
||||
<th class="right aligned">Caja Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['inmobiliarias'] as $inmobiliaria_rut => $informe)
|
||||
@foreach ($informe->cuentas as $i => $cuenta)
|
||||
<tr>
|
||||
@if ($i === 0)
|
||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
||||
@endif
|
||||
<td>{{$cuenta->banco}}</td>
|
||||
<td>{{$cuenta->numero}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->anterior)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->actual)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->diferencia())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->ffmm)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->deposito)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->saldo())}}</td>
|
||||
@if ($i === 0)
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->total())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->ffmm())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->deposito())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->caja())}}</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="bold">
|
||||
<th colspan="3">TOTAL</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->anterior)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->actual)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->diferencia())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmm)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->deposito)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->saldo())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->cuentas())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmms())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->depositos())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->caja())}}</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th class="right aligned">INGRESOS</th>
|
||||
<th class="right aligned">EGRESOS</th>
|
||||
<th>FECHA</th>
|
||||
<th>BANCO</th>
|
||||
<th>DESCRIPCIÓN</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['movimientos'] as $tipo => $movimientos)
|
||||
@if ($tipo === 'capital dap')
|
||||
@if (count($movimientos['ingresos']) === 0 and count($movimientos['egresos']) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $t => $ms)
|
||||
@foreach ($ms as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@continue
|
||||
@endif
|
||||
@if (count($movimientos) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
@ -2,6 +2,13 @@
|
||||
Contabilidad
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
Informes
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/informes/tesoreria">Tesorería</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
<a class="text" href="{{$urls->base}}/contabilidad/centros_costos">Centros de Costos</a>
|
||||
@ -9,5 +16,7 @@
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<form id="search_form" class="ui form" action="{{$urls->base}}/search" method="post">
|
||||
<div class="field">
|
||||
<div class="ui fluid input" data-tooltip="Para buscar frases se deben encerrar entre comillas. ej, 'portal la viña' o "portal la viña"" data-position="bottom left">
|
||||
<div class="ui fluid input" data-tooltip="Para buscar frases se deben encerrar entre comillas. ej, 'portal la viña' o "portal la viña"" data-position="top right">
|
||||
<input type="text" name="query" />
|
||||
</div>
|
||||
</div>
|
||||
@ -56,7 +56,7 @@
|
||||
unidad.html(unidad.html() + ' (I)')
|
||||
}
|
||||
propietario = $('<a></a>')
|
||||
.attr('href','{{$urls->base}}/search/' + encodeURIComponent(this.venta.propietario.nombre_completo) + '/propietario')
|
||||
.attr('href','{{$urls->base}}/search/"' + encodeURIComponent(this.venta.propietario.nombre_completo) + '"/propietario')
|
||||
.html(this.venta.propietario.nombre_completo)
|
||||
fecha = dateFormatter.format(new Date(this.venta.fecha))
|
||||
if (typeof this.venta.entrega !== 'undefined') {
|
||||
@ -309,15 +309,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
set: function() {
|
||||
return {
|
||||
query: value => {
|
||||
$("[name='query']").val(value)
|
||||
this.get().results()
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.get().results()
|
||||
|
||||
$('#tipo').dropdown().dropdown('set selected', '*')
|
||||
@if (trim($post) !== '')
|
||||
$("[name='query']").val('{{$post}}')
|
||||
this.set().query('{!! $post !!}')
|
||||
@elseif (trim($query) !== '')
|
||||
$("[name='query']").val('{{$query}}')
|
||||
this.set().query('{!! $query !!}')
|
||||
@endif
|
||||
@if (trim($tipo) !== '')
|
||||
$('#tipo').dropdown('set selected', '{{$tipo}}')
|
||||
|
@ -4,10 +4,10 @@ use Psr\Container\ContainerInterface;
|
||||
return [
|
||||
Incoviba\Common\Define\Database::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Common\Implement\Database\MySQL(
|
||||
$container->has('MYSQL_HOST') ? $container->get('MYSQL_HOST') : 'db',
|
||||
$container->get('MYSQL_DATABASE'),
|
||||
$container->get('MYSQL_USER'),
|
||||
$container->get('MYSQL_PASSWORD')
|
||||
$container->has('DB_HOST') ? $container->get('DB_HOST') : 'db',
|
||||
$container->get('DB_DATABASE'),
|
||||
$container->get('DB_USER'),
|
||||
$container->get('DB_PASSWORD')
|
||||
);
|
||||
},
|
||||
Incoviba\Common\Define\Connection::class => function(ContainerInterface $container) {
|
||||
|
@ -20,7 +20,9 @@ return [
|
||||
$ine = new Incoviba\Service\Money\Ine(new GuzzleHttp\Client([
|
||||
'base_uri' => 'https://api-calculadora.ine.cl/ServiciosCalculadoraVariacion'
|
||||
]));
|
||||
return (new Incoviba\Service\Money())->register('uf', $mindicador)
|
||||
return (new Incoviba\Service\Money($container->get(Psr\Log\LoggerInterface::class)))
|
||||
->register('uf', $mindicador)
|
||||
->register('usd', $mindicador)
|
||||
->register('ipc', $ine);
|
||||
},
|
||||
Predis\Client::class => function(ContainerInterface $container) {
|
||||
@ -32,8 +34,13 @@ return [
|
||||
},
|
||||
Incoviba\Service\Cartola::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Cartola(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Psr\Http\Message\StreamFactoryInterface::class),
|
||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class)
|
||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
|
||||
$container->get(Incoviba\Repository\Movimiento::class),
|
||||
$container->get(Incoviba\Repository\Cartola::class)
|
||||
))
|
||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
||||
@ -48,6 +55,7 @@ return [
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Nubox::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Nubox(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Incoviba\Repository\Nubox::class),
|
||||
$container->get(Incoviba\Service\Redis::class),
|
||||
new GuzzleHttp\Client(),
|
||||
|
@ -11,6 +11,7 @@ return [
|
||||
'format' => $container->get(Incoviba\Service\Format::class),
|
||||
'API_KEY' => $container->get('API_KEY'),
|
||||
'UF' => $container->get(Incoviba\Service\UF::class),
|
||||
'USD' => $container->get(Incoviba\Service\USD::class),
|
||||
'IPC' => $container->get(Incoviba\Service\IPC::class)
|
||||
];
|
||||
if ($global_variables['login']->isIn()) {
|
||||
|
@ -2,51 +2,16 @@
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Contabilidad
|
||||
class Contabilidad extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesarCartola(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['movimientos'] = $cartolaService->process($inmobiliaria, $banco, $mes, $file);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function exportarCartola(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'filename' => ''
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$output['filename'] = $cartolaService->export($inmobiliaria, $banco, $mes, json_decode($body['movimientos']));
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Cartolas extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['movimientos'] = $cartolaService->process($inmobiliaria, $banco, $mes, $file);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'filename' => ''
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$output['filename'] = $cartolaService->export($inmobiliaria, $banco, $mes, json_decode($body['movimientos']));
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['cartola'] = $cartolaService->diaria($inmobiliaria, $banco, $fecha, $file);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->debug($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Cartola $cartolaRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$cuenta = $cuentaRepository->fetchByInmobiliariaAndBanco($inmobiliaria->rut, $banco->id);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['cartola'] = $cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->critical($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
68
app/src/Controller/API/Contabilidad/DAPs.php
Normal file
68
app/src/Controller/API/Contabilidad/DAPs.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class DAPs extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Deposito $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'depositos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($inmobiliaria_rut);
|
||||
$cuentas = $cuentaRepository->fetchByInmobiliaria($inmobiliaria->rut);
|
||||
foreach ($cuentas as $cuenta) {
|
||||
$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);
|
||||
}
|
||||
}
|
64
app/src/Controller/Contabilidad.php
Normal file
64
app/src/Controller/Contabilidad.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyResult, EmptyRedis};
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Contabilidad extends Controller
|
||||
{
|
||||
use withRedis;
|
||||
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive();
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias'));
|
||||
}
|
||||
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive();
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
$depositos = [];
|
||||
try {
|
||||
$depositos = $dapRepository->fetchAll();
|
||||
} catch (EmptyResult) {}
|
||||
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'depositos'));
|
||||
}
|
||||
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Contabilidad\Informe\Tesoreria $contabilidadService,
|
||||
string $fecha = 'today'): ResponseInterface
|
||||
{
|
||||
$fecha = new DateTimeImmutable($fecha);
|
||||
$anterior = $contabilidadService->getAnterior($fecha);
|
||||
$informes = $contabilidadService->build($fecha);
|
||||
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'informes'));
|
||||
}
|
||||
}
|
26
app/src/Model/Cartola.php
Normal file
26
app/src/Model/Cartola.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Cartola extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public DateTimeInterface $fecha;
|
||||
|
||||
public int $cargos = 0;
|
||||
public int $abonos = 0;
|
||||
public int $saldo = 0;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'cargos' => $this->cargos,
|
||||
'abonos' => $this->abonos,
|
||||
'saldo' => $this->saldo
|
||||
]);
|
||||
}
|
||||
}
|
36
app/src/Model/Deposito.php
Normal file
36
app/src/Model/Deposito.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Deposito extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public int $capital;
|
||||
public int $futuro;
|
||||
public DateTimeInterface $inicio;
|
||||
public DateTimeInterface $termino;
|
||||
|
||||
public function plazo(): int
|
||||
{
|
||||
return $this->termino->diff($this->inicio)->days;
|
||||
}
|
||||
public function tasa(): float
|
||||
{
|
||||
return ($this->futuro - $this->capital) / $this->capital;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'capital' => $this->capital,
|
||||
'futuro' => $this->futuro,
|
||||
'inicio' => $this->inicio->format('Y-m-d'),
|
||||
'termino' => $this->termino->format('Y-m-d'),
|
||||
'plazo' => $this->plazo(),
|
||||
'tasa' => $this->tasa()
|
||||
]);
|
||||
}
|
||||
}
|
29
app/src/Model/Movimiento.php
Normal file
29
app/src/Model/Movimiento.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Movimiento extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public DateTimeInterface $fecha;
|
||||
public string $glosa;
|
||||
public string $documento;
|
||||
public int $cargo;
|
||||
public int $abono;
|
||||
public int $saldo;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'glosa' => $this->glosa,
|
||||
'documento' => $this->documento,
|
||||
'cargo' => $this->cargo,
|
||||
'abono' => $this->abono,
|
||||
'saldo' => $this->saldo
|
||||
]);
|
||||
}
|
||||
}
|
68
app/src/Repository/Cartola.php
Normal file
68
app/src/Repository/Cartola.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Cartola extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Repository\Inmobiliaria\Cuenta $cuentaRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('cartolas');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Cartola
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['cargos', 'abonos', 'saldo']))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
->register('cuenta_id', (new Implement\Repository\Mapper())
|
||||
->setProperty('cuenta')
|
||||
->setFunction(function($data) {
|
||||
return $this->cuentaRepository->fetchById($data['cuenta_id']);
|
||||
}));
|
||||
return $this->parseData(new Model\Cartola(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Cartola
|
||||
{
|
||||
$model->id = $this->saveNew([
|
||||
'cuenta_id',
|
||||
'fecha',
|
||||
'cargos',
|
||||
'abonos',
|
||||
'saldo'
|
||||
], [
|
||||
$model->cuenta->id,
|
||||
$model->fecha->format('Y-m-d'),
|
||||
$model->cargos,
|
||||
$model->abonos,
|
||||
$model->saldo
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Cartola
|
||||
{
|
||||
return $this->update($model, ['cuenta_id', 'fecha', 'cargos', 'abonos', 'saldo'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByFecha(DateTimeInterface $fecha): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('fecha = ?');
|
||||
return $this->fetchMany($query, [$fecha->format('Y-m-d')]);
|
||||
}
|
||||
public function fetchByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): Model\Cartola
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('cuenta_id = ? AND fecha = ?');
|
||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||
}
|
||||
}
|
54
app/src/Repository/Deposito.php
Normal file
54
app/src/Repository/Deposito.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Deposito extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Repository\Inmobiliaria\Cuenta $cuentaRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('depositos');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Deposito
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['id', 'capital', 'futuro']))
|
||||
->register('cuenta_id', (new Implement\Repository\Mapper())
|
||||
->setProperty('cuenta')
|
||||
->setFunction(function(array $data) {
|
||||
return $this->cuentaRepository->fetchById($data['cuenta_id']);
|
||||
}))
|
||||
->register('inicio', new Implement\Repository\Mapper\DateTime('inicio'))
|
||||
->register('termino', new Implement\Repository\Mapper\DateTime('termino'));
|
||||
return $this->parseData(new Model\Deposito(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Deposito
|
||||
{
|
||||
$this->saveNew([
|
||||
'id', 'cuenta_id', 'capital', 'futuro', 'inicio', 'termino'
|
||||
], [
|
||||
$model->id, $model->cuenta->id, $model->capital, $model->futuro,
|
||||
$model->inicio->format('Y-m-d'), $model->termino->format('Y-m-d')
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function edit(Define\Model $model, array $new_data): Model\Deposito
|
||||
{
|
||||
return $this->update($model, ['cuenta_id', 'capital', 'futuro', 'inicio', 'termino'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByCuenta(int $cuenta_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('cuenta_id = ?');
|
||||
return $this->fetchMany($query, [$cuenta_id]);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ use Incoviba\Common\Ideal;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Common\Implement;
|
||||
use PhpParser\Node\Expr\BinaryOp\Mod;
|
||||
|
||||
class Cuenta extends Ideal\Repository
|
||||
{
|
||||
@ -49,4 +50,12 @@ class Cuenta extends Ideal\Repository
|
||||
->where('inmobiliaria = ?');
|
||||
return $this->fetchMany($query, [$inmobiliaria_rut]);
|
||||
}
|
||||
public function fetchByInmobiliariaAndBanco(int $inmobiliaria_rut, int $banco_id): Model\Inmobiliaria\Cuenta
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('inmobiliaria = ? AND banco = ?');
|
||||
return $this->fetchOne($query, [$inmobiliaria_rut, $banco_id]);
|
||||
}
|
||||
}
|
||||
|
72
app/src/Repository/Movimiento.php
Normal file
72
app/src/Repository/Movimiento.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Movimiento extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Inmobiliaria\Cuenta $cuentaRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('movimientos');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Movimiento
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['cargo', 'abono', 'saldo', 'glosa', 'documento']))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
->register('cuenta_id', (new Implement\Repository\Mapper())
|
||||
->setProperty('cuenta')
|
||||
->setFunction(function($data) {
|
||||
return $this->cuentaRepository->fetchById($data['cuenta_id']);
|
||||
})
|
||||
);
|
||||
return $this->parseData(new Model\Movimiento(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Movimiento
|
||||
{
|
||||
$model->id = $this->saveNew([
|
||||
'cuenta_id',
|
||||
'fecha',
|
||||
'glosa',
|
||||
'documento',
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo'
|
||||
], [
|
||||
$model->cuenta->id,
|
||||
$model->fecha->format('Y-m-d'),
|
||||
$model->glosa,
|
||||
$model->documento,
|
||||
$model->cargo,
|
||||
$model->abono,
|
||||
$model->saldo
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Movimiento
|
||||
{
|
||||
return $this->update($model, ['cuenta_id', 'fecha', 'glosa', 'documento', 'cargo', 'abono', 'saldo'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('cuenta_id = ? AND fecha = ?');
|
||||
return $this->fetchMany($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||
}
|
||||
public function fetchByCuentaAndFechaAndMonto(int $cuenta_id, DateTimeInterface $fecha, int $monto): Model\Movimiento
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('cuenta_id = ? AND fecha = ? AND (cargo = ? OR abono = ?)');
|
||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $monto, $monto]);
|
||||
}
|
||||
}
|
@ -2,15 +2,28 @@
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Define\Cartola\Banco;
|
||||
use Incoviba\Common\Define\Contabilidad\Exporter;
|
||||
use Incoviba\Common\Implement\Exception;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Cartola
|
||||
class Cartola extends Service
|
||||
{
|
||||
public function __construct(protected StreamFactoryInterface $streamFactory, protected Exporter $exporter) {}
|
||||
public function __construct(LoggerInterface $logger,
|
||||
protected StreamFactoryInterface $streamFactory, protected Exporter $exporter,
|
||||
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
protected Repository\Movimiento $movimientoRepository,
|
||||
protected Repository\Cartola $cartolaRepository) {
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
protected array $bancos;
|
||||
public function register(string $name, Banco $banco): Cartola
|
||||
@ -26,4 +39,75 @@ class Cartola
|
||||
{
|
||||
return $this->exporter->export($inmobiliaria, $banco, $mes, $movimientos);
|
||||
}
|
||||
public function diaria(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $fecha, UploadedFileInterface $file): array
|
||||
{
|
||||
$cuenta = $this->cuentaRepository->fetchByInmobiliariaAndBanco($inmobiliaria->rut, $banco->id);
|
||||
|
||||
$ms = $this->getMovimientosDiarios($banco, $file);
|
||||
|
||||
$cartolaData = [
|
||||
'cargos' => 0,
|
||||
'abonos' => 0,
|
||||
'saldo' => 0
|
||||
];
|
||||
$movimientos = [];
|
||||
foreach ($ms as $m) {
|
||||
$movimiento = $this->buildMovimiento($cuenta, $m);
|
||||
|
||||
if ($movimiento->fecha->getTimestamp() === $fecha->getTimestamp()) {
|
||||
$movimientos []= $movimiento;
|
||||
$cartolaData['cargos'] += $movimiento->cargo;
|
||||
$cartolaData['abonos'] += $movimiento->abono;
|
||||
}
|
||||
$cartolaData['saldo'] = $movimiento->saldo;
|
||||
}
|
||||
$cartola = $this->buildCartola($cuenta, $fecha, $cartolaData);
|
||||
return compact('cartola', 'movimientos');
|
||||
}
|
||||
|
||||
protected function getMovimientosDiarios(Model\Banco $banco, UploadedFileInterface $file): array
|
||||
{
|
||||
$movimientos = $this->bancos[strtolower($banco->nombre)]->process($file);
|
||||
switch (strtolower($banco->nombre)) {
|
||||
case 'security':
|
||||
$movimientos = $this->processMovimientosDiariosSecurity($movimientos);
|
||||
break;
|
||||
case 'itau':
|
||||
case 'santander':
|
||||
break;
|
||||
}
|
||||
return $movimientos;
|
||||
}
|
||||
protected function processMovimientosDiariosSecurity(array $movimientos): array
|
||||
{
|
||||
$movimientos = array_reverse($movimientos);
|
||||
array_shift($movimientos);
|
||||
return $movimientos;
|
||||
}
|
||||
protected function buildCartola(Model\Inmobiliaria\Cuenta $cuenta, DateTimeInterface $fecha, array $data): Model\Cartola
|
||||
{
|
||||
try {
|
||||
return $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
} catch (Exception\EmptyResult) {
|
||||
$data['cuenta_id'] = $cuenta->id;
|
||||
$data['fecha'] = $fecha->format('Y-m-d');
|
||||
$cartola = $this->cartolaRepository->create($data);
|
||||
return $this->cartolaRepository->save($cartola);
|
||||
}
|
||||
}
|
||||
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Movimiento
|
||||
{
|
||||
try {
|
||||
return $this->movimientoRepository
|
||||
->fetchByCuentaAndFechaAndMonto(
|
||||
$cuenta->id,
|
||||
new DateTimeImmutable($data['fecha']),
|
||||
$data['cargo'] ?? $data['abono']
|
||||
);
|
||||
} catch (Exception\EmptyResult) {
|
||||
$data['cuenta_id'] = $cuenta->id;
|
||||
$movimiento = $this->movimientoRepository->create($data);
|
||||
return $this->movimientoRepository->save($movimiento);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,10 @@ class Security extends Banco
|
||||
'fecha' => 'fecha',
|
||||
'descripción' => 'glosa',
|
||||
'número de documentos' => 'documento',
|
||||
'nº documento' => 'documento',
|
||||
'cargos' => 'cargo',
|
||||
'abonos' => 'abono'
|
||||
'abonos' => 'abono',
|
||||
'saldos' => 'saldo'
|
||||
];
|
||||
}
|
||||
|
||||
@ -33,10 +35,9 @@ class Security extends Banco
|
||||
{
|
||||
$filename = '/tmp/cartola.xls';
|
||||
$file->moveTo($filename);
|
||||
$reader = PhpSpreadsheet\IOFactory::createReader('Xls');
|
||||
$xlsx = $reader->load($filename);
|
||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
||||
$worksheet = $xlsx->getActiveSheet();
|
||||
$rows = $worksheet->getRowIterator();
|
||||
$rows = $worksheet->getRowIterator(3);
|
||||
$dataFound = false;
|
||||
$columns = [];
|
||||
$data = [];
|
||||
@ -44,10 +45,10 @@ class Security extends Banco
|
||||
$cells = $row->getCellIterator();
|
||||
$rowData = [];
|
||||
foreach ($cells as $cell) {
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() === "fecha ") {
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() !== null and strtolower($cell->getCalculatedValue()) === "fecha ") {
|
||||
$cols = $row->getColumnIterator();
|
||||
foreach ($cols as $col) {
|
||||
$columns[$col->getColumn()] = trim($col->getCalculatedValue());
|
||||
$columns[$col->getColumn()] = trim(strtolower($col->getCalculatedValue()), ' ');
|
||||
}
|
||||
$dataFound = true;
|
||||
break;
|
||||
@ -62,7 +63,11 @@ class Security extends Banco
|
||||
$col = $columns[$cell->getColumn()];
|
||||
$value = $cell->getCalculatedValue();
|
||||
if ($col === 'fecha') {
|
||||
$value = PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue(), 'America/Santiago')->format('Y-m-d');
|
||||
if ((int) $cell->getValue() !== $cell->getValue()) {
|
||||
$value = implode('-', array_reverse(explode('-', $cell->getValue())));
|
||||
} else {
|
||||
$value = PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue(), 'America/Santiago')->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
$rowData[$col] = $value;
|
||||
}
|
||||
|
20
app/src/Service/Contabilidad.php
Normal file
20
app/src/Service/Contabilidad.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Contabilidad extends Ideal\Controller
|
||||
{
|
||||
public function __construct(LoggerInterface $logger,
|
||||
protected Contabilidad\Informe\Tesoreria $tesoreriaService)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function tesoreria(DateTimeInterface $fecha): array
|
||||
{
|
||||
return $this->tesoreriaService->build($fecha);
|
||||
}
|
||||
}
|
277
app/src/Service/Contabilidad/Informe/Tesoreria.php
Normal file
277
app/src/Service/Contabilidad/Informe/Tesoreria.php
Normal file
@ -0,0 +1,277 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Contabilidad\Informe;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateInterval;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Tesoreria extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger,
|
||||
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
protected Repository\Deposito $depositoRepository,
|
||||
protected Repository\Cartola $cartolaRepository,
|
||||
protected Repository\Movimiento $movimientoRepository)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
|
||||
$this->movimientos = new class() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->dap = new class()
|
||||
{
|
||||
public array $ingresos = [];
|
||||
public array $egresos = [];
|
||||
};
|
||||
}
|
||||
public object $dap;
|
||||
public array $ingresos = [];
|
||||
public array $egresos = [];
|
||||
|
||||
const INGRESOS = 'ingresos';
|
||||
const EGRESOS = 'egresos';
|
||||
public function addDap(string $tipo, array $movimientos)
|
||||
{
|
||||
foreach ($movimientos as $movimiento) {
|
||||
$this->dap->{$tipo} []= $movimiento;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function build(): array
|
||||
{
|
||||
return [
|
||||
'capital dap' => [
|
||||
'ingresos' => $this->dap->ingresos,
|
||||
'egresos' => $this->dap->egresos
|
||||
],
|
||||
'ingresos' => $this->ingresos,
|
||||
'egresos' => $this->egresos
|
||||
];
|
||||
}
|
||||
};
|
||||
$this->totales = new class() {
|
||||
public int $anterior = 0;
|
||||
public int $actual = 0;
|
||||
public int $ffmm = 0;
|
||||
public int $deposito = 0;
|
||||
|
||||
public function diferencia(): int
|
||||
{
|
||||
return $this->actual - $this->anterior;
|
||||
}
|
||||
public function saldo(): int
|
||||
{
|
||||
return $this->diferencia() + $this->ffmm + $this->deposito;
|
||||
}
|
||||
public function cuentas(): int
|
||||
{
|
||||
return $this->actual;
|
||||
}
|
||||
public function ffmms(): int
|
||||
{
|
||||
return $this->ffmm;
|
||||
}
|
||||
public function depositos(): int
|
||||
{
|
||||
return $this->deposito;
|
||||
}
|
||||
public function caja(): int
|
||||
{
|
||||
return $this->cuentas() + $this->ffmms() + $this->depositos();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const DAP_INGRESOS = 'dap->ingresos';
|
||||
const DAP_EGRESOS = 'dap->egresos';
|
||||
const INGRESOS = 'ingresos';
|
||||
const EGRESOS = 'egresos';
|
||||
const TOTAL_ANTERIOR = 'anterior';
|
||||
const TOTAL_ACTUAL = 'actual';
|
||||
const TOTAL_FFMM = 'ffmm';
|
||||
const TOTAL_DAP = 'deposito';
|
||||
|
||||
protected DateTimeInterface $anterior;
|
||||
protected object $totales;
|
||||
protected object $movimientos;
|
||||
|
||||
public function getAnterior(DateTimeInterface $fecha): DateTimeInterface
|
||||
{
|
||||
if (!isset($this->anterior)) {
|
||||
$this->anterior = $fecha->sub(new DateInterval('P1D'));
|
||||
if ($this->anterior->format('N') === '7') {
|
||||
$this->anterior = $fecha->sub(new DateInterval('P3D'));
|
||||
}
|
||||
}
|
||||
return $this->anterior;
|
||||
}
|
||||
public function build(DateTimeInterface $fecha): array
|
||||
{
|
||||
try {
|
||||
$inmobiliarias = $this->inmobiliariaRepository->fetchAllActive();
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
$informe = ['inmobiliarias' => []];
|
||||
foreach ($inmobiliarias as $inmobiliaria) {
|
||||
$informe['inmobiliarias'][$inmobiliaria->rut] = $this->buildInmobiliaria($inmobiliaria, $fecha);
|
||||
}
|
||||
$informe['movimientos'] = $this->buildMovimientos();
|
||||
$informe['totales'] = $this->buildTotales();
|
||||
return $informe;
|
||||
}
|
||||
|
||||
protected function buildInmobiliaria(Model\Inmobiliaria $inmobiliaria, DateTimeInterface $fecha): object
|
||||
{
|
||||
$dataInmobiliaria = new class() {
|
||||
public Model\Inmobiliaria $inmobiliaria;
|
||||
public array $cuentas = [];
|
||||
public function total(): int
|
||||
{
|
||||
return array_reduce($this->cuentas, function(int $sum, $cuenta) {
|
||||
return $sum + $cuenta->actual;
|
||||
}, 0);
|
||||
}
|
||||
public function ffmm(): int
|
||||
{
|
||||
return array_reduce($this->cuentas, function(int $sum, $cuenta) {
|
||||
return $sum + $cuenta->ffmm;
|
||||
}, 0);
|
||||
}
|
||||
public function deposito(): int
|
||||
{
|
||||
return array_reduce($this->cuentas, function(int $sum, $cuenta) {
|
||||
return $sum + $cuenta->deposito;
|
||||
}, 0);
|
||||
}
|
||||
public function caja(): int
|
||||
{
|
||||
return array_reduce($this->cuentas, function(int $sum, $cuenta) {
|
||||
return $sum + $cuenta->saldo();
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
$dataInmobiliaria->inmobiliaria = $inmobiliaria;
|
||||
try {
|
||||
$cuentas = $this->cuentaRepository->fetchByInmobiliaria($inmobiliaria->rut);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return $dataInmobiliaria;
|
||||
}
|
||||
foreach ($cuentas as $cuenta) {
|
||||
$data = new class() {
|
||||
public string $banco;
|
||||
public string $numero;
|
||||
public int $anterior = 0;
|
||||
public int $actual = 0;
|
||||
public int $ffmm = 0;
|
||||
public int $deposito = 0;
|
||||
|
||||
public function diferencia(): int
|
||||
{
|
||||
return $this->actual - $this->anterior;
|
||||
}
|
||||
public function saldo(): int
|
||||
{
|
||||
return $this->diferencia() + $this->ffmm + $this->deposito;
|
||||
}
|
||||
};
|
||||
$data->banco = $cuenta->banco->nombre;
|
||||
$data->numero = $cuenta->cuenta;
|
||||
try {
|
||||
$depositos = $this->depositoRepository->fetchByCuenta($cuenta->id);
|
||||
foreach ($depositos as $deposito) {
|
||||
$data->deposito += $deposito->capital;
|
||||
$this->addTotal(self::TOTAL_DAP, $deposito->capital);
|
||||
|
||||
if ($deposito->inicio === $fecha) {
|
||||
$this->addMovimientos(self::DAP_EGRESOS, [(object) [
|
||||
'cuenta' => $deposito->cuenta,
|
||||
'fecha' => $deposito->inicio,
|
||||
'cargo' => - $deposito->capital,
|
||||
'abono' => 0,
|
||||
'saldo' => - $deposito->capital,
|
||||
'glosa' => 'INVERSION DAP'
|
||||
]]);
|
||||
}
|
||||
if ($deposito->termino === $fecha) {
|
||||
$data->deposito -= $deposito->capital;
|
||||
$this->addTotal(self::TOTAL_DAP, -$deposito->capital);
|
||||
|
||||
$this->addMovimientos(self::DAP_INGRESOS, [(object) [
|
||||
'cuenta' => $deposito->cuenta,
|
||||
'fecha' => $deposito->termino,
|
||||
'cargo' => 0,
|
||||
'abono' => $deposito->futuro,
|
||||
'saldo' => $deposito->futuro,
|
||||
'glosa' => 'RESCATE DAP'
|
||||
]]);
|
||||
}
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
try {
|
||||
$cartola = $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
$data->actual = $cartola->saldo;
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
try {
|
||||
$cartola = $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $this->getAnterior($fecha));
|
||||
$data->anterior = $cartola->saldo;
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
if ($data->diferencia() !== 0) {
|
||||
try {
|
||||
$movimientos = $this->movimientoRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
$this->addMovimientos(self::INGRESOS,
|
||||
array_filter($movimientos, function(Model\Movimiento $movimiento) {
|
||||
return $movimiento->abono > 0;
|
||||
}));
|
||||
$this->addMovimientos(self::EGRESOS,
|
||||
array_filter($movimientos, function(Model\Movimiento $movimiento) {
|
||||
return $movimiento->cargo > 0;
|
||||
}));
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
}
|
||||
$dataInmobiliaria->cuentas []= $data;
|
||||
|
||||
$this->addTotal(
|
||||
[self::TOTAL_ANTERIOR, self::TOTAL_ACTUAL],
|
||||
[$data->anterior, $data->actual]
|
||||
);
|
||||
}
|
||||
return $dataInmobiliaria;
|
||||
}
|
||||
protected function buildMovimientos(): array
|
||||
{
|
||||
return $this->movimientos->build();
|
||||
}
|
||||
protected function buildTotales(): object
|
||||
{
|
||||
return $this->totales;
|
||||
}
|
||||
protected function addMovimientos(string $tipo, array $movimientos): Tesoreria
|
||||
{
|
||||
if (str_contains($tipo, 'dap')) {
|
||||
list($d, $t) = explode('->', $tipo);
|
||||
$this->movimientos->addDap($t, $movimientos);
|
||||
return $this;
|
||||
}
|
||||
foreach ($movimientos as $movimiento) {
|
||||
$this->movimientos->{$tipo} []= $movimiento;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
protected function addTotal(string|array $tipo, int|array $total): Tesoreria
|
||||
{
|
||||
if (is_array($tipo)) {
|
||||
foreach ($tipo as $i => $t) {
|
||||
$this->addTotal($t, $total[$i]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
$this->totales->{$tipo} += $total;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -4,20 +4,25 @@ namespace Incoviba\Service\Contabilidad;
|
||||
use DateTimeInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Implement\Exception;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use function Symfony\Component\Translation\t;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Nubox
|
||||
class Nubox extends Ideal\Service
|
||||
{
|
||||
public function __construct(protected Repository\Nubox $nuboxRepository,
|
||||
public function __construct(protected LoggerInterface $logger,
|
||||
protected Repository\Nubox $nuboxRepository,
|
||||
protected Service\Redis $redisService,
|
||||
protected ClientInterface $client,
|
||||
protected RequestFactoryInterface $requestFactory,
|
||||
protected string $api_url) {}
|
||||
protected string $api_url)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
protected array $tokens;
|
||||
public function getToken(int $inmobiliaria_rut): string
|
||||
@ -120,7 +125,7 @@ class Nubox
|
||||
$uri = 'contabilidad/libro-diario?' . http_build_query($query);
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
error_log(var_export($uri,true).PHP_EOL,3,'/logs/debug');
|
||||
$this->logger->debug($uri);
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $response->getStatusCode());
|
||||
}
|
||||
return json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
|
@ -25,12 +25,12 @@ class Format
|
||||
{
|
||||
return "{$this->number($number, $decimal_places)}%";
|
||||
}
|
||||
public function pesos(string $valor): string
|
||||
public function pesos(string $valor, int $decimal_places = 0): string
|
||||
{
|
||||
return "$ {$this->number($valor)}";
|
||||
return "$ {$this->number($valor, $decimal_places)}";
|
||||
}
|
||||
public function ufs(string $valor): string
|
||||
public function ufs(string $valor, int $decimal_places = 2): string
|
||||
{
|
||||
return "{$this->number($valor, 2)} UF";
|
||||
return "{$this->number($valor, $decimal_places)} UF";
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,12 @@ use DateInterval;
|
||||
use Incoviba\Common\Define\Money\Provider;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResponse;
|
||||
use Incoviba\Service\Money\MiIndicador;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Money
|
||||
{
|
||||
public function __construct(protected LoggerInterface $logger) {}
|
||||
|
||||
protected array $providers;
|
||||
public function register(string $name, Provider $provider): Money
|
||||
{
|
||||
@ -49,4 +52,13 @@ class Money
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public function getUSD(DateTimeInterface $dateTime): float
|
||||
{
|
||||
try {
|
||||
return $this->getProvider('usd')->get(MiIndicador::USD, $dateTime);
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->critical($exception);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class MiIndicador implements Provider
|
||||
{
|
||||
const UF = 'uf';
|
||||
const IPC = 'ipc';
|
||||
const USD = 'dolar_intercambio';
|
||||
const USD = 'dolar';
|
||||
|
||||
public function __construct(protected ClientInterface $client) {}
|
||||
|
||||
|
@ -142,7 +142,7 @@ class Search
|
||||
}
|
||||
protected function findPago(string $query): array
|
||||
{
|
||||
if ($query != 0) {
|
||||
if ((int) $query === 0) {
|
||||
return [];
|
||||
}
|
||||
$methods = [
|
||||
@ -156,6 +156,7 @@ class Search
|
||||
$pagos = [];
|
||||
try {
|
||||
$pagos = $this->pagoRepository->fetchByValue((int) $valor);
|
||||
error_log(var_export($pagos,true).PHP_EOL,3,'/logs/debug');
|
||||
} catch (EmptyResult) {}
|
||||
$results = [];
|
||||
foreach ($methods as $method) {
|
||||
|
34
app/src/Service/USD.php
Normal file
34
app/src/Service/USD.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
|
||||
class USD
|
||||
{
|
||||
protected string $redisKey = 'usd';
|
||||
|
||||
public function __construct(protected Redis $redisService, protected Money $moneyService) {}
|
||||
|
||||
public function get(?DateTimeInterface $date = null): float
|
||||
{
|
||||
if ($date === null) {
|
||||
$date = new DateTimeImmutable();
|
||||
}
|
||||
$usds = [];
|
||||
try {
|
||||
$usds = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
||||
if (!isset($usds[$date->format('Y-m-d')])) {
|
||||
throw new EmptyRedis($this->redisKey);
|
||||
}
|
||||
$usd = $usds[$date->format('Y-m-d')];
|
||||
} catch (EmptyRedis) {
|
||||
$usd = $this->moneyService->getUSD($date);
|
||||
$usds[$date->format('Y-m-d')] = $usd;
|
||||
ksort($usds);
|
||||
$this->redisService->set($this->redisKey, json_encode($usds), 60 * 60 * 24 * 30);
|
||||
}
|
||||
return $usd;
|
||||
}
|
||||
}
|
5
cli/bin/incoviba
Normal file
5
cli/bin/incoviba
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /etc/profile
|
||||
|
||||
/usr/local/bin/php /code/bin/index.php "$@"
|
16
cli/crontab
16
cli/crontab
@ -1,8 +1,8 @@
|
||||
0 2 * * * php /code/bin/index.php ventas:cuotas:hoy 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php ventas:cuotas:pendientes 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php ventas:cuotas:vencer 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php ventas:cierres:vigentes 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php proyectos:activos 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php comunas 2>&1 >> /logs/commands
|
||||
0 2 * * * php /code/bin/index.php money:uf 2>&1 >> /logs/commands
|
||||
0 2 1 * * php /code/bin/index.php money:ipc 2>&1 >> /logs/commands
|
||||
0 2 * * * /code/bin/incoviba ventas:cuotas:hoy >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba ventas:cuotas:pendientes >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba ventas:cuotas:vencer >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba ventas:cierres:vigentes >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba proyectos:activos >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba comunas >> /logs/commands 2>&1
|
||||
0 2 * * * /code/bin/incoviba money:uf >> /logs/commands 2>&1
|
||||
0 2 1 * * /code/bin/incoviba money:ipc >> /logs/commands 2>&1
|
||||
|
@ -1,15 +1,10 @@
|
||||
version: '3'
|
||||
|
||||
x-restart: &restart
|
||||
restart: unless-stopped
|
||||
|
||||
services:
|
||||
proxy:
|
||||
profiles:
|
||||
- app
|
||||
image: nginx:alpine
|
||||
container_name: incoviba_proxy
|
||||
<<: *restart
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${APP_PORT}:80"
|
||||
volumes:
|
||||
@ -22,12 +17,10 @@ services:
|
||||
- app
|
||||
build: .
|
||||
container_name: incoviba_web
|
||||
<<: *restart
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ${APP_PATH:-.}/.env
|
||||
- ${APP_PATH:-.}/.db.env
|
||||
- ./.key.env
|
||||
#- ${APP_PATH:-.}/.remote.env
|
||||
volumes:
|
||||
- ${APP_PATH:-.}/:/code
|
||||
- ./logs/php:/logs
|
||||
@ -37,7 +30,7 @@ services:
|
||||
- db
|
||||
image: mariadb:latest
|
||||
container_name: incoviba_db
|
||||
<<: *restart
|
||||
restart: unless-stopped
|
||||
env_file: ${APP_PATH:-.}/.db.env
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
@ -53,22 +46,13 @@ services:
|
||||
- cache
|
||||
image: redis
|
||||
container_name: incoviba_redis
|
||||
<<: *restart
|
||||
restart: unless-stopped
|
||||
env_file: ${APP_PATH:-.}/.redis.env
|
||||
volumes:
|
||||
- incoviba_redis:/data
|
||||
ports:
|
||||
- "63790:6379"
|
||||
|
||||
python:
|
||||
profiles:
|
||||
- python
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Python.Dockerfile
|
||||
container_name: incoviba_python
|
||||
<<: *restart
|
||||
|
||||
logview:
|
||||
profiles:
|
||||
- log
|
||||
@ -81,7 +65,7 @@ services:
|
||||
WEB_URL: 'http://provm.cl:8084'
|
||||
WEB_PORT: '8084'
|
||||
volumes:
|
||||
- "./logs:/logs"
|
||||
- ./logs:/logs
|
||||
ports:
|
||||
- "8084:80"
|
||||
cli:
|
||||
@ -91,7 +75,7 @@ services:
|
||||
context: .
|
||||
dockerfile: CLI.Dockerfile
|
||||
container_name: incoviba_cli
|
||||
<<: *restart
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ${CLI_PATH:-.}/.env
|
||||
- ./.key.env
|
||||
|
Reference in New Issue
Block a user