Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneyreport.cpp
Show All 28 Lines | |||||
29 | // KDE Includes | 29 | // KDE Includes | ||
30 | 30 | | |||
31 | // ---------------------------------------------------------------------------- | 31 | // ---------------------------------------------------------------------------- | ||
32 | // Project Includes | 32 | // Project Includes | ||
33 | 33 | | |||
34 | #include "mymoneyfile.h" | 34 | #include "mymoneyfile.h" | ||
35 | #include "reportdebug.h" | 35 | #include "reportdebug.h" | ||
36 | 36 | | |||
37 | const MyMoneyReport::Report::Type MyMoneyReport::Report::kTypeArray[] = { NoReport, PivotTable, PivotTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, QueryTable, PivotTable, PivotTable, InfoTable, InfoTable, InfoTable, QueryTable, QueryTable, NoReport }; | ||||
37 | const QStringList MyMoneyReport::Column::kTypeText = QString("none,months,bimonths,quarters,4,5,6,weeks,8,9,10,11,years").split(','); | 38 | const QStringList MyMoneyReport::Column::kTypeText = QString("none,months,bimonths,quarters,4,5,6,weeks,8,9,10,11,years").split(','); | ||
38 | // if you add names here, don't forget to update the bitmap for QueryColumns::Type | 39 | // if you add names here, don't forget to update the bitmap for QueryColumns::Type | ||
39 | // and shift the bit for QueryColumns::end one position to the left | 40 | // and shift the bit for QueryColumns::end one position to the left | ||
40 | const QStringList MyMoneyReport::QueryColumns::kText = QString("none,number,payee,category,tag,memo,account,reconcileflag,action,shares,price,performance,loan,balance").split(','); | 41 | const QStringList MyMoneyReport::QueryColumns::kText = QString("none,number,payee,category,tag,memo,account,reconcileflag,action,shares,price,performance,loan,balance").split(','); | ||
41 | 42 | | |||
42 | const QStringList MyMoneyReport::kRowTypeText = QString("none,assetliability,expenseincome,category,topcategory,account,tag,payee,month,week,topaccount,topaccount-account,equitytype,accounttype,institution,budget,budgetactual,schedule,accountinfo,accountloaninfo,accountreconcile,cashflow").split(','); | 43 | const QStringList MyMoneyReport::kRowTypeText = QString("none,assetliability,expenseincome,category,topcategory,account,tag,payee,month,week,topaccount,topaccount-account,equitytype,accounttype,institution,budget,budgetactual,schedule,accountinfo,accountloaninfo,accountreconcile,cashflow").split(','); | ||
43 | 44 | | |||
44 | const MyMoneyReport::EReportType MyMoneyReport::kTypeArray[] = { eNoReport, ePivotTable, ePivotTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, ePivotTable, ePivotTable, eInfoTable, eInfoTable, eInfoTable, eQueryTable, eQueryTable, eNoReport }; | | |||
45 | const QStringList MyMoneyReport::kDetailLevelText = QString("none,all,top,group,total,invalid").split(','); | 45 | const QStringList MyMoneyReport::kDetailLevelText = QString("none,all,top,group,total,invalid").split(','); | ||
46 | const QStringList MyMoneyReport::kChartTypeText = QString("none,line,bar,pie,ring,stackedbar,invalid").split(','); | 46 | const QStringList MyMoneyReport::kChartTypeText = QString("none,line,bar,pie,ring,stackedbar,invalid").split(','); | ||
47 | 47 | | |||
48 | // This should live in mymoney/mymoneytransactionfilter.h | 48 | // This should live in mymoney/mymoneytransactionfilter.h | ||
49 | const QStringList kTypeText = QString("all,payments,deposits,transfers,none").split(','); | 49 | const QStringList kTypeText = QString("all,payments,deposits,transfers,none").split(','); | ||
50 | const QStringList kStateText = QString("all,notreconciled,cleared,reconciled,frozen,none").split(','); | 50 | const QStringList kStateText = QString("all,notreconciled,cleared,reconciled,frozen,none").split(','); | ||
51 | const QStringList kDateLockText = QString("alldates,untiltoday,currentmonth,currentyear,monthtodate,yeartodate,yeartomonth,lastmonth,lastyear,last7days,last30days,last3months,last6months,last12months,next7days,next30days,next3months,next6months,next12months,userdefined,last3tonext3months,last11Months,currentQuarter,lastQuarter,nextQuarter,currentFiscalYear,lastFiscalYear,today,next18months").split(','); | 51 | const QStringList kDateLockText = QString("alldates,untiltoday,currentmonth,currentyear,monthtodate,yeartodate,yeartomonth,lastmonth,lastyear,last7days,last30days,last3months,last6months,last12months,next7days,next30days,next3months,next6months,next12months,userdefined,last3tonext3months,last11Months,currentQuarter,lastQuarter,nextQuarter,currentFiscalYear,lastFiscalYear,today,next18months").split(','); | ||
52 | const QStringList kAccountTypeText = QString("unknown,checkings,savings,cash,creditcard,loan,certificatedep,investment,moneymarket,asset,liability,currency,income,expense,assetloan,stock,equity,invalid").split(','); | 52 | const QStringList kAccountTypeText = QString("unknown,checkings,savings,cash,creditcard,loan,certificatedep,investment,moneymarket,asset,liability,currency,income,expense,assetloan,stock,equity,invalid").split(','); | ||
53 | 53 | | |||
54 | QString MyMoneyReport::Report::toString(Type type) | ||||
55 | { | ||||
56 | switch(type) { | ||||
57 | case NoReport: return "NoReport"; | ||||
58 | case PivotTable: return "PivotTable"; | ||||
59 | case QueryTable: return "QueryTable"; | ||||
60 | case InfoTable: return "InfoTable"; | ||||
61 | default: return "undefined"; | ||||
62 | } | ||||
63 | } | ||||
64 | | ||||
54 | MyMoneyReport::MyMoneyReport() : | 65 | MyMoneyReport::MyMoneyReport() : | ||
55 | m_name("Unconfigured Pivot Table Report"), | 66 | m_name("Unconfigured Pivot Table Report"), | ||
56 | m_detailLevel(eDetailNone), | 67 | m_detailLevel(eDetailNone), | ||
57 | m_convertCurrency(true), | 68 | m_convertCurrency(true), | ||
58 | m_favorite(false), | 69 | m_favorite(false), | ||
59 | m_tax(false), | 70 | m_tax(false), | ||
60 | m_investments(false), | 71 | m_investments(false), | ||
61 | m_loans(false), | 72 | m_loans(false), | ||
62 | m_reportType(kTypeArray[eExpenseIncome]), | 73 | m_reportType(Report::kTypeArray[eExpenseIncome]), | ||
63 | m_rowType(eExpenseIncome), | 74 | m_rowType(eExpenseIncome), | ||
64 | m_columnType(Column::Months), | 75 | m_columnType(Column::Months), | ||
65 | m_columnsAreDays(false), | 76 | m_columnsAreDays(false), | ||
66 | m_queryColumns(QueryColumns::None), | 77 | m_queryColumns(QueryColumns::None), | ||
67 | m_dateLock(userDefined), | 78 | m_dateLock(userDefined), | ||
68 | m_accountGroupFilter(false), | 79 | m_accountGroupFilter(false), | ||
69 | m_chartType(eChartLine), | 80 | m_chartType(eChartLine), | ||
70 | m_chartDataLabels(true), | 81 | m_chartDataLabels(true), | ||
Show All 29 Lines | 110 | MyMoneyReport::MyMoneyReport(ERowType _rt, unsigned _ct, dateOptionE _dl, EDetailLevel _ss, const QString& _name, const QString& _comment) : | |||
100 | m_name(_name), | 111 | m_name(_name), | ||
101 | m_comment(_comment), | 112 | m_comment(_comment), | ||
102 | m_detailLevel(_ss), | 113 | m_detailLevel(_ss), | ||
103 | m_convertCurrency(true), | 114 | m_convertCurrency(true), | ||
104 | m_favorite(false), | 115 | m_favorite(false), | ||
105 | m_tax(false), | 116 | m_tax(false), | ||
106 | m_investments(false), | 117 | m_investments(false), | ||
107 | m_loans(false), | 118 | m_loans(false), | ||
108 | m_reportType(kTypeArray[_rt]), | 119 | m_reportType(Report::kTypeArray[_rt]), | ||
109 | m_rowType(_rt), | 120 | m_rowType(_rt), | ||
110 | m_columnType(Column::Months), | 121 | m_columnType(Column::Months), | ||
111 | m_columnsAreDays(false), | 122 | m_columnsAreDays(false), | ||
112 | m_queryColumns(QueryColumns::None), | 123 | m_queryColumns(QueryColumns::None), | ||
113 | m_dateLock(_dl), | 124 | m_dateLock(_dl), | ||
114 | m_accountGroupFilter(false), | 125 | m_accountGroupFilter(false), | ||
115 | m_chartType(eChartLine), | 126 | m_chartType(eChartLine), | ||
116 | m_chartDataLabels(true), | 127 | m_chartDataLabels(true), | ||
Show All 12 Lines | |||||
129 | m_mixedTime(false), | 140 | m_mixedTime(false), | ||
130 | m_currentDateColumn(0), | 141 | m_currentDateColumn(0), | ||
131 | m_skipZero(false) | 142 | m_skipZero(false) | ||
132 | { | 143 | { | ||
133 | //set initial values | 144 | //set initial values | ||
134 | m_chartLineWidth = m_lineWidth; | 145 | m_chartLineWidth = m_lineWidth; | ||
135 | 146 | | |||
136 | //set report type | 147 | //set report type | ||
137 | if (m_reportType == ePivotTable) | 148 | if (m_reportType == Report::PivotTable) | ||
138 | m_columnType = static_cast<Column::Type>(_ct); | 149 | m_columnType = static_cast<Column::Type>(_ct); | ||
139 | if (m_reportType == eQueryTable) | 150 | if (m_reportType == Report::QueryTable) | ||
140 | m_queryColumns = static_cast<QueryColumns::Type>(_ct); | 151 | m_queryColumns = static_cast<QueryColumns::Type>(_ct); | ||
141 | setDateFilter(_dl); | 152 | setDateFilter(_dl); | ||
142 | 153 | | |||
143 | //throw exception if the type is inconsistent | 154 | //throw exception if the type is inconsistent | ||
144 | if ((_rt > static_cast<ERowType>(sizeof(kTypeArray) / sizeof(kTypeArray[0]))) | 155 | if ((_rt > static_cast<ERowType>(sizeof(Report::kTypeArray) / sizeof(Report::kTypeArray[0]))) | ||
145 | || (m_reportType == eNoReport)) | 156 | || (m_reportType == Report::NoReport)) | ||
146 | throw MYMONEYEXCEPTION("Invalid report type"); | 157 | throw MYMONEYEXCEPTION("Invalid report type"); | ||
147 | 158 | | |||
148 | //add the corresponding account groups | 159 | //add the corresponding account groups | ||
149 | if (_rt == MyMoneyReport::eAssetLiability) { | 160 | if (_rt == MyMoneyReport::eAssetLiability) { | ||
150 | addAccountGroup(MyMoneyAccount::Asset); | 161 | addAccountGroup(MyMoneyAccount::Asset); | ||
151 | addAccountGroup(MyMoneyAccount::Liability); | 162 | addAccountGroup(MyMoneyAccount::Liability); | ||
152 | m_showRowTotals = true; | 163 | m_showRowTotals = true; | ||
153 | } | 164 | } | ||
Show All 31 Lines | |||||
185 | if (_rt == MyMoneyReport::eCashFlow) { | 196 | if (_rt == MyMoneyReport::eCashFlow) { | ||
186 | addAccountGroup(MyMoneyAccount::Expense); | 197 | addAccountGroup(MyMoneyAccount::Expense); | ||
187 | addAccountGroup(MyMoneyAccount::Income); | 198 | addAccountGroup(MyMoneyAccount::Income); | ||
188 | addAccountGroup(MyMoneyAccount::Asset); | 199 | addAccountGroup(MyMoneyAccount::Asset); | ||
189 | addAccountGroup(MyMoneyAccount::Liability); | 200 | addAccountGroup(MyMoneyAccount::Liability); | ||
190 | } | 201 | } | ||
191 | #ifdef DEBUG_REPORTS | 202 | #ifdef DEBUG_REPORTS | ||
192 | QDebug dbg = qDebug(); | 203 | QDebug dbg = qDebug(); | ||
193 | dbg << _name << toString(_rt) << toString(m_reportType); | 204 | dbg << _name << toString(_rt) << Report::toString(m_reportType); | ||
194 | foreach(const MyMoneyAccount::accountTypeE accountType, m_accountGroups) | 205 | foreach(const MyMoneyAccount::accountTypeE accountType, m_accountGroups) | ||
195 | dbg << MyMoneyAccount::accountTypeToString(accountType); | 206 | dbg << MyMoneyAccount::accountTypeToString(accountType); | ||
196 | if (m_accounts.size() > 0) | 207 | if (m_accounts.size() > 0) | ||
197 | dbg << m_accounts; | 208 | dbg << m_accounts; | ||
198 | #endif | 209 | #endif | ||
199 | } | 210 | } | ||
200 | 211 | | |||
201 | MyMoneyReport::MyMoneyReport(const QDomElement& node) : | 212 | MyMoneyReport::MyMoneyReport(const QDomElement& node) : | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 231 | { | |||
258 | } | 269 | } | ||
259 | if (_db > _de) | 270 | if (_db > _de) | ||
260 | _db = _de; | 271 | _db = _de; | ||
261 | } | 272 | } | ||
262 | 273 | | |||
263 | void MyMoneyReport::setRowType(ERowType _rt) | 274 | void MyMoneyReport::setRowType(ERowType _rt) | ||
264 | { | 275 | { | ||
265 | m_rowType = _rt; | 276 | m_rowType = _rt; | ||
266 | m_reportType = kTypeArray[_rt]; | 277 | m_reportType = Report::kTypeArray[_rt]; | ||
267 | 278 | | |||
268 | m_accountGroupFilter = false; | 279 | m_accountGroupFilter = false; | ||
269 | m_accountGroups.clear(); | 280 | m_accountGroups.clear(); | ||
270 | 281 | | |||
271 | if (_rt == MyMoneyReport::eAssetLiability) { | 282 | if (_rt == MyMoneyReport::eAssetLiability) { | ||
272 | addAccountGroup(MyMoneyAccount::Asset); | 283 | addAccountGroup(MyMoneyAccount::Asset); | ||
273 | addAccountGroup(MyMoneyAccount::Liability); | 284 | addAccountGroup(MyMoneyAccount::Liability); | ||
274 | } | 285 | } | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 402 | } else { | |||
392 | e.setAttribute("charttype", kChartTypeText[m_chartType]); | 403 | e.setAttribute("charttype", kChartTypeText[m_chartType]); | ||
393 | } | 404 | } | ||
394 | e.setAttribute("chartdatalabels", m_chartDataLabels); | 405 | e.setAttribute("chartdatalabels", m_chartDataLabels); | ||
395 | e.setAttribute("chartgridlines", m_chartGridLines); | 406 | e.setAttribute("chartgridlines", m_chartGridLines); | ||
396 | e.setAttribute("chartbydefault", m_chartByDefault); | 407 | e.setAttribute("chartbydefault", m_chartByDefault); | ||
397 | e.setAttribute("chartlinewidth", m_chartLineWidth); | 408 | e.setAttribute("chartlinewidth", m_chartLineWidth); | ||
398 | e.setAttribute("skipZero", m_skipZero); | 409 | e.setAttribute("skipZero", m_skipZero); | ||
399 | 410 | | |||
400 | if (m_reportType == ePivotTable) { | 411 | if (m_reportType == Report::PivotTable) { | ||
401 | e.setAttribute("type", "pivottable 1.15"); | 412 | e.setAttribute("type", "pivottable 1.15"); | ||
402 | e.setAttribute("detail", kDetailLevelText[m_detailLevel]); | 413 | e.setAttribute("detail", kDetailLevelText[m_detailLevel]); | ||
403 | e.setAttribute("columntype", Column::kTypeText[m_columnType]); | 414 | e.setAttribute("columntype", Column::kTypeText[m_columnType]); | ||
404 | e.setAttribute("showrowtotals", m_showRowTotals); | 415 | e.setAttribute("showrowtotals", m_showRowTotals); | ||
405 | } else if (m_reportType == eQueryTable) { | 416 | } else if (m_reportType == Report::QueryTable) { | ||
406 | e.setAttribute("type", "querytable 1.14"); | 417 | e.setAttribute("type", "querytable 1.14"); | ||
407 | 418 | | |||
408 | QStringList columns; | 419 | QStringList columns; | ||
409 | unsigned qc = m_queryColumns; | 420 | unsigned qc = m_queryColumns; | ||
410 | unsigned it_qc = QueryColumns::Begin; | 421 | unsigned it_qc = QueryColumns::Begin; | ||
411 | unsigned index = 1; | 422 | unsigned index = 1; | ||
412 | while (it_qc != QueryColumns::End) { | 423 | while (it_qc != QueryColumns::End) { | ||
413 | if (qc & it_qc) | 424 | if (qc & it_qc) | ||
414 | columns += QueryColumns::kText[index]; | 425 | columns += QueryColumns::kText[index]; | ||
415 | it_qc *= 2; | 426 | it_qc *= 2; | ||
416 | index++; | 427 | index++; | ||
417 | } | 428 | } | ||
418 | e.setAttribute("querycolumns", columns.join(",")); | 429 | e.setAttribute("querycolumns", columns.join(",")); | ||
419 | } else if (m_reportType == eInfoTable) { | 430 | } else if (m_reportType == Report::InfoTable) { | ||
420 | e.setAttribute("type", "infotable 1.0"); | 431 | e.setAttribute("type", "infotable 1.0"); | ||
421 | e.setAttribute("detail", kDetailLevelText[m_detailLevel]); | 432 | e.setAttribute("detail", kDetailLevelText[m_detailLevel]); | ||
422 | e.setAttribute("showrowtotals", m_showRowTotals); | 433 | e.setAttribute("showrowtotals", m_showRowTotals); | ||
423 | } | 434 | } | ||
424 | 435 | | |||
425 | // | 436 | // | ||
426 | // Text Filter | 437 | // Text Filter | ||
427 | // | 438 | // | ||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Line(s) | 633 | ) { | |||
624 | clear(); | 635 | clear(); | ||
625 | 636 | | |||
626 | int i; | 637 | int i; | ||
627 | m_name = e.attribute("name"); | 638 | m_name = e.attribute("name"); | ||
628 | m_comment = e.attribute("comment", "Extremely old report"); | 639 | m_comment = e.attribute("comment", "Extremely old report"); | ||
629 | 640 | | |||
630 | //set report type | 641 | //set report type | ||
631 | if (!e.attribute("type").indexOf("pivottable")) { | 642 | if (!e.attribute("type").indexOf("pivottable")) { | ||
632 | m_reportType = MyMoneyReport::ePivotTable; | 643 | m_reportType = MyMoneyReport::Report::PivotTable; | ||
633 | } else if (!e.attribute("type").indexOf("querytable")) { | 644 | } else if (!e.attribute("type").indexOf("querytable")) { | ||
634 | m_reportType = MyMoneyReport::eQueryTable; | 645 | m_reportType = MyMoneyReport::Report::QueryTable; | ||
635 | } else if (!e.attribute("type").indexOf("infotable")) { | 646 | } else if (!e.attribute("type").indexOf("infotable")) { | ||
636 | m_reportType = MyMoneyReport::eInfoTable; | 647 | m_reportType = MyMoneyReport::Report::InfoTable; | ||
637 | } else { | 648 | } else { | ||
638 | m_reportType = MyMoneyReport::eNoReport; | 649 | m_reportType = MyMoneyReport::Report::NoReport; | ||
639 | } | 650 | } | ||
640 | 651 | | |||
641 | // Removed the line that screened out loading reports that are called | 652 | // Removed the line that screened out loading reports that are called | ||
642 | // "Default Report". It's possible for the user to change the comment | 653 | // "Default Report". It's possible for the user to change the comment | ||
643 | // to this, and we'd hate for it to break as a result. | 654 | // to this, and we'd hate for it to break as a result. | ||
644 | m_group = e.attribute("group"); | 655 | m_group = e.attribute("group"); | ||
645 | m_id = e.attribute("id"); | 656 | m_id = e.attribute("id"); | ||
646 | 657 | | |||
Show All 28 Lines | |||||
675 | m_mixedTime = e.attribute("mixedtime", "0").toUInt(); | 686 | m_mixedTime = e.attribute("mixedtime", "0").toUInt(); | ||
676 | m_includeMovingAverage = e.attribute("includesmovingaverage", "0").toUInt(); | 687 | m_includeMovingAverage = e.attribute("includesmovingaverage", "0").toUInt(); | ||
677 | m_skipZero = e.attribute("skipZero", "0").toUInt(); | 688 | m_skipZero = e.attribute("skipZero", "0").toUInt(); | ||
678 | if (m_includeMovingAverage) | 689 | if (m_includeMovingAverage) | ||
679 | m_movingAverageDays = e.attribute("movingaveragedays", "1").toUInt(); | 690 | m_movingAverageDays = e.attribute("movingaveragedays", "1").toUInt(); | ||
680 | 691 | | |||
681 | //only load chart data if it is a pivot table | 692 | //only load chart data if it is a pivot table | ||
682 | m_chartType = static_cast<EChartType>(0); | 693 | m_chartType = static_cast<EChartType>(0); | ||
683 | if (m_reportType == ePivotTable) { | 694 | if (m_reportType == Report::PivotTable) { | ||
684 | i = kChartTypeText.indexOf(e.attribute("charttype")); | 695 | i = kChartTypeText.indexOf(e.attribute("charttype")); | ||
685 | 696 | | |||
686 | if (i >= 0) | 697 | if (i >= 0) | ||
687 | m_chartType = static_cast<EChartType>(i); | 698 | m_chartType = static_cast<EChartType>(i); | ||
688 | 699 | | |||
689 | // if it is invalid, set to first type | 700 | // if it is invalid, set to first type | ||
690 | if (m_chartType >= eChartEnd) | 701 | if (m_chartType >= eChartEnd) | ||
691 | m_chartType = eChartLine; | 702 | m_chartType = eChartLine; | ||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | 842 | { | |||
850 | case eSchedule : return "eSchedule"; | 861 | case eSchedule : return "eSchedule"; | ||
851 | case eAccountInfo : return "eAccountInfo"; | 862 | case eAccountInfo : return "eAccountInfo"; | ||
852 | case eAccountLoanInfo : return "eAccountLoanInfo"; | 863 | case eAccountLoanInfo : return "eAccountLoanInfo"; | ||
853 | case eAccountReconcile : return "eAccountReconcile"; | 864 | case eAccountReconcile : return "eAccountReconcile"; | ||
854 | case eCashFlow : return "eCashFlow"; | 865 | case eCashFlow : return "eCashFlow"; | ||
855 | default : return "undefined"; | 866 | default : return "undefined"; | ||
856 | } | 867 | } | ||
857 | } | 868 | } | ||
858 | | ||||
859 | QString MyMoneyReport::toString(MyMoneyReport::EReportType type) | | |||
860 | { | | |||
861 | switch(type) { | | |||
862 | case eNoReport: return "eNoReport"; | | |||
863 | case ePivotTable: return "ePivotTable"; | | |||
864 | case eQueryTable: return "eQueryTable"; | | |||
865 | case eInfoTable: return "eInfoTable"; | | |||
866 | default: return "undefined"; | | |||
867 | } | | |||
868 | } | |