Compare commits
19 Commits
c784d1bee9
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
8caa80459e | |||
98953cce42 | |||
c7dd309185 | |||
48bfe5d8ab | |||
d9b5bc6507 | |||
21d1ef653f | |||
e8d43e43ff | |||
fc9788a1cd | |||
02dcc950f4 | |||
370b6714bc | |||
dc7a9f9e7a | |||
cfe18c1909 | |||
5156858205 | |||
415ba31270 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@
|
|||||||
**/modules/
|
**/modules/
|
||||||
**/.idea/
|
**/.idea/
|
||||||
**/upload?/
|
**/upload?/
|
||||||
|
**/informe?/
|
||||||
|
10
app/common/Define/Informe.php
Normal file
10
app/common/Define/Informe.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Common\Define;
|
||||||
|
|
||||||
|
interface Informe
|
||||||
|
{
|
||||||
|
public function setTitle(string $title): Informe;
|
||||||
|
public function setFilename(string $filename): Informe;
|
||||||
|
public function addData(array $rows): Informe;
|
||||||
|
public function build(): void;
|
||||||
|
}
|
0
app/public/informes/.gitkeep
Normal file
0
app/public/informes/.gitkeep
Normal file
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||||
|
|
||||||
|
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||||
|
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||||
|
});
|
@ -1,4 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\Search;
|
use Incoviba\Controller\API\Search;
|
||||||
|
|
||||||
$app->post('/search', [Search::class, 'query']);
|
$app->group('/search', function($app) {
|
||||||
|
$app->group('/ventas', function($app) {
|
||||||
|
$app->post('/unidades', [Search::class, 'unidades']);
|
||||||
|
$app->get('/unidad/{unidad_id}', [Search::class, 'unidad']);
|
||||||
|
$app->post('[/]', [Search::class, 'ventas']);
|
||||||
|
});
|
||||||
|
$app->get('/venta/{venta_id}', [Search::class, 'venta']);
|
||||||
|
$app->post('[/]', [Search::class, 'query']);
|
||||||
|
});
|
||||||
|
@ -22,6 +22,7 @@ $app->group('/ventas', function($app) {
|
|||||||
$app->group('/by', function($app) {
|
$app->group('/by', function($app) {
|
||||||
$app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']);
|
$app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']);
|
||||||
});
|
});
|
||||||
|
$app->post('/get[/]', [Ventas::class, 'getMany']);
|
||||||
$app->post('[/]', [Ventas::class, 'proyecto']);
|
$app->post('[/]', [Ventas::class, 'proyecto']);
|
||||||
});
|
});
|
||||||
$app->group('/venta/{venta_id}', function($app) {
|
$app->group('/venta/{venta_id}', function($app) {
|
||||||
|
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Contabilidad\Informes;
|
||||||
|
|
||||||
|
$app->group('/xlsx', function($app) {
|
||||||
|
$app->get('/tesoreria/{fecha}[/]', [Informes::class, 'tesoreria']);
|
||||||
|
});
|
@ -15,47 +15,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<form class="ui form" id="cartola_form">
|
<form class="ui form" id="cartola_form">
|
||||||
<input type="hidden" id="fields" name="fields" value="0" />
|
<input type="hidden" id="fields" name="fields" value="0" />
|
||||||
{{--<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>
|
</form>
|
||||||
<div class="ui two columns grid">
|
<div class="ui two columns grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@ -93,12 +52,69 @@
|
|||||||
<th class="right aligned">Cargo</th>
|
<th class="right aligned">Cargo</th>
|
||||||
<th class="right aligned">Abono</th>
|
<th class="right aligned">Abono</th>
|
||||||
<th class="right aligned">Saldo</th>
|
<th class="right aligned">Saldo</th>
|
||||||
|
<th>Centro de Costo</th>
|
||||||
|
<th>Detalle</th>
|
||||||
<th>Orden</th>
|
<th>Orden</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="movimientos"></tbody>
|
<tbody id="movimientos"></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui modal" id="manual_modal">
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">
|
||||||
|
Movimientos |
|
||||||
|
<span id="modal_inmobiliaria"></span> |
|
||||||
|
<span id="modal_cuenta"></span> |
|
||||||
|
<span id="modal_fecha"></span>
|
||||||
|
</div>
|
||||||
|
<div class="ui one column grid">
|
||||||
|
<div class="right aligned column">
|
||||||
|
<button class="ui green icon button" id="add_manual">
|
||||||
|
<i class="plus icon"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form class="ui form" id="modal_form">
|
||||||
|
<input type="hidden" name="movimientos" value="[1]" />
|
||||||
|
<div id="modal_movimientos">
|
||||||
|
<div class="fields" data-movimiento="1">
|
||||||
|
<div class="field">
|
||||||
|
<label>Glosa</label>
|
||||||
|
<input type="text" name="glosa1" />
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Cargo</label>
|
||||||
|
<div class="ui left labeled input">
|
||||||
|
<div class="ui basic label">$</div>
|
||||||
|
<input type="text" name="cargo1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Abono</label>
|
||||||
|
<div class="ui left labeled input">
|
||||||
|
<div class="ui basic label">$</div>
|
||||||
|
<input type="text" name="abono1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Saldo</label>
|
||||||
|
<div class="ui left labeled input">
|
||||||
|
<div class="ui basic label">$</div>
|
||||||
|
<input type="text" name="saldo1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="ui approve button">
|
||||||
|
Procesar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@include('layout.head.styles.datatables')
|
@include('layout.head.styles.datatables')
|
||||||
@ -171,29 +187,69 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
update() {
|
||||||
|
return {
|
||||||
|
centro: (idx, centro_id) => {
|
||||||
|
const id = this.movimientos[idx].id
|
||||||
|
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||||
|
const body = new FormData()
|
||||||
|
body.set('centro_id', centro_id)
|
||||||
|
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.json().then(json => {
|
||||||
|
if (!json.status) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const dropdown = $(".dropdown[data-idx='" + idx + "']")
|
||||||
|
dropdown.dropdown('set selected', json.centro.id, true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
detalle: (idx, detalle) => {
|
||||||
|
const id = this.movimientos[idx].id
|
||||||
|
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||||
|
const body = new FormData()
|
||||||
|
body.set('detalle', detalle)
|
||||||
|
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.json().then(json => {
|
||||||
|
if (!json.status) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const input = $("input[data-idx='" + idx + "']")
|
||||||
|
input.val(json.detalle)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
draw() {
|
draw() {
|
||||||
return {
|
return {
|
||||||
form: (form, inmobiliarias, first = false) => {
|
form: ($form, inmobiliarias, first = false) => {
|
||||||
const fields = $('<div></div>').addClass('fields cartola').attr('data-cartola', this.idx)
|
const $fields = $('<div></div>').addClass('fields cartola').attr('data-cartola', this.idx)
|
||||||
const inmobiliarias_menu = $('<div></div>').addClass('menu')
|
const $inmobiliarias_menu = $('<div></div>').addClass('menu')
|
||||||
inmobiliarias.forEach(inmobiliaria => {
|
inmobiliarias.forEach(inmobiliaria => {
|
||||||
inmobiliarias_menu.append(
|
$inmobiliarias_menu.append(
|
||||||
$('<div></div>').addClass('item').attr('data-value', inmobiliaria.rut).html(inmobiliaria.razon)
|
$('<div></div>').addClass('item').attr('data-value', inmobiliaria.rut).html(inmobiliaria.razon)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
const inmobiliarias_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'inmobiliaria' + this.idx).append(
|
const $inmobiliarias_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'inmobiliaria' + this.idx).append(
|
||||||
$('<input />').attr('type', 'hidden')//.attr('name', 'inmobiliaria_rut' + this.idx)
|
$('<input />').attr('type', 'hidden')//.attr('name', 'inmobiliaria_rut' + this.idx)
|
||||||
).append(
|
).append(
|
||||||
$('<i></i>').addClass('dropdown icon')
|
$('<i></i>').addClass('dropdown icon')
|
||||||
).append(
|
).append(
|
||||||
$('<div></div>').addClass('default text').html('Inmobiliaria')
|
$('<div></div>').addClass('default text').html('Inmobiliaria')
|
||||||
).append(inmobiliarias_menu)
|
).append($inmobiliarias_menu)
|
||||||
fields.append(
|
$fields.append(
|
||||||
$('<div></div>').addClass('six wide field').append(
|
$('<div></div>').addClass('six wide field').append(
|
||||||
$('<label></label>').attr('for', 'inmobiliaria' + this.idx).html('Sociedad')
|
$('<label></label>').attr('for', 'inmobiliaria' + this.idx).html('Sociedad')
|
||||||
).append(inmobiliarias_dropdown)
|
).append($inmobiliarias_dropdown)
|
||||||
)
|
)
|
||||||
const cuentas_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'cuenta' + this.idx).append(
|
const $cuentas_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'cuenta' + this.idx).append(
|
||||||
$('<input />').attr('type', 'hidden').attr('name', 'cuenta_id' + this.idx)
|
$('<input />').attr('type', 'hidden').attr('name', 'cuenta_id' + this.idx)
|
||||||
).append(
|
).append(
|
||||||
$('<i></i>').addClass('dropdown icon')
|
$('<i></i>').addClass('dropdown icon')
|
||||||
@ -202,35 +258,47 @@
|
|||||||
).append(
|
).append(
|
||||||
$('<div></div>').addClass('menu')
|
$('<div></div>').addClass('menu')
|
||||||
)
|
)
|
||||||
fields.append(
|
$fields.append(
|
||||||
$('<div></div>').addClass('four wide field').append(
|
$('<div></div>').addClass('four wide field').append(
|
||||||
$('<label></label>').html('Banco - Cuenta')
|
$('<label></label>').html('Banco - Cuenta')
|
||||||
).append(cuentas_dropdown)
|
).append($cuentas_dropdown)
|
||||||
)
|
)
|
||||||
const fecha_calendar = $('<div></div>').addClass('ui calendar').attr('id', 'fecha' + this.idx).append(
|
const $fecha_calendar = $('<div></div>').addClass('ui calendar').attr('id', 'fecha' + this.idx).append(
|
||||||
$('<div></div>').addClass('ui left icon input').append(
|
$('<div></div>').addClass('ui left icon input').append(
|
||||||
$('<i></i>').addClass('calendar icon')
|
$('<i></i>').addClass('calendar icon')
|
||||||
).append(
|
).append(
|
||||||
$('<input />').attr('type', 'text')
|
$('<input />').attr('type', 'text')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
fields.append(
|
$fields.append(
|
||||||
$('<div></div>').addClass('three wide field').append(
|
$('<div></div>').addClass('three wide field').append(
|
||||||
$('<label></label>').attr('for', 'fecha' + this.idx).html('Fecha')
|
$('<label></label>').attr('for', 'fecha' + this.idx).html('Fecha')
|
||||||
).append(fecha_calendar)
|
).append($fecha_calendar)
|
||||||
)
|
)
|
||||||
const file_field = $('<div></div>').addClass('field').append(
|
$fields.append(
|
||||||
$('<label></label>').attr('for', 'file' + this.idx).html('Cartola')
|
$('<div></div>').addClass('field').append(
|
||||||
).append(
|
$('<label></label>').html('Cartola')
|
||||||
$('<input />').addClass('ui invisible file input').attr('type', 'file').attr('name', 'file' + this.idx).attr('id', 'file' + this.idx)
|
).append(
|
||||||
).append(
|
$('<input />').addClass('ui invisible file input').attr('type', 'file').attr('name', 'file' + this.idx).attr('id', 'file' + this.idx)
|
||||||
$('<label></label>').addClass('ui icon button').attr('for', 'file' + this.idx).append(
|
).append(
|
||||||
$('<i></i>').addClass('file icon')
|
$('<label></label>').addClass('ui icon button').attr('for', 'file' + this.idx).append(
|
||||||
).append('Cargar')
|
$('<i></i>').addClass('file icon')
|
||||||
|
).append('Cargar')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
fields.append(file_field)
|
const $manual_checkbox = $('<div></div>').addClass('ui invisible checkbox').append(
|
||||||
|
$('<input />').attr('type', 'checkbox').attr('name', 'manual' + this.idx).attr('id', 'manual' + this.idx)
|
||||||
|
).append(
|
||||||
|
$('<label></label>').addClass('image').attr('for', 'manual' + this.idx).append(
|
||||||
|
$('<i></i>').addClass('large orange keyboard icon')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
$fields.append($('<div></div>').addClass('field').append(
|
||||||
|
$('<label></label>').html('Manual')
|
||||||
|
).append($manual_checkbox))
|
||||||
if (!first) {
|
if (!first) {
|
||||||
fields.append(
|
$fields.append(
|
||||||
$('<div></div>').addClass('field').append(
|
$('<div></div>').addClass('field').append(
|
||||||
$('<label></label>').html('Eliminar')
|
$('<label></label>').html('Eliminar')
|
||||||
).append(
|
).append(
|
||||||
@ -243,25 +311,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
form.append(fields)
|
$form.append($fields)
|
||||||
|
|
||||||
inmobiliarias_dropdown.dropdown({
|
|
||||||
fireOnInit: true,
|
|
||||||
onChange: (value, text, $choice) => {
|
|
||||||
this.inmobiliaria.rut = value
|
|
||||||
this.inmobiliaria.razon = text
|
|
||||||
this.get().bancos(value).then(() => {
|
|
||||||
cuentas_dropdown.dropdown('change values', this.bancos)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
cuentas_dropdown.dropdown({
|
|
||||||
fireOnInit: true,
|
|
||||||
onChange: (value, text, $choice) => {
|
|
||||||
this.cuenta.id = value
|
|
||||||
this.cuenta.descripcion = text
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const cdo = JSON.parse(JSON.stringify(calendar_date_options))
|
const cdo = JSON.parse(JSON.stringify(calendar_date_options))
|
||||||
cdo['initialDate'] = new Date()
|
cdo['initialDate'] = new Date()
|
||||||
@ -270,10 +320,48 @@
|
|||||||
this.fecha = date
|
this.fecha = date
|
||||||
}
|
}
|
||||||
this.fecha = cdo['initialDate']
|
this.fecha = cdo['initialDate']
|
||||||
fecha_calendar.calendar(cdo)
|
|
||||||
|
$inmobiliarias_dropdown.dropdown({
|
||||||
|
fireOnInit: true,
|
||||||
|
onChange: (value, text, $choice) => {
|
||||||
|
this.inmobiliaria.rut = value
|
||||||
|
this.inmobiliaria.razon = text
|
||||||
|
this.get().bancos(value).then(() => {
|
||||||
|
$cuentas_dropdown.dropdown('change values', this.bancos)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
$cuentas_dropdown.dropdown({
|
||||||
|
fireOnInit: true,
|
||||||
|
onChange: (value, text, $choice) => {
|
||||||
|
this.cuenta.id = value
|
||||||
|
this.cuenta.descripcion = text
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$fecha_calendar.calendar(cdo)
|
||||||
|
$manual_checkbox.change(event => {
|
||||||
|
const $element = $(event.currentTarget)
|
||||||
|
const status = $element.checkbox('is checked')
|
||||||
|
const $field = $element.parent().parent()
|
||||||
|
const $file = $field.find('#file' + this.idx).parent()
|
||||||
|
if (status) {
|
||||||
|
$file.find('input').attr('type', 'hidden')
|
||||||
|
$file.hide()
|
||||||
|
|
||||||
|
manual.data.inmobiliaria = $inmobiliarias_dropdown.dropdown('get text')
|
||||||
|
manual.data.cuenta = $cuentas_dropdown.dropdown('get text')
|
||||||
|
const fecha = $fecha_calendar.calendar('get date')
|
||||||
|
manual.data.fecha = [fecha.getDate(), (fecha.getMonth()+1).toString().padStart(2, '0'), fecha.getFullYear()].join('-')
|
||||||
|
manual.data.field = this.idx
|
||||||
|
manual.$modal.modal('show')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$file.find('input').attr('type', 'file')
|
||||||
|
$file.show()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
diferencia: (tbody, dateFormatter, numberFormatter) => {
|
diferencia: ($tbody, dateFormatter, numberFormatter) => {
|
||||||
tbody.append(
|
$tbody.append(
|
||||||
$('<tr></tr>').append(
|
$('<tr></tr>').append(
|
||||||
$('<td></td>').html(this.inmobiliaria.razon)
|
$('<td></td>').html(this.inmobiliaria.razon)
|
||||||
).append(
|
).append(
|
||||||
@ -289,29 +377,77 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
cartola: (tbody, dateFormatter, numberFormatter) => {
|
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
||||||
this.movimientos.forEach((row, idx) => {
|
this.movimientos.forEach((row, idx) => {
|
||||||
tbody.append(
|
$tbody.append(
|
||||||
$('<tr></tr>').append(
|
$('<tr></tr>').append(
|
||||||
$('<td></td>').html(this.inmobiliaria.razon)
|
'<td>' + this.inmobiliaria.razon + '</td>' + "\n"
|
||||||
|
+ '<td>' + this.cuenta.descripcion + '</td>' + "\n"
|
||||||
|
+ '<td>' + dateFormatter.format(row.fecha) + '</td>' + "\n"
|
||||||
|
+ '<td>' + row.glosa + '</td>' + "\n"
|
||||||
|
+ '<td class="right aligned">' + (row.cargo === 0 ? '' : numberFormatter.format(row.cargo)) + '</td>' + "\n"
|
||||||
|
+ '<td class="right aligned">' + (row.abono === 0 ? '' : numberFormatter.format(row.abono)) + '</td>' + "\n"
|
||||||
|
+ '<td class="right aligned">' + (row.saldo === 0 ? '' : numberFormatter.format(row.saldo)) + '</td>' + "\n"
|
||||||
).append(
|
).append(
|
||||||
$('<td></td>').html(this.cuenta.descripcion)
|
$('<td></td>').append(
|
||||||
|
this.draw().centroCosto(idx)
|
||||||
|
)
|
||||||
).append(
|
).append(
|
||||||
$('<td></td>').html(dateFormatter.format(row.fecha))
|
$('<td></td>').append(
|
||||||
).append(
|
this.draw().detalle(idx)
|
||||||
$('<td></td>').html(row.glosa)
|
)
|
||||||
).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(
|
).append(
|
||||||
$('<td></td>').html(idx + 1)
|
$('<td></td>').html(idx + 1)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
centroCosto: idx => {
|
||||||
|
const centros = JSON.parse('{!! json_encode($centrosCostos) !!}')
|
||||||
|
const menu = $('<div></div>').addClass('menu')
|
||||||
|
centros.forEach(centro => {
|
||||||
|
menu.append(
|
||||||
|
'<div class="item" data-value="' + centro.id + '">'
|
||||||
|
+ centro.id + ' - ' + centro.descripcion
|
||||||
|
+ '</div>'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
const dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('data-idx', idx).html(
|
||||||
|
'<input type="hidden" name="centro" />' + "\n" +
|
||||||
|
'<i class="dropdown icon"></i>' + "\n" +
|
||||||
|
'<div class="default text">Centro de Costo</div>' + "\n"
|
||||||
|
).append(menu)
|
||||||
|
dropdown.dropdown({
|
||||||
|
onChange: (value, text, $element) => {
|
||||||
|
const idx = $element.parent().parent().data('idx')
|
||||||
|
this.update().centro(idx, value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.movimientos[idx].centro !== '') {
|
||||||
|
const cid = centros.findIndex(centro => centro.descripcion === this.movimientos[idx].centro)
|
||||||
|
dropdown.dropdown('set selected', centros[cid].id, true)
|
||||||
|
}
|
||||||
|
return dropdown
|
||||||
|
},
|
||||||
|
detalle: idx => {
|
||||||
|
const detalle = document.createElement('input')
|
||||||
|
detalle.type = 'text'
|
||||||
|
detalle.name = 'detalle' + idx
|
||||||
|
detalle.placeholder = 'Detalle'
|
||||||
|
detalle.setAttribute('data-idx', idx)
|
||||||
|
const input = document.createElement('div')
|
||||||
|
input.className = 'ui input'
|
||||||
|
input.appendChild(detalle)
|
||||||
|
if (this.movimientos[idx].detalle !== '') {
|
||||||
|
detalle.value = this.movimientos[idx].detalle
|
||||||
|
}
|
||||||
|
detalle.addEventListener('blur', event => {
|
||||||
|
const idx = event.currentTarget.dataset['idx']
|
||||||
|
this.update().detalle(idx, event.currentTarget.value)
|
||||||
|
})
|
||||||
|
return $(input)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,6 +460,8 @@
|
|||||||
'cargo',
|
'cargo',
|
||||||
'abono',
|
'abono',
|
||||||
'saldo',
|
'saldo',
|
||||||
|
'centro',
|
||||||
|
'detalle',
|
||||||
'orden'
|
'orden'
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
@ -342,7 +480,7 @@
|
|||||||
width: '{{round((1/(count($columns) + 3 - 1)) * 100,2)}}%'
|
width: '{{round((1/(count($columns) + 3 - 1)) * 100,2)}}%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa']);})))}}],
|
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa', 'centro', 'detalle']);})))}}],
|
||||||
width: '{{round((1/(count($columns) + 3 - 1)) * 2 * 100, 2)}}%'
|
width: '{{round((1/(count($columns) + 3 - 1)) * 2 * 100, 2)}}%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -402,9 +540,9 @@
|
|||||||
Object.values(this.ids.table).forEach(id => $(id).find('tbody').html(''))
|
Object.values(this.ids.table).forEach(id => $(id).find('tbody').html(''))
|
||||||
},
|
},
|
||||||
diferencia: () => {
|
diferencia: () => {
|
||||||
const table = $(this.ids.table.diferencia)
|
const $table = $(this.ids.table.diferencia)
|
||||||
const tbody = table.find('tbody')
|
const $tbody = $table.find('tbody')
|
||||||
tbody.html('')
|
$tbody.html('')
|
||||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'numeric',
|
month: 'numeric',
|
||||||
@ -412,15 +550,15 @@
|
|||||||
})
|
})
|
||||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||||
this.data.cartolas.forEach(cartola => {
|
this.data.cartolas.forEach(cartola => {
|
||||||
cartola.draw().diferencia(tbody, dateFormatter, numberFormatter)
|
cartola.draw().diferencia($tbody, dateFormatter, numberFormatter)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
cartola: () => {
|
cartola: () => {
|
||||||
const table = $(this.ids.table.base)
|
const $table = $(this.ids.table.base)
|
||||||
table.DataTable().clear()
|
$table.DataTable().clear()
|
||||||
table.DataTable().destroy()
|
$table.DataTable().destroy()
|
||||||
const tbody = $(this.ids.table.body)
|
const $tbody = $(this.ids.table.body)
|
||||||
tbody.html('')
|
$tbody.html('')
|
||||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'numeric',
|
month: 'numeric',
|
||||||
@ -428,9 +566,9 @@
|
|||||||
})
|
})
|
||||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||||
this.data.cartolas.forEach(cartola => {
|
this.data.cartolas.forEach(cartola => {
|
||||||
cartola.draw().cartola(tbody, dateFormatter, numberFormatter)
|
cartola.draw().cartola($tbody, dateFormatter, numberFormatter)
|
||||||
})
|
})
|
||||||
table.DataTable(this.dataTableConfig)
|
$table.DataTable(this.dataTableConfig)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -445,7 +583,7 @@
|
|||||||
diaria.loader().show()
|
diaria.loader().show()
|
||||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
diaria.loader().hide()
|
diaria.loader().hide()
|
||||||
this.draw().empty()
|
this.draw().empty()
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -455,16 +593,20 @@
|
|||||||
}
|
}
|
||||||
Object.entries(json.cartolas).forEach(entry => {
|
Object.entries(json.cartolas).forEach(entry => {
|
||||||
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === parseInt(entry[0]))
|
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === parseInt(entry[0]))
|
||||||
|
this.data.cartolas[cartolaIdx].movimientos = []
|
||||||
entry[1].movimientos.forEach((row, idx) => {
|
entry[1].movimientos.forEach((row, idx) => {
|
||||||
const fecha = new Date(row.fecha)
|
const fecha = new Date(row.fecha)
|
||||||
fecha.setDate(fecha.getDate() + 1)
|
fecha.setDate(fecha.getDate() + 1)
|
||||||
this.data.cartolas[cartolaIdx].movimientos[idx] = {
|
this.data.cartolas[cartolaIdx].movimientos[idx] = {
|
||||||
|
id: row.id,
|
||||||
fecha: fecha,
|
fecha: fecha,
|
||||||
glosa: row.glosa,
|
glosa: row.glosa,
|
||||||
documento: row.documento,
|
documento: row.documento,
|
||||||
cargo: row.cargo,
|
cargo: row.cargo,
|
||||||
abono: row.abono,
|
abono: row.abono,
|
||||||
saldo: row.saldo
|
saldo: row.saldo,
|
||||||
|
centro: row.detalles?.centro_costo.descripcion ?? '',
|
||||||
|
detalle: row.detalles?.detalle ?? ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
||||||
@ -498,6 +640,160 @@
|
|||||||
this.cartolas().add()
|
this.cartolas().add()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const manual = {
|
||||||
|
ids: {},
|
||||||
|
$modal: null,
|
||||||
|
data: {
|
||||||
|
inmobiliaria: '',
|
||||||
|
cuenta: '',
|
||||||
|
fecha: '',
|
||||||
|
field: 0,
|
||||||
|
movimientos: [
|
||||||
|
{idx: 1}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
get movimientosIdx() {
|
||||||
|
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||||
|
return JSON.parse($movimientosIdx.val())
|
||||||
|
},
|
||||||
|
set movimientosIdx(list) {
|
||||||
|
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||||
|
$movimientosIdx.val(JSON.stringify(list))
|
||||||
|
},
|
||||||
|
update() {
|
||||||
|
return {
|
||||||
|
file: movimientos => {
|
||||||
|
const $file = $("[name='file" + this.data.field + "']")
|
||||||
|
$file.val(JSON.stringify(movimientos))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parse() {
|
||||||
|
return {
|
||||||
|
movimientos: () => {
|
||||||
|
const $fields = $(this.ids.movimientos).find('.fields')
|
||||||
|
const movimientos = []
|
||||||
|
$fields.each((i, fields) => {
|
||||||
|
const idx = $(fields).data('movimiento')
|
||||||
|
const inputs = [
|
||||||
|
'glosa',
|
||||||
|
'cargo',
|
||||||
|
'abono',
|
||||||
|
'saldo'
|
||||||
|
]
|
||||||
|
const data = {}
|
||||||
|
inputs.forEach(name => {
|
||||||
|
data[name] = $(fields).find("[name='"+name+idx+"']").val()
|
||||||
|
if (name !== 'glosa') {
|
||||||
|
data[name] = parseInt(data[name]) || 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
movimientos.push(data)
|
||||||
|
})
|
||||||
|
this.update().file(movimientos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
movimiento() {
|
||||||
|
return {
|
||||||
|
add: () => {
|
||||||
|
const idx = this.data.movimientos.reduce((prev, movimiento) => Math.max(prev, movimiento.idx), 0) + 1
|
||||||
|
const movimiento = {
|
||||||
|
idx
|
||||||
|
}
|
||||||
|
this.data.movimientos.push(movimiento)
|
||||||
|
const movimientosidx = this.movimientosIdx
|
||||||
|
movimientosidx.push(idx)
|
||||||
|
this.movimientosIdx = movimientosidx
|
||||||
|
this.draw().movimiento(idx)
|
||||||
|
},
|
||||||
|
remove: idx => {
|
||||||
|
const movimientosIdx = this.movimientosIdx
|
||||||
|
const i = movimientosIdx.findIndex(n => n === idx)
|
||||||
|
movimientosIdx.splice(i, 1)
|
||||||
|
const movimientoIdx = this.data.movimientos.findIndex(movimiento => movimiento.idx === idx)
|
||||||
|
this.data.movimientos.splice(movimientoIdx, 1)
|
||||||
|
$(this.ids.movimientos).find("[data-idx='"+idx+"']").parent().parent().remove()
|
||||||
|
this.movimientosIdx = movimientosIdx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
draw() {
|
||||||
|
return {
|
||||||
|
movimiento: idx => {
|
||||||
|
$(this.ids.movimientos).append(
|
||||||
|
$('<div></div>').addClass('fields').attr('data-movimiento', idx).append(
|
||||||
|
'<div class="field">' + "\n"
|
||||||
|
+ '<label>Glosa</label>' + "\n"
|
||||||
|
+ '<input type="text" name="glosa' + idx + '" />' + "\n"
|
||||||
|
+ '</div>' + "\n" +
|
||||||
|
'<div class="field">' + "\n"
|
||||||
|
+ '<label>Cargo</label>' + "\n"
|
||||||
|
+ '<div class="ui left labeled input">' + "\n"
|
||||||
|
+ '<div class="ui basic label">$</div>' + "\n"
|
||||||
|
+ '<input type="text" name="cargo' + idx + '" />' + "\n"
|
||||||
|
+ '</div>' + "\n"
|
||||||
|
+ '</div>' + "\n" +
|
||||||
|
'<div class="field">' + "\n"
|
||||||
|
+ '<label>Abono</label>' + "\n"
|
||||||
|
+ '<div class="ui left labeled input">' + "\n"
|
||||||
|
+ '<div class="ui basic label">$</div>' + "\n"
|
||||||
|
+ '<input type="text" name="abono' + idx + '" />' + "\n"
|
||||||
|
+ '</div>' + "\n"
|
||||||
|
+ '</div>' + "\n" +
|
||||||
|
'<div class="field">' + "\n"
|
||||||
|
+ '<label>Saldo</label>' + "\n"
|
||||||
|
+ '<div class="ui left labeled input">' + "\n"
|
||||||
|
+ '<div class="ui basic label">$</div>' + "\n"
|
||||||
|
+ '<input type="text" name="saldo' + idx + '" />' + "\n"
|
||||||
|
+ '</div>' + "\n"
|
||||||
|
+ '</div>'
|
||||||
|
).append(
|
||||||
|
$('<div></div>').addClass('field').append(
|
||||||
|
$('<label></label>').html('Eliminar')
|
||||||
|
).append(
|
||||||
|
$('<button></button>').addClass('ui red icon button').attr('type', 'button').attr('data-idx', idx).append(
|
||||||
|
$('<i></i>').addClass('remove icon')
|
||||||
|
).click(event => {
|
||||||
|
const idx = $(event.currentTarget).data('idx')
|
||||||
|
manual.movimiento().remove(idx)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(ids) {
|
||||||
|
this.ids = ids
|
||||||
|
|
||||||
|
$(this.ids.modal).modal({
|
||||||
|
onShow: () => {
|
||||||
|
$(this.ids.inmobiliaria).html(this.data.inmobiliaria)
|
||||||
|
$(this.ids.cuenta).html(this.data.cuenta)
|
||||||
|
$(this.ids.fecha).html(this.data.fecha)
|
||||||
|
this.movimientos = []
|
||||||
|
$(this.ids.form).trigger('reset')
|
||||||
|
},
|
||||||
|
onApprove: $element => {
|
||||||
|
this.parse().movimientos()
|
||||||
|
},
|
||||||
|
onHide: $element => {
|
||||||
|
this.parse().movimientos()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$modal = $(this.ids.modal)
|
||||||
|
$(this.ids.button).click(event => {
|
||||||
|
this.movimiento().add()
|
||||||
|
})
|
||||||
|
$(this.ids.form).submit(event => {
|
||||||
|
event.preventDefault()
|
||||||
|
this.$modal.modal('hide')
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
diaria.setup({
|
diaria.setup({
|
||||||
table: {
|
table: {
|
||||||
@ -513,6 +809,15 @@
|
|||||||
},
|
},
|
||||||
loader: '#loader'
|
loader: '#loader'
|
||||||
})
|
})
|
||||||
|
manual.setup({
|
||||||
|
modal: '#manual_modal',
|
||||||
|
button: '#add_manual',
|
||||||
|
inmobiliaria: '#modal_inmobiliaria',
|
||||||
|
cuenta: '#modal_cuenta',
|
||||||
|
fecha: '#modal_fecha',
|
||||||
|
form: '#modal_form',
|
||||||
|
movimientos: '#modal_movimientos'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -4,144 +4,153 @@
|
|||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||||
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
||||||
</div>
|
|
||||||
<div class="ui grid">
|
<div class="ui grid">
|
||||||
<div class="four wide column">
|
<div class="three wide column">
|
||||||
<table class="ui collapsing simple table">
|
<a href="/contabilidad/informes/xlsx/tesoreria/{{$fecha->format('Y-m-d')}}" target="_blank" style="color: inherit;">
|
||||||
<tr>
|
<div class="ui inverted green center aligned segment">
|
||||||
<td>Informe anterior</td>
|
Descargar en Excel <i class="file excel icon"></i>
|
||||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
</div>
|
||||||
</tr>
|
</a>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<table class="ui striped table">
|
</div>
|
||||||
<thead>
|
<div class="ui grid">
|
||||||
<tr>
|
<div class="four wide column">
|
||||||
<th>EMPRESA</th>
|
<table class="ui collapsing simple table">
|
||||||
<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>
|
<tr>
|
||||||
@if ($i === 0)
|
<td>Informe anterior</td>
|
||||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
<td>{{$anterior->format('d/m/Y')}}</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>
|
</tr>
|
||||||
@endforeach
|
<tr>
|
||||||
@endforeach
|
<td>Informe actual</td>
|
||||||
</tbody>
|
<td>{{$fecha->format('d/m/Y')}}</td>
|
||||||
<tfoot>
|
</tr>
|
||||||
<tr class="bold">
|
</table>
|
||||||
<th colspan="3">TOTAL</th>
|
</div>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->anterior)}}</th>
|
<div class="column"></div>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->actual)}}</th>
|
<div class="four wide column">
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->diferencia())}}</th>
|
<table class="ui collapsing simple table">
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmm)}}</th>
|
<tr>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->deposito)}}</th>
|
<td>Valor UF</td>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->saldo())}}</th>
|
<td class="right aligned">{{$format->pesos($UF->get($fecha), 2)}}</td>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->cuentas())}}</th>
|
</tr>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmms())}}</th>
|
<tr>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->depositos())}}</th>
|
<td>Valor Dólar</td>
|
||||||
<th class="right aligned">{{$format->pesos($informes['totales']->caja())}}</th>
|
<td class="right aligned">{{$format->pesos($USD->get($fecha), 2)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</table>
|
||||||
</table>
|
</div>
|
||||||
<table class="ui table">
|
</div>
|
||||||
<thead>
|
<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>
|
<tr>
|
||||||
<th>EMPRESA</th>
|
@if ($i === 0)
|
||||||
<th class="right aligned">INGRESOS</th>
|
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
||||||
<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
|
@endif
|
||||||
@if (count($movimientos) === 0)
|
<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
|
@continue
|
||||||
@endif
|
@endif
|
||||||
<tr class="grey">
|
<tr class="grey">
|
||||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@foreach ($movimientos as $movimiento)
|
@foreach ($movimientos as $ms)
|
||||||
<tr>
|
@foreach ($ms as $movimiento)
|
||||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
<tr>
|
||||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||||
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||||
<td>{{$movimiento->glosa}}</td>
|
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||||
</tr>
|
<td>{{$movimiento->glosa}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
@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>
|
@endforeach
|
||||||
</table>
|
</tbody>
|
||||||
|
</table>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.js" integrity="sha512-5cguXwRllb+6bcc2pogwIeQmQPXEzn2ddsqAexIBhh7FO1z5Hkek1J9mrK2+rmZCTU6b6pERxI7acnp1MpAg4Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function fetchAPI(url, options=null) {
|
function fetchAPI(url, options=null) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript" src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
|
{{--<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/1.13.5/js/dataTables.semanticui.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.1/js/dataTables.semanticui.min.js"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
@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/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.0/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.0/js/buttons.html5.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
||||||
|
@endpush
|
@ -1,3 +1,3 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.css" integrity="sha512-n//BDM4vMPvyca4bJjZPDh7hlqsQ7hqbP9RH18GF2hTXBY5amBwM2501M0GPiwCU/v9Tor2m13GOTFjk00tkQA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.css" integrity="sha512-3quBdRGJyLy79hzhDDcBzANW+mVqPctrGCfIPosHQtMKb3rKsCxfyslzwlz2wj1dT8A7UX+sEvDjaUv+WExQrA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
|
|
||||||
@stack('page_styles')
|
@stack('page_styles')
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
@push('page_styles')
|
@push('page_styles')
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.semanticui.min.css" />
|
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
@push('page_styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/3.0.0/css/buttons.semanticui.min.css" />
|
||||||
|
@endpush
|
@ -96,6 +96,10 @@
|
|||||||
id: '',
|
id: '',
|
||||||
data: [],
|
data: [],
|
||||||
table: null,
|
table: null,
|
||||||
|
queues: {
|
||||||
|
unidades: [],
|
||||||
|
ventas: []
|
||||||
|
},
|
||||||
get: function() {
|
get: function() {
|
||||||
return {
|
return {
|
||||||
results: () => {
|
results: () => {
|
||||||
@ -122,34 +126,33 @@
|
|||||||
}
|
}
|
||||||
const progress = this.draw().progress(data.results.length)
|
const progress = this.draw().progress(data.results.length)
|
||||||
const promises = []
|
const promises = []
|
||||||
data.results.forEach(row => {
|
this.queues.ventas = data.results.filter(row => row.tipo === 'venta').map(row => row.id)
|
||||||
if (row.tipo === 'venta') {
|
this.queues.unidades = data.results.filter(row => row.tipo !== 'venta').map(row => row.id)
|
||||||
return promises.push(this.get().venta(row.id).then(json => {
|
promises.push(this.get().ventas().then(arrays => {
|
||||||
if (json.venta === null) {
|
arrays.forEach(json => {
|
||||||
console.debug(json)
|
if (json.ventas.length === 0) {
|
||||||
return
|
console.debug(json)
|
||||||
}
|
return
|
||||||
const venta = json.venta
|
}
|
||||||
|
json.ventas.forEach(venta => {
|
||||||
progress.progress('increment')
|
progress.progress('increment')
|
||||||
const r = new Row({unidad: venta.propiedad.unidades[0], proyecto: venta.proyecto})
|
const r = new Row({unidad: venta.propiedad.unidades[0], proyecto: venta.proyecto})
|
||||||
r.venta = venta
|
r.venta = venta
|
||||||
this.data.push(r)
|
this.data.push(r)
|
||||||
}).catch(error => {
|
})
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
promises.push(this.get().unidades().then(arrays => {
|
||||||
|
arrays.forEach(json => {
|
||||||
|
if (json.unidades.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
json.unidades.forEach(unidad => {
|
||||||
progress.progress('increment')
|
progress.progress('increment')
|
||||||
console.error(row)
|
this.data.push(new Row({unidad: unidad, proyecto: unidad.proyecto_tipo_unidad.proyecto}))
|
||||||
console.error(error)
|
})
|
||||||
}))
|
})
|
||||||
}
|
}))
|
||||||
promises.push(this.get().unidad(row.id).then(json => {
|
|
||||||
const unidad = json.unidad
|
|
||||||
progress.progress('increment')
|
|
||||||
this.data.push(new Row({unidad: unidad, proyecto: unidad.proyecto_tipo_unidad.proyecto}))
|
|
||||||
}).catch(error => {
|
|
||||||
progress.progress('increment')
|
|
||||||
console.error(row)
|
|
||||||
console.error(error)
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
this.sort()
|
this.sort()
|
||||||
this.draw().clear()
|
this.draw().clear()
|
||||||
@ -157,22 +160,43 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unidad: id => {
|
unidades: () => {
|
||||||
const url = '{{$urls->api}}/ventas/unidad/' + id
|
const url = '{{$urls->api}}/search/ventas/unidades'
|
||||||
return fetchAPI(url).then(response => {
|
const chunks = []
|
||||||
if (response.ok) {
|
for (let i = 0; i < this.queues.unidades.length; i += 100) {
|
||||||
|
chunks.push(this.queues.unidades.slice(i, i + 100))
|
||||||
|
}
|
||||||
|
const promises = []
|
||||||
|
chunks.forEach(ids => {
|
||||||
|
const body = new FormData()
|
||||||
|
body.set('unidades', ids)
|
||||||
|
promises.push(fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}))
|
||||||
})
|
})
|
||||||
|
return Promise.all(promises)
|
||||||
},
|
},
|
||||||
venta: id => {
|
ventas: () => {
|
||||||
const url = '{{$urls->api}}/venta/' + id
|
const url = '{{$urls->api}}/search/ventas'
|
||||||
return fetchAPI(url).then(response => {
|
const chunks = []
|
||||||
if (!response) {
|
for (let i = 0; i < this.queues.ventas.length; i += 100) {
|
||||||
return
|
chunks.push(this.queues.ventas.slice(i, i + 100))
|
||||||
}
|
}
|
||||||
return response.json()
|
const promises = []
|
||||||
|
chunks.forEach(ids => {
|
||||||
|
const body = new FormData()
|
||||||
|
body.set('ventas', ids)
|
||||||
|
promises.push(fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json()
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
|
return Promise.all(promises)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -277,7 +277,7 @@
|
|||||||
this.draw().static('valor', this.data.valor)
|
this.draw().static('valor', this.data.valor)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.edit().fecha(valor)
|
this.edit().valor(valor)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,15 @@
|
|||||||
this.data.id = data.proyecto.id
|
this.data.id = data.proyecto.id
|
||||||
this.data.proyecto = data.proyecto.descripcion
|
this.data.proyecto = data.proyecto.descripcion
|
||||||
this.data.venta_ids = data.ventas
|
this.data.venta_ids = data.ventas
|
||||||
|
const chunkSize = 50
|
||||||
|
const chunks = []
|
||||||
|
for (let i = 0; i < data.ventas.length; i += chunkSize) {
|
||||||
|
chunks.push(data.ventas.splice(i, i + chunkSize))
|
||||||
|
}
|
||||||
const promises = []
|
const promises = []
|
||||||
data.ventas.forEach(venta_id => {
|
chunks.forEach(chunk => {
|
||||||
const promise = this.get().venta(venta_id).then(() => {
|
const promise = this.get().venta(chunk).then(count => {
|
||||||
progress.progress('increment')
|
progress.progress('increment', count)
|
||||||
})
|
})
|
||||||
promises.push(promise)
|
promises.push(promise)
|
||||||
})
|
})
|
||||||
@ -129,17 +134,22 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
venta: venta_id => {
|
venta: chunk => {
|
||||||
return fetchAPI('{{$urls->api}}/venta/' + venta_id).then(response => {
|
const body = new FormData()
|
||||||
|
body.set('ventas', chunk.join(','))
|
||||||
|
return fetchAPI('{{$urls->api}}/ventas/get', {method: 'post', body}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
if (typeof data.venta === 'undefined') {
|
if (data.ventas.length === 0) {
|
||||||
console.error(venta_id, data.error)
|
console.error(chunk, data.error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.add().venta(data.venta)
|
data.ventas.forEach(venta_id => {
|
||||||
|
this.add().venta(venta_id)
|
||||||
|
})
|
||||||
|
return data.ventas.length
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,10 @@
|
|||||||
</table>
|
</table>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@include('layout.head.styles.datatables')
|
||||||
|
@include('layout.head.styles.datatables.buttons')
|
||||||
@include('layout.body.scripts.datatables')
|
@include('layout.body.scripts.datatables')
|
||||||
|
@include('layout.body.scripts.datatables.buttons')
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -210,11 +213,6 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateRow({pago_id: json.pago_id, fecha: json.fecha, estado: 'Anulado', color: 'red', remove_fecha: true, disable: true})
|
updateRow({pago_id: json.pago_id, fecha: json.fecha, estado: 'Anulado', color: 'red', remove_fecha: true, disable: true})
|
||||||
/*const tr = $("button[data-id='" + json.pago_id + "']").parent().parent()
|
|
||||||
tr.addClass('disabled')
|
|
||||||
tr.find(':nth-child(7)').addClass('red').html('Anulado')
|
|
||||||
tr.find(':nth-child(8)').html(json.fecha)
|
|
||||||
tr.find(':nth-child(9)').html('')*/
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -296,7 +294,23 @@
|
|||||||
order: [
|
order: [
|
||||||
[0, 'asc'],
|
[0, 'asc'],
|
||||||
[2, 'asc']
|
[2, 'asc']
|
||||||
]
|
],
|
||||||
|
layout: {
|
||||||
|
top2End: {
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
extend: 'excel',
|
||||||
|
className: 'green',
|
||||||
|
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||||
|
title: 'Cuotas - {{$venta->proyecto()->descripcion}} - {{$venta->propiedad()->summary()}}',
|
||||||
|
download: 'open',
|
||||||
|
exportOptions: {
|
||||||
|
columns: ':visible'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -32,46 +32,3 @@ $showPropietario = true;
|
|||||||
@include('ventas.show.comentarios')
|
@include('ventas.show.comentarios')
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
{{--@section('page_content')
|
|
||||||
<div class="ui container">
|
|
||||||
<div class="ui two column grid">
|
|
||||||
<h1 class="four wide column header">
|
|
||||||
<div class="content">
|
|
||||||
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
|
|
||||||
{{$venta->propiedad()->summary()}}
|
|
||||||
</div>
|
|
||||||
</h1>
|
|
||||||
<div class="right floated column">
|
|
||||||
@include('ventas.show.propietario')
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<div class="ui fitted basic mini segment">
|
|
||||||
@if ($venta->currentEstado()->tipoEstadoVenta->activa)
|
|
||||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/desistir">
|
|
||||||
Desistir <i class="minus icon"></i>
|
|
||||||
</a>
|
|
||||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/ceder">
|
|
||||||
Ceder <i clasS="right chevron icon"></i>
|
|
||||||
</a>
|
|
||||||
@else
|
|
||||||
<div class="ui red icon label">
|
|
||||||
<i class="ban icon"></i>
|
|
||||||
{{ucwords($venta->currentEstado()->tipoEstadoVenta->descripcion)}}
|
|
||||||
(<a href="{{$urls->base}}/venta/{{$venta->id}}/desistida">
|
|
||||||
{{$format->pesos($venta->resciliacion()->valor)}}
|
|
||||||
</a>)
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
<div class="ui segments">
|
|
||||||
@include('ventas.show.propiedad')
|
|
||||||
@include('ventas.show.detalle')
|
|
||||||
@include('ventas.show.forma_pago', ['formaPago' => $venta->formaPago()])
|
|
||||||
@include('ventas.show.escritura')
|
|
||||||
@include('ventas.show.entrega')
|
|
||||||
@include('ventas.show.comentarios')
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endsection--}}
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<table class="ui very basic fluid table">
|
<table class="ui very basic fluid table">
|
||||||
@include('ventas.show.forma_pago.pie', ['pie' => $formaPago->pie])
|
@include('ventas.show.forma_pago.pie', ['pie' => $formaPago?->pie])
|
||||||
@include('ventas.show.forma_pago.escritura', ['escritura' => $formaPago->escritura])
|
@include('ventas.show.forma_pago.escritura', ['escritura' => $formaPago?->escritura])
|
||||||
@include('ventas.show.forma_pago.anticipo', ['anticipo' => ['uf' => $formaPago->anticipo(), 'pesos' => $formaPago->anticipo('pesos')]])
|
@include('ventas.show.forma_pago.anticipo', ['anticipo' => ['uf' => $formaPago?->anticipo(), 'pesos' => $formaPago?->anticipo('pesos')]])
|
||||||
@include('ventas.show.forma_pago.bono_pie', ['bonoPie' => $formaPago->bonoPie])
|
@include('ventas.show.forma_pago.bono_pie', ['bonoPie' => $formaPago?->bonoPie])
|
||||||
@include('ventas.show.forma_pago.subsidio', ['subsidio' => $formaPago->subsidio])
|
@include('ventas.show.forma_pago.subsidio', ['subsidio' => $formaPago?->subsidio])
|
||||||
@include('ventas.show.forma_pago.credito', ['credito' => $formaPago->credito])
|
@include('ventas.show.forma_pago.credito', ['credito' => $formaPago?->credito])
|
||||||
@include('ventas.show.forma_pago.total')
|
@include('ventas.show.forma_pago.total')
|
||||||
@include('ventas.show.forma_pago.devolucion', ['devolucion' => $formaPago->devolucion])
|
@include('ventas.show.forma_pago.devolucion', ['devolucion' => $formaPago?->devolucion])
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="pago_modal" class="ui modal">
|
<div id="pago_modal" class="ui modal">
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
||||||
<span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
|
<span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
|
||||||
</a>
|
</a>
|
||||||
@if (count($pie->cuotas()) < $pie->cuotas)
|
@if (count($pie->cuotas(false, true)) < $pie->cuotas)
|
||||||
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -8,7 +8,8 @@ return [
|
|||||||
'cache' => DI\String('{base}/cache'),
|
'cache' => DI\String('{base}/cache'),
|
||||||
'templates' => DI\String('{resources}/views'),
|
'templates' => DI\String('{resources}/views'),
|
||||||
'public' => DI\String('{base}/public'),
|
'public' => DI\String('{base}/public'),
|
||||||
'uploads' => DI\String('{public}/uploads')
|
'uploads' => DI\String('{public}/uploads'),
|
||||||
|
'informes' => DI\String('{public}/informes')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -40,6 +40,7 @@ return [
|
|||||||
$container->get(Incoviba\Repository\Inmobiliaria::class),
|
$container->get(Incoviba\Repository\Inmobiliaria::class),
|
||||||
$container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
|
$container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
|
||||||
$container->get(Incoviba\Repository\Movimiento::class),
|
$container->get(Incoviba\Repository\Movimiento::class),
|
||||||
|
$container->get(Incoviba\Service\Movimiento::class),
|
||||||
$container->get(Incoviba\Repository\Cartola::class)
|
$container->get(Incoviba\Repository\Cartola::class)
|
||||||
))
|
))
|
||||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||||
@ -61,5 +62,20 @@ return [
|
|||||||
new GuzzleHttp\Client(),
|
new GuzzleHttp\Client(),
|
||||||
$container->get(Psr\Http\Message\RequestFactoryInterface::class),
|
$container->get(Psr\Http\Message\RequestFactoryInterface::class),
|
||||||
$container->get('nubox')->get('url'));
|
$container->get('nubox')->get('url'));
|
||||||
|
},
|
||||||
|
Incoviba\Service\Informe::class => function(ContainerInterface $container) {
|
||||||
|
return (new Incoviba\Service\Informe(
|
||||||
|
$container->get(Psr\Log\LoggerInterface::class),
|
||||||
|
$container->get('folders')->get('informes'))
|
||||||
|
)
|
||||||
|
->register('xlsx', Incoviba\Service\Informe\Excel::class);
|
||||||
|
},
|
||||||
|
Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel::class => function(ContainerInterface $container) {
|
||||||
|
return new Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel(
|
||||||
|
$container->get(Psr\Log\LoggerInterface::class),
|
||||||
|
$container->get('folders')->get('informes'),
|
||||||
|
$container->get(Incoviba\Service\UF::class),
|
||||||
|
$container->get(Incoviba\Service\USD::class)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -66,6 +66,11 @@ class Cartolas extends Controller
|
|||||||
try {
|
try {
|
||||||
$cuenta = $cuentaRepository->fetchById($body["cuenta_id{$field}"]);
|
$cuenta = $cuentaRepository->fetchById($body["cuenta_id{$field}"]);
|
||||||
$fecha = new DateTimeImmutable($body["fecha{$field}"]);
|
$fecha = new DateTimeImmutable($body["fecha{$field}"]);
|
||||||
|
if (array_key_exists("manual{$field}", $body)) {
|
||||||
|
$file = json_decode($body["file{$field}"], JSON_OBJECT_AS_ARRAY);
|
||||||
|
$output['cartolas'][$field] = $cartolaService->diariaManual($cuenta, $fecha, $file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$file = $request->getUploadedFiles()["file{$field}"];
|
$file = $request->getUploadedFiles()["file{$field}"];
|
||||||
|
|
||||||
$output['cartolas'][$field] = $cartolaService->diaria($cuenta, $fecha, $file);
|
$output['cartolas'][$field] = $cartolaService->diaria($cuenta, $fecha, $file);
|
||||||
|
50
app/src/Controller/API/Contabilidad/Movimientos.php
Normal file
50
app/src/Controller/API/Contabilidad/Movimientos.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Controller\API\Contabilidad;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
|
use Incoviba\Controller\API\withJson;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
|
class Movimientos extends Ideal\Controller
|
||||||
|
{
|
||||||
|
use withJson;
|
||||||
|
|
||||||
|
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Movimiento $movimientoService,
|
||||||
|
Repository\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
|
||||||
|
{
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$output = [
|
||||||
|
'movimiento_id' => $movimiento_id,
|
||||||
|
'input' => $body,
|
||||||
|
'status' => false,
|
||||||
|
'movimiento' => null,
|
||||||
|
'centro' => null,
|
||||||
|
'detalle' => ''
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$movimiento = $movimientoService->getById($movimiento_id);
|
||||||
|
$output['movimiento'] = $movimiento;
|
||||||
|
$data = [];
|
||||||
|
if (isset($body['centro_id'])) {
|
||||||
|
$centro = $centroCostoRepository->fetchById($body['centro_id']);
|
||||||
|
$data['centro_costo_id'] = $centro->id;
|
||||||
|
}
|
||||||
|
if (isset($body['detalle'])) {
|
||||||
|
$data['detalle'] = $body['detalle'];
|
||||||
|
}
|
||||||
|
$movimientoService->setDetalles($movimiento, $data);
|
||||||
|
if (isset($body['centro_id'])) {
|
||||||
|
$output['centro'] = $centro;
|
||||||
|
}
|
||||||
|
if (isset($body['detalle'])) {
|
||||||
|
$output['detalle'] = $body['detalle'];
|
||||||
|
}
|
||||||
|
} catch (EmptyResult) {}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,13 @@ namespace Incoviba\Controller\API;
|
|||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Incoviba\Controller\withRedis;
|
||||||
|
use Incoviba\Common\Implement\Exception;
|
||||||
use Incoviba\Service;
|
use Incoviba\Service;
|
||||||
|
|
||||||
class Search
|
class Search
|
||||||
{
|
{
|
||||||
use withJson;
|
use withJson, withRedis;
|
||||||
|
|
||||||
public function query(ServerRequestInterface $request, ResponseInterface $response,
|
public function query(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
Service\Search $service): ResponseInterface
|
Service\Search $service): ResponseInterface
|
||||||
@ -17,4 +19,155 @@ class Search
|
|||||||
$output = compact('results');
|
$output = compact('results');
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
public function unidad(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||||
|
Service\Venta\Unidad $unidadService, int $unidad_id): ResponseInterface
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'unidad_id' => $unidad_id,
|
||||||
|
'unidad' => null
|
||||||
|
];
|
||||||
|
$redisKey = "search:unidad:{$unidad_id}";
|
||||||
|
try {
|
||||||
|
$output['unidad'] = $this->fetchRedis($redisService, $redisKey);
|
||||||
|
} catch (Exception\EmptyRedis) {
|
||||||
|
try {
|
||||||
|
$unidad = $unidadService->getByIdForSearch($unidad_id);
|
||||||
|
$output['unidad'] = [
|
||||||
|
'id' => $unidad['id'],
|
||||||
|
'descripcion' => $unidad['descripcion'],
|
||||||
|
'proyecto_tipo_unidad' => [
|
||||||
|
'proyecto' => [
|
||||||
|
'id' => $unidad['proyecto_id'],
|
||||||
|
'descripcion' => $unidad['proyecto_descripcion']
|
||||||
|
],
|
||||||
|
'tipo_unidad' => [
|
||||||
|
'descripcion' => $unidad['tipo_unidad_descripcion']
|
||||||
|
],
|
||||||
|
'superficie' => $unidad['superficie']
|
||||||
|
],
|
||||||
|
'current_precio' => [
|
||||||
|
'valor' => $unidad['precio']
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$this->saveRedis($redisService, $redisKey, $output['unidad']);
|
||||||
|
} catch (Exception\EmptyResult) {}
|
||||||
|
}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
|
public function unidades(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||||
|
Service\Venta\Unidad $unidadService): ResponseInterface
|
||||||
|
{
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$output = [
|
||||||
|
'input' => $body,
|
||||||
|
'unidades' => []
|
||||||
|
];
|
||||||
|
$unidades = explode(',', $body['unidades']);
|
||||||
|
foreach ($unidades as $unidad_id) {
|
||||||
|
$redisKey = "search:unidad:{$unidad_id}";
|
||||||
|
try {
|
||||||
|
$output['unidades'] []= $this->fetchRedis($redisService, $redisKey);
|
||||||
|
} catch (Exception\EmptyRedis) {
|
||||||
|
try {
|
||||||
|
$unidad = $unidadService->getByIdForSearch($unidad_id);
|
||||||
|
$unidad = [
|
||||||
|
'id' => $unidad['id'],
|
||||||
|
'descripcion' => $unidad['descripcion'],
|
||||||
|
'proyecto_tipo_unidad' => [
|
||||||
|
'proyecto' => [
|
||||||
|
'id' => $unidad['proyecto_id'],
|
||||||
|
'descripcion' => $unidad['proyecto_descripcion']
|
||||||
|
],
|
||||||
|
'tipo_unidad' => [
|
||||||
|
'descripcion' => $unidad['tipo_unidad_descripcion']
|
||||||
|
],
|
||||||
|
'superficie' => $unidad['superficie']
|
||||||
|
],
|
||||||
|
'current_precio' => [
|
||||||
|
'valor' => $unidad['precio']
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$output['unidades'] []= $unidad;
|
||||||
|
$this->saveRedis($redisService, $redisKey, $unidad);
|
||||||
|
} catch (Exception\EmptyResult) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
|
public function venta(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||||
|
Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'venta_id' => $venta_id,
|
||||||
|
'venta' => null
|
||||||
|
];
|
||||||
|
$redisKey = "search:venta:{$venta_id}";
|
||||||
|
try {
|
||||||
|
$output['venta'] = $this->fetchRedis($redisService, $redisKey);
|
||||||
|
} catch (Exception\EmptyRedis) {
|
||||||
|
try {
|
||||||
|
$venta = $ventaService->getById($venta_id);
|
||||||
|
/*$output['venta'] = [
|
||||||
|
'id' => $venta->id,
|
||||||
|
''
|
||||||
|
];*/
|
||||||
|
$output['venta'] = $venta;
|
||||||
|
$this->saveRedis($redisService, $redisKey, $output['venta']);
|
||||||
|
} catch (Exception\EmptyResult) {}
|
||||||
|
}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
|
public function ventas(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||||
|
Service\Venta $ventaService): ResponseInterface
|
||||||
|
{
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$output = [
|
||||||
|
'input' => $body,
|
||||||
|
'ventas' => []
|
||||||
|
];
|
||||||
|
$ventas = explode(',', $body['ventas']);
|
||||||
|
foreach ($ventas as $venta_id) {
|
||||||
|
$redisKey = "search:venta:{$venta_id}";
|
||||||
|
try {
|
||||||
|
$output['ventas'] []= $this->fetchRedis($redisService, $redisKey);
|
||||||
|
} catch (Exception\EmptyRedis) {
|
||||||
|
try {
|
||||||
|
$venta = $ventaService->getByIdForSearch($venta_id);
|
||||||
|
$venta = [
|
||||||
|
'id' => $venta['id'],
|
||||||
|
'proyecto' => [
|
||||||
|
'id' => $venta['proyecto_id'],
|
||||||
|
'descripcion' => $venta['proyecto_descripcion']
|
||||||
|
],
|
||||||
|
'propietario' => [
|
||||||
|
'nombre_completo' => $venta['propietario']
|
||||||
|
],
|
||||||
|
'propiedad' => [
|
||||||
|
'unidades' => [
|
||||||
|
[
|
||||||
|
'descripcion' => $venta['unidad_descripcion'],
|
||||||
|
'proyecto_tipo_unidad' => [
|
||||||
|
'tipo_unidad' => [
|
||||||
|
'descripcion' => $venta['tipo_unidad_descripcion']
|
||||||
|
],
|
||||||
|
'superficie' => $venta['superficie']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'fecha' => $venta['fecha'],
|
||||||
|
'current_estado' => [
|
||||||
|
'tipo_estado_venta' => [
|
||||||
|
'activa' => $venta['activa']
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'valor' => $venta['valor']
|
||||||
|
];
|
||||||
|
$output['ventas'] []= $venta;
|
||||||
|
$this->saveRedis($redisService, $redisKey, json_encode($venta));
|
||||||
|
} catch (Exception\EmptyResult) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,32 @@ class Ventas extends Controller
|
|||||||
}
|
}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
public function getMany(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||||
|
Service\Venta $service): ResponseInterface
|
||||||
|
{
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$output = [
|
||||||
|
'input' => $body,
|
||||||
|
'ventas' => []
|
||||||
|
];
|
||||||
|
$ventas = explode(',', $body['ventas']);
|
||||||
|
foreach ($ventas as $venta_id) {
|
||||||
|
$redisKey = "venta:{$venta_id}";
|
||||||
|
try {
|
||||||
|
$venta = $this->fetchRedis($redisService, $redisKey);
|
||||||
|
$output['ventas'] []= $venta;
|
||||||
|
} catch (EmptyRedis) {
|
||||||
|
try {
|
||||||
|
$venta = $service->getById($venta_id);
|
||||||
|
$output['ventas'] []= $venta;
|
||||||
|
$this->saveRedis($redisService, $redisKey, $venta);
|
||||||
|
} catch (EmptyResult $exception) {
|
||||||
|
$this->logger->notice($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
public function porFirmar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService, Service\Redis $redisService): ResponseInterface
|
public function porFirmar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService, Service\Redis $redisService): ResponseInterface
|
||||||
{
|
{
|
||||||
$body = $request->getBody();
|
$body = $request->getBody();
|
||||||
|
@ -18,7 +18,8 @@ class Contabilidad extends Controller
|
|||||||
|
|
||||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Redis $redisService,
|
Service\Redis $redisService,
|
||||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||||
|
Repository\CentroCosto $centroCostoRepository): ResponseInterface
|
||||||
{
|
{
|
||||||
$redisKey = 'inmobiliarias';
|
$redisKey = 'inmobiliarias';
|
||||||
$inmobiliarias = [];
|
$inmobiliarias = [];
|
||||||
@ -30,7 +31,8 @@ class Contabilidad extends Controller
|
|||||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||||
} catch (EmptyResult) {}
|
} catch (EmptyResult) {}
|
||||||
}
|
}
|
||||||
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias'));
|
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||||
|
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias', 'centrosCostos'));
|
||||||
}
|
}
|
||||||
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Redis $redisService,
|
Service\Redis $redisService,
|
||||||
@ -62,12 +64,13 @@ class Contabilidad extends Controller
|
|||||||
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'activos', 'vencidos'));
|
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'activos', 'vencidos'));
|
||||||
}
|
}
|
||||||
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Contabilidad\Informe\Tesoreria $contabilidadService,
|
Service\Contabilidad\Informe\Tesoreria $contabilidadService,
|
||||||
string $fecha = 'today'): ResponseInterface
|
string $fecha = 'today'): ResponseInterface
|
||||||
{
|
{
|
||||||
$fecha = new DateTimeImmutable($fecha);
|
$fecha = new DateTimeImmutable($fecha);
|
||||||
$anterior = $contabilidadService->getAnterior($fecha);
|
$anterior = $contabilidadService->getAnterior($fecha);
|
||||||
$informes = $contabilidadService->build($fecha);
|
$informes = $contabilidadService->build($fecha);
|
||||||
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'informes'));
|
$filename = "Informe de Tesorería {$fecha->format('d.m.Y')}";
|
||||||
|
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'informes', 'filename'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
app/src/Controller/Contabilidad/Informes.php
Normal file
20
app/src/Controller/Contabilidad/Informes.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Controller\Contabilidad;
|
||||||
|
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
|
class Informes extends Ideal\Controller
|
||||||
|
{
|
||||||
|
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Informe\Tesoreria $tesoreriaService, string $fecha): ResponseInterface
|
||||||
|
{
|
||||||
|
$fecha = new DateTimeImmutable($fecha);
|
||||||
|
|
||||||
|
$tesoreriaService->buildInforme($fecha, $tesoreriaService->build($fecha));
|
||||||
|
$response->getBody()->write(file_get_contents('php://output'));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ class Login
|
|||||||
public function form(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
public function form(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
||||||
{
|
{
|
||||||
if ($service->isIn()) {
|
if ($service->isIn()) {
|
||||||
return $response->withStatus(301)->withHeader('Location', $view->get('urls')->base);
|
return $response->withStatus(302)->withHeader('Location', $view->get('urls')->base);
|
||||||
}
|
}
|
||||||
return $view->render($response, 'login.form');
|
return $view->render($response, 'login.form');
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,13 @@ class Ventas
|
|||||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Venta $service, int $venta_id): ResponseInterface
|
Service\Venta $service, int $venta_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$venta = $service->getById($venta_id);
|
try {
|
||||||
return $view->render($response, 'ventas.show', compact('venta'));
|
$venta = $service->getById($venta_id);
|
||||||
|
return $view->render($response, 'ventas.show', compact('venta'));
|
||||||
|
} catch (EmptyResult) {
|
||||||
|
$response = $response->withStatus(404);
|
||||||
|
return $view->render($response, 'not_found');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function showUnidad(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function showUnidad(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Venta $service, string $proyecto_nombre, int $unidad_descripcion): ResponseInterface
|
Service\Venta $service, string $proyecto_nombre, int $unidad_descripcion): ResponseInterface
|
||||||
|
@ -6,8 +6,8 @@ use Psr\Http\Message\ResponseFactoryInterface;
|
|||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Server\RequestHandlerInterface;
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
use Incoviba\Service;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
class Authentication
|
class Authentication
|
||||||
{
|
{
|
||||||
@ -27,7 +27,11 @@ class Authentication
|
|||||||
$response = $this->responseFactory->createResponse(301, 'Not logged in')
|
$response = $this->responseFactory->createResponse(301, 'Not logged in')
|
||||||
->withHeader('Referer', (string) $request->getUri())
|
->withHeader('Referer', (string) $request->getUri())
|
||||||
->withHeader('X-Redirected-URI', (string) $request->getUri());
|
->withHeader('X-Redirected-URI', (string) $request->getUri());
|
||||||
return $this->view->render($response, 'login.form', ['redirect_uri' => (string) $request->getUri()]);
|
$url = "{$request->getUri()}";
|
||||||
|
if (str_ends_with($url, '/login')) {
|
||||||
|
$url = str_replace('/login', '', $url);
|
||||||
|
}
|
||||||
|
return $this->view->render($response, 'login.form', ['redirect_uri' => $url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isValid(ServerRequestInterface $request): bool
|
protected function isValid(ServerRequestInterface $request): bool
|
||||||
|
@ -13,7 +13,7 @@ class CentroCosto extends Ideal\Model
|
|||||||
|
|
||||||
public function jsonSerialize(): mixed
|
public function jsonSerialize(): mixed
|
||||||
{
|
{
|
||||||
return array_map(parent::jsonSerialize(), [
|
return array_merge(parent::jsonSerialize(), [
|
||||||
'tipo_centro' => $this->tipoCentro,
|
'tipo_centro' => $this->tipoCentro,
|
||||||
'categoria' => $this->categoria,
|
'categoria' => $this->categoria,
|
||||||
'tipo_cuenta' => $this->tipoCuenta,
|
'tipo_cuenta' => $this->tipoCuenta,
|
||||||
|
@ -3,6 +3,7 @@ namespace Incoviba\Model;
|
|||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Model\Movimiento\Detalle;
|
||||||
|
|
||||||
class Movimiento extends Ideal\Model
|
class Movimiento extends Ideal\Model
|
||||||
{
|
{
|
||||||
@ -14,6 +15,15 @@ class Movimiento extends Ideal\Model
|
|||||||
public int $abono;
|
public int $abono;
|
||||||
public int $saldo;
|
public int $saldo;
|
||||||
|
|
||||||
|
protected ?Detalle $detalles;
|
||||||
|
public function getDetalles(): ?Detalle
|
||||||
|
{
|
||||||
|
if (!isset($this->detalles)) {
|
||||||
|
$this->detalles = $this->runFactory('detalles');
|
||||||
|
}
|
||||||
|
return $this->detalles;
|
||||||
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): mixed
|
public function jsonSerialize(): mixed
|
||||||
{
|
{
|
||||||
return array_merge(parent::jsonSerialize(), [
|
return array_merge(parent::jsonSerialize(), [
|
||||||
@ -23,7 +33,8 @@ class Movimiento extends Ideal\Model
|
|||||||
'documento' => $this->documento,
|
'documento' => $this->documento,
|
||||||
'cargo' => $this->cargo,
|
'cargo' => $this->cargo,
|
||||||
'abono' => $this->abono,
|
'abono' => $this->abono,
|
||||||
'saldo' => $this->saldo
|
'saldo' => $this->saldo,
|
||||||
|
'detalles' => $this->getDetalles() ?? null
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
app/src/Model/Movimiento/Detalle.php
Normal file
21
app/src/Model/Movimiento/Detalle.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Model\Movimiento;
|
||||||
|
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Model;
|
||||||
|
|
||||||
|
class Detalle extends Ideal\Model
|
||||||
|
{
|
||||||
|
public Model\Movimiento $movimiento;
|
||||||
|
public ?Model\CentroCosto $centroCosto;
|
||||||
|
public ?string $detalle;
|
||||||
|
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'movimiento_id' => $this->movimiento->id,
|
||||||
|
'centro_costo' => $this->centroCosto,
|
||||||
|
'detalle' => $this->detalle
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -4,13 +4,14 @@ namespace Incoviba\Model;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Controller\Ventas;
|
use Incoviba\Controller\Ventas;
|
||||||
|
use Incoviba\Model\Venta\FormaPago;
|
||||||
use Incoviba\Model\Venta\Pago;
|
use Incoviba\Model\Venta\Pago;
|
||||||
|
|
||||||
class Venta extends Ideal\Model
|
class Venta extends Ideal\Model
|
||||||
{
|
{
|
||||||
protected Venta\Propietario $propietario;
|
protected Venta\Propietario $propietario;
|
||||||
protected Venta\Propiedad $propiedad;
|
protected Venta\Propiedad $propiedad;
|
||||||
protected Venta\FormaPago $formaPago;
|
protected ?Venta\FormaPago $formaPago;
|
||||||
public DateTimeInterface $fecha;
|
public DateTimeInterface $fecha;
|
||||||
public DateTimeInterface $fechaIngreso;
|
public DateTimeInterface $fechaIngreso;
|
||||||
public float $valor;
|
public float $valor;
|
||||||
@ -36,7 +37,7 @@ class Venta extends Ideal\Model
|
|||||||
}
|
}
|
||||||
return $this->propiedad;
|
return $this->propiedad;
|
||||||
}
|
}
|
||||||
public function formaPago(): Venta\FormaPago
|
public function formaPago(): ?Venta\FormaPago
|
||||||
{
|
{
|
||||||
if (!isset($this->formaPago)) {
|
if (!isset($this->formaPago)) {
|
||||||
$this->formaPago = $this->runFactory('formaPago');
|
$this->formaPago = $this->runFactory('formaPago');
|
||||||
@ -104,7 +105,7 @@ class Venta extends Ideal\Model
|
|||||||
return array_merge(parent::jsonSerialize(), [
|
return array_merge(parent::jsonSerialize(), [
|
||||||
'propietario' => $this->propietario(),
|
'propietario' => $this->propietario(),
|
||||||
'propiedad' => $this->propiedad(),
|
'propiedad' => $this->propiedad(),
|
||||||
'forma_pago' => $this->formaPago()->ids(),
|
'forma_pago' => $this->formaPago()?->ids(),
|
||||||
'fecha' => $this->fecha->format('Y-m-d'),
|
'fecha' => $this->fecha->format('Y-m-d'),
|
||||||
'fecha_ingreso' => $this->fechaIngreso->format('Y-m-d'),
|
'fecha_ingreso' => $this->fechaIngreso->format('Y-m-d'),
|
||||||
'valor' => $this->valor,
|
'valor' => $this->valor,
|
||||||
|
@ -5,12 +5,12 @@ use JsonSerializable;
|
|||||||
|
|
||||||
class FormaPago implements JsonSerializable
|
class FormaPago implements JsonSerializable
|
||||||
{
|
{
|
||||||
public ?Pie $pie;
|
public ?Pie $pie = null;
|
||||||
public ?Escritura $escritura;
|
public ?Escritura $escritura = null;
|
||||||
public ?BonoPie $bonoPie;
|
public ?BonoPie $bonoPie = null;
|
||||||
public ?Subsidio $subsidio;
|
public ?Subsidio $subsidio = null;
|
||||||
public ?Credito $credito;
|
public ?Credito $credito = null;
|
||||||
public ?Pago $devolucion;
|
public ?Pago $devolucion = null;
|
||||||
|
|
||||||
public function anticipo(string $moneda = Pago::UF): float
|
public function anticipo(string $moneda = Pago::UF): float
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ class Pie extends Model
|
|||||||
public function cuotas(bool $pagadas = false, bool $vigentes = false): array
|
public function cuotas(bool $pagadas = false, bool $vigentes = false): array
|
||||||
{
|
{
|
||||||
if ($this->asociado !== null) {
|
if ($this->asociado !== null) {
|
||||||
return $this->asociado->cuotas($pagadas);
|
return $this->asociado->cuotas($pagadas, $vigentes);
|
||||||
}
|
}
|
||||||
if (!$pagadas and !$vigentes) {
|
if (!$pagadas and !$vigentes) {
|
||||||
return $this->cuotasArray;
|
return $this->cuotasArray;
|
||||||
|
@ -61,12 +61,12 @@ class Movimiento extends Ideal\Repository
|
|||||||
->where('cuenta_id = ? AND fecha = ?');
|
->where('cuenta_id = ? AND fecha = ?');
|
||||||
return $this->fetchMany($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
return $this->fetchMany($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||||
}
|
}
|
||||||
public function fetchByCuentaAndFechaAndMonto(int $cuenta_id, DateTimeInterface $fecha, int $monto): Model\Movimiento
|
public function fetchByCuentaAndFechaAndCargoAndAbonoAndSaldo(int $cuenta_id, DateTimeInterface $fecha, int $cargo, int $abono, int $saldo): Model\Movimiento
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select()
|
->select()
|
||||||
->from($this->getTable())
|
->from($this->getTable())
|
||||||
->where('cuenta_id = ? AND fecha = ? AND (cargo = ? OR abono = ?)');
|
->where('cuenta_id = ? AND fecha = ? AND cargo = ? AND abono = ? AND saldo = ?');
|
||||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $monto, $monto]);
|
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $cargo, $abono, $saldo]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
app/src/Repository/Movimiento/Detalle.php
Normal file
60
app/src/Repository/Movimiento/Detalle.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Repository\Movimiento;
|
||||||
|
|
||||||
|
use Incoviba\Common\Define;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Common\Implement;
|
||||||
|
use Incoviba\Model;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
|
||||||
|
class Detalle extends Ideal\Repository
|
||||||
|
{
|
||||||
|
public function __construct(Define\Connection $connection, protected Repository\Movimiento $movimientoRepository,
|
||||||
|
protected Repository\CentroCosto $centroCostoRepository)
|
||||||
|
{
|
||||||
|
parent::__construct($connection);
|
||||||
|
$this->setTable('movimientos_detalles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(?array $data = null): Model\Movimiento\Detalle
|
||||||
|
{
|
||||||
|
$map = (new Implement\Repository\MapperParser(['detalle']))
|
||||||
|
->register('movimiento_id', (new Implement\Repository\Mapper())
|
||||||
|
->setProperty('movimiento')
|
||||||
|
->setFunction(function(array $data) {
|
||||||
|
return $this->movimientoRepository->fetchById($data['movimiento_id']);
|
||||||
|
}))
|
||||||
|
->register('centro_costo_id', (new Implement\Repository\Mapper())
|
||||||
|
->setProperty('centroCosto')
|
||||||
|
->setFunction(function(array $data) {
|
||||||
|
return $this->centroCostoRepository->fetchById($data['centro_costo_id']);
|
||||||
|
}));
|
||||||
|
return $this->parseData(new Model\Movimiento\Detalle(), $data, $map);
|
||||||
|
}
|
||||||
|
public function save(Define\Model $model): Model\Movimiento\Detalle
|
||||||
|
{
|
||||||
|
$this->saveNew(
|
||||||
|
['movimiento_id', 'centro_costo_id', 'detalle'],
|
||||||
|
[$model->movimiento->id, $model->centroCosto->id, $model->detalle]
|
||||||
|
);
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
public function edit(Define\Model $model, array $new_data): Model\Movimiento\Detalle
|
||||||
|
{
|
||||||
|
return $this->update($model, ['movimiento_id', 'centro_costo_id', 'detalle'], $new_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fetchByMovimiento(int $movimiento_id): Model\Movimiento\Detalle
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select()
|
||||||
|
->from($this->getTable())
|
||||||
|
->where('movimiento_id = ?');
|
||||||
|
return $this->fetchOne($query, [$movimiento_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getKey(): string
|
||||||
|
{
|
||||||
|
return 'movimiento_id';
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,7 @@ class Venta extends Ideal\Repository
|
|||||||
->setFactory((new Implement\Repository\Factory())
|
->setFactory((new Implement\Repository\Factory())
|
||||||
->setCallable([$this->propiedadRepository, 'fetchById'])
|
->setCallable([$this->propiedadRepository, 'fetchById'])
|
||||||
->setArgs([$data['propiedad']])))
|
->setArgs([$data['propiedad']])))
|
||||||
->register('pie', (new Implement\Repository\Mapper())
|
/*->register('pie', (new Implement\Repository\Mapper())
|
||||||
->setProperty('formaPago')
|
->setProperty('formaPago')
|
||||||
->setFactory((new Implement\Repository\Factory())
|
->setFactory((new Implement\Repository\Factory())
|
||||||
->setCallable(function($repositories, $data) {
|
->setCallable(function($repositories, $data) {
|
||||||
@ -84,7 +84,7 @@ class Venta extends Ideal\Repository
|
|||||||
'escrituraRepository' => $this->escrituraRepository,
|
'escrituraRepository' => $this->escrituraRepository,
|
||||||
'subsidioRepository' => $this->subsidioRepository,
|
'subsidioRepository' => $this->subsidioRepository,
|
||||||
'pagoService' => $this->pagoService
|
'pagoService' => $this->pagoService
|
||||||
], $data])))
|
], $data])))*/
|
||||||
/*->register('escriturado', (new Implement\Repository\Mapper())
|
/*->register('escriturado', (new Implement\Repository\Mapper())
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
return $data['escritura'] !== null;
|
return $data['escritura'] !== null;
|
||||||
@ -295,8 +295,10 @@ class Venta extends Ideal\Repository
|
|||||||
->joined('JOIN `propietario` ON `propietario`.`rut` = a.`propietario`')
|
->joined('JOIN `propietario` ON `propietario`.`rut` = a.`propietario`')
|
||||||
->where("CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario
|
->where("CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario
|
||||||
OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario
|
OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario
|
||||||
OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario");
|
OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario
|
||||||
return $this->fetchIds($query, [':propietario' => "%{$propietario}%"]);
|
OR rut = :rut
|
||||||
|
OR CONCAT_WS('-', rut, dv) = :rut");
|
||||||
|
return $this->fetchIds($query, [':propietario' => "%{$propietario}%", ':rut' => $propietario]);
|
||||||
}
|
}
|
||||||
public function fetchByPropietarioNombreCompleto(string $propietario): array
|
public function fetchByPropietarioNombreCompleto(string $propietario): array
|
||||||
{
|
{
|
||||||
@ -353,6 +355,48 @@ class Venta extends Ideal\Repository
|
|||||||
->where('bono_pie = ?');
|
->where('bono_pie = ?');
|
||||||
return $this->fetchId($query, [$bono_id]);
|
return $this->fetchId($query, [$bono_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByIdForSearch(int $venta_id): array
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('venta.id AS id, venta.fecha AS fecha, venta.valor_uf AS valor')
|
||||||
|
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
|
||||||
|
->columns('CONCAT_WS(" ", propietario.nombres, propietario.apellido_paterno, propietario.apellido_materno) AS propietario')
|
||||||
|
->columns('unidad.descripcion AS unidad_descripcion, tu.descripcion AS tipo_unidad_descripcion, ptu.m2 + ptu.logia + ptu.terraza AS superficie')
|
||||||
|
->columns('tev.activa')
|
||||||
|
->from($this->getTable())
|
||||||
|
->joined('JOIN propietario ON propietario.rut = venta.propietario')
|
||||||
|
->joined('JOIN propiedad_unidad pu ON pu.propiedad = venta.propiedad')
|
||||||
|
->joined('JOIN unidad ON unidad.id = pu.unidad')
|
||||||
|
->joined('JOIN proyecto_tipo_unidad ptu ON unidad.pt = ptu.id')
|
||||||
|
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
|
||||||
|
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
||||||
|
->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = venta.id')
|
||||||
|
->joined('JOIN tipo_estado_venta tev ON ev.estado = tev.id')
|
||||||
|
->where('venta.id = ? AND tu.descripcion = "departamento"')
|
||||||
|
->group('venta.id');
|
||||||
|
return $this->connection->execute($query, [$venta_id])->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
public function fetchByIdForList(int $venta_id): array
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('venta.id AS id, venta.fecha AS fecha, venta.valor_uf AS valor')
|
||||||
|
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
|
||||||
|
->columns('CONCAT_WS(" ", propietario.nombres, propietario.apellido_paterno, propietario.apellido_materno) AS propietario')
|
||||||
|
->columns("GROUP_CONCAT(unidad.descripcion SEPARATOR ' - ') AS unidad_descripcion, tu.descripcion AS tipo_unidad_descripcion, ptu.m2 + ptu.logia + ptu.terraza AS superficie")
|
||||||
|
->columns('tev.activa')
|
||||||
|
->from($this->getTable())
|
||||||
|
->joined('JOIN propietario ON propietario.rut = venta.propietario')
|
||||||
|
->joined('JOIN propiedad_unidad pu ON pu.propiedad = venta.propiedad')
|
||||||
|
->joined('JOIN unidad ON unidad.id = pu.unidad')
|
||||||
|
->joined('JOIN proyecto_tipo_unidad ptu ON unidad.pt = ptu.id')
|
||||||
|
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
|
||||||
|
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
||||||
|
->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = venta.id')
|
||||||
|
->joined('JOIN tipo_estado_venta tev ON ev.estado = tev.id')
|
||||||
|
->where('venta.id = ?')
|
||||||
|
->group('venta.id');
|
||||||
|
return $this->connection->execute($query, [$venta_id])->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
protected function fetchIds(string $query, ?array $data = null): array
|
protected function fetchIds(string $query, ?array $data = null): array
|
||||||
{
|
{
|
||||||
|
@ -52,4 +52,13 @@ class BonoPie extends Ideal\Repository
|
|||||||
->where('pago = ?');
|
->where('pago = ?');
|
||||||
return $this->fetchOne($query, [$pago_id]);
|
return $this->fetchOne($query, [$pago_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByVenta(int $venta_id): Model\Venta\BonoPie
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.bono_pie = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,4 +53,13 @@ class Credito extends Ideal\Repository
|
|||||||
->where('pago = ?');
|
->where('pago = ?');
|
||||||
return $this->fetchOne($query, [$pago_id]);
|
return $this->fetchOne($query, [$pago_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByVenta(int $venta_id): Model\Venta\Credito
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.credito = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,13 @@ class Escritura extends Ideal\Repository
|
|||||||
->where('pago = ?');
|
->where('pago = ?');
|
||||||
return $this->fetchOne($query, [$pago_id]);
|
return $this->fetchOne($query, [$pago_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByVenta(int $venta_id): Model\Venta\Escritura
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.escritura = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,4 +108,13 @@ WHERE venta_id = ?";
|
|||||||
->where('valor = ? OR ROUND(valor/uf, 3) = ?');
|
->where('valor = ? OR ROUND(valor/uf, 3) = ?');
|
||||||
return $this->fetchMany($query, [$value, $value]);
|
return $this->fetchMany($query, [$value, $value]);
|
||||||
}
|
}
|
||||||
|
public function fetchDevolucionByVenta(int $venta_id): Model\Venta\Pago
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.devolucion = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,4 +72,13 @@ class Pie extends Ideal\Repository
|
|||||||
->where('reajuste = ?');
|
->where('reajuste = ?');
|
||||||
return $this->fetchOne($query, [$reajuste_id]);
|
return $this->fetchOne($query, [$reajuste_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByVenta(int $venta_id): Model\Venta\Pie
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.pie = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,4 +49,13 @@ class Subsidio extends Ideal\Repository
|
|||||||
->where('subsidio = ? OR pago = ?');
|
->where('subsidio = ? OR pago = ?');
|
||||||
return $this->fetchOne($query, [$pago_id, $pago_id]);
|
return $this->fetchOne($query, [$pago_id, $pago_id]);
|
||||||
}
|
}
|
||||||
|
public function fetchByVenta(int $venta_id): Model\Venta\Subsidio
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from("{$this->getTable()} a")
|
||||||
|
->joined('JOIN venta ON venta.subsidio = a.id')
|
||||||
|
->where('venta.id = ?');
|
||||||
|
return $this->fetchOne($query, [$venta_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,24 @@ class Unidad extends Ideal\Repository
|
|||||||
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
||||||
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
|
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
public function fetchByIdForSearch(int $unidad_id): array
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('unidad.id AS id, unidad.descripcion AS descripcion')
|
||||||
|
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
|
||||||
|
->columns('tu.descripcion AS tipo_unidad_descripcion')
|
||||||
|
->columns('ptu.m2 + ptu.logia + ptu.terraza AS superficie')
|
||||||
|
->columns('precio.valor AS precio')
|
||||||
|
->from($this->getTable())
|
||||||
|
->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
|
||||||
|
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
|
||||||
|
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
||||||
|
->joined('JOIN precio ON precio.unidad = unidad.id')
|
||||||
|
->joined('JOIN (SELECT ep1.* FROM estado_precio ep1 JOIN (SELECT MAX(id) AS id, precio FROM estado_precio GROUP BY precio) ep0 ON ep0.id = ep1.id) ep ON ep.precio = precio.id')
|
||||||
|
->where('unidad.id = ?')
|
||||||
|
->group('unidad.id');
|
||||||
|
return $this->connection->execute($query, [$unidad_id])->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
protected function joinProrrateo(): string
|
protected function joinProrrateo(): string
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ class Cartola extends Service
|
|||||||
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
||||||
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||||
protected Repository\Movimiento $movimientoRepository,
|
protected Repository\Movimiento $movimientoRepository,
|
||||||
|
protected Movimiento $movimientoService,
|
||||||
protected Repository\Cartola $cartolaRepository) {
|
protected Repository\Cartola $cartolaRepository) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
}
|
}
|
||||||
@ -51,6 +52,7 @@ class Cartola extends Service
|
|||||||
$movimientos = [];
|
$movimientos = [];
|
||||||
foreach ($ms as $m) {
|
foreach ($ms as $m) {
|
||||||
$movimiento = $this->buildMovimiento($cuenta, $m);
|
$movimiento = $this->buildMovimiento($cuenta, $m);
|
||||||
|
$movimiento = $this->movimientoService->process($movimiento);
|
||||||
|
|
||||||
if ($movimiento->fecha->getTimestamp() === $fecha->getTimestamp()) {
|
if ($movimiento->fecha->getTimestamp() === $fecha->getTimestamp()) {
|
||||||
$movimientos []= $movimiento;
|
$movimientos []= $movimiento;
|
||||||
@ -65,6 +67,29 @@ class Cartola extends Service
|
|||||||
$cartola = $this->buildCartola($cuenta, $fecha, $cartolaData);
|
$cartola = $this->buildCartola($cuenta, $fecha, $cartolaData);
|
||||||
return compact('cartola', 'movimientos');
|
return compact('cartola', 'movimientos');
|
||||||
}
|
}
|
||||||
|
public function diariaManual(Model\Inmobiliaria\Cuenta $cuenta, DateTimeInterface $fecha, array $data): array
|
||||||
|
{
|
||||||
|
$cartolaData = [
|
||||||
|
'cargos' => 0,
|
||||||
|
'abonos' => 0,
|
||||||
|
'saldos' => 0
|
||||||
|
];
|
||||||
|
$movimientos = [];
|
||||||
|
foreach ($data as $row) {
|
||||||
|
$dataMovimiento = $row;
|
||||||
|
$dataMovimiento['fecha'] = $fecha->format('Y-m-d');
|
||||||
|
$dataMovimiento['documento'] = '';
|
||||||
|
$movimiento = $this->buildMovimiento($cuenta, $dataMovimiento);
|
||||||
|
$movimiento = $this->movimientoService->process($movimiento);
|
||||||
|
|
||||||
|
$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
|
protected function getMovimientosDiarios(Model\Banco $banco, UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
@ -85,12 +110,13 @@ class Cartola extends Service
|
|||||||
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Movimiento
|
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Movimiento
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$valor = ($data['cargo'] !== 0 and $data['cargo'] !== null) ? $data['cargo'] : $data['abono'];
|
|
||||||
return $this->movimientoRepository
|
return $this->movimientoRepository
|
||||||
->fetchByCuentaAndFechaAndMonto(
|
->fetchByCuentaAndFechaAndCargoAndAbonoAndSaldo(
|
||||||
$cuenta->id,
|
$cuenta->id,
|
||||||
new DateTimeImmutable($data['fecha']),
|
new DateTimeImmutable($data['fecha']),
|
||||||
$valor
|
$data['cargo'] ?? 0,
|
||||||
|
$data['abono'] ?? 0,
|
||||||
|
$data['saldo']
|
||||||
);
|
);
|
||||||
} catch (Exception\EmptyResult $exception) {
|
} catch (Exception\EmptyResult $exception) {
|
||||||
$data['cuenta_id'] = $cuenta->id;
|
$data['cuenta_id'] = $cuenta->id;
|
||||||
|
@ -17,7 +17,12 @@ class Santander extends Banco
|
|||||||
'DESCRIPCIÓN MOVIMIENTO' => 'glosa',
|
'DESCRIPCIÓN MOVIMIENTO' => 'glosa',
|
||||||
'FECHA' => 'fecha',
|
'FECHA' => 'fecha',
|
||||||
'N° DOCUMENTO' => 'documento',
|
'N° DOCUMENTO' => 'documento',
|
||||||
'SALDO' => 'saldo'
|
'SALDO' => 'saldo',
|
||||||
|
'Fecha' => 'fecha',
|
||||||
|
'Cargo ($)' => 'cargo',
|
||||||
|
'Abono ($)' => 'abono',
|
||||||
|
'Descripcin' => 'glosa',
|
||||||
|
'Saldo Diario' => 'saldo'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
||||||
@ -26,7 +31,11 @@ class Santander extends Banco
|
|||||||
$uploadedFile->moveTo($filename);
|
$uploadedFile->moveTo($filename);
|
||||||
|
|
||||||
$reader = PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
$reader = PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||||
$xlsx = $reader->load($filename);
|
try {
|
||||||
|
$xlsx = $reader->load($filename);
|
||||||
|
} catch (PhpSpreadsheet\Reader\Exception) {
|
||||||
|
return $this->parseHtml($filename);
|
||||||
|
}
|
||||||
$sheet = $xlsx->getActiveSheet();
|
$sheet = $xlsx->getActiveSheet();
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
@ -74,4 +83,59 @@ class Santander extends Banco
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
protected function parseHtml(string $filename): array
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$lines = explode("\r\n", file_get_contents($filename));
|
||||||
|
$columns = [];
|
||||||
|
$found = false;
|
||||||
|
for ($rowIndex = 0; $rowIndex < count($lines); $rowIndex ++) {
|
||||||
|
if (!$found and str_contains($lines[$rowIndex], 'Cuenta Corriente: ')) {
|
||||||
|
$found = true;
|
||||||
|
$rowIndex += 2;
|
||||||
|
$columns = $this->parseHtmlRow($lines, $rowIndex);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$row = $this->parseHtmlRow($lines, $rowIndex);
|
||||||
|
if (str_contains($row[0], 'Saldo Contable')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$row = array_combine($columns, $row);
|
||||||
|
$row['Fecha'] = implode('-', array_reverse(explode('-', $row['Fecha'])));
|
||||||
|
foreach (['Cargo ($)', 'Abono ($)', 'Saldo Diario'] as $column) {
|
||||||
|
$row[$column] = (int) str_replace('.', '', $row[$column]);
|
||||||
|
}
|
||||||
|
$row['Saldo Diario'] -= ($row['Abono ($)'] - $row['Cargo ($)']);
|
||||||
|
$row['N° DOCUMENTO'] = '';
|
||||||
|
$data []= $row;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
protected function parseHtmlRow(array $lines, int &$rowIndex): array
|
||||||
|
{
|
||||||
|
if (!str_contains($lines[$rowIndex ++], '<tr>')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
while (!str_contains($lines[$rowIndex], '</tr>')) {
|
||||||
|
$tags = substr_count($lines[$rowIndex], '<') - substr_count($lines[$rowIndex], '</');
|
||||||
|
$ini = 0;
|
||||||
|
for ($t = 0; $t < $tags; $t ++) {
|
||||||
|
$ini = strpos($lines[$rowIndex], '>', $ini) + 1;
|
||||||
|
}
|
||||||
|
$end = strpos($lines[$rowIndex], '<', $ini + 1);
|
||||||
|
$cell = str_replace(' ', '', substr($lines[$rowIndex], $ini, $end - $ini));
|
||||||
|
$encoding = mb_detect_encoding($cell, ['Windows-1252', 'UTF-8']);
|
||||||
|
if ($encoding !== 'UTF-8') {
|
||||||
|
$cell = mb_convert_encoding($cell, $encoding, 'UTF-8');
|
||||||
|
$cell = str_replace('?', '', $cell);
|
||||||
|
}
|
||||||
|
$data []= $cell;
|
||||||
|
$rowIndex ++;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,12 @@ namespace Incoviba\Service\Contabilidad\Informe;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use PhpOffice\PhpSpreadsheet;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Common\Implement;
|
use Incoviba\Common\Implement;
|
||||||
use Incoviba\Repository;
|
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
class Tesoreria extends Ideal\Service
|
class Tesoreria extends Ideal\Service
|
||||||
{
|
{
|
||||||
@ -16,7 +18,9 @@ class Tesoreria extends Ideal\Service
|
|||||||
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||||
protected Repository\Deposito $depositoRepository,
|
protected Repository\Deposito $depositoRepository,
|
||||||
protected Repository\Cartola $cartolaRepository,
|
protected Repository\Cartola $cartolaRepository,
|
||||||
protected Repository\Movimiento $movimientoRepository)
|
protected Repository\Movimiento $movimientoRepository,
|
||||||
|
protected Service\Contabilidad\Informe\Tesoreria\Excel $excelService,
|
||||||
|
protected Service\Contabilidad\Informe\Tesoreria\PDF $pdfService)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
@ -123,8 +127,16 @@ class Tesoreria extends Ideal\Service
|
|||||||
}
|
}
|
||||||
$informe['movimientos'] = $this->buildMovimientos();
|
$informe['movimientos'] = $this->buildMovimientos();
|
||||||
$informe['totales'] = $this->buildTotales();
|
$informe['totales'] = $this->buildTotales();
|
||||||
|
|
||||||
|
//$this->buildInforme($fecha, $informe);
|
||||||
|
|
||||||
return $informe;
|
return $informe;
|
||||||
}
|
}
|
||||||
|
public function buildInforme(DateTimeInterface $fecha, array $data, string $type = 'Xlsx', ?string $filename = 'php://output'): void
|
||||||
|
{
|
||||||
|
$informe = $this->excelService->build($fecha, $data);
|
||||||
|
$this->excelService->save($fecha, $informe, $type, $filename);
|
||||||
|
}
|
||||||
|
|
||||||
protected function buildInmobiliaria(Model\Inmobiliaria $inmobiliaria, DateTimeInterface $fecha): object
|
protected function buildInmobiliaria(Model\Inmobiliaria $inmobiliaria, DateTimeInterface $fecha): object
|
||||||
{
|
{
|
||||||
@ -277,4 +289,5 @@ class Tesoreria extends Ideal\Service
|
|||||||
$this->totales->{$tipo} += $total;
|
$this->totales->{$tipo} += $total;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
503
app/src/Service/Contabilidad/Informe/Tesoreria/Excel.php
Normal file
503
app/src/Service/Contabilidad/Informe/Tesoreria/Excel.php
Normal file
@ -0,0 +1,503 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service\Contabilidad\Informe\Tesoreria;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use DateInterval;
|
||||||
|
use IntlDateFormatter;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use PhpOffice\PhpSpreadsheet;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
|
class Excel extends Ideal\Service
|
||||||
|
{
|
||||||
|
protected const CURRENCY_CODE = '_-$* #,##0_-;-$* #,##0_-;_-$* "-"??_-;_-@_-';
|
||||||
|
|
||||||
|
public function __construct(LoggerInterface $logger, protected string $folder, protected Service\UF $ufService, protected Service\USD $usdService)
|
||||||
|
{
|
||||||
|
parent::__construct($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(DateTimeInterface $fecha, array $data): PhpSpreadsheet\Spreadsheet
|
||||||
|
{
|
||||||
|
$title = "Informe de Tesorería {$fecha->format('d.m.Y')}";
|
||||||
|
$informe = new PhpSpreadsheet\Spreadsheet();
|
||||||
|
$informe->getProperties()
|
||||||
|
->setCompany('Incoviba')
|
||||||
|
->setCreator('admin@incoviba.cl')
|
||||||
|
->setTitle($title)
|
||||||
|
->setSubject($title)
|
||||||
|
->setCreated($fecha->getTimestamp());
|
||||||
|
|
||||||
|
$styles = [
|
||||||
|
'font' => [
|
||||||
|
'name' => 'Gill Sans MT',
|
||||||
|
'size' => 12
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$informe->getDefaultStyle()->applyFromArray($styles);
|
||||||
|
|
||||||
|
$sheet = $informe->getActiveSheet();
|
||||||
|
$sheet->setTitle($title);
|
||||||
|
|
||||||
|
$sheet->getColumnDimension('A')->setWidth('5.43');
|
||||||
|
|
||||||
|
$this->fillTitle($sheet, $fecha);
|
||||||
|
$this->fillFechas($sheet, $fecha);
|
||||||
|
$this->fillMonedas($sheet, $fecha);
|
||||||
|
|
||||||
|
$finalRow = $this->fillEmpresas($sheet, $data);
|
||||||
|
$finalRow = $this->fillCaja($sheet, $data, $finalRow + 2);
|
||||||
|
|
||||||
|
foreach (range('B', 'V') as $columnIndex) {
|
||||||
|
$sheet->getColumnDimension($columnIndex)->setAutoSize(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setPageSetup($sheet, $finalRow);
|
||||||
|
|
||||||
|
return $informe;
|
||||||
|
}
|
||||||
|
public function save(DateTimeInterface $fecha, PhpSpreadsheet\Spreadsheet $informe, string $type = 'Xlsx', ?string $filename = null): void
|
||||||
|
{
|
||||||
|
if ($filename === null) {
|
||||||
|
$ext = strtolower($type);
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [$this->folder, "{$informe->getActiveSheet()->getTitle()}.{$ext}"]);
|
||||||
|
}
|
||||||
|
$writer = PhpSpreadsheet\IOFactory::createWriter($informe, $type);
|
||||||
|
|
||||||
|
if (str_starts_with($filename, 'php://')) {
|
||||||
|
$downloadFilename = "Informe de Tesorería {$fecha->format('d.m.Y')}.xlsx";
|
||||||
|
// ZipStream, used by PhpSpreadsheet when saving, sends headers
|
||||||
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
|
header("Content-Disposition: attachment;filename=\"{$downloadFilename}\"");
|
||||||
|
header('Cache-Control: max-age=0');
|
||||||
|
}
|
||||||
|
|
||||||
|
$writer->save($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected 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;
|
||||||
|
}
|
||||||
|
protected function fillTitle(PhpSpreadsheet\Worksheet\Worksheet $sheet, DateTimeInterface $fecha): void
|
||||||
|
{
|
||||||
|
$intl = new IntlDateFormatter('es-CL');
|
||||||
|
$intl->setPattern('dd MMM yyyy');
|
||||||
|
|
||||||
|
$sheet->getCell('B2')->setValue('CONTROL DIARIO CAJA EMPRESAS');
|
||||||
|
$sheet->mergeCells('B2:V2');
|
||||||
|
$styles = [
|
||||||
|
'font' => [
|
||||||
|
'bold' => true,
|
||||||
|
'size' => 18
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => [
|
||||||
|
'argb' => 'FFFFC000'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER
|
||||||
|
],
|
||||||
|
'borders' => [
|
||||||
|
'outline' => [
|
||||||
|
'borderStyle' => PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$sheet->getStyle('B2:V2')->applyFromArray($styles);
|
||||||
|
$sheet->getCell('B3')->setValue(PhpSpreadsheet\Shared\Date::PHPToExcel($fecha));
|
||||||
|
$styles = [
|
||||||
|
'font' => [
|
||||||
|
'size' => 18
|
||||||
|
],
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER
|
||||||
|
],
|
||||||
|
'numberFormat' => [
|
||||||
|
'formatCode' => 'DD MMMM YYYY'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$sheet->getCell('B3')->getStyle()->applyFromArray($styles);
|
||||||
|
$sheet->mergeCells('B3:V3');
|
||||||
|
}
|
||||||
|
protected function fillFechas(PhpSpreadsheet\Worksheet\Worksheet $sheet, DateTimeInterface $fecha): void
|
||||||
|
{
|
||||||
|
$anterior = $this->getAnterior($fecha);
|
||||||
|
$sheet->getCell('B4')->setValue('Informe anterior');
|
||||||
|
$sheet->getCell('B5')->setValue('Informe actual');
|
||||||
|
$sheet->getCell('C4')->setValue(PhpSpreadsheet\Shared\Date::PHPToExcel($anterior));
|
||||||
|
$sheet->getCell('C5')->setValue(PhpSpreadsheet\Shared\Date::PHPToExcel($fecha));
|
||||||
|
$sheet->getStyle('C4:C5')->getNumberFormat()->setFormatCode(PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
|
||||||
|
$sheet->getStyle('B4:C5')->getBorders()->getOutline()->setBorderStyle(PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||||
|
}
|
||||||
|
protected function fillMonedas(PhpSpreadsheet\Worksheet\Worksheet $sheet, DateTimeInterface $fecha): void
|
||||||
|
{
|
||||||
|
$sheet->getCell('E4')->setValue('Valor UF');
|
||||||
|
$sheet->getCell('E5')->setValue('Valor Dólar');
|
||||||
|
$sheet->getCell('F4')->setValue($this->ufService->get($fecha));
|
||||||
|
$sheet->getCell('F5')->setValue($this->usdService->get($fecha));
|
||||||
|
$sheet->getStyle('F4:F5')->getNumberFormat()->setFormatCode("$ #,##0.00");
|
||||||
|
$sheet->getStyle('E4:F5')->getBorders()->getOutline()->setBorderStyle(PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||||
|
}
|
||||||
|
protected function fillEmpresas(PhpSpreadsheet\Worksheet\Worksheet $sheet, array $data, int $startRow = 7): int
|
||||||
|
{
|
||||||
|
$columns = ['EMPRESA', 'Banco', 'Cuenta', 'Saldo anterior', 'Saldo actual', 'Diferencia', 'FFMM', 'DAP',
|
||||||
|
'Saldo empresa', 'Total Cuentas', 'Total FFMM', 'Total DAP', 'Caja Total'];
|
||||||
|
$styles = [
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER
|
||||||
|
],
|
||||||
|
'borders' => [
|
||||||
|
'outline' => [
|
||||||
|
'borderStyle' => PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'color' => [
|
||||||
|
'argb' => 'FF333F4F'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'color' => [
|
||||||
|
'argb' => PhpSpreadsheet\Style\Color::COLOR_WHITE
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$this->fillColumns($sheet, $columns, $styles, $startRow);
|
||||||
|
|
||||||
|
$rowIndex = $startRow + 1;
|
||||||
|
foreach ($data['inmobiliarias'] as $dataInmobiliaria) {
|
||||||
|
$rowIndex += $this->fillInmobiliaria($sheet, $dataInmobiliaria, $rowIndex);
|
||||||
|
}
|
||||||
|
$finalRow = $rowIndex;
|
||||||
|
|
||||||
|
$sheet->getStyle("B7:N{$finalRow}")->getBorders()->getAllBorders()
|
||||||
|
->setBorderStyle(PhpSpreadsheet\Style\Border::BORDER_THIN)
|
||||||
|
->getColor()->setARGB('FFD9D9D9');
|
||||||
|
$sheet->getStyle("C8:D{$finalRow}")->getAlignment()
|
||||||
|
->setHorizontal(PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$this->fillTotals($sheet, 7, $finalRow ++);
|
||||||
|
$sheet->getStyle("E8:N{$finalRow}")->getNumberFormat()
|
||||||
|
->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
|
||||||
|
return $finalRow;
|
||||||
|
}
|
||||||
|
protected function fillCaja(PhpSpreadsheet\Worksheet\Worksheet $sheet, array $data, $startRow): int
|
||||||
|
{
|
||||||
|
$sheet->getCell("B{$startRow}")->setValue('CUADRATURA CAJA DÍA ANTERIOR');
|
||||||
|
$sheet->mergeCells("B{$startRow}:V{$startRow}");
|
||||||
|
|
||||||
|
$sheet->getStyle("B{$startRow}:V{$startRow}")->applyFromArray([
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER
|
||||||
|
],
|
||||||
|
'borders' => [
|
||||||
|
'outline' => [
|
||||||
|
'borderStyle' => PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'color' => [
|
||||||
|
'argb' => 'FFFFC000'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$rowIndex = $startRow;
|
||||||
|
|
||||||
|
$columns = ['EMPRESA', 'INGRESOS', 'EGRESOS', 'FECHA', 'BANCO', 'DESCRIPCIÓN', '', 'CATEGORIA', '', 'CC',
|
||||||
|
'DETALLE', '', 'N° DOC.', 'RUT', 'NOMBRES', '', '', '', '', '', ''];
|
||||||
|
$styles = [
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => [
|
||||||
|
'argb' => 'FFD9D9D9'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->fillColumns($sheet, $columns, $styles, ++ $rowIndex);
|
||||||
|
$sheet->mergeCells("G{$rowIndex}:H{$rowIndex}")
|
||||||
|
->mergeCells("I{$rowIndex}:J{$rowIndex}")
|
||||||
|
->mergeCells("L{$rowIndex}:M{$rowIndex}")
|
||||||
|
->mergeCells("P{$rowIndex}:R{$rowIndex}")
|
||||||
|
->mergeCells("S{$rowIndex}:V{$rowIndex}");
|
||||||
|
|
||||||
|
$rowIndex += 2;
|
||||||
|
$sheet->getCell("T{$rowIndex}")
|
||||||
|
->setValue("Saldo Consolidado al")
|
||||||
|
->getStyle()->applyFromArray([
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$sheet->getCell("U{$rowIndex}")->setValue("=C4")
|
||||||
|
->getStyle()->applyFromArray([
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'numberFormat' => [
|
||||||
|
'formatCode' => PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$sheet->getCell("V{$rowIndex}")->setValue(0)->getStyle()->applyFromArray([
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'numberFormat' => [
|
||||||
|
'formatCode' => self::CURRENCY_CODE
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$rowSaldoAnterior = $rowIndex;
|
||||||
|
$rowIndex ++;
|
||||||
|
|
||||||
|
$styles = [
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => [
|
||||||
|
'argb' => 'FFD9E1F2'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$rowDap = null;
|
||||||
|
$rowIngreso = null;
|
||||||
|
$rowEgreso = null;
|
||||||
|
foreach ($data['movimientos'] as $tipo => $movimientos) {
|
||||||
|
if ($tipo === 'capital dap') {
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue('CAPITAL DAP');
|
||||||
|
$sheet->getCell("T{$rowIndex}")->setValue('SUMA DAP');
|
||||||
|
$sheet->getStyle("B{$rowIndex}:V{$rowIndex}")->applyFromArray($styles);
|
||||||
|
$sheet->getCell("V{$rowIndex}")->getStyle()->getNumberFormat()->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
$totalRow = $rowIndex;
|
||||||
|
$rowDap = $rowIndex;
|
||||||
|
$rowIndex ++;
|
||||||
|
if (count($movimientos['ingresos']) === 0 and count($movimientos['egresos']) === 0) {
|
||||||
|
$sheet->getCell("V{$totalRow}")->setValue(0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$start = $rowIndex;
|
||||||
|
foreach ($movimientos as $ms) {
|
||||||
|
foreach ($ms as $movimiento) {
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue($movimiento->cuenta->inmobiliaria->razon);
|
||||||
|
$sheet->getCell("C{$rowIndex}")->setValue($movimiento->abono);
|
||||||
|
$sheet->getCell("D{$rowIndex}")->setValue($movimiento->cargo);
|
||||||
|
$sheet->getCell("E{$rowIndex}")->setValue(PhpSpreadsheet\Shared\Date::PHPToExcel($movimiento->fecha));
|
||||||
|
$sheet->getCell("F{$rowIndex}")->setValue($movimiento->cuenta->banco->nombre);
|
||||||
|
$sheet->getCell("G{$rowIndex}")->setValue($movimiento->glosa);
|
||||||
|
$rowIndex ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$end = $rowIndex;
|
||||||
|
$sheet->getCell("V{$totalRow}")->setValue("=SUM(C{$start}:D{$end})");
|
||||||
|
$sheet->getStyle("C{$start}:D{$end}")->getNumberFormat()->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue(strtoupper($tipo));
|
||||||
|
$sheet->getCell("T{$rowIndex}")->setValue('SUMA '.strtoupper($tipo));
|
||||||
|
$sheet->getStyle("B{$rowIndex}:V{$rowIndex}")->applyFromArray($styles);
|
||||||
|
$sheet->getCell("V{$rowIndex}")->getStyle()->getNumberFormat()
|
||||||
|
->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
$totalRow = $rowIndex;
|
||||||
|
if (!isset($rowIngreso) or $rowIngreso === null) {
|
||||||
|
$rowIngreso = $rowIndex;
|
||||||
|
} else {
|
||||||
|
$rowEgreso = $rowIndex;
|
||||||
|
}
|
||||||
|
$rowIndex ++;
|
||||||
|
if (count($movimientos) === 0) {
|
||||||
|
$sheet->getCell("V{$totalRow}")->setValue(0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$start = $rowIndex;
|
||||||
|
foreach ($movimientos as $movimiento) {
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue($movimiento->cuenta->inmobiliaria->razon);
|
||||||
|
$sheet->getCell("C{$rowIndex}")->setValue($movimiento->abono);
|
||||||
|
$sheet->getCell("D{$rowIndex}")->setValue($movimiento->cargo);
|
||||||
|
$sheet->getCell("E{$rowIndex}")->setValue(PhpSpreadsheet\Shared\Date::PHPToExcel($movimiento->fecha));
|
||||||
|
$sheet->getCell("F{$rowIndex}")->setValue($movimiento->cuenta->banco->nombre);
|
||||||
|
$sheet->getCell("G{$rowIndex}")->setValue($movimiento->glosa);
|
||||||
|
$rowIndex ++;
|
||||||
|
}
|
||||||
|
$end = $rowIndex;
|
||||||
|
$sheet->getCell("V{$totalRow}")->setValue("=SUM(C{$start}:D{$end})");
|
||||||
|
$sheet->getStyle("C{$start}:D{$end}")->getNumberFormat()
|
||||||
|
->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
}
|
||||||
|
$end = $rowIndex;
|
||||||
|
$rowIndex ++;
|
||||||
|
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue('TOTAL');
|
||||||
|
$sheet->getCell("C{$rowIndex}")->setValue("=SUM(C{$startRow}:C{$end})");
|
||||||
|
$sheet->getCell("D{$rowIndex}")->setValue("=SUM(D{$startRow}:D{$end})");
|
||||||
|
$sheet->getCell("T{$rowIndex}")->setValue('Saldo final al')
|
||||||
|
->getStyle()->applyFromArray([
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$sheet->getCell("U{$rowIndex}")->setValue('=C5')
|
||||||
|
->getStyle()->applyFromArray([
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'numberFormat' => [
|
||||||
|
'formatCode' => PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$sheet->getCell("V{$rowIndex}")->setValue("=V{$rowSaldoAnterior}+V{$rowDap}+V{$rowIngreso}+V{$rowEgreso}")->getStyle()->applyFromArray([
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'numberFormat' => [
|
||||||
|
'formatCode' => self::CURRENCY_CODE
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sheet->getStyle("B{$rowIndex}:V{$rowIndex}")->applyFromArray([
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => [
|
||||||
|
'argb' => 'FFD9D9D9'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$sheet->getStyle("C{$startRow}:D{$rowIndex}")->getNumberFormat()->setFormatCode(self::CURRENCY_CODE);
|
||||||
|
$columnRanges = [
|
||||||
|
['B', 'B'],
|
||||||
|
['C', 'C'],
|
||||||
|
['D', 'D'],
|
||||||
|
['E', 'E'],
|
||||||
|
['F', 'F'],
|
||||||
|
['G', 'H'],
|
||||||
|
['I', 'J'],
|
||||||
|
['K', 'K'],
|
||||||
|
['L', 'M'],
|
||||||
|
['N', 'N'],
|
||||||
|
['O', 'O'],
|
||||||
|
['P', 'R'],
|
||||||
|
['S', 'V']
|
||||||
|
];
|
||||||
|
foreach ($columnRanges as $range) {
|
||||||
|
$sheet->getStyle("{$range[0]}{$startRow}:{$range[1]}{$rowIndex}")->getBorders()->getOutline()
|
||||||
|
->setBorderStyle(PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rowIndex;
|
||||||
|
}
|
||||||
|
protected function fillColumns(PhpSpreadsheet\Worksheet\Worksheet $sheet, array $columns, array $styles, $rowIndex): void
|
||||||
|
{
|
||||||
|
$columnIndex = 2;
|
||||||
|
foreach ($columns as $index => $column) {
|
||||||
|
$columnIndex = 2 + $index;
|
||||||
|
$sheet->getCell([$columnIndex, $rowIndex])->setValue($column);
|
||||||
|
}
|
||||||
|
$sheet->getStyle([2, $rowIndex, $columnIndex, $rowIndex])->applyFromArray($styles);
|
||||||
|
}
|
||||||
|
protected function fillInmobiliaria(PhpSpreadsheet\Worksheet\Worksheet $sheet, object $dataInmobiliaria, int $baseRowIndex): int
|
||||||
|
{
|
||||||
|
$rowIndex = $baseRowIndex;
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue($dataInmobiliaria->inmobiliaria->razon);
|
||||||
|
foreach ($dataInmobiliaria->cuentas as $cuentaRowIndex => $cuenta) {
|
||||||
|
$this->fillCuenta($sheet, $cuenta, 3, $baseRowIndex + $cuentaRowIndex);
|
||||||
|
}
|
||||||
|
$sheet->getCell("K{$rowIndex}")->setValue($dataInmobiliaria->total());
|
||||||
|
$sheet->getCell("L{$rowIndex}")->setValue($dataInmobiliaria->ffmm());
|
||||||
|
$sheet->getCell("M{$rowIndex}")->setValue($dataInmobiliaria->deposito());
|
||||||
|
$sheet->getCell("N{$rowIndex}")->setValue($dataInmobiliaria->caja());
|
||||||
|
|
||||||
|
if (count($dataInmobiliaria->cuentas) > 1) {
|
||||||
|
$finalRow = $rowIndex + count($dataInmobiliaria->cuentas) - 1;
|
||||||
|
$sheet->mergeCells("B{$rowIndex}:B{$finalRow}");
|
||||||
|
$sheet->mergeCells("K{$rowIndex}:K{$finalRow}");
|
||||||
|
$sheet->mergeCells("L{$rowIndex}:L{$finalRow}");
|
||||||
|
$sheet->mergeCells("M{$rowIndex}:M{$finalRow}");
|
||||||
|
$sheet->mergeCells("N{$rowIndex}:N{$finalRow}");
|
||||||
|
}
|
||||||
|
return count($dataInmobiliaria->cuentas);
|
||||||
|
}
|
||||||
|
protected function fillCuenta(PhpSpreadsheet\Worksheet\Worksheet $sheet, object $cuenta, int $startColumnIndex, int $rowIndex): void
|
||||||
|
{
|
||||||
|
$columnIndex = $startColumnIndex;
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->banco);
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->numero);
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->anterior);
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->actual);
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue("=F{$rowIndex}-E{$rowIndex}");
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->ffmm);
|
||||||
|
$sheet->getCell([$columnIndex ++, $rowIndex])->setValue($cuenta->deposito);
|
||||||
|
$sheet->getCell([$columnIndex, $rowIndex])->setValue("=SUM(F{$rowIndex},H{$rowIndex}:I{$rowIndex})");
|
||||||
|
}
|
||||||
|
protected function fillTotals(PhpSpreadsheet\Worksheet\Worksheet $sheet, int $startRow, int $finalRow): void
|
||||||
|
{
|
||||||
|
$rowIndex = $finalRow + 1;
|
||||||
|
$sheet->getCell("B{$rowIndex}")->setValue('TOTAL');
|
||||||
|
foreach (range('E', 'N') as $columnIndex) {
|
||||||
|
$sheet->getCell("{$columnIndex}{$rowIndex}")->setValue("=SUBTOTAL(109,{$columnIndex}{$startRow}:{$columnIndex}{$finalRow})");
|
||||||
|
}
|
||||||
|
|
||||||
|
$styles = [
|
||||||
|
'font' => [
|
||||||
|
'bold' => true
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => [
|
||||||
|
'argb' => 'FFD9D9D9'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'borders' => [
|
||||||
|
'outline' => [
|
||||||
|
'borderStyle' => PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||||
|
'color' => [
|
||||||
|
'argb' => PhpSpreadsheet\Style\Color::COLOR_BLACK
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$sheet->getStyle("B{$rowIndex}:N{$rowIndex}")->applyFromArray($styles);
|
||||||
|
}
|
||||||
|
protected function setPageSetup(PhpSpreadsheet\Worksheet\Worksheet $sheet, int $finalRow): void
|
||||||
|
{
|
||||||
|
$sheet->getPageSetup()
|
||||||
|
->setPrintArea("B2:V{$finalRow}")
|
||||||
|
->setFitToWidth(1)
|
||||||
|
->setPaperSize(PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL)
|
||||||
|
->setOrientation(PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||||
|
$sheet->setShowGridlines(false);
|
||||||
|
$sheet->getSheetView()
|
||||||
|
->setView(PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW)
|
||||||
|
->setZoomScale(70);
|
||||||
|
}
|
||||||
|
}
|
12
app/src/Service/Contabilidad/Informe/Tesoreria/PDF.php
Normal file
12
app/src/Service/Contabilidad/Informe/Tesoreria/PDF.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service\Contabilidad\Informe\Tesoreria;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
|
||||||
|
class PDF
|
||||||
|
{
|
||||||
|
public function build(DateTimeInterface $fecha, array $data): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
34
app/src/Service/Informe.php
Normal file
34
app/src/Service/Informe.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service;
|
||||||
|
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Informe extends Ideal\Service
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger, protected string $folder)
|
||||||
|
{
|
||||||
|
parent::__construct($logger);
|
||||||
|
if (!file_exists($this->folder)) {
|
||||||
|
mkdir($this->folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected array $informes;
|
||||||
|
|
||||||
|
public function register(string $name, string $informeClass): Informe
|
||||||
|
{
|
||||||
|
$this->informes[$name] = $informeClass;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(string $type, string $filename, string $title, array $data): void
|
||||||
|
{
|
||||||
|
$informe = new $this->informes[$type]();
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [$this->folder, "{$filename}.xlsx"]);
|
||||||
|
$informe->setFilename($filename);
|
||||||
|
$informe->setTitle($title);
|
||||||
|
$informe->addData($data);
|
||||||
|
$informe->build();
|
||||||
|
}
|
||||||
|
}
|
63
app/src/Service/Informe/Excel.php
Normal file
63
app/src/Service/Informe/Excel.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service\Informe;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet;
|
||||||
|
use Incoviba\Common\Define;
|
||||||
|
|
||||||
|
class Excel implements Define\Informe
|
||||||
|
{
|
||||||
|
protected string $title;
|
||||||
|
protected string $filename;
|
||||||
|
protected array $data;
|
||||||
|
|
||||||
|
public function setTitle(string $title): Excel
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function setFilename(string $filename): Excel
|
||||||
|
{
|
||||||
|
$this->filename = $filename;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function addData(array $rows): Excel
|
||||||
|
{
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$this->addRow($row);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function addRow(array $row): Excel
|
||||||
|
{
|
||||||
|
foreach ($row as $cell) {
|
||||||
|
$this->addCell($cell);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function addCell(PhpSpreadsheet\Cell\Cell $cell): Excel
|
||||||
|
{
|
||||||
|
$this->data []= $cell;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(): void
|
||||||
|
{
|
||||||
|
$spreadsheet = new PhpSpreadsheet\Spreadsheet();
|
||||||
|
$spreadsheet->getProperties()
|
||||||
|
->setCreator('admin@incoviba.cl')
|
||||||
|
->setSubject($this->title)
|
||||||
|
->setCompany('Incoviba')
|
||||||
|
->setTitle($this->title);
|
||||||
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
$sheet->setTitle($this->title);
|
||||||
|
|
||||||
|
foreach ($this->data as $rowIndex => $row) {
|
||||||
|
foreach ($row as $columnIndex => $cell) {
|
||||||
|
$sheet->getCell([$columnIndex + 1, $rowIndex + 1])->setValue($cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$writer = PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||||
|
$writer->save($this->filename);
|
||||||
|
}
|
||||||
|
}
|
43
app/src/Service/Movimiento.php
Normal file
43
app/src/Service/Movimiento.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Incoviba\Common\Ideal\Service;
|
||||||
|
use Incoviba\Common\Implement;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
use Incoviba\Model;
|
||||||
|
|
||||||
|
class Movimiento extends Service
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger, protected Repository\Movimiento $movimientoRepository,
|
||||||
|
protected Repository\Movimiento\Detalle $detalleRepository)
|
||||||
|
{
|
||||||
|
parent::__construct($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getById(int $movimiento_id): Model\Movimiento
|
||||||
|
{
|
||||||
|
return $this->process($this->movimientoRepository->fetchById($movimiento_id));
|
||||||
|
}
|
||||||
|
public function setDetalles(Model\Movimiento $movimiento, array $data): Model\Movimiento
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$detalles = $this->detalleRepository->fetchByMovimiento($movimiento->id);
|
||||||
|
$this->detalleRepository->edit($detalles, $data);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {
|
||||||
|
$data['movimiento_id'] = $movimiento->id;
|
||||||
|
$detalles = $this->detalleRepository->create($data);
|
||||||
|
$this->detalleRepository->save($detalles);
|
||||||
|
}
|
||||||
|
return $movimiento;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(Model\Movimiento $movimiento): Model\Movimiento
|
||||||
|
{
|
||||||
|
$movimiento->addFactory('detalles', (new Implement\Repository\Factory())->setCallable(function(int $movimiento_id) {
|
||||||
|
return $this->detalleRepository->fetchByMovimiento($movimiento_id);
|
||||||
|
})->setArgs(['movimiento_id' => $movimiento->id]));
|
||||||
|
return $movimiento;
|
||||||
|
}
|
||||||
|
}
|
@ -54,10 +54,10 @@ class Search
|
|||||||
}
|
}
|
||||||
protected function find(string $query, string $tipo): array
|
protected function find(string $query, string $tipo): array
|
||||||
{
|
{
|
||||||
preg_match_all('/["\']([\s\w]+)["\']|(\w+)/iu', $query, $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL);
|
preg_match_all('/["\']([\s\w\-]+)["\']|([\w\-]+)/iu', $query, $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL);
|
||||||
$queries = array_map(function($match) {
|
$queries = array_map(function($match) {
|
||||||
array_shift($match);
|
array_shift($match);
|
||||||
$valid = array_filter($match, function($line) {return $line !== null;});
|
$valid = array_filter($match, function($line) {return $line !== null and trim($line); });
|
||||||
return implode(' ', $valid);
|
return implode(' ', $valid);
|
||||||
}, $matches);
|
}, $matches);
|
||||||
$tiposUnidades = $this->getTiposUnidades();
|
$tiposUnidades = $this->getTiposUnidades();
|
||||||
|
@ -6,7 +6,6 @@ use Incoviba\Common\Ideal\Service;
|
|||||||
use Incoviba\Common\Implement;
|
use Incoviba\Common\Implement;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
use PhpParser\Node\Expr\AssignOp\Mod;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Venta extends Service
|
class Venta extends Service
|
||||||
@ -20,6 +19,7 @@ class Venta extends Service
|
|||||||
protected Repository\Venta\Escritura $escrituraRepository,
|
protected Repository\Venta\Escritura $escrituraRepository,
|
||||||
protected Repository\Venta\Pago $pagoRepository,
|
protected Repository\Venta\Pago $pagoRepository,
|
||||||
protected Repository\Venta\EstadoPago $estadoPagoRepository,
|
protected Repository\Venta\EstadoPago $estadoPagoRepository,
|
||||||
|
protected Venta\FormaPago $formaPagoService,
|
||||||
protected Venta\Propietario $propietarioService,
|
protected Venta\Propietario $propietarioService,
|
||||||
protected Venta\Propiedad $propiedadService,
|
protected Venta\Propiedad $propiedadService,
|
||||||
protected Venta\Pie $pieService,
|
protected Venta\Pie $pieService,
|
||||||
@ -75,9 +75,20 @@ class Venta extends Service
|
|||||||
$ventas = $this->ventaRepository->fetchEscriturasByProyecto($proyecto_id);
|
$ventas = $this->ventaRepository->fetchEscriturasByProyecto($proyecto_id);
|
||||||
return array_map([$this, 'process'], $ventas);
|
return array_map([$this, 'process'], $ventas);
|
||||||
}
|
}
|
||||||
|
public function getByIdForSearch(int $venta_id): array
|
||||||
|
{
|
||||||
|
return $this->ventaRepository->fetchByIdForSearch($venta_id);
|
||||||
|
}
|
||||||
|
public function getByIdForList(int $venta_id): array
|
||||||
|
{
|
||||||
|
return $this->ventaRepository->fetchByIdForList($venta_id);
|
||||||
|
}
|
||||||
|
|
||||||
protected function process(Model\Venta $venta): Model\Venta
|
protected function process(Model\Venta $venta): Model\Venta
|
||||||
{
|
{
|
||||||
|
$venta->addFactory('formaPago', (new Implement\Repository\Factory())
|
||||||
|
->setCallable([$this->formaPagoService, 'getByVenta'])
|
||||||
|
->setArgs(['venta_id' => $venta->id]));
|
||||||
$venta->addFactory('estados', (new Implement\Repository\Factory())
|
$venta->addFactory('estados', (new Implement\Repository\Factory())
|
||||||
->setCallable([$this->estadoVentaRepository, 'fetchByVenta'])
|
->setCallable([$this->estadoVentaRepository, 'fetchByVenta'])
|
||||||
->setArgs([$venta->id]));
|
->setArgs([$venta->id]));
|
||||||
@ -227,7 +238,8 @@ class Venta extends Service
|
|||||||
}
|
}
|
||||||
protected function addFormaPago(array $data): Model\Venta\FormaPago
|
protected function addFormaPago(array $data): Model\Venta\FormaPago
|
||||||
{
|
{
|
||||||
$fields = [
|
return $this->formaPagoService->add($data);
|
||||||
|
/*$fields = [
|
||||||
'pie',
|
'pie',
|
||||||
'subsidio',
|
'subsidio',
|
||||||
'credito',
|
'credito',
|
||||||
@ -241,9 +253,9 @@ class Venta extends Service
|
|||||||
$forma_pago->{$name} = $obj;
|
$forma_pago->{$name} = $obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $forma_pago;
|
return $forma_pago;*/
|
||||||
}
|
}
|
||||||
protected function addPie(array $data): Model\Venta\Pie
|
/*protected function addPie(array $data): Model\Venta\Pie
|
||||||
{
|
{
|
||||||
$fields = array_fill_keys([
|
$fields = array_fill_keys([
|
||||||
'fecha_venta',
|
'fecha_venta',
|
||||||
@ -305,7 +317,7 @@ class Venta extends Service
|
|||||||
'valor'
|
'valor'
|
||||||
], $filtered_data);
|
], $filtered_data);
|
||||||
return $this->bonoPieService->add($mapped_data);
|
return $this->bonoPieService->add($mapped_data);
|
||||||
}
|
}*/
|
||||||
protected function addEstado(Model\Venta $venta, Model\Venta\TipoEstadoVenta $tipoEstadoVenta, array $data): void
|
protected function addEstado(Model\Venta $venta, Model\Venta\TipoEstadoVenta $tipoEstadoVenta, array $data): void
|
||||||
{
|
{
|
||||||
$fecha = new DateTimeImmutable($data['fecha']);
|
$fecha = new DateTimeImmutable($data['fecha']);
|
||||||
|
@ -12,4 +12,8 @@ class BonoPie
|
|||||||
{
|
{
|
||||||
return new Model\Venta\BonoPie();
|
return new Model\Venta\BonoPie();
|
||||||
}
|
}
|
||||||
|
public function getByVenta(int $venta_id): Model\Venta\BonoPie
|
||||||
|
{
|
||||||
|
return $this->bonoPieRepository->fetchByVenta($venta_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,11 @@ class Credito extends Service
|
|||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getByVenta(int $venta_id): Model\Venta\Credito
|
||||||
|
{
|
||||||
|
return $this->creditoRepository->fetchByVenta($venta_id);
|
||||||
|
}
|
||||||
|
|
||||||
public function add(array $data): Model\Venta\Credito
|
public function add(array $data): Model\Venta\Credito
|
||||||
{
|
{
|
||||||
$fecha = new DateTimeImmutable($data['fecha']);
|
$fecha = new DateTimeImmutable($data['fecha']);
|
||||||
|
143
app/src/Service/Venta/FormaPago.php
Normal file
143
app/src/Service/Venta/FormaPago.php
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service\Venta;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Incoviba\Common\Implement;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Model;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
|
||||||
|
class FormaPago extends Ideal\Service
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger,
|
||||||
|
protected Pie $pieService,
|
||||||
|
protected BonoPie $bonoPieService,
|
||||||
|
protected Credito $creditoService,
|
||||||
|
protected Repository\Venta\Escritura $escrituraRepository,
|
||||||
|
protected Subsidio $subsidioService,
|
||||||
|
protected Pago $pagoService)
|
||||||
|
{
|
||||||
|
parent::__construct($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByVenta(int $venta_id): Model\Venta\FormaPago
|
||||||
|
{
|
||||||
|
$formaPago = new Model\Venta\FormaPago();
|
||||||
|
try {
|
||||||
|
$formaPago->pie = $this->pieService->getByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
try {
|
||||||
|
$formaPago->bonoPie = $this->bonoPieService->getByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
try {
|
||||||
|
$formaPago->credito = $this->creditoService->getByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
try {
|
||||||
|
$formaPago->escritura = $this->escrituraRepository->fetchByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
try {
|
||||||
|
$formaPago->subsidio = $this->subsidioService->getByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
try {
|
||||||
|
$formaPago->devolucion = $this->pagoService->getDevolucionByVenta($venta_id);
|
||||||
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
|
|
||||||
|
return $formaPago;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(array $data): Model\Venta\FormaPago
|
||||||
|
{
|
||||||
|
$fields = [
|
||||||
|
'pie',
|
||||||
|
'subsidio',
|
||||||
|
'credito',
|
||||||
|
'bono_pie'
|
||||||
|
];
|
||||||
|
$forma_pago = new Model\Venta\FormaPago();
|
||||||
|
foreach ($fields as $name) {
|
||||||
|
if (isset($data["has_{$name}"])) {
|
||||||
|
try {
|
||||||
|
$method = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
|
||||||
|
$obj = $this->{$method}($data);
|
||||||
|
$forma_pago->{$name} = $obj;
|
||||||
|
} catch (\Error $error) {
|
||||||
|
$this->logger->critical($error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $forma_pago;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addPie(array $data): Model\Venta\Pie
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'pie',
|
||||||
|
'cuotas',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$this->logger->critical(var_export($filtered_data,true));
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor',
|
||||||
|
'cuotas',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
$mapped_data['valor'] = $this->cleanValue($mapped_data['valor']);
|
||||||
|
return $this->pieService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addSubsidio(array $data): Model\Venta\Subsidio
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'ahorro',
|
||||||
|
'subsidio',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'ahorro',
|
||||||
|
'subsidio',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->subsidioService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addCredito(array $data): Model\Venta\Credito
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'credito',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->creditoService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addBonoPie(array $data): Model\Venta\BonoPie
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'bono_pie'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->bonoPieService->add($mapped_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function cleanValue($value): float
|
||||||
|
{
|
||||||
|
if ((float) $value == $value) {
|
||||||
|
return (float) $value;
|
||||||
|
}
|
||||||
|
return (float) str_replace(['.', ','], ['', '.'], $value);
|
||||||
|
}
|
||||||
|
}
|
@ -109,6 +109,10 @@ class Pago
|
|||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
public function getDevolucionByVenta(int $venta_id): Model\Venta\Pago
|
||||||
|
{
|
||||||
|
return $this->process($this->pagoRepository->fetchDevolucionByVenta($venta_id));
|
||||||
|
}
|
||||||
|
|
||||||
public function add(array $data): Model\Venta\Pago
|
public function add(array $data): Model\Venta\Pago
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,10 @@ class Pie
|
|||||||
{
|
{
|
||||||
return $this->process($this->pieRepository->fetchById($pie_id));
|
return $this->process($this->pieRepository->fetchById($pie_id));
|
||||||
}
|
}
|
||||||
|
public function getByVenta(int $venta_id): Model\Venta\Pie
|
||||||
|
{
|
||||||
|
return $this->process($this->pieRepository->fetchByVenta($venta_id));
|
||||||
|
}
|
||||||
|
|
||||||
public function add(array $data): Model\Venta\Pie
|
public function add(array $data): Model\Venta\Pie
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,11 @@ class Subsidio
|
|||||||
protected Service\Money $moneyService
|
protected Service\Money $moneyService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public function getByVenta(int $venta_id): Model\Venta\Subsidio
|
||||||
|
{
|
||||||
|
return $this->subsidioRepository->fetchByVenta($venta_id);
|
||||||
|
}
|
||||||
|
|
||||||
public function add(array $data): Model\Venta\Subsidio
|
public function add(array $data): Model\Venta\Subsidio
|
||||||
{
|
{
|
||||||
$fecha = new DateTimeImmutable($data['fecha']);
|
$fecha = new DateTimeImmutable($data['fecha']);
|
||||||
|
@ -33,6 +33,10 @@ class Unidad
|
|||||||
{
|
{
|
||||||
return $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
return $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
||||||
}
|
}
|
||||||
|
public function getByIdForSearch(int $unidad_id): array
|
||||||
|
{
|
||||||
|
return $this->unidadRepository->fetchByIdForSearch($unidad_id);
|
||||||
|
}
|
||||||
|
|
||||||
protected function process($unidad): Model\Venta\Unidad
|
protected function process($unidad): Model\Venta\Unidad
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user