This commit is contained in:
James Cole
2025-09-13 07:13:30 +02:00
parent deae94b658
commit f13e0991fb
4 changed files with 14 additions and 13 deletions

View File

@@ -598,16 +598,16 @@ trait MetaCollection
$foundTagCount = 0; $foundTagCount = 0;
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
$transactionTagCount = count($transaction['tags']); $transactionTagCount = count($transaction['tags']);
app('log')->debug(sprintf('Transaction #%d has %d tag(s)', $transaction['transaction_journal_id'], $transactionTagCount)); Log::debug(sprintf('Transaction #%d has %d tag(s)', $transaction['transaction_journal_id'], $transactionTagCount));
if ($transactionTagCount < $expectedTagCount) { if ($transactionTagCount < $expectedTagCount) {
app('log')->debug(sprintf('Transaction has %d tag(s), we expect %d tag(s), return false.', $transactionTagCount, $expectedTagCount)); Log::debug(sprintf('Transaction has %d tag(s), we expect %d tag(s), return false.', $transactionTagCount, $expectedTagCount));
return false; return false;
} }
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower((string) $tag['name']), $list, true)) { if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name'])); Log::debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
++$foundTagCount; ++$foundTagCount;
$journalId = $transaction['transaction_journal_id']; $journalId = $transaction['transaction_journal_id'];
// #8377 prevent adding a transaction twice when multiple tag searches find this transaction // #8377 prevent adding a transaction twice when multiple tag searches find this transaction
@@ -776,6 +776,9 @@ trait MetaCollection
$this->withTagInformation(); $this->withTagInformation();
$this->query->whereNotNull('tag_transaction_journal.tag_id'); $this->query->whereNotNull('tag_transaction_journal.tag_id');
// Added this while fixing #10898, not sure why a post filter was ever necessary.
$this->query->whereIn('tag_transaction_journal.tag_id', $tags->pluck('id')->toArray());
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list); $list = array_map('strtolower', $list);
@@ -785,13 +788,13 @@ trait MetaCollection
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower((string) $tag['name']), $list, true)) { if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name'])); Log::debug(sprintf('Transaction has tag "%s" so return true.', $tag['name']));
return true; return true;
} }
} }
} }
app('log')->debug('Transaction has no tags from the list, so return false.'); Log::debug('Transaction has no tags from the list, so return false.');
return false; return false;
}; };
@@ -813,11 +816,11 @@ trait MetaCollection
$filter = static function (array $object) use ($list): bool { $filter = static function (array $object) use ($list): bool {
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags']))); Log::debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower((string) $tag['name']), $list, true)) { if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name'])); Log::debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name']));
return false; return false;
} }

View File

@@ -631,7 +631,7 @@ class GroupCollector implements GroupCollectorInterface
} }
// also merge attachments: // also merge attachments:
if (array_key_exists('attachment_id', $result)) { if (array_key_exists('attachment_id', $result) && null !== $result['attachment_id']) {
$uploaded = 1 === (int)$result['attachment_uploaded']; $uploaded = 1 === (int)$result['attachment_uploaded'];
$attachmentId = (int)$augumentedJournal['attachment_id']; $attachmentId = (int)$augumentedJournal['attachment_id'];
if (0 !== $attachmentId && $uploaded) { if (0 !== $attachmentId && $uploaded) {
@@ -659,7 +659,7 @@ class GroupCollector implements GroupCollectorInterface
private function convertToInteger(array $array): array private function convertToInteger(array $array): array
{ {
foreach ($this->integerFields as $field) { foreach ($this->integerFields as $field) {
$array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null; $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (int)$array[$field] : null;
} }
return $array; return $array;

View File

@@ -250,10 +250,7 @@ class TagController extends Controller
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation() $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()->setTag($tag)->withBudgetInformation()->withCategoryInformation()->withAttachmentInformation();
->setTag($tag)->withBudgetInformation()->withCategoryInformation()
->withAttachmentInformation()
;
$groups = $collector->getPaginatedGroups(); $groups = $collector->getPaginatedGroups();
$groups->setPath($path); $groups->setPath($path);
$sums = $this->repository->sumsOfTag($tag, $start, $end); $sums = $this->repository->sumsOfTag($tag, $start, $end);

View File

@@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [Discussion 10883](https://github.com/orgs/firefly-iii/discussions/10883) (Initial balance for account is missing from exported CSV) started by @ajaskiewiczpl - [Discussion 10883](https://github.com/orgs/firefly-iii/discussions/10883) (Initial balance for account is missing from exported CSV) started by @ajaskiewiczpl
- #10888 - #10888
- #10891 - #10891
- #10898
### API ### API