Skip to content

Firefly III: a personal finances manager

Fix a variety of code.

James Coleeb6d585bb2d6
diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php
index 52ec2d19eb..fbb28afd1d 100644
--- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php
@@ -53,21 +53,21 @@ use Override;
*/
class AccountEnrichment implements EnrichmentInterface
{
- private array $ids;
- private array $accountTypeIds;
- private array $accountTypes;
+ private array $ids = [];
+ private array $accountTypeIds = [];
+ private array $accountTypes = [];
private Collection $collection;
- private array $currencies;
- private array $locations;
- private array $meta;
+ private array $currencies = [];
+ private array $locations = [];
+ private array $meta = [];
private TransactionCurrency $primaryCurrency;
- private array $notes;
- private array $openingBalances;
+ private array $notes = [];
+ private array $openingBalances = [];
private User $user;
private UserGroup $userGroup;
- private array $lastActivities;
+ private array $lastActivities = [];
private ?Carbon $date = null;
- private bool $convertToPrimary = false;
+ private bool $convertToPrimary;
private array $balances = [];
private array $objectGroups = [];
private array $mappedObjects = [];
@@ -77,15 +77,6 @@ class AccountEnrichment implements EnrichmentInterface
*/
public function __construct()
{
- $this->ids = [];
- $this->openingBalances = [];
- $this->currencies = [];
- $this->accountTypeIds = [];
- $this->accountTypes = [];
- $this->meta = [];
- $this->notes = [];
- $this->lastActivities = [];
- $this->locations = [];
$this->primaryCurrency = Amount::getPrimaryCurrency();
$this->convertToPrimary = Amount::convertToPrimary();
}
diff --git a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php
index 53b2881659..395b2d857b 100644
--- a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php
@@ -43,7 +43,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
private User $user;
private UserGroup $userGroup;
private TransactionCurrency $primaryCurrency;
- private bool $convertToPrimary = false;
+ private bool $convertToPrimary;
private array $ids = [];
private array $currencyIds = [];
private array $currencies = [];
@@ -157,7 +157,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
$currency = $this->currencies[$currencyId];
$meta = [
'currency' => $currency,
- 'spent_in_budgets' => $this->spentInsideBudgets[$id] ?? [],
+ 'spent_in_budgets' => $this->spentInBudgets[$id] ?? [],
'pc_spent_in_budgets' => $this->pcSpentInBudgets[$id] ?? [],
'spent_outside_budgets' => $this->spentOutsideBudgets[$id] ?? [],
'pc_spent_outside_budgets' => $this->pcSpentOutsideBudgets[$id] ?? [],
diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php
index d5fbf15348..e2dc09e041 100644
--- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php
@@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Log;
class BudgetEnrichment implements EnrichmentInterface
{
private Collection $collection;
- private bool $convertToPrimary = true;
+ private bool $convertToPrimary;
private TransactionCurrency $primaryCurrency;
private User $user;
private UserGroup $userGroup;
diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php
index 0e41e3ce37..273acb1a4f 100644
--- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php
@@ -29,7 +29,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
private array $currencyIds = [];
private array $currencies = [];
private array $accountIds = [];
- private array $accountCurrencies = [];
+ //private array $accountCurrencies = [];
private array $notes = [];
private array $mappedObjects = [];
private TransactionCurrency $primaryCurrency;
@@ -121,7 +121,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
if (!array_key_exists($currencyId, $this->currencies)) {
$this->currencies[$currencyId] = TransactionCurrency::find($currencyId);
}
- $this->accountCurrencies[$accountId] = $this->currencies[$currencyId];
+ //$this->accountCurrencies[$accountId] = $this->currencies[$currencyId];
}
// get account info.
diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php
index f6adc6075b..76ea5318f4 100644
--- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php
@@ -25,7 +25,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
private array $journalIds = [];
private array $groupIds = [];
private array $accountIds = [];
- private array $piggybankIds = [];
+ private array $piggyBankIds = [];
private array $accountCurrencies = [];
private array $currencies = [];
// private bool $convertToPrimary = false;
@@ -72,7 +72,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
foreach ($this->collection as $event) {
$this->ids[] = (int)$event->id;
$this->journalIds[(int)$event->id] = (int)$event->transaction_journal_id;
- $this->piggybankIds[(int)$event->id] = (int)$event->piggy_bank_id;
+ $this->piggyBankIds[(int)$event->id] = (int)$event->piggy_bank_id;
}
$this->ids = array_unique($this->ids);
// collect groups with journal info.
@@ -84,7 +84,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
}
// collect account info.
- $set = DB::table('account_piggy_bank')->whereIn('piggy_bank_id', $this->piggybankIds)->get(['piggy_bank_id', 'account_id']);
+ $set = DB::table('account_piggy_bank')->whereIn('piggy_bank_id', $this->piggyBankIds)->get(['piggy_bank_id', 'account_id']);
foreach ($set as $item) {
$id = (int)$item->piggy_bank_id;
if (!array_key_exists($id, $this->accountIds)) {
@@ -93,7 +93,6 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
}
// get account currency preference for ALL.
- // TODO This method does a find in a loop.
$set = AccountMeta::whereIn('account_id', array_values($this->accountIds))->where('name', 'currency_id')->get();
/** @var AccountMeta $item */
diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
index 4df4e7a66b..5046e59e54 100644
--- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
@@ -27,7 +27,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
private User $user;
private UserGroup $userGroup;
private Collection $collection;
- private bool $convertToPrimary = false;
+ private bool $convertToPrimary;
private ?Carbon $start = null;
private ?Carbon $end = null;
private array $subscriptionIds = [];
diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php
index 44a05d212d..ab776d94ce 100644
--- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php
@@ -45,26 +45,20 @@ use Override;
class TransactionGroupEnrichment implements EnrichmentInterface
{
- private array $attachmentCount;
+ private array $attachmentCount = [];
private Collection $collection;
private readonly array $dateFields;
- private array $journalIds;
- private array $locations;
- private array $metaData; // @phpstan-ignore-line
- private array $notes; // @phpstan-ignore-line
- private array $tags;
+ private array $journalIds = [];
+ private array $locations = [];
+ private array $metaData = [];
+ private array $notes = [];
+ private array $tags = [];
private User $user;
private readonly TransactionCurrency $primaryCurrency;
private UserGroup $userGroup;
public function __construct()
{
- $this->notes = [];
- $this->journalIds = [];
- $this->tags = [];
- $this->metaData = [];
- $this->locations = [];
- $this->attachmentCount = [];
$this->dateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
$this->primaryCurrency = Amount::getPrimaryCurrency();
}