Commit 2e591fa1 authored by Łukasz Wojniłowicz's avatar Łukasz Wojniłowicz
Browse files

Add hide transactions for reports

BUG:344172
FIXED-IN:5.0

Differential Revision: https://phabricator.kde.org/D5228

Signed-off-by: Łukasz Wojniłowicz's avatarŁukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
parent c6e31c96
......@@ -242,6 +242,7 @@ void KReportConfigurationFilterDlg::slotSearch()
m_currentState.setDetailLevel(m_tab3->findChild<QCheckBox*>("m_checkHideSplitDetails")->isChecked() ?
MyMoneyReport::eDetailNone : MyMoneyReport::eDetailAll);
m_currentState.setHideTransactions(m_tab3->findChild<QCheckBox*>("m_checkHideTransactions")->isChecked());
}
if (m_tabChart) {
......@@ -439,8 +440,11 @@ void KReportConfigurationFilterDlg::slotReset()
m_tab3->findChild<QCheckBox*>("m_checkInvestments")->setChecked(m_initialState.isInvestmentsOnly());
m_tab3->findChild<QCheckBox*>("m_checkLoans")->setChecked(m_initialState.isLoansOnly());
m_tab3->findChild<QCheckBox*>("m_checkHideTransactions")->setChecked(m_initialState.isHideTransactions());
m_tab3->findChild<QCheckBox*>("m_checkHideSplitDetails")->setEnabled(!m_initialState.isHideTransactions());
m_tab3->findChild<QCheckBox*>("m_checkHideSplitDetails")->setChecked
(m_initialState.detailLevel() == MyMoneyReport::eDetailNone);
(m_initialState.detailLevel() == MyMoneyReport::eDetailNone || m_initialState.isHideTransactions());
}
if (m_tabChart) {
......
......@@ -216,6 +216,11 @@ table.report tr#topparent td.left {/*parent label for each row group containing
color:WindowText;
}
table.report tr.sectionfooterbasic td { /* totals for without top border */
padding: 0 0.5em 0.5em 0.5em;
color:WindowText;
}
table.report tr.sectionfooter td { /* totals for each section -subtotals */
border-top: 1px solid black;
padding: 0 0.5em 0.5em 0.5em;
......
......@@ -57,6 +57,7 @@ MyMoneyReport::MyMoneyReport() :
m_tax(false),
m_investments(false),
m_loans(false),
m_hideTransactions(false),
m_reportType(kTypeArray[eExpenseIncome]),
m_rowType(eExpenseIncome),
m_columnType(eMonths),
......@@ -106,6 +107,7 @@ MyMoneyReport::MyMoneyReport(ERowType _rt, unsigned _ct, dateOptionE _dl, EDetai
m_tax(false),
m_investments(false),
m_loans(false),
m_hideTransactions(false),
m_reportType(kTypeArray[_rt]),
m_rowType(_rt),
m_columnsAreDays(false),
......@@ -347,6 +349,7 @@ void MyMoneyReport::write(QDomElement& e, QDomDocument *doc, bool anonymous) con
e.setAttribute("tax", m_tax);
e.setAttribute("investments", m_investments);
e.setAttribute("loans", m_loans);
e.setAttribute("hidetransactions", m_hideTransactions);
e.setAttribute("rowtype", kRowTypeText[m_rowType]);
e.setAttribute("datelock", kDateLockText[m_dateLock]);
e.setAttribute("datalock", kDataLockText[m_dataLock]);
......@@ -383,10 +386,10 @@ void MyMoneyReport::write(QDomElement& e, QDomDocument *doc, bool anonymous) con
e.setAttribute("dataMinorTick", m_dataMinorTick);
e.setAttribute("dataLock", m_dataLock);
e.setAttribute("skipZero", m_skipZero);
e.setAttribute("detail", kDetailLevelText[m_detailLevel]);
if (m_reportType == ePivotTable) {
e.setAttribute("type", "pivottable 1.15");
e.setAttribute("detail", kDetailLevelText[m_detailLevel]);
e.setAttribute("columntype", kColumnTypeText[m_columnType]);
e.setAttribute("showrowtotals", m_showRowTotals);
} else if (m_reportType == eQueryTable) {
......@@ -405,7 +408,6 @@ void MyMoneyReport::write(QDomElement& e, QDomDocument *doc, bool anonymous) con
e.setAttribute("querycolumns", columns.join(","));
} else if (m_reportType == eInfoTable) {
e.setAttribute("type", "infotable 1.0");
e.setAttribute("detail", kDetailLevelText[m_detailLevel]);
e.setAttribute("showrowtotals", m_showRowTotals);
}
......@@ -649,6 +651,7 @@ bool MyMoneyReport::read(const QDomElement& e)
m_tax = e.attribute("tax", "0").toUInt();
m_investments = e.attribute("investments", "0").toUInt();
m_loans = e.attribute("loans", "0").toUInt();
m_hideTransactions = e.attribute("hidetransactions", "0").toUInt();
m_includeSchedules = e.attribute("includeschedules", "0").toUInt();
m_columnsAreDays = e.attribute("columnsaredays", "0").toUInt();
m_includeTransfers = e.attribute("includestransfers", "0").toUInt();
......
......@@ -140,6 +140,9 @@ public:
EDetailLevel detailLevel() const {
return m_detailLevel;
}
bool isHideTransactions() const {
return m_hideTransactions;
}
EChartType chartType() const {
return m_chartType;
}
......@@ -263,6 +266,9 @@ public:
void setDetailLevel(EDetailLevel _detail) {
m_detailLevel = _detail;
}
void setHideTransactions(bool _f) {
m_hideTransactions = _f;
}
void setChartType(EChartType _type) {
m_chartType = _type;
}
......@@ -558,6 +564,10 @@ private:
* How much detail to show in the accounts
*/
enum EDetailLevel m_detailLevel;
/**
* Whether to show transactions or just totals.
*/
bool m_hideTransactions;
/**
* Whether to convert all currencies to the base currency of the file (true).
* If this is false, it's up to the report generator to decide how to handle
......
......@@ -242,6 +242,7 @@ void ListTable::render(QString& result, QString& csv) const
//
bool row_odd = true;
bool isHigherGroupTotal = false; // hack to inform whether to put separator line or not
// ***DV***
MyMoneyMoney startingBalance;
......@@ -260,12 +261,18 @@ void ListTable::render(QString& result, QString& csv) const
// detect whether any of groups changed and display new group header in that case
for (int i = 0; i < groups.count(); ++i) {
if (prevGrpNames.at(i) != (*it_row)[groups.at(i)]) {
row_odd = true;
result += "<tr class=\"sectionheader\">"
"<td class=\"left" + QString::number(i) + "\" "
"colspan=\"" + QString::number(columns.count()) + "\">" +
(*it_row)[groups.at(i)] + "</td></tr>\n";
csv += "\"" + (*it_row)[groups.at(i)] + "\"\n";
// group header of lowest group doesn't bring any useful information
// if hide transaction is enabled, so don't display it
if (!m_config.isHideTransactions() || i != groups.count() - 1) {
row_odd = true;
result += "<tr class=\"sectionheader\">"
"<td class=\"left" + QString::number(i) + "\" "
"colspan=\"" + QString::number(columns.count()) + "\">" +
(*it_row)[groups.at(i)] + "</td></tr>\n";
csv += "\"" + (*it_row)[groups.at(i)] + "\"\n";
}
if (i == groups.count() - 1) // lowest group has been switched...
isHigherGroupTotal = false; // ...so expect lowest group total
prevGrpNames.replace(i, (*it_row)[groups.at(i)]);
}
}
......@@ -274,34 +281,40 @@ void ListTable::render(QString& result, QString& csv) const
// Columns
//
// skip the opening and closing balance row,
// if the balance column is not shown
// rank = 0 for opening balance, rank = 3 for closing balance
if ((columns.contains("balance") == 0) && ((*it_row)["rank"] == "0" || (*it_row)["rank"] == "3"))
continue;
bool need_label = true;
QString tlink; // link information to account and transaction
// ***DV***
if ((* it_row)["rank"] == "1") {
row_odd = ! row_odd;
tlink = QString("id=%1&tid=%2")
.arg((* it_row)["accountid"], (* it_row)["id"]);
}
if ((*it_row)["rank"] == "0" || (*it_row)["rank"] == "3")
result += QString("<tr class=\"item%1\">").arg((* it_row)["id"]);
else if ((* it_row)["rank"] == "2")
result += QString("<tr class=\"%1\">").arg(row_odd ? "item1" : "item0");
else if ((* it_row)["rank"] == "4") {
if (m_config.rowType() == MyMoneyReport::eTag || //If we order by Tags don't show the Grand total as we can have multiple tags per transaction
!m_config.isConvertCurrency() && std::next(it_row) == m_rows.end())// grand total may be invalid if multiple currencies are used, so don't display it
continue;
else
result += QString("<tr class=\"sectionfooter\">");
if (!m_config.isHideTransactions() || (*it_row)["rank"] == "4") { // if hide transaction is enabled display only total rows i.e. rank = 4
if ((*it_row)["rank"] == "0" || (*it_row)["rank"] == "3") {
// skip the opening and closing balance row,
// if the balance column is not shown
// rank = 0 for opening balance, rank = 3 for closing balance
if (!columns.contains("balance"))
continue;
result += QString("<tr class=\"item%1\">").arg((* it_row)["id"]);
// ***DV***
} else if ((* it_row)["rank"] == "1") {
row_odd = ! row_odd;
tlink = QString("id=%1&tid=%2")
.arg((* it_row)["accountid"], (* it_row)["id"]);
result += QString("<tr class=\"%1\">").arg(row_odd ? "row-odd " : "row-even");
} else if ((* it_row)["rank"] == "2")
result += QString("<tr class=\"%1\">").arg(row_odd ? "item1" : "item0");
else if ((* it_row)["rank"] == "4") {
if ((m_config.rowType() == MyMoneyReport::eTag) || //If we order by Tags don't show the Grand total as we can have multiple tags per transaction
(!m_config.isConvertCurrency() && std::next(it_row) == m_rows.end()))// grand total may be invalid if multiple currencies are used, so don't display it
continue;
// display special footer (i.e. without horizontal separator) only for lowest group totals
else if (m_config.isHideTransactions() && !isHigherGroupTotal && std::next(it_row) != m_rows.end()) {
result += QString("<tr class=\"sectionfooterbasic\">");
isHigherGroupTotal = true;
} else
result += QString("<tr class=\"sectionfooter\">");
} else
result += QString("<tr class=\"%1\">").arg(row_odd ? "row-odd " : "row-even");
} else
result += QString("<tr class=\"%1\">").arg(row_odd ? "row-odd " : "row-even");
continue;
QStringList::const_iterator it_column = columns.constBegin();
while (it_column != columns.constEnd()) {
......
......@@ -72,6 +72,14 @@ kMyMoneyReportConfigTab3Decl::kMyMoneyReportConfigTab3Decl(QWidget *parent)
ui->buttonGroup1->setId(ui->m_checkCategory, 7);
ui->buttonGroup1->setId(ui->m_checkAction, 8);
ui->buttonGroup1->setId(ui->m_checkBalance, 9);
connect(ui->m_checkHideTransactions, SIGNAL(toggled(bool)), this, SLOT(slotHideTransactionsChanged(bool)));
}
void kMyMoneyReportConfigTab3Decl::slotHideTransactionsChanged(bool checked)
{
if (checked) // toggle m_checkHideSplitDetails only if it's mandatory
ui->m_checkHideSplitDetails->setChecked(checked);
ui->m_checkHideSplitDetails->setEnabled(!checked); // hiding transactions without hiding splits isn't allowed
}
kMyMoneyReportConfigTab3Decl::~kMyMoneyReportConfigTab3Decl()
......
......@@ -54,11 +54,14 @@ private:
class kMyMoneyReportConfigTab3Decl : public QWidget
{
Q_OBJECT
public:
kMyMoneyReportConfigTab3Decl(QWidget *parent);
virtual ~kMyMoneyReportConfigTab3Decl();
private:
Ui::kMyMoneyReportConfigTab3Decl* ui;
private slots:
void slotHideTransactionsChanged(bool checked);
};
class kMyMoneyReportConfigTabChartDecl : public QWidget
......
Markdown is supported
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