Fix various bugs in the import routine, discovered by Doug.

This commit is contained in:
James Cole
2018-06-13 19:03:18 +02:00
parent f4b66b980b
commit 477a3c7eb2
10 changed files with 50 additions and 7 deletions

View File

@@ -303,7 +303,7 @@ class ImportArrayStorage
'existing' => $existingId,
'description' => $transaction['description'] ?? '',
'amount' => $transaction['transactions'][0]['amount'] ?? 0,
'date' => isset($transaction['date']) ? $transaction['date'] : '',
'date' => $transaction['date'] ?? '',
]
);
@@ -413,7 +413,14 @@ class ImportArrayStorage
$store['date'] = Carbon::createFromFormat('Y-m-d', $store['date']);
$store['description'] = $store['description'] === '' ? '(empty description)' : $store['description'];
// store the journal.
$journal = $this->journalRepos->store($store);
try {
$journal = $this->journalRepos->store($store);
} catch(FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->repository->addErrorMessage($this->importJob, sprintf('Row #%d could not be imported. %s', $index, $e->getMessage()));
continue;
}
Log::debug(sprintf('Stored as journal #%d', $journal->id));
$collection->push($journal);
}