mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix some sums.
This commit is contained in:
@@ -155,7 +155,6 @@ class TagController extends Controller
|
||||
*/
|
||||
public function accounts(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
||||
{
|
||||
$tagIds = $tags->pluck('id')->toArray();
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, $tags);
|
||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts, $tags);
|
||||
$report = [];
|
||||
@@ -185,9 +184,6 @@ class TagController extends Controller
|
||||
'total_sum' => '0',
|
||||
];
|
||||
foreach ($currency['tags'] as $tag) {
|
||||
if(!array_key_exists($tag['id'], $tagIds)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$sourceAccountId = $journal['source_account_id'];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId] ??= [
|
||||
@@ -226,9 +222,6 @@ class TagController extends Controller
|
||||
'total_sum' => '0',
|
||||
];
|
||||
foreach ($currency['tags'] as $tag) {
|
||||
if(!array_key_exists($tag['id'], $tagIds)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$destinationAccountId = $journal['destination_account_id'];
|
||||
$report[$destinationAccountId]['currencies'][$currencyId] ??= [
|
||||
|
@@ -48,14 +48,17 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$tagIds = [];
|
||||
if (null !== $accounts && $accounts->count() > 0) {
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
if (null !== $tags && $tags->count() > 0) {
|
||||
$collector->setTags($tags);
|
||||
$tagIds = $tags->pluck('id')->toArray();
|
||||
}
|
||||
if (null === $tags || 0 === $tags->count()) {
|
||||
$collector->setTags($this->getTags());
|
||||
$tagIds = $this->getTags()->pluck('id')->toArray();
|
||||
}
|
||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
||||
$journals = $collector->getExtractedJournals();
|
||||
@@ -77,7 +80,11 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
$tagId = (int)$tag['id'];
|
||||
$tagName = (string)$tag['name'];
|
||||
$journalId = (int)$journal['transaction_journal_id'];
|
||||
if(!in_array($tagId, $tagIds, true)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO not sure what this check does.
|
||||
if (in_array($journalId, $listedJournals, true)) {
|
||||
continue;
|
||||
}
|
||||
@@ -123,14 +130,17 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT]);
|
||||
$tagIds = [];
|
||||
if (null !== $accounts && $accounts->count() > 0) {
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
if (null !== $tags && $tags->count() > 0) {
|
||||
$collector->setTags($tags);
|
||||
$tagIds = $tags->pluck('id')->toArray();
|
||||
}
|
||||
if (null === $tags || 0 === $tags->count()) {
|
||||
$collector->setTags($this->getTags());
|
||||
$tagIds = $this->getTags()->pluck('id')->toArray();
|
||||
}
|
||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation()->withTagInformation();
|
||||
$journals = $collector->getExtractedJournals();
|
||||
@@ -150,6 +160,9 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
// may have multiple tags:
|
||||
foreach ($journal['tags'] as $tag) {
|
||||
if(!in_array($tagId, $tagIds, true)){
|
||||
continue;
|
||||
}
|
||||
$tagId = (int)$tag['id'];
|
||||
$tagName = (string)$tag['name'];
|
||||
$journalId = (int)$journal['transaction_journal_id'];
|
||||
@@ -204,6 +217,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
private function getTags(): Collection
|
||||
{
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
|
||||
return $repository->get();
|
||||
|
Reference in New Issue
Block a user