Commit 65461d92 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Fix 'No display of transactions in the tags view when tags are specified in a split'

Since it is currently not clear whether this change will lead
to unwanted side effects at other code locations, the new method
setConsiderCategorySplits() has been added to enable this
functionality.

BUG:412429
FIXED-IN:5.0.8
Test Plan: tested on linux with mymoneytransactionsfiltertest
Reviewed By: tbaumgart, #kmymoney
Differential Revision: https://phabricator.kde.org/D24426
parent af7f9739
......@@ -48,6 +48,7 @@ public:
MyMoneyTransactionFilterPrivate()
: m_reportAllSplits(false)
, m_considerCategory(false)
, m_considerCategorySplits(false)
, m_matchOnly(false)
, m_treatTransfersAsIncomeExpense(false)
, m_matchingSplitsCount(0)
......@@ -59,6 +60,7 @@ public:
MyMoneyTransactionFilter::FilterSet m_filterSet;
bool m_reportAllSplits;
bool m_considerCategory;
bool m_considerCategorySplits;
bool m_matchOnly;
bool m_treatTransfersAsIncomeExpense;
......@@ -267,6 +269,12 @@ void MyMoneyTransactionFilter::setReportAllSplits(const bool report)
d->m_reportAllSplits = report;
}
void MyMoneyTransactionFilter::setConsiderCategorySplits(const bool check)
{
Q_D(MyMoneyTransactionFilter);
d->m_considerCategorySplits = check;
}
void MyMoneyTransactionFilter::setConsiderCategory(const bool check)
{
Q_D(MyMoneyTransactionFilter);
......@@ -418,7 +426,8 @@ QVector<MyMoneySplit> MyMoneyTransactionFilter::matchingSplits(const MyMoneyTran
break;
}
if (!isCategory) {
bool includeSplit = d->m_considerCategorySplits || (!d->m_considerCategorySplits && !isCategory);
if (includeSplit) {
// check the payee list
if (filter.payeeFilter) {
if (!d->m_payees.isEmpty()) {
......
......@@ -293,6 +293,16 @@ public:
*/
void setReportAllSplits(const bool report = true);
/**
* Consider splits in categories
*
* With this setting, splits in categories that are not considered
* by default are taken into account.
*
* @param check check state
*/
void setConsiderCategorySplits(const bool check = true);
/**
* Consider income and expense categories
*
......
......@@ -521,7 +521,7 @@ void MyMoneyTransactionFilterTest::testMatchTransactionTag()
QVERIFY(filter.match(transaction));
QCOMPARE(filter.matchingSplits(transaction).size(), 1);
// check no category support
// check disabled category splits support
MyMoneySplit split4;
split4.setAccountId(acExpenseId);
split4.setShares(MyMoneyMoney(123.00));
......@@ -535,7 +535,10 @@ void MyMoneyTransactionFilterTest::testMatchTransactionTag()
QVERIFY(!filter.match(transaction2));
QCOMPARE(filter.matchingSplits(transaction2).size(), 0);
qDebug() << "tags on categories could not be tested";
// check enabled category splits support
filter.setConsiderCategorySplits(true);
QVERIFY(filter.match(transaction2));
QCOMPARE(filter.matchingSplits(transaction2).size(), 1);
}
void MyMoneyTransactionFilterTest::testMatchTransactionTypeAllTypes()
......
......@@ -301,6 +301,7 @@ void KTagsView::showTransactions()
// setup the list and the pointer vector
MyMoneyTransactionFilter filter;
filter.setConsiderCategorySplits();
filter.addTag(d->m_tag.id());
filter.setDateFilter(KMyMoneySettings::startDate().date(), QDate());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment