From 3aa835a985cfb0f66d730d11edbd06fb6777c1c9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 28 Oct 2020 06:14:12 +0100 Subject: [PATCH] Fix #4003 --- app/Http/Requests/BudgetFormStoreRequest.php | 2 +- app/Repositories/Budget/BudgetRepository.php | 31 ++++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/Http/Requests/BudgetFormStoreRequest.php b/app/Http/Requests/BudgetFormStoreRequest.php index e029c99027..ea3a6c189c 100644 --- a/app/Http/Requests/BudgetFormStoreRequest.php +++ b/app/Http/Requests/BudgetFormStoreRequest.php @@ -47,7 +47,7 @@ class BudgetFormStoreRequest extends FormRequest 'name' => $this->string('name'), 'active' => $this->boolean('active'), 'auto_budget_type' => $this->integer('auto_budget_type'), - 'transaction_currency_id' => $this->integer('transaction_currency_id'), + 'transaction_currency_id' => $this->integer('auto_budget_currency_id'), 'auto_budget_amount' => $this->string('auto_budget_amount'), 'auto_budget_period' => $this->string('auto_budget_period'), ]; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index aee88db882..548b6a229f 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -161,6 +161,7 @@ class BudgetRepository implements BudgetRepositoryInterface if (null !== $journal) { return $journal->date; } + return null; } @@ -208,7 +209,7 @@ class BudgetRepository implements BudgetRepositoryInterface /** * @param string $query - * @param int $limit + * @param int $limit * * @return Collection */ @@ -220,7 +221,7 @@ class BudgetRepository implements BudgetRepositoryInterface $search->where('name', 'LIKE', sprintf('%%%s%%', $query)); } $search->orderBy('order', 'ASC') - ->orderBy('name', 'ASC')->where('active', 1); + ->orderBy('name', 'ASC')->where('active', 1); return $search->take($limit)->get(); } @@ -277,15 +278,15 @@ class BudgetRepository implements BudgetRepositoryInterface if ('rollover' === $type) { $type = AutoBudget::AUTO_BUDGET_ROLLOVER; } - $repos = app(CurrencyRepositoryInterface::class); - $currencyId = (int)($data['transaction_currency_id'] ?? 0); + $repos = app(CurrencyRepositoryInterface::class); + $currencyId = (int)($data['transaction_currency_id'] ?? 0); $currencyCode = (string)($data['transaction_currency_code'] ?? ''); $currency = $repos->findNull($currencyId); - if(null === $currency) { + if (null === $currency) { $currency = $repos->findByCodeNull($currencyCode); } - if(null === $currency) { + if (null === $currency) { $currency = app('amount')->getDefaultCurrencyByUser($this->user); } @@ -306,11 +307,11 @@ class BudgetRepository implements BudgetRepositoryInterface $limitRepos->setUser($this->user); $limitRepos->store( [ - 'budget_id' => $newBudget->id, - 'transaction_currency_id' => $autoBudget->transaction_currency_id, - 'start_date' => $start, - 'end_date' => $end, - 'amount' => $autoBudget->amount, + 'budget_id' => $newBudget->id, + 'currency_id' => $autoBudget->transaction_currency_id, + 'start_date' => $start, + 'end_date' => $end, + 'amount' => $autoBudget->amount, ] ); @@ -348,15 +349,15 @@ class BudgetRepository implements BudgetRepositoryInterface $autoBudget->budget()->associate($budget); } - $repos = app(CurrencyRepositoryInterface::class); - $currencyId = (int)($data['transaction_currency_id'] ?? 0); + $repos = app(CurrencyRepositoryInterface::class); + $currencyId = (int)($data['transaction_currency_id'] ?? 0); $currencyCode = (string)($data['transaction_currency_code'] ?? ''); $currency = $repos->findNull($currencyId); - if(null === $currency) { + if (null === $currency) { $currency = $repos->findByCodeNull($currencyCode); } - if(null === $currency) { + if (null === $currency) { $currency = app('amount')->getDefaultCurrencyByUser($this->user); }