Commit c47a6355 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'

BUG:412429
FIXED-IN:4.8.5,5.0.8

(cherry-picked from commit 1285c644)
parent 1285c644
......@@ -38,6 +38,7 @@ MyMoneyTransactionFilter::MyMoneyTransactionFilter()
m_filterSet.allFilter = 0;
m_reportAllSplits = true;
m_considerCategory = true;
m_considerCategorySplits = false;
m_invertText = false;
}
......@@ -46,6 +47,7 @@ MyMoneyTransactionFilter::MyMoneyTransactionFilter(const QString& id)
m_filterSet.allFilter = 0;
m_reportAllSplits = false;
m_considerCategory = false;
m_considerCategorySplits = false;
m_invertText = false;
addAccount(id);
......@@ -210,6 +212,11 @@ void MyMoneyTransactionFilter::setReportAllSplits(const bool report)
m_reportAllSplits = report;
}
void MyMoneyTransactionFilter::setConsiderCategorySplits(const bool check)
{
m_considerCategorySplits = check;
}
void MyMoneyTransactionFilter::setConsiderCategory(const bool check)
{
m_considerCategory = check;
......@@ -427,7 +434,8 @@ bool MyMoneyTransactionFilter::match(const MyMoneyTransaction& transaction)
break;
}
if (!isCategory && !removeSplit) {
bool includeSplit = m_considerCategorySplits || (!m_considerCategorySplits && !isCategory);
if (includeSplit && !removeSplit) {
// check the payee list
if (!removeSplit && m_filterSet.singleFilter.payeeFilter) {
if (m_payees.count() > 0) {
......
......@@ -344,6 +344,15 @@ 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
*
......@@ -616,6 +625,7 @@ protected:
FilterSet m_filterSet;
bool m_reportAllSplits;
bool m_considerCategory;
bool m_considerCategorySplits;
QRegExp m_text;
bool m_invertText;
......
......@@ -542,7 +542,7 @@ void MyMoneyTransactionFilterTest::testMatchTransactionTag()
QVERIFY(filter.match(transaction));
QCOMPARE(filter.matchingSplits().size(), 1);
// check no category support
// check disabled category splits support
MyMoneySplit split4;
split4.setAccountId(acExpenseId);
split4.setShares(MyMoneyMoney(123.00));
......@@ -556,7 +556,10 @@ void MyMoneyTransactionFilterTest::testMatchTransactionTag()
QVERIFY(!filter.match(transaction2));
QCOMPARE(filter.matchingSplits().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().size(), 1);
}
void MyMoneyTransactionFilterTest::testMatchTransactionTypeAllTypes()
......
......@@ -393,6 +393,7 @@ void KTagsView::showTransactions()
// setup the list and the pointer vector
MyMoneyTransactionFilter filter;
filter.setConsiderCategorySplits();
filter.addTag(m_tag.id());
filter.setDateFilter(KMyMoneyGlobalSettings::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