mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This commit is contained in:
parent
e435ff8b1c
commit
a45a050e7d
@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
trait CollectorProperties
|
trait CollectorProperties
|
||||||
{
|
{
|
||||||
public const TEST = 'Test';
|
public const TEST = 'Test';
|
||||||
|
private bool $expandGroupSearch;
|
||||||
private array $fields;
|
private array $fields;
|
||||||
private bool $hasAccountInfo;
|
private bool $hasAccountInfo;
|
||||||
private bool $hasBillInformation;
|
private bool $hasBillInformation;
|
||||||
|
@ -76,6 +76,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
$this->hasNotesInformation = false;
|
$this->hasNotesInformation = false;
|
||||||
$this->hasJoinedTagTables = false;
|
$this->hasJoinedTagTables = false;
|
||||||
$this->hasJoinedAttTables = false;
|
$this->hasJoinedAttTables = false;
|
||||||
|
$this->expandGroupSearch = false;
|
||||||
$this->hasJoinedMetaTables = false;
|
$this->hasJoinedMetaTables = false;
|
||||||
$this->integerFields = [
|
$this->integerFields = [
|
||||||
'transaction_group_id',
|
'transaction_group_id',
|
||||||
@ -454,6 +455,14 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getExpandGroupSearch(): bool
|
||||||
|
{
|
||||||
|
return $this->expandGroupSearch;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the transaction journals without group information. Is useful in some instances.
|
* Return the transaction journals without group information. Is useful in some instances.
|
||||||
*
|
*
|
||||||
@ -480,10 +489,16 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
* Return the groups.
|
* Return the groups.
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
*/
|
||||||
public function getGroups(): Collection
|
public function getGroups(): Collection
|
||||||
{
|
{
|
||||||
|
if ($this->expandGroupSearch) {
|
||||||
|
// get group ID's for the query:
|
||||||
|
$groupIds = $this->getCollectedGroupIds();
|
||||||
|
// add to query:
|
||||||
|
$this->query->orWhereIn('transaction_journals.transaction_group_id', $groupIds);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->query->get($this->fields);
|
$result = $this->query->get($this->fields);
|
||||||
|
|
||||||
// now to parse this into an array.
|
// now to parse this into an array.
|
||||||
@ -505,6 +520,14 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getCollectedGroupIds(): array
|
||||||
|
{
|
||||||
|
return $this->query->get(['transaction_journals.transaction_group_id'])->pluck('transaction_group_id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $collection
|
* @param Collection $collection
|
||||||
*
|
*
|
||||||
@ -516,7 +539,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
$groups = [];
|
$groups = [];
|
||||||
/** @var TransactionJournal $augumentedJournal */
|
/** @var TransactionJournal $augumentedJournal */
|
||||||
foreach ($collection as $augumentedJournal) {
|
foreach ($collection as $augumentedJournal) {
|
||||||
$groupId = $augumentedJournal->transaction_group_id;
|
$groupId = (int)$augumentedJournal->transaction_group_id;
|
||||||
|
|
||||||
if (!array_key_exists($groupId, $groups)) {
|
if (!array_key_exists($groupId, $groups)) {
|
||||||
// make new array
|
// make new array
|
||||||
@ -871,6 +894,14 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $expandGroupSearch
|
||||||
|
*/
|
||||||
|
public function setExpandGroupSearch(bool $expandGroupSearch): void
|
||||||
|
{
|
||||||
|
$this->expandGroupSearch = $expandGroupSearch;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
@ -583,6 +583,11 @@ interface GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function foreignAmountMore(string $amount): GroupCollectorInterface;
|
public function foreignAmountMore(string $amount): GroupCollectorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getExpandGroupSearch(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the transaction journals without group information. Is useful in some instances.
|
* Return the transaction journals without group information. Is useful in some instances.
|
||||||
*
|
*
|
||||||
@ -1072,6 +1077,11 @@ interface GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $expandGroupSearch
|
||||||
|
*/
|
||||||
|
public function setExpandGroupSearch(bool $expandGroupSearch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for specific external ID's.
|
* Look for specific external ID's.
|
||||||
*
|
*
|
||||||
@ -1502,4 +1512,6 @@ interface GroupCollectorInterface
|
|||||||
* @return GroupCollectorInterface
|
* @return GroupCollectorInterface
|
||||||
*/
|
*/
|
||||||
public function yearIsNot(string $year): GroupCollectorInterface;
|
public function yearIsNot(string $year): GroupCollectorInterface;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,12 @@ class ShowController extends Controller
|
|||||||
->setLimit($pageSize)
|
->setLimit($pageSize)
|
||||||
->setPage($page)->withAccountInformation()->withCategoryInformation()
|
->setPage($page)->withAccountInformation()->withCategoryInformation()
|
||||||
->setRange($start, $end);
|
->setRange($start, $end);
|
||||||
|
|
||||||
|
// this search will not include transaction groups where this asset account (or liability)
|
||||||
|
// is just part of ONE of the journals. To force this:
|
||||||
|
$collector->setExpandGroupSearch(true);
|
||||||
|
|
||||||
|
|
||||||
$groups = $collector->getPaginatedGroups();
|
$groups = $collector->getPaginatedGroups();
|
||||||
|
|
||||||
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||||
|
Loading…
Reference in New Issue
Block a user