Cartolas Security
This commit is contained in:
@ -9,6 +9,8 @@ use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
class Security extends Banco
|
||||
{
|
||||
use isExcel;
|
||||
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
$movimientos = array_reverse($movimientos);
|
||||
@ -39,11 +41,13 @@ class Security extends Banco
|
||||
'descripción' => 'glosa',
|
||||
'número de documentos' => 'documento',
|
||||
'nº documento' => 'documento',
|
||||
'n de docu' => 'documento',
|
||||
'cargos' => 'cargo',
|
||||
'abonos' => 'abono',
|
||||
'saldos' => 'saldo',
|
||||
'categoría' => 'categoria',
|
||||
'centro costos' => 'centro_costo',
|
||||
'centro costo' => 'centro_costo',
|
||||
'detalle' => 'detalle',
|
||||
'factura boleta' => 'identificador',
|
||||
'rut' => 'rut',
|
||||
@ -56,43 +60,30 @@ class Security extends Banco
|
||||
{
|
||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
||||
$worksheet = $xlsx->getActiveSheet();
|
||||
$rows = $worksheet->getRowIterator(3);
|
||||
$dataFound = false;
|
||||
$columns = [];
|
||||
|
||||
$rowIterator = $worksheet->getRowIterator(3);
|
||||
$titleRow = $this->findTitlesRow($rowIterator, 'fecha', caseInsensitive: true);
|
||||
$columns = $this->grabTitlesRow($titleRow, toLower: true);
|
||||
$rowIterator->next();
|
||||
|
||||
$titleValueMap = [
|
||||
'fecha' => 'fecha',
|
||||
'cargos' => 'int',
|
||||
'abonos' => 'int',
|
||||
'saldos' => 'int',
|
||||
'centro costo' => 'int',
|
||||
'centro costos' => 'int',
|
||||
];
|
||||
$data = [];
|
||||
foreach ($rows as $row) {
|
||||
$cells = $row->getCellIterator();
|
||||
$rowData = [];
|
||||
foreach ($cells as $cell) {
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() !== null and strtolower($cell->getCalculatedValue()) === "fecha ") {
|
||||
$cols = $row->getColumnIterator();
|
||||
foreach ($cols as $col) {
|
||||
$columns[$col->getColumn()] = trim(strtolower($col->getCalculatedValue()), ' ');
|
||||
}
|
||||
$dataFound = true;
|
||||
break;
|
||||
}
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() === null) {
|
||||
$dataFound = false;
|
||||
break;
|
||||
}
|
||||
if (!$dataFound) {
|
||||
break;
|
||||
}
|
||||
$col = $columns[$cell->getColumn()];
|
||||
$value = $cell->getCalculatedValue();
|
||||
if ($col === 'fecha') {
|
||||
if ((int) $cell->getValue() !== $cell->getValue()) {
|
||||
$value = implode('-', array_reverse(explode('-', $cell->getValue())));
|
||||
} else {
|
||||
$value = PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue(), 'America/Santiago')->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
$rowData[$col] = $value;
|
||||
while ($rowIterator->valid()) {
|
||||
if ($this->isExitValue($rowIterator->current(), ['resúmen del período', 'resumen del período', 'Resúmen del período', 'Resumen del período', null])) {
|
||||
break;
|
||||
}
|
||||
$rowData = $this->grabRow($rowIterator->current(), $columns, process: true, titleValueMap: $titleValueMap);
|
||||
if (count($rowData) > 0) {
|
||||
$data []= $rowData;
|
||||
}
|
||||
$rowIterator->next();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user