Fix for issue #328. Turns out the import routine converts accounts back and forth instead of creating new entries.

This commit is contained in:
James Cole
2016-09-24 18:59:31 +02:00
parent abc4f856ce
commit ad2b254be0
4 changed files with 24 additions and 6 deletions

View File

@@ -178,10 +178,25 @@ class ImportValidator
$result = $repository->findByName($account->name, [$type]);
if (is_null($result->id)) {
// can convert account:
Log::debug(sprintf('No account named %s of type %s, will convert.', $account->name, $type));
$result = $repository->updateAccountType($account, $type);
Log::debug(sprintf('No account named %s of type %s, create new account.', $account->name, $type));
$result = $repository->store(
[
'user' => $this->user->id,
'accountType' => config('firefly.shortNamesByFullName.' . $type),
'name' => $account->name,
'virtualBalance' => 0,
'active' => true,
'iban' => null,
'openingBalance' => 0,
]
);
}
Log::debug(
sprintf(
'Using another account named %s (#%d) of type %s, will use that one instead of %s (#%d)', $account->name, $result->id, $type, $account->name,
$account->id
)
);
return $result;