Santander
This commit is contained in:
@ -9,10 +9,16 @@ abstract class Banco implements Define\Cartola\Banco
|
|||||||
public function process(UploadedFileInterface $file): array
|
public function process(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
$data = $this->parseFile($file);
|
$data = $this->parseFile($file);
|
||||||
return array_map(function($row) {
|
$temp = [];
|
||||||
$columns = $this->columnMap();
|
$columns = $this->columnMap();
|
||||||
return array_combine(array_values($columns), array_values($row));
|
foreach ($data as $row) {
|
||||||
}, $data);
|
$r = [];
|
||||||
|
foreach ($columns as $old => $new) {
|
||||||
|
$r[$new] = $row[$old];
|
||||||
|
}
|
||||||
|
$temp []= $r;
|
||||||
|
}
|
||||||
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function columnMap(): array;
|
abstract protected function columnMap(): array;
|
||||||
|
@ -77,7 +77,6 @@
|
|||||||
<th>Documento</th>
|
<th>Documento</th>
|
||||||
<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>Centro de Costo</th>
|
<th>Centro de Costo</th>
|
||||||
<th>Detalle</th>
|
<th>Detalle</th>
|
||||||
<th>Orden</th>
|
<th>Orden</th>
|
||||||
@ -138,6 +137,24 @@
|
|||||||
})))) !!}'),
|
})))) !!}'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
dataTableConfig: {
|
||||||
|
pageLength: 100,
|
||||||
|
order: [[7, 'asc']],
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: [0, 2, 3, 4],
|
||||||
|
width: '10%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [1],
|
||||||
|
width: '20%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [7],
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
get() {
|
get() {
|
||||||
return {
|
return {
|
||||||
bancos: inmobiliaria_rut => {
|
bancos: inmobiliaria_rut => {
|
||||||
@ -210,7 +227,6 @@
|
|||||||
documento: row.documento,
|
documento: row.documento,
|
||||||
cargo: row.cargo,
|
cargo: row.cargo,
|
||||||
abono: row.abono,
|
abono: row.abono,
|
||||||
saldo: row.saldo
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.draw().cartola()
|
this.draw().cartola()
|
||||||
@ -291,8 +307,6 @@
|
|||||||
$('<td></td>').addClass('right aligned').html(row.cargo === 0 ? '' : numberFormatter.format(row.cargo))
|
$('<td></td>').addClass('right aligned').html(row.cargo === 0 ? '' : numberFormatter.format(row.cargo))
|
||||||
).append(
|
).append(
|
||||||
$('<td></td>').addClass('right aligned').html(row.abono === 0 ? '' : numberFormatter.format(row.abono))
|
$('<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>').append(this.draw().centrosDropdown(idx + 1, row.cargo === 0))
|
$('<td></td>').append(this.draw().centrosDropdown(idx + 1, row.cargo === 0))
|
||||||
).append(
|
).append(
|
||||||
@ -306,24 +320,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
table.DataTable({
|
table.DataTable(this.dataTableConfig)
|
||||||
pageLength: 100,
|
|
||||||
order: [[8, 'asc']],
|
|
||||||
columnDefs: [
|
|
||||||
{
|
|
||||||
targets: [1, 2, 3, 4, 5],
|
|
||||||
width: '10%'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
targets: [1],
|
|
||||||
width: '20%'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
targets: [8],
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
centrosDropdown: (idx, ingreso=true) => {
|
centrosDropdown: (idx, ingreso=true) => {
|
||||||
const menu = $('<div></div>').addClass('menu')
|
const menu = $('<div></div>').addClass('menu')
|
||||||
@ -336,7 +333,7 @@
|
|||||||
$('<div></div>').addClass('item').attr('data-value', centro.id).html(centro.id + ' - ' + centro.descripcion)
|
$('<div></div>').addClass('item').attr('data-value', centro.id).html(centro.id + ' - ' + centro.descripcion)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return $('<div></div>').addClass('ui selection search dropdown centro').attr('data-index', idx).append(
|
return $('<div></div>').addClass('ui selection search dropdown centro').attr('data-index', idx).css('width', '80%').append(
|
||||||
$('<input />').attr('type', 'hidden').attr('name', 'centro' + idx)
|
$('<input />').attr('type', 'hidden').attr('name', 'centro' + idx)
|
||||||
).append(
|
).append(
|
||||||
$('<i></i>').addClass('dropdown icon')
|
$('<i></i>').addClass('dropdown icon')
|
||||||
@ -375,7 +372,7 @@
|
|||||||
}
|
}
|
||||||
$(this.ids.form.mes).calendar(calendar_date_options)
|
$(this.ids.form.mes).calendar(calendar_date_options)
|
||||||
$(this.ids.form.base).submit(this.parse().cartola)
|
$(this.ids.form.base).submit(this.parse().cartola)
|
||||||
$(this.ids.table.base).DataTable()
|
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||||
|
|
||||||
$(this.ids.button).click(this.export().cartola)
|
$(this.ids.button).click(this.export().cartola)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ return [
|
|||||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class)
|
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class)
|
||||||
))
|
))
|
||||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||||
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class));
|
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
||||||
|
->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class));
|
||||||
},
|
},
|
||||||
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
||||||
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
|
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
|
||||||
|
@ -13,11 +13,9 @@ class Itau extends Banco
|
|||||||
return [
|
return [
|
||||||
'Fecha' => 'fecha',
|
'Fecha' => 'fecha',
|
||||||
'Número de operación' => 'documento',
|
'Número de operación' => 'documento',
|
||||||
'Sucursal' => 'sucursal',
|
|
||||||
'Descripción' => 'glosa',
|
'Descripción' => 'glosa',
|
||||||
'Depósitos o abonos' => 'abono',
|
'Depósitos o abonos' => 'abono',
|
||||||
'Giros o cargos' => 'cargo',
|
'Giros o cargos' => 'cargo'
|
||||||
'Saldo diario' => 'saldo'
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
80
app/src/Service/Cartola/Santander.php
Normal file
80
app/src/Service/Cartola/Santander.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Service\Cartola;
|
||||||
|
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
use PhpOffice\PhpSpreadsheet;
|
||||||
|
use Incoviba\Common\Ideal\Cartola\Banco;
|
||||||
|
|
||||||
|
class Santander extends Banco
|
||||||
|
{
|
||||||
|
protected function columnMap(): array
|
||||||
|
{
|
||||||
|
// MONTO DESCRIPCIÓN MOVIMIENTO FECHA N° DOCUMENTO SUCURSAL CARGO/ABONO
|
||||||
|
return [
|
||||||
|
'cargo' => 'cargo',
|
||||||
|
'abono' => 'abono',
|
||||||
|
'DESCRIPCIÓN MOVIMIENTO' => 'glosa',
|
||||||
|
'FECHA' => 'fecha',
|
||||||
|
'N° DOCUMENTO' => 'documento',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
||||||
|
{
|
||||||
|
function log(mixed $elem): void
|
||||||
|
{
|
||||||
|
if (!is_string($elem)) {
|
||||||
|
$elem = var_export($elem,true);
|
||||||
|
}
|
||||||
|
error_log($elem.PHP_EOL,3,'/logs/debug');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = '/tmp/cartola.xlsx';
|
||||||
|
$uploadedFile->moveTo($filename);
|
||||||
|
|
||||||
|
$reader = PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||||
|
$xlsx = $reader->load($filename);
|
||||||
|
$sheet = $xlsx->getActiveSheet();
|
||||||
|
|
||||||
|
$rowIndex = 16;
|
||||||
|
$columns = [];
|
||||||
|
$row = $sheet->getRowIterator($rowIndex)->current();
|
||||||
|
$cols = $row->getColumnIterator('A', 'H');
|
||||||
|
foreach ($cols as $col) {
|
||||||
|
$columns []= $col->getCalculatedValue();
|
||||||
|
}
|
||||||
|
$rowIndex ++;
|
||||||
|
$rows = $sheet->getRowIterator($rowIndex);
|
||||||
|
$data = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($sheet->getCell("A{$rowIndex}")->getCalculatedValue() === 'Resumen comisiones') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$cols = $row->getColumnIterator('A', 'H');
|
||||||
|
$colIndex = 0;
|
||||||
|
$rowData = [];
|
||||||
|
foreach ($cols as $col) {
|
||||||
|
$value = $col->getCalculatedValue();
|
||||||
|
$col = $columns[$colIndex];
|
||||||
|
if ($col === 'FECHA') {
|
||||||
|
log($value);
|
||||||
|
list($d,$m,$Y) = explode('/', $value);
|
||||||
|
$value = "{$Y}-{$m}-{$d}";
|
||||||
|
}
|
||||||
|
$rowData[$col] = $value;
|
||||||
|
$colIndex ++;
|
||||||
|
}
|
||||||
|
if ($rowData['CARGO/ABONO'] === 'C') {
|
||||||
|
$rowData['cargo'] = -$rowData['MONTO'];
|
||||||
|
$rowData['abono'] = 0;
|
||||||
|
} else {
|
||||||
|
$rowData['cargo'] = 0;
|
||||||
|
$rowData['abono'] = $rowData['MONTO'];
|
||||||
|
}
|
||||||
|
$data []= $rowData;
|
||||||
|
$rowIndex ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -25,8 +25,7 @@ class Security extends Banco
|
|||||||
'descripción' => 'glosa',
|
'descripción' => 'glosa',
|
||||||
'número de documentos' => 'documento',
|
'número de documentos' => 'documento',
|
||||||
'cargos' => 'cargo',
|
'cargos' => 'cargo',
|
||||||
'abonos' => 'abono',
|
'abonos' => 'abono'
|
||||||
'saldos' => 'saldo'
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user