mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Auto commit for release 'branch-v6.2' on 2024-12-22
This commit is contained in:
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
@@ -37,8 +36,6 @@ use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Override;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class AccountEnrichment
|
||||
@@ -66,7 +63,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
$this->end = null;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
public function enrichSingle(Model $model): Account
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
@@ -76,7 +73,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
return $collection->first();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
/**
|
||||
* Do the actual enrichment.
|
||||
*/
|
||||
@@ -147,7 +144,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
$metaFields = $this->repository->getMetaValues($this->collection, ['is_multi_currency', 'currency_id', 'account_role', 'account_number', 'liability_direction', 'interest', 'interest_period', 'current_debt']);
|
||||
$currencyIds = $metaFields->where('name', 'currency_id')->pluck('data')->toArray();
|
||||
|
||||
$currencies = [];
|
||||
$currencies = [];
|
||||
foreach ($this->currencyRepository->getByIds($currencyIds) as $currency) {
|
||||
$id = $currency->id;
|
||||
$currencies[$id] = $currency;
|
||||
@@ -177,8 +174,8 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
$default = $this->default;
|
||||
|
||||
// get start and end, so the balance difference can be generated.
|
||||
$start = null;
|
||||
$end = null;
|
||||
$start = null;
|
||||
$end = null;
|
||||
if (null !== $this->start) {
|
||||
$start = Balance::getAccountBalances($this->collection, $this->start);
|
||||
}
|
||||
@@ -200,7 +197,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
'balance_difference' => null,
|
||||
];
|
||||
if (array_key_exists($account->id, $balances)) {
|
||||
$set = [];
|
||||
$set = [];
|
||||
foreach ($balances[$account->id] as $currencyId => $entry) {
|
||||
$left = $start[$account->id][$currencyId]['balance'] ?? null;
|
||||
$right = $end[$account->id][$currencyId]['balance'] ?? null;
|
||||
@@ -242,11 +239,12 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
private function getObjectGroups(): void
|
||||
{
|
||||
$set = DB::table('object_groupables')
|
||||
->where('object_groupable_type', Account::class)
|
||||
->whereIn('object_groupable_id', $this->collection->pluck('id')->toArray())
|
||||
->distinct()
|
||||
->get(['object_groupables.object_groupable_id', 'object_groupables.object_group_id']);
|
||||
$set = \DB::table('object_groupables')
|
||||
->where('object_groupable_type', Account::class)
|
||||
->whereIn('object_groupable_id', $this->collection->pluck('id')->toArray())
|
||||
->distinct()
|
||||
->get(['object_groupables.object_groupable_id', 'object_groupables.object_group_id'])
|
||||
;
|
||||
// get the groups:
|
||||
$groupIds = $set->pluck('object_group_id')->toArray();
|
||||
$groups = ObjectGroup::whereIn('id', $groupIds)->get();
|
||||
@@ -256,7 +254,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
$this->objectGroups[$group->id] = $group;
|
||||
}
|
||||
|
||||
/** @var stdClass $entry */
|
||||
/** @var \stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$this->grouped[(int) $entry->object_groupable_id] = (int) $entry->object_group_id;
|
||||
}
|
||||
|
Reference in New Issue
Block a user