API Movimientos y cartola diaria
This commit is contained in:
@ -24,8 +24,10 @@ class Security extends Banco
|
||||
'fecha' => 'fecha',
|
||||
'descripción' => 'glosa',
|
||||
'número de documentos' => 'documento',
|
||||
'nº documento' => 'documento',
|
||||
'cargos' => 'cargo',
|
||||
'abonos' => 'abono'
|
||||
'abonos' => 'abono',
|
||||
'saldos' => 'saldo'
|
||||
];
|
||||
}
|
||||
|
||||
@ -33,10 +35,9 @@ class Security extends Banco
|
||||
{
|
||||
$filename = '/tmp/cartola.xls';
|
||||
$file->moveTo($filename);
|
||||
$reader = PhpSpreadsheet\IOFactory::createReader('Xls');
|
||||
$xlsx = $reader->load($filename);
|
||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
||||
$worksheet = $xlsx->getActiveSheet();
|
||||
$rows = $worksheet->getRowIterator();
|
||||
$rows = $worksheet->getRowIterator(3);
|
||||
$dataFound = false;
|
||||
$columns = [];
|
||||
$data = [];
|
||||
@ -44,10 +45,10 @@ class Security extends Banco
|
||||
$cells = $row->getCellIterator();
|
||||
$rowData = [];
|
||||
foreach ($cells as $cell) {
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() === "fecha ") {
|
||||
if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() !== null and strtolower($cell->getCalculatedValue()) === "fecha ") {
|
||||
$cols = $row->getColumnIterator();
|
||||
foreach ($cols as $col) {
|
||||
$columns[$col->getColumn()] = trim($col->getCalculatedValue());
|
||||
$columns[$col->getColumn()] = trim(strtolower($col->getCalculatedValue()), ' ');
|
||||
}
|
||||
$dataFound = true;
|
||||
break;
|
||||
@ -62,7 +63,11 @@ class Security extends Banco
|
||||
$col = $columns[$cell->getColumn()];
|
||||
$value = $cell->getCalculatedValue();
|
||||
if ($col === 'fecha') {
|
||||
$value = PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue(), 'America/Santiago')->format('Y-m-d');
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user