mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 04:41:01 +00:00
Fix various import bugs.
This commit is contained in:
@@ -99,6 +99,13 @@ class CsvConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function isJobConfigured(): bool
|
||||
{
|
||||
$config = $this->job->configuration;
|
||||
$config['initial-config-complete'] = $config['initial-config-complete'] ?? false;
|
||||
$config['column-roles-complete'] = $config['column-roles-complete'] ?? false;
|
||||
$config['column-mapping-complete'] = $config['column-mapping-complete'] ?? false;
|
||||
$this->job->configuration = $config;
|
||||
$this->job->save();
|
||||
|
||||
if ($this->job->configuration['initial-config-complete']
|
||||
&& $this->job->configuration['column-roles-complete']
|
||||
&& $this->job->configuration['column-mapping-complete']
|
||||
|
||||
@@ -70,7 +70,6 @@ class CsvProcessor implements FileProcessorInterface
|
||||
$index = 0;
|
||||
Log::notice('Building importable objects from CSV file.');
|
||||
foreach ($entries as $index => $row) {
|
||||
sleep(1);
|
||||
// verify if not exists already:
|
||||
if ($this->rowAlreadyImported($row)) {
|
||||
$message = sprintf('Row #%d has already been imported.', $index);
|
||||
@@ -198,8 +197,6 @@ class CsvProcessor implements FileProcessorInterface
|
||||
->where('data', $json)
|
||||
->where('name', 'importHash')
|
||||
->first();
|
||||
|
||||
return rand(1, 10) === 3;
|
||||
if (!is_null($entry)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ class ImportRoutine
|
||||
return false;
|
||||
}
|
||||
set_time_limit(0);
|
||||
Log::debug(sprintf('Start with import job %s', $this->job->key));
|
||||
Log::info(sprintf('Start with import job %s', $this->job->key));
|
||||
|
||||
$importObjects = $this->getImportObjects();
|
||||
$this->lines = $importObjects->count();
|
||||
|
||||
// once done, use storage thing to actually store them:
|
||||
Log::debug(sprintf('Returned %d valid objects from file processor', $this->lines));
|
||||
Log::info(sprintf('Returned %d valid objects from file processor', $this->lines));
|
||||
|
||||
$storage = $this->storeObjects($importObjects);
|
||||
|
||||
@@ -78,7 +78,7 @@ class ImportRoutine
|
||||
// create tag, link tag to all journals:
|
||||
$this->createImportTag();
|
||||
|
||||
Log::debug(sprintf('Done with import job %s', $this->job->key));
|
||||
Log::info(sprintf('Done with import job %s', $this->job->key));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ class ImportStorage
|
||||
{
|
||||
$this->defaultCurrency = Amount::getDefaultCurrencyByUser($this->job->user);
|
||||
|
||||
|
||||
// routine below consists of 3 steps.
|
||||
/**
|
||||
* @var int $index
|
||||
@@ -283,10 +282,8 @@ class ImportStorage
|
||||
|
||||
private function storeImportJournal(int $index, ImportJournal $importJournal): bool
|
||||
{
|
||||
sleep(1);
|
||||
Log::debug(sprintf('Going to store object #%d with description "%s"', $index, $importJournal->description));
|
||||
|
||||
$errors = new MessageBag;
|
||||
$asset = $importJournal->asset->getAccount();
|
||||
$amount = $importJournal->getAmount();
|
||||
$currency = $this->getCurrency($importJournal);
|
||||
@@ -354,7 +351,6 @@ class ImportStorage
|
||||
$this->job->addStepsDone(1);
|
||||
|
||||
$this->journals->push($journal);
|
||||
$this->errors->push($errors);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user