diff --git a/app/common/Ideal/Cartola/Banco.php b/app/common/Ideal/Cartola/Banco.php
index d4e10c6..16d88e2 100644
--- a/app/common/Ideal/Cartola/Banco.php
+++ b/app/common/Ideal/Cartola/Banco.php
@@ -9,10 +9,16 @@ abstract class Banco implements Define\Cartola\Banco
public function process(UploadedFileInterface $file): array
{
$data = $this->parseFile($file);
- return array_map(function($row) {
- $columns = $this->columnMap();
- return array_combine(array_values($columns), array_values($row));
- }, $data);
+ $temp = [];
+ $columns = $this->columnMap();
+ foreach ($data as $row) {
+ $r = [];
+ foreach ($columns as $old => $new) {
+ $r[$new] = $row[$old];
+ }
+ $temp []= $r;
+ }
+ return $temp;
}
abstract protected function columnMap(): array;
diff --git a/app/resources/views/contabilidad/centros_costos/asignar.blade.php b/app/resources/views/contabilidad/centros_costos/asignar.blade.php
index ee54783..80fd04f 100644
--- a/app/resources/views/contabilidad/centros_costos/asignar.blade.php
+++ b/app/resources/views/contabilidad/centros_costos/asignar.blade.php
@@ -77,7 +77,6 @@
Documento |
Cargo |
Abono |
- Saldo |
Centro de Costo |
Detalle |
Orden |
@@ -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() {
return {
bancos: inmobiliaria_rut => {
@@ -210,7 +227,6 @@
documento: row.documento,
cargo: row.cargo,
abono: row.abono,
- saldo: row.saldo
}
})
this.draw().cartola()
@@ -291,8 +307,6 @@
$(' | ').addClass('right aligned').html(row.cargo === 0 ? '' : numberFormatter.format(row.cargo))
).append(
$(' | ').addClass('right aligned').html(row.abono === 0 ? '' : numberFormatter.format(row.abono))
- ).append(
- $(' | ').addClass('right aligned').html(row.saldo === 0 ? '' : numberFormatter.format(row.saldo))
).append(
$(' | ').append(this.draw().centrosDropdown(idx + 1, row.cargo === 0))
).append(
@@ -306,24 +320,7 @@
)
)
})
- table.DataTable({
- pageLength: 100,
- order: [[8, 'asc']],
- columnDefs: [
- {
- targets: [1, 2, 3, 4, 5],
- width: '10%'
- },
- {
- targets: [1],
- width: '20%'
- },
- {
- targets: [8],
- visible: false
- }
- ],
- })
+ table.DataTable(this.dataTableConfig)
},
centrosDropdown: (idx, ingreso=true) => {
const menu = $('').addClass('menu')
@@ -336,7 +333,7 @@
$('').addClass('item').attr('data-value', centro.id).html(centro.id + ' - ' + centro.descripcion)
)
})
- return $('').addClass('ui selection search dropdown centro').attr('data-index', idx).append(
+ return $('').addClass('ui selection search dropdown centro').attr('data-index', idx).css('width', '80%').append(
$('').attr('type', 'hidden').attr('name', 'centro' + idx)
).append(
$('').addClass('dropdown icon')
@@ -375,7 +372,7 @@
}
$(this.ids.form.mes).calendar(calendar_date_options)
$(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)
}
diff --git a/app/setup/setups/services.php b/app/setup/setups/services.php
index e90b3b3..485eda8 100644
--- a/app/setup/setups/services.php
+++ b/app/setup/setups/services.php
@@ -36,7 +36,8 @@ return [
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::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) {
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
diff --git a/app/src/Service/Cartola/Itau.php b/app/src/Service/Cartola/Itau.php
index 98117f0..6634156 100644
--- a/app/src/Service/Cartola/Itau.php
+++ b/app/src/Service/Cartola/Itau.php
@@ -13,11 +13,9 @@ class Itau extends Banco
return [
'Fecha' => 'fecha',
'Número de operación' => 'documento',
- 'Sucursal' => 'sucursal',
'Descripción' => 'glosa',
'Depósitos o abonos' => 'abono',
- 'Giros o cargos' => 'cargo',
- 'Saldo diario' => 'saldo'
+ 'Giros o cargos' => 'cargo'
];
}
diff --git a/app/src/Service/Cartola/Santander.php b/app/src/Service/Cartola/Santander.php
new file mode 100644
index 0000000..748f566
--- /dev/null
+++ b/app/src/Service/Cartola/Santander.php
@@ -0,0 +1,80 @@
+ '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;
+ }
+}
diff --git a/app/src/Service/Cartola/Security.php b/app/src/Service/Cartola/Security.php
index ae8f26b..28323a2 100644
--- a/app/src/Service/Cartola/Security.php
+++ b/app/src/Service/Cartola/Security.php
@@ -25,8 +25,7 @@ class Security extends Banco
'descripción' => 'glosa',
'número de documentos' => 'documento',
'cargos' => 'cargo',
- 'abonos' => 'abono',
- 'saldos' => 'saldo'
+ 'abonos' => 'abono'
];
}