Fix ignoring category filter in transaction by 'month reports'
Needs RevisionPublic

Authored by habacker on Jun 29 2018, 10:19 PM.

Details

Reviewers
tbaumgart
Summary

The issue was caused because there was no implementation of
MyMoneyDatabaseMgr::transactionList() returning a modified list
of splits for QueryTable::constructTransactionTable().

There is a bug in MyMoneyTransactionFilter in case a report uses
setInvestmentsOnly(true) not returning the requested splits.
To work arround this issue, the original splits are used in
QueryTable::constructTransactionTable() in this specific case.

BUG:395327
FIXED-IN:4.8.3

Test Plan

compiled and verified with test case from related bug and querytabletest

Diff Detail

Repository
R261 KMyMoney
Branch
4.8
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 537
Build 549: arc lint + arc unit
habacker requested review of this revision.Jun 29 2018, 10:19 PM
habacker created this revision.
habacker updated this revision to Diff 36936.Jun 30 2018, 9:01 AM
  • less invasive fix

Note: Unfortunally querytabletest fails without and with this fix - need to investigate what break it

habacker edited the summary of this revision. (Show Details)Jun 30 2018, 9:07 AM
habacker edited the summary of this revision. (Show Details)Jun 30 2018, 9:10 AM
tbaumgart added inline comments.Jun 30 2018, 10:02 AM
kmymoney/reports/querytable.cpp
433

Why don't you use report.setReportAllSplits(true) here as well in the other spot below and initialize it to false in the beginning but go through a temporary variable not used otherwise?

459

Can't you use

const MyMoneyTransaction& t = (*it_t).first;

here? After all, the QList does not change, or am I missing something?

habacker added inline comments.Jun 30 2018, 8:03 PM
kmymoney/reports/querytable.cpp
433

Rethined about report.setReportAllSplits(true) :

Below the implementation was

QList<MyMoneyTransaction> transactions = file->transactionList(report);
for (QList<MyMoneyTransaction>::const_iterator it_transaction = transactions.constBegin(); it_transaction != transactions.constEnd(); ++it_transaction) {  
...
const QList<MyMoneySplit>& splits = (*it_transaction).splits();

These splits are from the not filtered original transaction and are available independently from report.setReportAllSplits()

Now it is:

QList<QPair<MyMoneyTransaction, QList<MyMoneySplit> > >transactions;
 for (QList<QPair<MyMoneyTransaction, QList<MyMoneySplit> > >::const_iterator it_t = transactions.constBegin(); it_t != transactions.constEnd(); ++it_t) {
... 
QList<MyMoneySplit> splits = (*it_t).second;

These splits are filtered from the transaction, but to have all it is required to set

report.setReportAllSplits(true)

unconditional - I will update the patch

BTW: This also fixes most fails of querytabletest (except Investment transactions)

459

yes

492–493

here

const QList<MyMoneySplit> &splits = (*it_t).second;

is also possible

habacker updated this revision to Diff 36968.Jun 30 2018, 8:07 PM
habacker edited the summary of this revision. (Show Details)
habacker edited the test plan for this revision. (Show Details)
  • fix mentioned issues
habacker updated this revision to Diff 36969.Jun 30 2018, 8:11 PM
habacker marked 3 inline comments as done.
  • use const ... &
habacker marked 2 inline comments as done.Jun 30 2018, 8:11 PM
habacker updated this revision to Diff 37016.Jul 1 2018, 3:37 PM
habacker edited the summary of this revision. (Show Details)
habacker edited the test plan for this revision. (Show Details)
  • fix remaining querytabletest issue

After compiling with this patch, all tests are complete.

x@y:~/src/kmymoney-4.8-build> make test
...
100% tests passed, 0 tests failed out of 34
tbaumgart accepted this revision.Jul 6 2018, 7:46 PM

I have not tested any of this but formally it looks OK to me. Is this change also needed for 5.0?

This revision is now accepted and ready to land.Jul 6 2018, 7:46 PM

I have not tested any of this

and it looks that the current test case (querytabletest) do not see this bug

but formally it looks OK to me.

okay

Is this change also needed for 5.0?

yes, but the patch do not apply to 5.x or master.

I have not tested any of this

and it looks that the current test case (querytabletest) do not see this bug

I will look for some test cases to get a better overview

The problem with this patch is that it breaks other report types caused by the way the MyMoneyTransactionsFilter has been implemented.

tbaumgart requested changes to this revision.Dec 5 2019, 4:02 PM

Seems to be in the wrong state for 5.0. I reset it by requesting changes. if it works for 5.0 (preferably the 5.0 stable branch) we will accept it (again).

This revision now requires changes to proceed.Dec 5 2019, 4:02 PM