Itau funcionando para ByV y Vialcorp
This commit is contained in:
@ -8,6 +8,8 @@ use Psr\Http\Message\UploadedFileInterface;
|
|||||||
|
|
||||||
class Itau extends Banco
|
class Itau extends Banco
|
||||||
{
|
{
|
||||||
|
use isExcel;
|
||||||
|
|
||||||
const CUENTA_CORRIENTE = 0;
|
const CUENTA_CORRIENTE = 0;
|
||||||
const ULTIMOS_MOVIMIENTOS = 1;
|
const ULTIMOS_MOVIMIENTOS = 1;
|
||||||
|
|
||||||
@ -24,6 +26,7 @@ class Itau extends Banco
|
|||||||
'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',
|
||||||
'Documentos' => 'documento',
|
'Documentos' => 'documento',
|
||||||
'Movimientos' => 'glosa',
|
'Movimientos' => 'glosa',
|
||||||
'Saldos' => 'saldo',
|
'Saldos' => 'saldo',
|
||||||
@ -65,54 +68,46 @@ class Itau extends Banco
|
|||||||
}
|
}
|
||||||
protected function parseCuentaCorriente(PhpSpreadsheet\Worksheet\Worksheet $sheet): array
|
protected function parseCuentaCorriente(PhpSpreadsheet\Worksheet\Worksheet $sheet): array
|
||||||
{
|
{
|
||||||
|
$titleValueMap = [
|
||||||
|
'Giros o cargos' => 'int',
|
||||||
|
'Depósitos o abonos' => 'int',
|
||||||
|
'Saldos' => 'int',
|
||||||
|
'Saldo diario' => 'int',
|
||||||
|
];
|
||||||
$found = false;
|
$found = false;
|
||||||
$year = 0;
|
$year = 0;
|
||||||
$columns = [];
|
$columns = [];
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($sheet->getRowIterator() as $row) {
|
$rowIterator = $sheet->getRowIterator();
|
||||||
if (!$found and $sheet->getCell("A{$row->getRowIndex()}")->getCalculatedValue() === 'Cartola Histórica') {
|
while ($rowIterator->valid()) {
|
||||||
$columnIndex = 'A';
|
$row = $rowIterator->current();
|
||||||
foreach ($row->getColumnIterator() as $column) {
|
if ($sheet->getCell("A{$row->getRowIndex()}")->getCalculatedValue() === 'Cartola Histórica') {
|
||||||
if ($column->getValue() !== 'Periodo') {
|
$range = $this->getDateRange($row);
|
||||||
continue;
|
$year = $range[0]->format('Y');
|
||||||
}
|
$rowIterator->next();
|
||||||
$columnIndex = $column->getColumn();
|
continue;
|
||||||
break;
|
|
||||||
}
|
|
||||||
$dates = explode(' - ', $sheet->getCell("{$columnIndex}{$row->getRowIndex()}")->getCalculatedValue());
|
|
||||||
$date = DateTimeImmutable::createFromFormat('d/m/Y', $dates[0]);
|
|
||||||
$year = $date->format('Y');
|
|
||||||
}
|
}
|
||||||
if (!$found and $sheet->getCell("A{$row->getRowIndex()}")->getCalculatedValue() === 'Movimientos') {
|
if ($sheet->getCell("A{$row->getRowIndex()}")->getCalculatedValue() === 'Movimientos') {
|
||||||
$found = true;
|
$found = true;
|
||||||
foreach ($row->getColumnIterator() as $column) {
|
$rowIterator->next();
|
||||||
if ($column->getValue() === null) {
|
$row = $rowIterator->current();
|
||||||
break;
|
$columns = $this->grabTitlesRow($row);
|
||||||
}
|
$rowIterator->next();
|
||||||
$columns[$column->getColumn()] = trim($column->getValue());
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$found) {
|
if (!$found) {
|
||||||
|
$rowIterator->next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($sheet->getCell("A{$row->getRowIndex()}")->getValue() === null) {
|
if ($sheet->getCell("A{$row->getRowIndex()}")->getValue() === null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$rowData = [];
|
$rowData = $this->grabRow($row, $columns, process: true, titleValueMap: $titleValueMap);
|
||||||
foreach ($columns as $columnIndex => $column) {
|
$fecha = explode('/', $rowData['Fecha']);
|
||||||
$value = $sheet->getCell("{$columnIndex}{$row->getRowIndex()}")->getCalculatedValue();
|
$rowData['Fecha'] = "{$year}-{$fecha[1]}-{$fecha[0]}";
|
||||||
$mapped = $this->columnMap()[$column];
|
|
||||||
if ($mapped === 'fecha') {
|
|
||||||
list($d, $m) = explode('/', $value);
|
|
||||||
$value = "{$year}-{$m}-{$d}";
|
|
||||||
}
|
|
||||||
if (in_array($mapped, ['cargo', 'abono', 'saldo'])) {
|
|
||||||
$value = (int) $value;
|
|
||||||
}
|
|
||||||
$rowData[$column] = $value;
|
|
||||||
}
|
|
||||||
$data []= $rowData;
|
$data []= $rowData;
|
||||||
|
|
||||||
|
$rowIterator->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@ -184,4 +179,22 @@ class Itau extends Banco
|
|||||||
}
|
}
|
||||||
throw new PhpSpreadsheet\Exception();
|
throw new PhpSpreadsheet\Exception();
|
||||||
}
|
}
|
||||||
|
protected function getDateRange(PhpSpreadsheet\Worksheet\Row $row): array
|
||||||
|
{
|
||||||
|
$columnIndex = 'A';
|
||||||
|
$columnIterator = $row->getColumnIterator();
|
||||||
|
while ($columnIterator->valid()) {
|
||||||
|
$column = $columnIterator->current();
|
||||||
|
if (str_contains($column->getValue(), '-')) {
|
||||||
|
$columnIndex = $column->getColumn();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$columnIterator->next();
|
||||||
|
}
|
||||||
|
$value = $row->getWorksheet()->getCell("{$columnIndex}{$row->getRowIndex()}")->getCalculatedValue();
|
||||||
|
$dates = explode(' - ', $value);
|
||||||
|
return array_map(function($date) {
|
||||||
|
return DateTimeImmutable::createFromFormat('d/m/Y', $date);
|
||||||
|
}, $dates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user