Bug 499255 - Ledger appears blank (no transactions)
Summary: Ledger appears blank (no transactions)
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: git (master)
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-28 20:29 UTC by Alexandre
Modified: 2025-01-30 16:43 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.2
Sentry Crash Report:


Attachments
kmymoney file (962 bytes, application/x-kmymoney)
2025-01-28 20:29 UTC, Alexandre
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre 2025-01-28 20:29:52 UTC
Created attachment 177778 [details]
kmymoney file

SUMMARY
Ledger appear blank (no transactions). I bisected it to this commit  cbcaed2493329507191b24fb7c8d0fa3a36eed92.

From cbcaed2493329507191b24fb7c8d0fa3a36eed92 Mon Sep 17 00:00:00 2001
From: Thomas Baumgart <thb@net-bembel.de>
Date: Sat, 18 Jan 2025 11:22:06 +0100
Subject: [PATCH 1/1] Fix tag filtering in tags view

The transaction tab in the tags view did not show transactions that
referenced more than one tag. Only those that had a single tag assigned
were shown.

This change fixes the problem by interpreting the returned data from the
journal model properly as list of ids and checks each single one for a
match.
---
 kmymoney/models/ledgerfilterbase.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kmymoney/models/ledgerfilterbase.cpp b/kmymoney/models/ledgerfilterbase.cpp
index eabf7913c..fc69ffeb0 100644
--- a/kmymoney/models/ledgerfilterbase.cpp
+++ b/kmymoney/models/ledgerfilterbase.cpp
@@ -181,8 +181,17 @@ bool LedgerFilterBase::filterAcceptsRow(int source_row, const QModelIndex& sourc
     }
 
     if (LedgerSortProxyModel::filterAcceptsRow(source_row, source_parent)) {
-        const auto id = idx.data(filterRole()).toString();
-        bool rc = d->filterIds.contains(id);
+        const QVariant dataItem = idx.data(filterRole());
+        bool rc = false;
+        if (dataItem.canConvert<QVariantList>()) {
+            QSequentialIterable vList = dataItem.value<QSequentialIterable>();
+            for (const auto& v : vList) {
+                rc |= d->filterIds.contains(v.toString());
+            }
+        } else {
+            const auto id = idx.data(filterRole()).toString();
+            rc = d->filterIds.contains(id);
+        }
 
         // in case a journal entry has no id, it is the new transaction placeholder
         if (!rc) {
-- 
2.48.1

STEPS TO REPRODUCE
1. Use the attached test.kmy  (created with a single account and two transactions)
2. Go to ledgers->select account test
3. 

OBSERVED RESULT
Ledger appears blank

EXPECTED RESULT
Two transactions being printed

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
KMyMoney: 5.1.90-13115d9f4
Alkimia: 8.1.92(I18N_ARGUMENT_MISSING) (build against 8.1.92(I18N_ARGUMENT_MISSING))
Gpgme: Unknown(I18N_ARGUMENT_MISSING) (build against 1.24.1(I18N_ARGUMENT_MISSING))
KDiagram: Unknown(I18N_ARGUMENT_MISSING) (build against (I18N_ARGUMENT_MISSING))
libofx: Unknown(I18N_ARGUMENT_MISSING) (build against 0.10.9(I18N_ARGUMENT_MISSING))
KDE Frameworks: 6.10.0
Qt: Using 6.8.1 and built against 6.8.1
Gentoo Linux (Wayland)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.13.0-gentoo-archlinux

ADDITIONAL INFORMATION
Comment 1 Alexandre 2025-01-28 20:32:01 UTC
Reverting the references commit fixes the error.
Comment 2 Thomas Baumgart 2025-01-29 17:06:53 UTC
I am unable to duplicate the problem :( Both transactions show up just fine here (latest master). Are you building against Qt5 or Qt6?
Comment 3 Alexandre 2025-01-29 18:06:56 UTC
Against qt6
Comment 4 Alexandre 2025-01-30 00:22:14 UTC
A little additional debugging. Running with this debug added:
        const QVariant dataItem = idx.data(filterRole());
        bool rc = false;
        if (dataItem.canConvert<QVariantList>()) {
            QSequentialIterable vList = dataItem.value<QSequentialIterable>();
            for (const auto& v : vList) {
                qDebug() << "Processing filterRole " << v.toString();
                rc |= d->filterIds.contains(v.toString());
                qDebug() << "Result filterRole " << rc;
            }
        } else {
            const auto id = idx.data(filterRole()).toString();
            qDebug() << "Processing filterRole " << id;
            rc = d->filterIds.contains(id);
            qDebug() << "Result filterRole " << rc;
        }

Produces:
-----------------------------------------------
Processing filterRole  "A"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "1"
Result filterRole  false
Processing filterRole  "A"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "1"
Result filterRole  false
Processing filterRole  ""
Result filterRole  false
Processing filterRole  ""
Result filterRole  false
Processing filterRole  "A"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "1"
Result filterRole  false
Processing filterRole  "A"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "0"
Result filterRole  false
Processing filterRole  "1"
Result filterRole  false
----------------------------------------------

commenting the lines and running again:
       const QVariant dataItem = idx.data(filterRole());
        bool rc = false;
        //if (dataItem.canConvert<QVariantList>()) {
        //    QSequentialIterable vList = dataItem.value<QSequentialIterable>();
        //    for (const auto& v : vList) {
        //      qDebug() << "Processing filterRole " << v.toString();
        //        rc |= d->filterIds.contains(v.toString());
        //      qDebug() << "Result filterRole " << rc;
        //    }
        //} else {
            const auto id = idx.data(filterRole()).toString();
            qDebug() << "Processing filterRole " << id;
            rc = d->filterIds.contains(id);
            qDebug() << "Result filterRole " << rc;
        //}
Produces:
-----------------------------------------------
Processing filterRole  "A000001"
Result filterRole  true
Processing filterRole  "A000001"
Result filterRole  true
Processing filterRole  ""
Result filterRole  false
Processing filterRole  "A000001"
Result filterRole  true
Processing filterRole  "A000001"
Result filterRole  true
Processing filterRole  ""
Result filterRole  false
----------------------------------------------
Comment 5 Thomas Baumgart 2025-01-30 15:43:31 UTC
Seems that the problem is the apparently different behavior of QVariant::canConvert<QVariantList>() when used on a QVariant created from a QString between Qt5 (results in false) and Qt6 (results in true).
Comment 6 Thomas Baumgart 2025-01-30 16:43:42 UTC
Git commit d9db245c0e7125d9236421af5159b926376dad67 by Thomas Baumgart.
Committed on 30/01/2025 at 16:43.
Pushed by tbaumgart into branch 'master'.

Resolve different behavior of Qt5 vs Qt6 with QVariant
FIXED-IN: 5.2

M  +3    -9    kmymoney/models/ledgerfilterbase.cpp

https://invent.kde.org/office/kmymoney/-/commit/d9db245c0e7125d9236421af5159b926376dad67