diff --git a/app/Console/AutoImports.php b/app/Console/AutoImports.php
index f9c89a55..b508cb7b 100644
--- a/app/Console/AutoImports.php
+++ b/app/Console/AutoImports.php
@@ -453,7 +453,7 @@ private function startImport(Configuration $configuration): void
// get files from disk:
if (!$disk->has($fileName)) {
SubmissionStatusManager::setSubmissionStatus(SubmissionStatus::SUBMISSION_ERRORED, $this->identifier);
- $message = sprintf('File "%s" not found, cannot continue.', $fileName);
+ $message = sprintf('[a100]: File "%s" not found, cannot continue.', $fileName);
$this->error($message);
SubmissionStatusManager::addError($this->identifier, 0, $message);
$this->importMessages = $routine->getAllMessages();
@@ -469,7 +469,7 @@ private function startImport(Configuration $configuration): void
app('log')->debug(sprintf('Found %d transactions on the drive.', count($transactions)));
} catch (FileNotFoundException|\JsonException $e) {
SubmissionStatusManager::setSubmissionStatus(SubmissionStatus::SUBMISSION_ERRORED, $this->identifier);
- $message = sprintf('File "%s" could not be decoded, cannot continue..', $fileName);
+ $message = sprintf('[a101]: File "%s" could not be decoded, cannot continue..', $fileName);
$this->error($message);
SubmissionStatusManager::addError($this->identifier, 0, $message);
$this->importMessages = $routine->getAllMessages();
diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php
index f730c014..daf6c2b4 100644
--- a/app/Console/Commands/Import.php
+++ b/app/Console/Commands/Import.php
@@ -54,7 +54,7 @@ final class Import extends Command
*
* @var string
*/
- protected $signature = 'importer:import
+ protected $signature = 'importer:import
{config : The configuration file. }
{file? : Optionally, the importable file you want to import}
';
@@ -66,7 +66,7 @@ final class Import extends Command
*/
public function handle(): int
{
- $access = $this->haveAccess();
+ $access = $this->haveAccess();
if (false === $access) {
$this->error(sprintf('No access granted, or no connection is possible to your local Firefly III instance at %s.', config('importer.url')));
app('log')->error(sprintf('Exit code is %s.', ExitCode::NO_CONNECTION->name));
@@ -76,8 +76,8 @@ public function handle(): int
$this->info(sprintf('Welcome to the Firefly III data importer, v%s', config('importer.version')));
app('log')->debug(sprintf('Now in %s', __METHOD__));
- $file = (string) $this->argument('file');
- $config = (string) $this->argument('config'); // @phpstan-ignore-line
+ $file = (string) $this->argument('file');
+ $config = (string) $this->argument('config'); // @phpstan-ignore-line
// validate config path:
if ('' !== $config) {
@@ -110,7 +110,7 @@ public function handle(): int
return ExitCode::CANNOT_READ_CONFIG->value;
}
- $jsonResult = $this->verifyJSON($config);
+ $jsonResult = $this->verifyJSON($config);
if (false === $jsonResult) {
$message = 'The importer can\'t import: could not decode the JSON in the config file.';
$this->error($message);
@@ -142,11 +142,18 @@ public function handle(): int
$this->reportConversion();
// crash here if the conversion failed.
- $exitCode = ExitCode::SUCCESS->value;
+ $exitCode = ExitCode::SUCCESS->value;
if (0 !== count($this->conversionErrors)) {
- $this->error('There are many errors in the data conversion. The import will stop here.');
- $exitCode = ExitCode::TOO_MANY_ERRORS_PROCESSING->value;
app('log')->error(sprintf('Exit code is %s.', ExitCode::TOO_MANY_ERRORS_PROCESSING->name));
+ $exitCode = ExitCode::TOO_MANY_ERRORS_PROCESSING->value;
+ // could still be that there were simply no transactions (from GoCardless). This can result
+ // in another exit code.
+ if($this->isNothingDownloaded()) {
+ app('log')->error(sprintf('Exit code changed to %s.', ExitCode::NOTHING_WAS_IMPORTED->name));
+ $exitCode = ExitCode::NOTHING_WAS_IMPORTED->value;
+ }
+
+ $this->error('There are many errors in the data conversion. The import will stop here.');
}
if (0 === count($this->conversionErrors)) {
$this->line(sprintf('Done converting from file %s using configuration %s.', $file, $config));
@@ -158,9 +165,9 @@ public function handle(): int
$this->reportBalanceDifferences($configuration);
// merge things:
- $messages = array_merge($this->importMessages, $this->conversionMessages);
- $warnings = array_merge($this->importWarnings, $this->conversionWarnings);
- $errors = array_merge($this->importErrors, $this->conversionErrors);
+ $messages = array_merge($this->importMessages, $this->conversionMessages);
+ $warnings = array_merge($this->importWarnings, $this->conversionWarnings);
+ $errors = array_merge($this->importErrors, $this->conversionErrors);
event(new ImportedTransactions($messages, $warnings, $errors, $this->conversionRateLimits));
if (0 !== count($this->importErrors)) {
@@ -177,4 +184,18 @@ public function handle(): int
return $exitCode;
}
+
+ private function isNothingDownloaded(): bool
+ {
+ /** @var array $errors */
+ foreach ($this->conversionErrors as $errors) {
+ /** @var string $error */
+ foreach ($errors as $error) {
+ if (str_contains($error, '[a111]')) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/app/Services/CSV/Conversion/Routine/CSVFileProcessor.php b/app/Services/CSV/Conversion/Routine/CSVFileProcessor.php
index 032e4b52..3a1da9c6 100644
--- a/app/Services/CSV/Conversion/Routine/CSVFileProcessor.php
+++ b/app/Services/CSV/Conversion/Routine/CSVFileProcessor.php
@@ -65,7 +65,7 @@ public function processCSVFile(): array
} catch (Exception $e) {
app('log')->error($e->getMessage());
// app('log')->error($e->getTraceAsString());
- $message = sprintf('Could not set delimiter: %s', $e->getMessage());
+ $message = sprintf('[a106]: Could not set delimiter: %s', $e->getMessage());
$this->addError(0, $message);
return [];
@@ -78,7 +78,7 @@ public function processCSVFile(): array
} catch (Exception $e) {
app('log')->error($e->getMessage());
// app('log')->error($e->getTraceAsString());
- $message = sprintf('Could not read CSV: %s', $e->getMessage());
+ $message = sprintf('[a107]: Could not read CSV: %s', $e->getMessage());
$this->addError(0, $message);
return [];
@@ -89,7 +89,7 @@ public function processCSVFile(): array
} catch (ImporterErrorException $e) {
app('log')->error($e->getMessage());
// app('log')->error($e->getTraceAsString());
- $message = sprintf('Could not parse CSV: %s', $e->getMessage());
+ $message = sprintf('[a108]: Could not parse CSV: %s', $e->getMessage());
$this->addError(0, $message);
return [];
diff --git a/app/Services/CSV/Conversion/RoutineManager.php b/app/Services/CSV/Conversion/RoutineManager.php
index 2d7b2a80..bb03596b 100644
--- a/app/Services/CSV/Conversion/RoutineManager.php
+++ b/app/Services/CSV/Conversion/RoutineManager.php
@@ -151,7 +151,7 @@ public function start(): array
// $this->addWarning(7, '7: No transactions found in CSV file.');
if (0 === $count) {
- $this->addError(0, 'No transactions found in CSV file.');
+ $this->addError(0, '[a105]: No transactions found in CSV file.');
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
diff --git a/app/Services/Camt/Conversion/RoutineManager.php b/app/Services/Camt/Conversion/RoutineManager.php
index 8935bd01..f2ba79cb 100644
--- a/app/Services/Camt/Conversion/RoutineManager.php
+++ b/app/Services/Camt/Conversion/RoutineManager.php
@@ -104,7 +104,7 @@ public function start(): array
$camtMessage = $this->getCamtMessage();
if (null === $camtMessage) {
app('log')->error('The CAMT object is NULL, probably due to a previous error');
- $this->addError(0, 'The CAMT object is NULL, probably due to a previous error');
+ $this->addError(0, '[a102]: The CAMT object is NULL, probably due to a previous error');
// at this point there are very few (if not zero) errors from other steps in the routine.
// Still: merge errors so they can be reported to the user:
$this->mergeMessages(1);
@@ -124,7 +124,7 @@ public function start(): array
if (0 === count($transactions)) {
app('log')->error('No transactions found in CAMT file');
- $this->addError(0, 'No transactions found in CAMT file.');
+ $this->addError(0, '[a103]: No transactions found in CAMT file.');
$this->mergeMessages(1);
$this->mergeWarnings(1);
@@ -158,7 +158,7 @@ private function getCamtMessage(): ?Message
} catch (InvalidMessageException $e) {
app('log')->error('Conversion error in RoutineManager::getCamtMessage');
app('log')->error($e->getMessage());
- $this->addError(0, sprintf('Could not convert CAMT.053 file: %s', $e->getMessage()));
+ $this->addError(0, sprintf('[a104]: Could not convert CAMT.053 file: %s', $e->getMessage()));
return null;
}
diff --git a/app/Services/Nordigen/Conversion/Routine/TransactionProcessor.php b/app/Services/Nordigen/Conversion/Routine/TransactionProcessor.php
index 11bb431c..3feabc60 100644
--- a/app/Services/Nordigen/Conversion/Routine/TransactionProcessor.php
+++ b/app/Services/Nordigen/Conversion/Routine/TransactionProcessor.php
@@ -84,7 +84,7 @@ public function download(): array
} catch (AgreementExpiredException $e) {
$this->addError(
0,
- 'Your GoCardless End User Agreement has expired. You must refresh it by generating a new one through the Firefly III Data Importer user interface. See the other error messages for more information.'
+ '[a113]: Your GoCardless End User Agreement has expired. You must refresh it by generating a new one through the Firefly III Data Importer user interface. See the other error messages for more information.'
);
if (array_key_exists('summary', $e->json) && '' !== (string) $e->json['summary']) {
$this->addError(0, $e->json['summary']);
@@ -133,7 +133,7 @@ public function download(): array
app('log')->debug(sprintf('Ran into %s instead of GetTransactionsResponse', get_class($e)));
// agreement expired, whoops.
$return[$account] = [];
- $this->addError(0, $e->json['detail'] ?? 'Your EUA has expired.');
+ $this->addError(0, $e->json['detail'] ?? '[a114]: Your EUA has expired.');
// save rate limits, even though they may not be there.
$this->rateLimits[$account] = [
'remaining' => $request->getRemaining(),
diff --git a/app/Services/Nordigen/Conversion/RoutineManager.php b/app/Services/Nordigen/Conversion/RoutineManager.php
index 1ae575b8..4f8069f4 100644
--- a/app/Services/Nordigen/Conversion/RoutineManager.php
+++ b/app/Services/Nordigen/Conversion/RoutineManager.php
@@ -244,7 +244,7 @@ private function downloadFromGoCardless(): void
app('log')->error($e->getMessage());
// add error to current error thing:
- $this->addError(0, sprintf('Could not download from GoCardless: %s', $e->getMessage()));
+ $this->addError(0, sprintf('[a109]: Could not download from GoCardless: %s', $e->getMessage()));
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
@@ -275,7 +275,7 @@ private function collectTargetAccounts(): void
try {
$this->transactionGenerator->collectTargetAccounts();
} catch (ApiHttpException $e) {
- $this->addError(0, sprintf('Error while collecting target accounts: %s', $e->getMessage()));
+ $this->addError(0, sprintf('[a110]: Error while collecting target accounts: %s', $e->getMessage()));
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
@@ -328,7 +328,7 @@ private function breakOnDownload(): bool
if (0 === $total) {
app('log')->warning('Downloaded nothing, will return nothing.');
// add error to current error thing:
- $this->addError(0, 'No transactions were downloaded from GoCardless. You may be rate limited or something else went wrong.');
+ $this->addError(0, '[a111]: No transactions were downloaded from GoCardless. You may be rate limited or something else went wrong.');
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
@@ -347,7 +347,7 @@ private function collectGoCardlessAccounts(): void
app('log')->error('Could not collect info on all GoCardless accounts, but this info isn\'t used at the moment anyway.');
app('log')->error($e->getMessage());
} catch (AgreementExpiredException $e) {
- $this->addError(0, 'The connection between your bank and GoCardless has expired.');
+ $this->addError(0, '[a112]: The connection between your bank and GoCardless has expired.');
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
diff --git a/app/Services/Shared/Import/Routine/ApiSubmitter.php b/app/Services/Shared/Import/Routine/ApiSubmitter.php
index 5acd1ad9..d8f5cf6d 100644
--- a/app/Services/Shared/Import/Routine/ApiSubmitter.php
+++ b/app/Services/Shared/Import/Routine/ApiSubmitter.php
@@ -171,7 +171,7 @@ private function uniqueTransaction(int $index, array $line): ?bool
sprintf('Looks like field "%s" with value "%s" is not unique, found in group #%d. Return false', $field, $value, $searchResult)
);
$message = sprintf(
- 'There is already a transaction with %s "%s" (link).',
+ '[a115]: There is already a transaction with %s "%s" (link).',
$field,
$value,
$this->vanityURL,
@@ -258,7 +258,7 @@ private function processTransaction(int $index, array $line): array
return $return;
}
- $message = sprintf('Submission HTTP error: %s', e($e->getMessage()));
+ $message = sprintf('[a116]: Submission HTTP error: %s', e($e->getMessage()));
app('log')->error($e->getMessage());
$this->addError($index, $message);
@@ -269,7 +269,7 @@ private function processTransaction(int $index, array $line): array
foreach ($response->errors->messages() as $key => $errors) {
app('log')->error(sprintf('Submission error: %d', $key), $errors);
foreach ($errors as $error) {
- $msg = sprintf('%s: %s (original value: "%s")', $key, $error, $this->getOriginalValue($key, $line));
+ $msg = sprintf('[a117]: %s: %s (original value: "%s")', $key, $error, $this->getOriginalValue($key, $line));
if (false === $this->isDuplicationError($key, $error) || false === config('importer.ignore_duplicate_errors')) {
$this->addError($index, $msg);
}
@@ -284,7 +284,7 @@ private function processTransaction(int $index, array $line): array
/** @var TransactionGroup $group */
$group = $response->getTransactionGroup();
if (null === $group) {
- $message = 'Could not create transaction. Unexpected empty response from Firefly III. Check the logs.';
+ $message = '[a118]: Could not create transaction. Unexpected empty response from Firefly III. Check the logs.';
app('log')->error($message, $response->getRawData());
$this->addError($index, $message);
@@ -293,7 +293,7 @@ private function processTransaction(int $index, array $line): array
// perhaps zero transactions in the array.
if (0 === count($group->transactions)) {
- $message = 'Could not create transaction. Transaction-count from Firefly III is zero. Check the logs.';
+ $message = '[a119]: Could not create transaction. Transaction-count from Firefly III is zero. Check the logs.';
app('log')->error($message, $response->getRawData());
$this->addError($index, $message);
@@ -495,7 +495,7 @@ private function addTagToGroups(array $groupInfo): void
} catch (ApiHttpException $e) {
app('log')->error($e->getMessage());
// app('log')->error($e->getTraceAsString());
- $this->addError(0, 'Could not store transaction: see the log files.');
+ $this->addError(0, '[a120]: Could not store transaction: see the log files.');
}
app('log')->debug(sprintf('Added import tag to transaction group #%d', $groupId));
}
@@ -522,7 +522,7 @@ private function createTag(): void
/** @var PostTagResponse $response */
$response = $request->post();
} catch (ApiHttpException $e) {
- $message = sprintf('Could not create tag. %s', $e->getMessage());
+ $message = sprintf('[a121]: Could not create tag. %s', $e->getMessage());
app('log')->error($message);
// app('log')->error($e->getTraceAsString());
$this->addError(0, $message);
diff --git a/app/Services/Spectre/Conversion/RoutineManager.php b/app/Services/Spectre/Conversion/RoutineManager.php
index f432182e..2ff34711 100644
--- a/app/Services/Spectre/Conversion/RoutineManager.php
+++ b/app/Services/Spectre/Conversion/RoutineManager.php
@@ -103,7 +103,7 @@ public function start(): array
try {
$this->transactionGenerator->collectTargetAccounts();
} catch (ApiHttpException $e) {
- $this->addError(0, sprintf('Cannot download Spectre accounts: %s', $e->getMessage()));
+ $this->addError(0, sprintf('[a122]: Cannot download Spectre accounts: %s', $e->getMessage()));
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);
@@ -114,7 +114,7 @@ public function start(): array
$converted = $this->transactionGenerator->getTransactions($transactions);
app('log')->debug(sprintf('Generated %d Firefly III transactions.', count($converted)));
if (0 === count($converted)) {
- $this->addError(0, 'No transactions were converted, probably zero found at Spectre.');
+ $this->addError(0, '[a123]: No transactions were converted, probably zero found at Spectre.');
$this->mergeMessages(1);
$this->mergeWarnings(1);
$this->mergeErrors(1);