Informe Tesoreria

This commit is contained in:
Juan Pablo Vial
2024-02-13 01:16:17 -03:00
parent 19333bc338
commit e44ab30665
23 changed files with 896 additions and 40 deletions

View 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> 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"> 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

View 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