Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove unnecessary setters.
James Cole061c01da5330
diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex cff344abea..e838b87e7f 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -97,7 +97,6 @@ class ShowController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$accounts = $enrichment->enrich($accounts);// make paginator:@@ -132,7 +131,6 @@ class ShowController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$account = $enrichment->enrichSingle($account);diff --git a/app/Api/V1/Controllers/Models/Account/StoreController.php b/app/Api/V1/Controllers/Models/Account/StoreController.phpindex 92b6fe3237..e72b7650ea 100644--- a/app/Api/V1/Controllers/Models/Account/StoreController.php+++ b/app/Api/V1/Controllers/Models/Account/StoreController.php@@ -76,7 +76,6 @@ class StoreController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */diff --git a/app/Api/V1/Controllers/Models/Account/UpdateController.php b/app/Api/V1/Controllers/Models/Account/UpdateController.phpindex 0a7cc4d2e4..f1653bf1e3 100644--- a/app/Api/V1/Controllers/Models/Account/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Account/UpdateController.php@@ -81,7 +81,6 @@ class UpdateController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */diff --git a/app/Api/V1/Controllers/Models/Bill/ShowController.php b/app/Api/V1/Controllers/Models/Bill/ShowController.phpindex eb47d778ac..6c767f16a6 100644--- a/app/Api/V1/Controllers/Models/Bill/ShowController.php+++ b/app/Api/V1/Controllers/Models/Bill/ShowController.php@@ -83,8 +83,6 @@ class ShowController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bills = $enrichment->enrich($bills);@@ -114,8 +112,6 @@ class ShowController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bill = $enrichment->enrichSingle($bill);diff --git a/app/Api/V1/Controllers/Models/Bill/StoreController.php b/app/Api/V1/Controllers/Models/Bill/StoreController.phpindex a461f3a23e..e0ab4b23d5 100644--- a/app/Api/V1/Controllers/Models/Bill/StoreController.php+++ b/app/Api/V1/Controllers/Models/Bill/StoreController.php@@ -79,8 +79,6 @@ class StoreController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bill = $enrichment->enrichSingle($bill);diff --git a/app/Api/V1/Controllers/Models/Bill/UpdateController.php b/app/Api/V1/Controllers/Models/Bill/UpdateController.phpindex 87d2998e5f..bca0351efe 100644--- a/app/Api/V1/Controllers/Models/Bill/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Bill/UpdateController.php@@ -74,8 +74,6 @@ class UpdateController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bill = $enrichment->enrichSingle($bill);diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.phpindex 924d43fa2b..cdda960026 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php@@ -85,8 +85,6 @@ class ListController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bills = $enrichment->enrich($bills);diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php b/app/Api/V1/Controllers/Models/PiggyBank/ListController.phpindex fc8d7068ae..da2a3d2420 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php@@ -84,7 +84,6 @@ class ListController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$accounts = $enrichment->enrich($accounts);// make paginator:diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.phpindex f158e781e1..3220893923 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php@@ -108,7 +108,6 @@ class ListController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$accounts = $enrichment->enrich($accounts);// make paginator:@@ -188,8 +187,6 @@ class ListController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$bills = $enrichment->enrichSingle($bills);diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.phpindex 6c775a4713..22f35be905 100644--- a/app/Api/V1/Controllers/Search/AccountController.php+++ b/app/Api/V1/Controllers/Search/AccountController.php@@ -89,7 +89,6 @@ class AccountController extends Controller$admin = auth()->user();$enrichment = new AccountEnrichment();$enrichment->setUser($admin);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$accounts = $enrichment->enrich($accounts);/** @var AccountTransformer $transformer */diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.phpindex 57587b7b55..d63d7930b3 100644--- a/app/Generator/Webhook/StandardMessageGenerator.php+++ b/app/Generator/Webhook/StandardMessageGenerator.php@@ -177,7 +177,6 @@ class StandardMessageGenerator implements MessageGeneratorInterface$accounts = $this->collectAccounts($model);$enrichment = new AccountEnrichment();$enrichment->setUser($model->user);- $enrichment->setPrimaryCurrency(Amount::getPrimaryCurrencyByUserGroup($model->userGroup));$accounts = $enrichment->enrich($accounts);foreach ($accounts as $account) {$transformer = new AccountTransformer();diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.phpindex b47886e648..73589644d5 100644--- a/app/Http/Controllers/Bill/IndexController.php+++ b/app/Http/Controllers/Bill/IndexController.php@@ -91,8 +91,6 @@ class IndexController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($tempStart);$enrichment->setEnd($end);$collection = $enrichment->enrich($collection);diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.phpindex b1982bab94..554ecf3a73 100644--- a/app/Http/Controllers/Bill/ShowController.php+++ b/app/Http/Controllers/Bill/ShowController.php@@ -149,8 +149,6 @@ class ShowController extends Controller$admin = auth()->user();$enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);- $enrichment->setConvertToPrimary($this->convertToPrimary);- $enrichment->setPrimaryCurrency($this->primaryCurrency);$enrichment->setStart($start);$enrichment->setEnd($end);$bill = $enrichment->enrichSingle($bill);diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex 73ca74f147..283b2aca7d 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -148,7 +148,6 @@ class IndexController extends Controller// enrich each account.$enrichment = new AccountEnrichment();$enrichment->setUser(auth()->user());- $enrichment->setPrimaryCurrency($this->primaryCurrency);$return = [];/** @var PiggyBank $piggy */diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.phpindex 9336a11791..fb1c5566b7 100644--- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php+++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php@@ -34,6 +34,7 @@ use FireflyIII\Models\Location;use FireflyIII\Models\Note;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Models\UserGroup;+use FireflyIII\Support\Facades\Amount;use FireflyIII\Support\Facades\Steam;use FireflyIII\User;use Illuminate\Database\Eloquent\Model;@@ -76,6 +77,7 @@ class AccountEnrichment implements EnrichmentInterface$this->notes = [];$this->lastActivities = [];$this->locations = [];+ $this->primaryCurrency = Amount::getPrimaryCurrency();// $this->repository = app(AccountRepositoryInterface::class);// $this->currencyRepository = app(CurrencyRepositoryInterface::class);// $this->start = null;@@ -281,11 +283,6 @@ class AccountEnrichment implements EnrichmentInterface});}- public function setPrimaryCurrency(TransactionCurrency $primary): void- {- $this->primaryCurrency = $primary;- }-private function collectLastActivities(): void{$this->lastActivities = Steam::getLastActivities($this->accountIds);diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.phpindex f1c9f142db..3255ba869a 100644--- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php+++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php@@ -12,6 +12,7 @@ use FireflyIII\Models\ObjectGroup;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Models\TransactionJournal;use FireflyIII\Models\UserGroup;+use FireflyIII\Support\Facades\Amount;use FireflyIII\Support\Facades\Steam;use FireflyIII\Support\Http\Api\ExchangeRateConverter;use FireflyIII\Support\Models\BillDateCalculator;@@ -38,6 +39,12 @@ class SubscriptionEnrichment implements EnrichmentInterfaceprivate TransactionCurrency $primaryCurrency;private BillDateCalculator $calculator;+ public function __construct()+ {+ $this->convertToPrimary = Amount::convertToPrimary();+ $this->primaryCurrency = Amount::getPrimaryCurrency();+ }+public function enrich(Collection $collection): Collection{Log::debug(sprintf('%s(%s item(s))', __METHOD__, $collection->count()));@@ -140,16 +147,6 @@ class SubscriptionEnrichment implements EnrichmentInterface$this->userGroup = $userGroup;}- public function setConvertToPrimary(bool $convertToPrimary): void- {- $this->convertToPrimary = $convertToPrimary;- }-- public function setPrimaryCurrency(TransactionCurrency $primaryCurrency): void- {- $this->primaryCurrency = $primaryCurrency;- }-private function collectSubscriptionIds(): void{/** @var Bill $bill */