mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand import routine.
This commit is contained in:
@@ -243,9 +243,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
|
||||
// account may exist already:
|
||||
$existingAccount = $this->findByName($data['name'], [$data['accountType']]);
|
||||
$existingAccount = $this->findByName($data['name'], [$type]);
|
||||
if (!is_null($existingAccount->id)) {
|
||||
throw new FireflyException(sprintf('There already is an account named "%s" of type "%s".', $data['name'], $data['accountType']));
|
||||
Log::warning(sprintf('There already is an account named "%s" of type "%s".', $data['name'], $type));
|
||||
|
||||
return $existingAccount;
|
||||
}
|
||||
|
||||
// create it:
|
||||
@@ -267,6 +269,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
);
|
||||
throw new FireflyException(sprintf('Tried to create account named "%s" but failed. The logs have more details.', $data['name']));
|
||||
}
|
||||
Log::debug(sprintf('Created new account #%d named "%s" of type %s.', $newAccount->id, $newAccount->name, $accountType->type));
|
||||
|
||||
return $newAccount;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ trait FindAccountsTrait
|
||||
$query->whereIn('account_types.type', $types);
|
||||
|
||||
}
|
||||
Log::debug(sprintf('Searching for account named %s of the following type(s)', $name), ['types' => $types]);
|
||||
Log::debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
|
||||
$accounts = $query->get(['accounts.*']);
|
||||
/** @var Account $account */
|
||||
@@ -118,7 +118,7 @@ trait FindAccountsTrait
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
Log::debug('Found nothing.');
|
||||
Log::debug(sprintf('There is no account with name "%s" or types', $name), $types);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user