mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Fix a variety of code.
This commit is contained in:
@@ -53,21 +53,21 @@ use Override;
|
|||||||
*/
|
*/
|
||||||
class AccountEnrichment implements EnrichmentInterface
|
class AccountEnrichment implements EnrichmentInterface
|
||||||
{
|
{
|
||||||
private array $ids;
|
private array $ids = [];
|
||||||
private array $accountTypeIds;
|
private array $accountTypeIds = [];
|
||||||
private array $accountTypes;
|
private array $accountTypes = [];
|
||||||
private Collection $collection;
|
private Collection $collection;
|
||||||
private array $currencies;
|
private array $currencies = [];
|
||||||
private array $locations;
|
private array $locations = [];
|
||||||
private array $meta;
|
private array $meta = [];
|
||||||
private TransactionCurrency $primaryCurrency;
|
private TransactionCurrency $primaryCurrency;
|
||||||
private array $notes;
|
private array $notes = [];
|
||||||
private array $openingBalances;
|
private array $openingBalances = [];
|
||||||
private User $user;
|
private User $user;
|
||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
private array $lastActivities;
|
private array $lastActivities = [];
|
||||||
private ?Carbon $date = null;
|
private ?Carbon $date = null;
|
||||||
private bool $convertToPrimary = false;
|
private bool $convertToPrimary;
|
||||||
private array $balances = [];
|
private array $balances = [];
|
||||||
private array $objectGroups = [];
|
private array $objectGroups = [];
|
||||||
private array $mappedObjects = [];
|
private array $mappedObjects = [];
|
||||||
@@ -77,15 +77,6 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
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->primaryCurrency = Amount::getPrimaryCurrency();
|
||||||
$this->convertToPrimary = Amount::convertToPrimary();
|
$this->convertToPrimary = Amount::convertToPrimary();
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
private User $user;
|
private User $user;
|
||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
private TransactionCurrency $primaryCurrency;
|
private TransactionCurrency $primaryCurrency;
|
||||||
private bool $convertToPrimary = false;
|
private bool $convertToPrimary;
|
||||||
private array $ids = [];
|
private array $ids = [];
|
||||||
private array $currencyIds = [];
|
private array $currencyIds = [];
|
||||||
private array $currencies = [];
|
private array $currencies = [];
|
||||||
@@ -157,7 +157,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
$currency = $this->currencies[$currencyId];
|
$currency = $this->currencies[$currencyId];
|
||||||
$meta = [
|
$meta = [
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'spent_in_budgets' => $this->spentInsideBudgets[$id] ?? [],
|
'spent_in_budgets' => $this->spentInBudgets[$id] ?? [],
|
||||||
'pc_spent_in_budgets' => $this->pcSpentInBudgets[$id] ?? [],
|
'pc_spent_in_budgets' => $this->pcSpentInBudgets[$id] ?? [],
|
||||||
'spent_outside_budgets' => $this->spentOutsideBudgets[$id] ?? [],
|
'spent_outside_budgets' => $this->spentOutsideBudgets[$id] ?? [],
|
||||||
'pc_spent_outside_budgets' => $this->pcSpentOutsideBudgets[$id] ?? [],
|
'pc_spent_outside_budgets' => $this->pcSpentOutsideBudgets[$id] ?? [],
|
||||||
|
@@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
class BudgetEnrichment implements EnrichmentInterface
|
class BudgetEnrichment implements EnrichmentInterface
|
||||||
{
|
{
|
||||||
private Collection $collection;
|
private Collection $collection;
|
||||||
private bool $convertToPrimary = true;
|
private bool $convertToPrimary;
|
||||||
private TransactionCurrency $primaryCurrency;
|
private TransactionCurrency $primaryCurrency;
|
||||||
private User $user;
|
private User $user;
|
||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
|
@@ -29,7 +29,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
|||||||
private array $currencyIds = [];
|
private array $currencyIds = [];
|
||||||
private array $currencies = [];
|
private array $currencies = [];
|
||||||
private array $accountIds = [];
|
private array $accountIds = [];
|
||||||
private array $accountCurrencies = [];
|
//private array $accountCurrencies = [];
|
||||||
private array $notes = [];
|
private array $notes = [];
|
||||||
private array $mappedObjects = [];
|
private array $mappedObjects = [];
|
||||||
private TransactionCurrency $primaryCurrency;
|
private TransactionCurrency $primaryCurrency;
|
||||||
@@ -121,7 +121,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
|||||||
if (!array_key_exists($currencyId, $this->currencies)) {
|
if (!array_key_exists($currencyId, $this->currencies)) {
|
||||||
$this->currencies[$currencyId] = TransactionCurrency::find($currencyId);
|
$this->currencies[$currencyId] = TransactionCurrency::find($currencyId);
|
||||||
}
|
}
|
||||||
$this->accountCurrencies[$accountId] = $this->currencies[$currencyId];
|
//$this->accountCurrencies[$accountId] = $this->currencies[$currencyId];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get account info.
|
// get account info.
|
||||||
|
@@ -25,7 +25,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
|||||||
private array $journalIds = [];
|
private array $journalIds = [];
|
||||||
private array $groupIds = [];
|
private array $groupIds = [];
|
||||||
private array $accountIds = [];
|
private array $accountIds = [];
|
||||||
private array $piggybankIds = [];
|
private array $piggyBankIds = [];
|
||||||
private array $accountCurrencies = [];
|
private array $accountCurrencies = [];
|
||||||
private array $currencies = [];
|
private array $currencies = [];
|
||||||
// private bool $convertToPrimary = false;
|
// private bool $convertToPrimary = false;
|
||||||
@@ -72,7 +72,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
|||||||
foreach ($this->collection as $event) {
|
foreach ($this->collection as $event) {
|
||||||
$this->ids[] = (int)$event->id;
|
$this->ids[] = (int)$event->id;
|
||||||
$this->journalIds[(int)$event->id] = (int)$event->transaction_journal_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);
|
$this->ids = array_unique($this->ids);
|
||||||
// collect groups with journal info.
|
// collect groups with journal info.
|
||||||
@@ -84,7 +84,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// collect account info.
|
// 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) {
|
foreach ($set as $item) {
|
||||||
$id = (int)$item->piggy_bank_id;
|
$id = (int)$item->piggy_bank_id;
|
||||||
if (!array_key_exists($id, $this->accountIds)) {
|
if (!array_key_exists($id, $this->accountIds)) {
|
||||||
@@ -93,7 +93,6 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get account currency preference for ALL.
|
// 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();
|
$set = AccountMeta::whereIn('account_id', array_values($this->accountIds))->where('name', 'currency_id')->get();
|
||||||
|
|
||||||
/** @var AccountMeta $item */
|
/** @var AccountMeta $item */
|
||||||
|
@@ -27,7 +27,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
|||||||
private User $user;
|
private User $user;
|
||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
private Collection $collection;
|
private Collection $collection;
|
||||||
private bool $convertToPrimary = false;
|
private bool $convertToPrimary;
|
||||||
private ?Carbon $start = null;
|
private ?Carbon $start = null;
|
||||||
private ?Carbon $end = null;
|
private ?Carbon $end = null;
|
||||||
private array $subscriptionIds = [];
|
private array $subscriptionIds = [];
|
||||||
|
@@ -45,26 +45,20 @@ use Override;
|
|||||||
|
|
||||||
class TransactionGroupEnrichment implements EnrichmentInterface
|
class TransactionGroupEnrichment implements EnrichmentInterface
|
||||||
{
|
{
|
||||||
private array $attachmentCount;
|
private array $attachmentCount = [];
|
||||||
private Collection $collection;
|
private Collection $collection;
|
||||||
private readonly array $dateFields;
|
private readonly array $dateFields;
|
||||||
private array $journalIds;
|
private array $journalIds = [];
|
||||||
private array $locations;
|
private array $locations = [];
|
||||||
private array $metaData; // @phpstan-ignore-line
|
private array $metaData = [];
|
||||||
private array $notes; // @phpstan-ignore-line
|
private array $notes = [];
|
||||||
private array $tags;
|
private array $tags = [];
|
||||||
private User $user;
|
private User $user;
|
||||||
private readonly TransactionCurrency $primaryCurrency;
|
private readonly TransactionCurrency $primaryCurrency;
|
||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
|
|
||||||
public function __construct()
|
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->dateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
|
||||||
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user