Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various fixes.
James Cole18f779c6deba
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.phpindex cc615dcc7d..7e9e9e6ad6 100644--- a/app/Factory/TransactionFactory.php+++ b/app/Factory/TransactionFactory.php@@ -107,7 +107,7 @@ class TransactionFactoryLog::debug(sprintf('Expect source destination to be of type %s', $destinationType));$destinationAccount = $this->findAccount($destinationType, $data['destination_id'], $data['destination_name']);- Log::debug(sprintf('Source type is "%s", destination type is "%s"', $sourceType, $destinationType));+ Log::debug(sprintf('Source type is "%s", destination type is "%s"', $sourceAccount->accountType->type, $destinationAccount->accountType->type));// throw big fat error when source type === dest typeif ($sourceAccount->accountType->type === $destinationAccount->accountType->type && $journal->transactionType->type !== TransactionType::TRANSFER) {throw new FireflyException(sprintf('Source and destination account cannot be both of the type "%s"', $destinationAccount->accountType->type));diff --git a/app/Repositories/Account/FindAccountsTrait.php b/app/Repositories/Account/FindAccountsTrait.phpindex de9b338488..347d458d4c 100644--- a/app/Repositories/Account/FindAccountsTrait.php+++ b/app/Repositories/Account/FindAccountsTrait.php@@ -158,9 +158,11 @@ trait FindAccountsTraitLog::debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));return $account;+ } else{+ Log::debug(sprintf('"%s" does not equal "%s"', $account->name, $name));}}- Log::debug(sprintf('There is no account with name "%s" or types', $name), $types);+ Log::debug(sprintf('There is no account with name "%s" of types', $name), $types);return null;}diff --git a/app/Services/Spectre/Request/NewCustomerRequest.php b/app/Services/Spectre/Request/NewCustomerRequest.phpindex eea0b17c05..099a40cfd9 100644--- a/app/Services/Spectre/Request/NewCustomerRequest.php+++ b/app/Services/Spectre/Request/NewCustomerRequest.php@@ -23,7 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Spectre\Request;use FireflyIII\Services\Spectre\Object\Customer;-+use Log;/*** Class NewCustomerRequest*/@@ -43,6 +43,7 @@ class NewCustomerRequest extends SpectreRequest],];$uri = '/api/v4/customers/';+ Log::debug(sprintf('Going to call %s with info:', $uri), $data);$response = $this->sendSignedSpectrePost($uri, $data);// create customer:$this->customer = new Customer($response['data']);diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.phpindex a8a3e91453..d111940c02 100644--- a/app/Support/ExpandedForm.php+++ b/app/Support/ExpandedForm.php@@ -562,7 +562,9 @@ class ExpandedForm/** @var PiggyBankRepositoryInterface $repository */$repository = app(PiggyBankRepositoryInterface::class);$piggyBanks = $repository->getPiggyBanksWithAmount();- $array = [];+ $array = [+ 0 => trans('firefly.none_in_select_list'),+ ];/** @var PiggyBank $piggy */foreach ($piggyBanks as $piggy) {$array[$piggy->id] = $piggy->name;diff --git a/app/Support/Import/Routine/File/CurrencyMapper.php b/app/Support/Import/Routine/File/CurrencyMapper.phpindex 2dd366d4d6..506e2291c8 100644--- a/app/Support/Import/Routine/File/CurrencyMapper.php+++ b/app/Support/Import/Routine/File/CurrencyMapper.php@@ -71,10 +71,13 @@ class CurrencyMapperreturn $result;}}+ if (null === $data['code']) {+ return null;+ }+// if still nothing, and fields not null, try to create it- $code = $data['code'] ?? null;$creation = [- 'code' => $code,+ 'code' => $data['code'],'name' => $data['name'] ?? $code,'symbol' => $data['symbol'] ?? $code,'decimal_places' => 2,diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.phpindex 73c3963354..6cc4f65141 100644--- a/app/Support/Import/Routine/File/ImportableConverter.php+++ b/app/Support/Import/Routine/File/ImportableConverter.php@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\AccountType;use FireflyIII\Models\ImportJob;use FireflyIII\Models\TransactionCurrency;+use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;use FireflyIII\Support\Import\Placeholder\ImportTransaction;use InvalidArgumentException;@@ -39,6 +40,8 @@ use Log;*/class ImportableConverter{+ /** @var AccountRepositoryInterface */+ private $accountRepository;/** @var AssetAccountMapper */private $assetMapper;/** @var array */@@ -102,6 +105,10 @@ class ImportableConverter$this->assetMapper->setUser($importJob->user);$this->assetMapper->setDefaultAccount($this->config['import-account'] ?? 0);+ // asset account repository is used for currency information+ $this->accountRepository = app(AccountRepositoryInterface::class);+ $this->accountRepository->setUser($importJob->user);+// opposing account mapper:$this->opposingMapper = app(OpposingAccountMapper::class);$this->opposingMapper->setUser($importJob->user);@@ -154,10 +161,6 @@ class ImportableConverter$currency = $this->currencyMapper->map($currencyId, $importable->getCurrencyData());$foreignCurrency = $this->currencyMapper->map($foreignCurrencyId, $importable->getForeignCurrencyData());- if (null === $currency) {- Log::debug(sprintf('Could not map currency, use default (%s)', $this->defaultCurrency->code));- $currency = $this->defaultCurrency;- }Log::debug(sprintf('"%s" (#%d) is source and "%s" (#%d) is destination.', $source->name, $source->id, $destination->name, $destination->id));if (bccomp($amount, '0') === 1) {@@ -171,6 +174,28 @@ class ImportableConverter);}+ // get currency preference from source asset account (preferred)+ // or destination asset account+ if (null === $currency) {+ if ($destination->accountType->type === AccountType::ASSET) {+ // destination is asset, might have currency preference:+ $destinationCurrencyId = (int)$this->accountRepository->getMetaValue($destination, 'currency_id');+ $currency = $destinationCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []);+ Log::debug(sprintf('Destination is an asset account, and has currency preference %s', $currency->code));+ }++ if ($source->accountType->type === AccountType::ASSET) {+ // source is asset, might have currency preference:+ $sourceCurrencyId = (int)$this->accountRepository->getMetaValue($source, 'currency_id');+ $currency = $sourceCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []);+ Log::debug(sprintf('Source is an asset account, and has currency preference %s', $currency->code));+ }+ }+ if (null === $currency) {+ Log::debug(sprintf('Could not map currency, use default (%s)', $this->defaultCurrency->code));+ $currency = $this->defaultCurrency;+ }+if ($source->accountType->type === AccountType::ASSET && $destination->accountType->type === AccountType::ASSET) {Log::debug('Source and destination are asset accounts. This is a transfer.');$transactionType = 'transfer';@@ -281,11 +306,13 @@ class ImportableConverter{if (isset($this->mappedValues[$key]) && \in_array($objectId, $this->mappedValues[$key], true)) {- Log::debug(sprintf('verifyObjectId(%s, %d) is valid!',$key, $objectId));+ Log::debug(sprintf('verifyObjectId(%s, %d) is valid!', $key, $objectId));+return $objectId;}- Log::debug(sprintf('verifyObjectId(%s, %d) is NOT in the list, but it could still be valid.',$key, $objectId));+ Log::debug(sprintf('verifyObjectId(%s, %d) is NOT in the list, but it could still be valid.', $key, $objectId));+return $objectId;}diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 0f1378c614..ab709109db 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -1155,8 +1155,9 @@ return ['cannot_convert_split_journal' => 'Cannot convert a split transaction',// Import page (general strings only)- 'import_index_title' => 'Import data into Firefly III',+ 'import_index_title' => 'Import transactions into Firefly III','import_data' => 'Import data',+ 'import_transactions' => 'Import transactions',// sandstorm.io errors and messages:'sandstorm_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.',diff --git a/resources/views/partials/menu-sidebar.twig b/resources/views/partials/menu-sidebar.twigindex e9f7a016e0..7c29a52920 100644--- a/resources/views/partials/menu-sidebar.twig+++ b/resources/views/partials/menu-sidebar.twig@@ -117,7 +117,7 @@</a><ul class="treeview-menu"><li class="{{ activeRoutePartial('import') }}">- <a href="{{ route('import.index') }}"><i class="fa fa-archive fa-fw"></i> {{ 'import_data'|_ }}</a>+ <a href="{{ route('import.index') }}"><i class="fa fa-archive fa-fw"></i> {{ 'import_transactions'|_ }}</a></li><li class="{{ activeRoutePartial('export') }}"><a href="{{ route('export.index') }}"><i class="fa fa-file-archive-o fa-fw"></i> {{ 'export_and_backup_data'|_ }}</a>