Some TODO's for the future.

This commit is contained in:
James Cole
2019-08-16 06:20:07 +02:00
parent 1ba45afeab
commit fdf99400bc
11 changed files with 16 additions and 0 deletions

View File

@@ -125,6 +125,7 @@ class OtherCurrenciesCorrections extends Command
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
} }
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$result = $this->currencyRepos->findNull($currencyId); $result = $this->currencyRepos->findNull($currencyId);
if (null === $result) { if (null === $result) {

View File

@@ -147,6 +147,7 @@ class TransferCurrenciesCorrections extends Command
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
} }
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$result = $this->currencyRepos->findNull($currencyId); $result = $this->currencyRepos->findNull($currencyId);
if (null === $result) { if (null === $result) {

View File

@@ -109,6 +109,7 @@ class JavascriptController extends Controller
$account = $repository->findNull((int)$request->get('account')); $account = $repository->findNull((int)$request->get('account'));
$currencyId = 0; $currencyId = 0;
if (null !== $account) { if (null !== $account) {
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$repository->getMetaValue($account, 'currency_id'); $currencyId = (int)$repository->getMetaValue($account, 'currency_id');
} }
/** @var TransactionCurrency $currency */ /** @var TransactionCurrency $currency */

View File

@@ -94,6 +94,7 @@ class PiggyBankController extends Controller
// get currency: // get currency:
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
@@ -120,6 +121,7 @@ class PiggyBankController extends Controller
// get currency: // get currency:
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
@@ -298,6 +300,7 @@ class PiggyBankController extends Controller
{ {
$amount = $request->get('amount') ?? '0'; $amount = $request->get('amount') ?? '0';
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
@@ -340,6 +343,7 @@ class PiggyBankController extends Controller
{ {
$amount = $request->get('amount') ?? '0'; $amount = $request->get('amount') ?? '0';
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
@@ -383,6 +387,7 @@ class PiggyBankController extends Controller
$repetition = $this->piggyRepos->getRepetition($piggyBank); $repetition = $this->piggyRepos->getRepetition($piggyBank);
// get currency: // get currency:
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
@@ -403,6 +408,7 @@ class PiggyBankController extends Controller
$repetition = $this->piggyRepos->getRepetition($piggyBank); $repetition = $this->piggyRepos->getRepetition($piggyBank);
// get currency: // get currency:
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);

View File

@@ -75,6 +75,7 @@ trait ChartGeneration
$chartData = []; $chartData = [];
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
// TODO we can use getAccountCurrency() instead
$currency = $repository->findNull((int)$accountRepos->getMetaValue($account, 'currency_id')); $currency = $repository->findNull((int)$accountRepos->getMetaValue($account, 'currency_id'));
if (null === $currency) { if (null === $currency) {
$currency = $default; $currency = $default;

View File

@@ -154,6 +154,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
/** @var AccountModel $localAccount */ /** @var AccountModel $localAccount */
foreach ($collection as $localAccount) { foreach ($collection as $localAccount) {
$accountId = $localAccount->id; $accountId = $localAccount->id;
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepository->getMetaValue($localAccount, 'currency_id'); $currencyId = (int)$this->accountRepository->getMetaValue($localAccount, 'currency_id');
$currency = $this->getCurrency($currencyId); $currency = $this->getCurrency($currencyId);
$localAccounts[$accountId] = [ $localAccounts[$accountId] = [

View File

@@ -157,6 +157,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
/** @var AccountModel $account */ /** @var AccountModel $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
$currency = $this->getCurrency($currencyId); $currency = $this->getCurrency($currencyId);
$array[$accountId] = [ $array[$accountId] = [

View File

@@ -127,6 +127,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
/** @var Account $account */ /** @var Account $account */
foreach ($ffAccounts as $account) { foreach ($ffAccounts as $account) {
$accountId = $account->id; $accountId = $account->id;
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
$currency = $this->getCurrency($currencyId); $currency = $this->getCurrency($currencyId);
$array[$accountId] = [ $array[$accountId] = [

View File

@@ -170,6 +170,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface
} }
/** @var Account $account */ /** @var Account $account */
foreach ($this->accounts as $account) { foreach ($this->accounts as $account) {
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
Log::debug(sprintf('Currency of %s is %d (looking for %d).', $account->name, $currencyId, $currency->id)); Log::debug(sprintf('Currency of %s is %d (looking for %d).', $account->name, $currencyId, $currency->id));
if ($currencyId === $currency->id) { if ($currencyId === $currency->id) {

View File

@@ -75,6 +75,7 @@ class PiggyBankEventTransformer extends AbstractTransformer
$this->piggyRepos->setUser($account->user); $this->piggyRepos->setUser($account->user);
// get associated currency or fall back to the default: // get associated currency or fall back to the default:
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
if (null === $currency) { if (null === $currency) {

View File

@@ -77,6 +77,7 @@ class PiggyBankTransformer extends AbstractTransformer
$this->piggyRepos->setUser($account->user); $this->piggyRepos->setUser($account->user);
// get currency from account, or use default. // get currency from account, or use default.
// TODO we can use getAccountCurrency() instead
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id'); $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
if (null === $currency) { if (null === $currency) {