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