From 528da3f08e484411ca4dbdc2b878fdfd31660b1b Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 12 May 2018 20:56:34 +0200 Subject: [PATCH] Allow the mapping of asset accounts for opposing value --- app/Factory/TransactionFactory.php | 1 - app/Import/Storage/ImportArrayStorage.php | 4 ++-- app/Support/Import/Routine/File/OpposingAccountMapper.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index 473f2e3c37..d908467baf 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -55,7 +55,6 @@ class TransactionFactory Log::debug('Start of TransactionFactory::create()'); $currencyId = $data['currency_id'] ?? null; $currencyId = isset($data['currency']) ? $data['currency']->id : $currencyId; - Log::debug('We dont make it here'); if ('' === $data['amount']) { throw new FireflyException('Amount is an empty string, which Firefly III cannot handle. Apologies.'); } diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index 76168ee1da..3500ddbe6b 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -379,8 +379,8 @@ class ImportArrayStorage foreach ($toStore as $index => $store) { Log::debug(sprintf('Going to store entry %d of %d', $index + 1, $count)); // convert the date to an object: - $store['date'] = Carbon::createFromFormat('Y-m-d', $store['date']); - + $store['date'] = Carbon::createFromFormat('Y-m-d', $store['date']); + $store['description'] = $store['description'] === '' ? '(empty description)' : $store['description']; // store the journal. $collection->push($this->journalRepos->store($store)); } diff --git a/app/Support/Import/Routine/File/OpposingAccountMapper.php b/app/Support/Import/Routine/File/OpposingAccountMapper.php index 42664b8c9e..2ba07bf2ef 100644 --- a/app/Support/Import/Routine/File/OpposingAccountMapper.php +++ b/app/Support/Import/Routine/File/OpposingAccountMapper.php @@ -62,7 +62,7 @@ class OpposingAccountMapper if ((int)$accountId > 0) { // find any account with this ID: $result = $this->repository->findNull($accountId); - if (null !== $result && $result->accountType->type === $expectedType) { + if (null !== $result && ($result->accountType->type === $expectedType || $result->accountType->type === AccountType::ASSET)) { Log::debug(sprintf('Found account "%s" (%s) based on given ID %d. Return it!', $result->name, $result->accountType->type, $accountId)); return $result; @@ -112,7 +112,7 @@ class OpposingAccountMapper // not found? Create it! $creation = [ 'name' => $data['name'] ?? '(no name)', - 'iban' => $data['iban']?? null, + 'iban' => $data['iban'] ?? null, 'accountNumber' => $data['number'] ?? null, 'account_type_id' => null, 'accountType' => $expectedType,