From fdf99400bc99918f5f2756c70f0c49b8af7630e6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 16 Aug 2019 06:20:07 +0200 Subject: [PATCH] Some TODO's for the future. --- app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php | 1 + .../Commands/Upgrade/TransferCurrenciesCorrections.php | 1 + app/Http/Controllers/JavascriptController.php | 1 + app/Http/Controllers/PiggyBankController.php | 6 ++++++ app/Support/Http/Controllers/ChartGeneration.php | 1 + .../Import/JobConfiguration/Bunq/ChooseAccountsHandler.php | 1 + .../JobConfiguration/Spectre/ChooseAccountsHandler.php | 1 + .../Import/JobConfiguration/Ynab/SelectAccountsHandler.php | 1 + .../Import/JobConfiguration/Ynab/SelectBudgetHandler.php | 1 + app/Transformers/PiggyBankEventTransformer.php | 1 + app/Transformers/PiggyBankTransformer.php | 1 + 11 files changed, 16 insertions(+) diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php index 3cbce9de70..3af284a899 100644 --- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php +++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php @@ -125,6 +125,7 @@ class OtherCurrenciesCorrections extends Command if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore } + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $result = $this->currencyRepos->findNull($currencyId); if (null === $result) { diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php index b6717d32f5..36d51f678c 100644 --- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php +++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php @@ -147,6 +147,7 @@ class TransferCurrenciesCorrections extends Command if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore } + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $result = $this->currencyRepos->findNull($currencyId); if (null === $result) { diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 30f4a847cf..639695c320 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -109,6 +109,7 @@ class JavascriptController extends Controller $account = $repository->findNull((int)$request->get('account')); $currencyId = 0; if (null !== $account) { + // TODO we can use getAccountCurrency() instead $currencyId = (int)$repository->getMetaValue($account, 'currency_id'); } /** @var TransactionCurrency $currency */ diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 4f51a874d9..1c5880646a 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -94,6 +94,7 @@ class PiggyBankController extends Controller // get currency: $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); @@ -120,6 +121,7 @@ class PiggyBankController extends Controller // get currency: $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); @@ -298,6 +300,7 @@ class PiggyBankController extends Controller { $amount = $request->get('amount') ?? '0'; $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); @@ -340,6 +343,7 @@ class PiggyBankController extends Controller { $amount = $request->get('amount') ?? '0'; $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); @@ -383,6 +387,7 @@ class PiggyBankController extends Controller $repetition = $this->piggyRepos->getRepetition($piggyBank); // get currency: $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); @@ -403,6 +408,7 @@ class PiggyBankController extends Controller $repetition = $this->piggyRepos->getRepetition($piggyBank); // get currency: $currency = app('amount')->getDefaultCurrency(); + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); if ($currencyId > 0) { $currency = $this->currencyRepos->findNull($currencyId); diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php index fd31d54706..5a22354a26 100644 --- a/app/Support/Http/Controllers/ChartGeneration.php +++ b/app/Support/Http/Controllers/ChartGeneration.php @@ -75,6 +75,7 @@ trait ChartGeneration $chartData = []; /** @var Account $account */ foreach ($accounts as $account) { + // TODO we can use getAccountCurrency() instead $currency = $repository->findNull((int)$accountRepos->getMetaValue($account, 'currency_id')); if (null === $currency) { $currency = $default; diff --git a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php index 48bf73f351..c991c27777 100644 --- a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php @@ -154,6 +154,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface /** @var AccountModel $localAccount */ foreach ($collection as $localAccount) { $accountId = $localAccount->id; + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepository->getMetaValue($localAccount, 'currency_id'); $currency = $this->getCurrency($currencyId); $localAccounts[$accountId] = [ diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php index 268c789c36..3e78eb8af1 100644 --- a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php @@ -157,6 +157,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface /** @var AccountModel $account */ foreach ($accounts as $account) { $accountId = $account->id; + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); $currency = $this->getCurrency($currencyId); $array[$accountId] = [ diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php index 1602a4de96..0c23723baa 100644 --- a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php @@ -127,6 +127,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface /** @var Account $account */ foreach ($ffAccounts as $account) { $accountId = $account->id; + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); $currency = $this->getCurrency($currencyId); $array[$accountId] = [ diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php index e04ea1b84c..cec0e7259b 100644 --- a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php +++ b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php @@ -170,6 +170,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface } /** @var Account $account */ foreach ($this->accounts as $account) { + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); Log::debug(sprintf('Currency of %s is %d (looking for %d).', $account->name, $currencyId, $currency->id)); if ($currencyId === $currency->id) { diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php index dd9f1d40ab..22211b28b3 100644 --- a/app/Transformers/PiggyBankEventTransformer.php +++ b/app/Transformers/PiggyBankEventTransformer.php @@ -75,6 +75,7 @@ class PiggyBankEventTransformer extends AbstractTransformer $this->piggyRepos->setUser($account->user); // get associated currency or fall back to the default: + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->repository->getMetaValue($account, 'currency_id'); $currency = $this->currencyRepos->findNull($currencyId); if (null === $currency) { diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index 268994ba22..35fe31dfdd 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -77,6 +77,7 @@ class PiggyBankTransformer extends AbstractTransformer $this->piggyRepos->setUser($account->user); // get currency from account, or use default. + // TODO we can use getAccountCurrency() instead $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $currency = $this->currencyRepos->findNull($currencyId); if (null === $currency) {