Skip to content

Commit

Permalink
🐛 #20
Browse files Browse the repository at this point in the history
  • Loading branch information
robvankeilegom committed Mar 6, 2024
1 parent 2140ce7 commit b4aa6a8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Firefly.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ public function push(Transaction $transaction): bool
} catch (RequestException $e) {
// If a request exception is thrown, it could be because the account already exists
// This happens if the account was already created be another importer or created manually
$response = null;

if ($e->hasResponse()) {
$response = json_decode($e->getResponse()->getBody(), true);
}

if ('This account name is already in use.' === Arr::get($response, 'errors.name.0')) {
// Find the account by name
$fireflyId = $this->findAccountByName($payer->name, $direction);
}
if ('This account name is already in use.' === Arr::get($response, 'errors.name.0')) {
// Find the account by name
$fireflyId = $this->findAccountByName($payer->name, $direction);
} else {
throw $e;
}
}

Expand Down

0 comments on commit b4aa6a8

Please sign in to comment.