From c0033ae56bf10baac02a19c5af01b943cb45a936 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 10 Aug 2019 17:11:57 +0200 Subject: [PATCH] Code cleanup in AccountForm. --- app/Support/Amount.php | 10 +- app/Support/Form/AccountForm.php | 242 ++++++++++++------------------- app/Support/Form/FormSupport.php | 28 ++++ app/Support/Steam.php | 16 +- 4 files changed, 126 insertions(+), 170 deletions(-) diff --git a/app/Support/Amount.php b/app/Support/Amount.php index fa8d176d2c..65cffb7b10 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Support; use Crypt; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\User; use Illuminate\Contracts\Encryption\DecryptException; @@ -269,8 +268,6 @@ class Amount /** * @return \FireflyIII\Models\TransactionCurrency - * - * @throws \FireflyIII\Exceptions\FireflyException */ public function getDefaultCurrency(): TransactionCurrency { @@ -287,8 +284,6 @@ class Amount * @param User $user * * @return \FireflyIII\Models\TransactionCurrency - * - * @throws \FireflyIII\Exceptions\FireflyException */ public function getDefaultCurrencyByUser(User $user): TransactionCurrency { @@ -309,12 +304,13 @@ class Amount // could still be json encoded: if (strlen($currencyCode) > 3) { - $currencyCode = json_decode($currencyCode) ?? 'EUR'; + $currencyCode = json_decode($currencyCode, true) ?? 'EUR'; } $currency = TransactionCurrency::where('code', $currencyCode)->first(); if (null === $currency) { - throw new FireflyException(sprintf('No currency found with code "%s"', $currencyCode)); + // get EUR + $currency = TransactionCurrency::where('code', 'EUR')->first(); } $cache->store($currency); diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.php index c94d150dbc..b32a19105a 100644 --- a/app/Support/Form/AccountForm.php +++ b/app/Support/Form/AccountForm.php @@ -22,11 +22,8 @@ namespace FireflyIII\Support\Form; -use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; -use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use Log; use Throwable; @@ -43,88 +40,75 @@ class AccountForm use FormSupport; /** - * TODO describe. + * Shows a