mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 04:41:01 +00:00
Allow account grouping
This commit is contained in:
@@ -47,6 +47,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
private array $currencies;
|
||||
private TransactionCurrency $default;
|
||||
private array $lastActivity;
|
||||
private array $objectGroups;
|
||||
|
||||
/**
|
||||
* This method collects meta-data for one or all accounts in the transformer's collection.
|
||||
@@ -58,6 +59,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
$this->accountTypes = [];
|
||||
$this->fullTypes = [];
|
||||
$this->lastActivity = [];
|
||||
$this->objectGroups = [];
|
||||
$this->convertedBalances = [];
|
||||
$this->balanceDifferences = [];
|
||||
|
||||
@@ -81,6 +83,9 @@ class AccountTransformer extends AbstractTransformer
|
||||
$this->getBalanceDifference($objects, $this->parameters->get('start'), $this->parameters->get('end'));
|
||||
}
|
||||
|
||||
// get object groups"
|
||||
$this->getObjectGroups($objects);
|
||||
|
||||
return $this->sortAccounts($objects);
|
||||
}
|
||||
|
||||
@@ -127,6 +132,11 @@ class AccountTransformer extends AbstractTransformer
|
||||
$order = null;
|
||||
}
|
||||
|
||||
// object group
|
||||
$objectGroupId = $this->objectGroups[$id]['id'] ?? null;
|
||||
$objectGroupOrder = $this->objectGroups[$id]['order'] ?? null;
|
||||
$objectGroupTitle = $this->objectGroups[$id]['title'] ?? null;
|
||||
|
||||
// balance difference
|
||||
$diffStart = null;
|
||||
$diffEnd = null;
|
||||
@@ -181,6 +191,11 @@ class AccountTransformer extends AbstractTransformer
|
||||
'interest_period' => $interestPeriod,
|
||||
'current_debt' => $currentDebt,
|
||||
|
||||
// object group
|
||||
'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
|
||||
// 'notes' => $this->repository->getNoteText($account),
|
||||
// 'monthly_payment_date' => $monthlyPaymentDate,
|
||||
// 'credit_card_type' => $creditCardType,
|
||||
@@ -394,4 +409,11 @@ class AccountTransformer extends AbstractTransformer
|
||||
return $rightCurrent <=> $leftCurrent;
|
||||
});
|
||||
}
|
||||
|
||||
private function getObjectGroups(Collection $accounts): void
|
||||
{
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$this->objectGroups = $accountRepository->getObjectGroups($accounts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user