FIX: Skip handling import errors
This commit is contained in:
@ -2,17 +2,18 @@
|
||||
namespace Incoviba\Service\Contabilidad;
|
||||
|
||||
use DateMalformedStringException;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use PDOException;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use PhpOffice\PhpSpreadsheet;
|
||||
use Incoviba\Common\Define\Cartola\Banco;
|
||||
use Incoviba\Common\Define\Contabilidad\Exporter;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Implement\Exception;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
@ -34,6 +35,13 @@ class Cartola extends Service
|
||||
$this->bancos[$name] = $banco;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\Contabilidad\Banco $banco
|
||||
* @param UploadedFileInterface $file
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
public function process(Model\Contabilidad\Banco $banco, UploadedFileInterface $file): array
|
||||
{
|
||||
return $this->bancos[strtolower($banco->nombre)]->process($file);
|
||||
@ -153,6 +161,10 @@ class Cartola extends Service
|
||||
$fechas = array_unique(array_map(function($movimiento) {
|
||||
return $movimiento['fecha']->format('Y-m-d');
|
||||
}, $movimientos));
|
||||
if (count($fechas) === 0) {
|
||||
throw new Read(__CLASS__);
|
||||
}
|
||||
|
||||
foreach ($fechas as $dia) {
|
||||
try {
|
||||
$dayDate = new DateTimeImmutable($dia);
|
||||
|
||||
@ -3,6 +3,7 @@ namespace Incoviba\Service\Contabilidad\Cartola;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal\Cartola\Banco;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use PhpOffice\PhpSpreadsheet;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
@ -44,6 +45,12 @@ class Itau extends Banco
|
||||
$ext = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
|
||||
return "/tmp/cartola.{$ext}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
protected function parseFile(string $filename): array
|
||||
{
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
@ -62,7 +69,7 @@ class Itau extends Banco
|
||||
break;
|
||||
}
|
||||
} catch (PhpSpreadsheet\Exception $exception) {
|
||||
$this->logger->critical($exception);
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -166,6 +173,11 @@ class Itau extends Banco
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PhpSpreadsheet\Worksheet\Worksheet $sheet
|
||||
* @return int
|
||||
* @throws PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function identifySheet(PhpSpreadsheet\Worksheet\Worksheet $sheet): int
|
||||
{
|
||||
foreach ($sheet->getRowIterator(1, 10) as $row) {
|
||||
@ -177,7 +189,7 @@ class Itau extends Banco
|
||||
return self::ULTIMOS_MOVIMIENTOS;
|
||||
}
|
||||
}
|
||||
throw new PhpSpreadsheet\Exception();
|
||||
throw new PhpSpreadsheet\Exception('Incorrect type of Worksheet');
|
||||
}
|
||||
protected function getDateRange(PhpSpreadsheet\Worksheet\Row $row): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user