Cartolas Security
This commit is contained in:
@ -9,6 +9,8 @@ use Psr\Http\Message\UploadedFileInterface;
|
|||||||
|
|
||||||
class Security extends Banco
|
class Security extends Banco
|
||||||
{
|
{
|
||||||
|
use isExcel;
|
||||||
|
|
||||||
public function processMovimientosDiarios(array $movimientos): array
|
public function processMovimientosDiarios(array $movimientos): array
|
||||||
{
|
{
|
||||||
$movimientos = array_reverse($movimientos);
|
$movimientos = array_reverse($movimientos);
|
||||||
@ -39,11 +41,13 @@ class Security extends Banco
|
|||||||
'descripción' => 'glosa',
|
'descripción' => 'glosa',
|
||||||
'número de documentos' => 'documento',
|
'número de documentos' => 'documento',
|
||||||
'nº documento' => 'documento',
|
'nº documento' => 'documento',
|
||||||
|
'n de docu' => 'documento',
|
||||||
'cargos' => 'cargo',
|
'cargos' => 'cargo',
|
||||||
'abonos' => 'abono',
|
'abonos' => 'abono',
|
||||||
'saldos' => 'saldo',
|
'saldos' => 'saldo',
|
||||||
'categoría' => 'categoria',
|
'categoría' => 'categoria',
|
||||||
'centro costos' => 'centro_costo',
|
'centro costos' => 'centro_costo',
|
||||||
|
'centro costo' => 'centro_costo',
|
||||||
'detalle' => 'detalle',
|
'detalle' => 'detalle',
|
||||||
'factura boleta' => 'identificador',
|
'factura boleta' => 'identificador',
|
||||||
'rut' => 'rut',
|
'rut' => 'rut',
|
||||||
@ -56,43 +60,30 @@ class Security extends Banco
|
|||||||
{
|
{
|
||||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
||||||
$worksheet = $xlsx->getActiveSheet();
|
$worksheet = $xlsx->getActiveSheet();
|
||||||
$rows = $worksheet->getRowIterator(3);
|
|
||||||
$dataFound = false;
|
$rowIterator = $worksheet->getRowIterator(3);
|
||||||
$columns = [];
|
$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 = [];
|
$data = [];
|
||||||
foreach ($rows as $row) {
|
while ($rowIterator->valid()) {
|
||||||
$cells = $row->getCellIterator();
|
if ($this->isExitValue($rowIterator->current(), ['resúmen del período', 'resumen del período', 'Resúmen del período', 'Resumen del período', null])) {
|
||||||
$rowData = [];
|
break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
$rowData = $this->grabRow($rowIterator->current(), $columns, process: true, titleValueMap: $titleValueMap);
|
||||||
if (count($rowData) > 0) {
|
if (count($rowData) > 0) {
|
||||||
$data []= $rowData;
|
$data []= $rowData;
|
||||||
}
|
}
|
||||||
|
$rowIterator->next();
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user