File indexing completed on 2024-05-12 05:06:43

0001 /*
0002     SPDX-FileCopyrightText: 2004-2006 Ace Jones <acejones@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2006 Darren Gould <darren_gould@gmx.de>
0004     SPDX-FileCopyrightText: 2007-2010 Alvaro Soliverez <asoliverez@gmail.com>
0005     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0006     SPDX-FileCopyrightText: 2018 Michael Kiefer <Michael-Kiefer@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef MYMONEYREPORT_P_H
0011 #define MYMONEYREPORT_P_H
0012 
0013 #include "mymoneyreport.h"
0014 
0015 // ----------------------------------------------------------------------------
0016 // QT Includes
0017 
0018 #include <QString>
0019 #include <QHash>
0020 #include <QDate>
0021 #include <QList>
0022 
0023 // ----------------------------------------------------------------------------
0024 // KDE Includes
0025 
0026 // ----------------------------------------------------------------------------
0027 // Project Includes
0028 
0029 #include "mymoneyobject_p.h"
0030 #include "mymoneyenums.h"
0031 
0032 class MyMoneyReportPrivate : public MyMoneyObjectPrivate
0033 {
0034 public:
0035     MyMoneyReportPrivate(MyMoneyReport* qq)
0036         : q(qq)
0037         , m_name(QStringLiteral("Unconfigured Pivot Table Report"))
0038         , m_detailLevel(eMyMoney::Report::DetailLevel::None)
0039         , m_investmentSum(eMyMoney::Report::InvestmentSum::Sold)
0040         , m_hideTransactions(false)
0041         , m_convertCurrency(true)
0042         , m_favorite(false)
0043         , m_tax(false)
0044         , m_propagateBudgetDifference(false)
0045         , m_investments(false)
0046         , m_loans(false)
0047         , m_reportType(rowTypeToReportType(eMyMoney::Report::RowType::ExpenseIncome))
0048         , m_rowType(eMyMoney::Report::RowType::ExpenseIncome)
0049         , m_columnType(eMyMoney::Report::ColumnType::Months)
0050         , m_columnsAreDays(false)
0051         , m_queryColumns(eMyMoney::Report::QueryColumn::None)
0052         , m_dateLock(eMyMoney::TransactionFilter::Date::UserDefined)
0053         , m_accountGroupFilter(false)
0054         , m_chartType(eMyMoney::Report::ChartType::Line)
0055         , m_chartPalette(eMyMoney::Report::ChartPalette::Application)
0056         , m_chartDataLabels(true)
0057         , m_chartCHGridLines(true)
0058         , m_chartSVGridLines(true)
0059         , m_chartByDefault(false)
0060         , m_chartLineWidth(MyMoneyReport::m_lineWidth)
0061         , m_logYaxis(false)
0062         , m_negExpenses(false)
0063         , m_dataRangeStart('0')
0064         , m_dataRangeEnd('0')
0065         , m_dataMajorTick('0')
0066         , m_dataMinorTick('0')
0067         , m_yLabelsPrecision(2)
0068         , m_dataLock(eMyMoney::Report::DataLock::Automatic)
0069         , m_includeSchedules(false)
0070         , m_includeTransfers(false)
0071         , m_includeBudgetActuals(false)
0072         , m_includeUnusedAccounts(false)
0073         , m_showRowTotals(false)
0074         , m_showColumnTotals(true)
0075         , m_includeForecast(false)
0076         , m_includeMovingAverage(false)
0077         , m_movingAverageDays(0)
0078         , m_includePrice(false)
0079         , m_includeAveragePrice(false)
0080         , m_mixedTime(false)
0081         , m_currentDateColumn(0)
0082         , m_settlementPeriod(3)
0083         , m_showSTLTCapitalGains(false)
0084         , m_tseparator(QDate::currentDate().addYears(-1))
0085         , m_skipZero(false)
0086     {
0087     }
0088 
0089     static eMyMoney::Report::ReportType rowTypeToReportType(eMyMoney::Report::RowType rowType)
0090     {
0091         static const QHash<eMyMoney::Report::RowType, eMyMoney::Report::ReportType> reportTypes {
0092             {eMyMoney::Report::RowType::NoRows,               eMyMoney::Report::ReportType::NoReport},
0093             {eMyMoney::Report::RowType::AssetLiability,       eMyMoney::Report::ReportType::PivotTable},
0094             {eMyMoney::Report::RowType::ExpenseIncome,        eMyMoney::Report::ReportType::PivotTable},
0095             {eMyMoney::Report::RowType::Category,             eMyMoney::Report::ReportType::QueryTable},
0096             {eMyMoney::Report::RowType::TopCategory,          eMyMoney::Report::ReportType::QueryTable},
0097             {eMyMoney::Report::RowType::Account,              eMyMoney::Report::ReportType::QueryTable},
0098             {eMyMoney::Report::RowType::Tag,                  eMyMoney::Report::ReportType::QueryTable},
0099             {eMyMoney::Report::RowType::Payee,                eMyMoney::Report::ReportType::QueryTable},
0100             {eMyMoney::Report::RowType::Month,                eMyMoney::Report::ReportType::QueryTable},
0101             {eMyMoney::Report::RowType::Week,                 eMyMoney::Report::ReportType::QueryTable},
0102             {eMyMoney::Report::RowType::TopAccount,           eMyMoney::Report::ReportType::QueryTable},
0103             {eMyMoney::Report::RowType::AccountByTopAccount,  eMyMoney::Report::ReportType::QueryTable},
0104             {eMyMoney::Report::RowType::EquityType,           eMyMoney::Report::ReportType::QueryTable},
0105             {eMyMoney::Report::RowType::AccountType,          eMyMoney::Report::ReportType::QueryTable},
0106             {eMyMoney::Report::RowType::Institution,          eMyMoney::Report::ReportType::QueryTable},
0107             {eMyMoney::Report::RowType::Budget,               eMyMoney::Report::ReportType::PivotTable},
0108             {eMyMoney::Report::RowType::BudgetActual,         eMyMoney::Report::ReportType::PivotTable},
0109             {eMyMoney::Report::RowType::Schedule,             eMyMoney::Report::ReportType::InfoTable},
0110             {eMyMoney::Report::RowType::AccountInfo,          eMyMoney::Report::ReportType::InfoTable},
0111             {eMyMoney::Report::RowType::AccountLoanInfo,      eMyMoney::Report::ReportType::InfoTable},
0112             {eMyMoney::Report::RowType::AccountReconcile,     eMyMoney::Report::ReportType::QueryTable},
0113             {eMyMoney::Report::RowType::CashFlow,             eMyMoney::Report::ReportType::QueryTable},
0114         };
0115         return reportTypes.value(rowType, eMyMoney::Report::ReportType::Invalid);
0116     }
0117 
0118     void collectReferencedObjects() override
0119     {
0120         QStringList list;
0121         q->accounts(list);
0122         q->categories(list);
0123         q->payees(list);
0124         q->tags(list);
0125         if (!m_budgetId.isEmpty()) {
0126             list.append(m_budgetId);
0127         }
0128         m_referencedObjects = QSet<QString>(list.constBegin(), list.constEnd());
0129     }
0130 
0131     MyMoneyReport* q;
0132     /**
0133       * The user-assigned name of the report
0134       */
0135     QString m_name;
0136     /**
0137       * The user-assigned comment for the report, in case they want to make
0138       * additional notes for themselves about the report.
0139       */
0140     QString m_comment;
0141     /**
0142       * Where to group this report amongst the others in the UI view.  This
0143       * should be assigned by the UI system.
0144       */
0145     QString m_group;
0146     /**
0147       * How much detail to show in the accounts
0148       */
0149     eMyMoney::Report::DetailLevel m_detailLevel;
0150     /**
0151       * Whether to sum: all, sold, bought or owned value
0152       */
0153     eMyMoney::Report::InvestmentSum m_investmentSum;
0154     /**
0155       * Whether to show transactions or just totals.
0156       */
0157     bool m_hideTransactions;
0158     /**
0159       * Whether to convert all currencies to the base currency of the file (true).
0160       * If this is false, it's up to the report generator to decide how to handle
0161       * the currency.
0162       */
0163     bool m_convertCurrency;
0164     /**
0165       * Whether this is one of the users' favorite reports
0166       */
0167     bool m_favorite;
0168     /**
0169       * Whether this report should only include categories marked as "Tax"="Yes"
0170       */
0171     bool m_tax;
0172     /**
0173      * Whether budget differences should be propagated into the next period
0174      */
0175     bool m_propagateBudgetDifference;
0176     /**
0177       * Whether this report should only include investment accounts
0178       */
0179     bool m_investments;
0180     /**
0181       * Whether this report should only include loan accounts
0182       * Applies only to querytable reports.  Mutually exclusive with
0183       * m_investments.
0184       */
0185     bool m_loans;
0186     /**
0187       * What sort of algorithm should be used to run the report
0188       */
0189     eMyMoney::Report::ReportType m_reportType;
0190     /**
0191       * What sort of values should show up on the ROWS of this report
0192       */
0193     eMyMoney::Report::RowType m_rowType;
0194     /**
0195       * What sort of values should show up on the COLUMNS of this report,
0196       * in the case of a 'PivotTable' report.  Really this is used more as a
0197       * QUANTITY of months or days.  Whether it's months or days is determined
0198       * by m_columnsAreDays.
0199       */
0200     eMyMoney::Report::ColumnType m_columnType;
0201     /**
0202      * Whether the base unit of columns of this report is days.  Only applies to
0203      * 'PivotTable' reports.  If false, then columns are months or multiples thereof.
0204      */
0205     bool m_columnsAreDays;
0206     /**
0207        * What sort of values should show up on the COLUMNS of this report,
0208        * in the case of a 'QueryTable' report
0209        */
0210     eMyMoney::Report::QueryColumn m_queryColumns;
0211 
0212     /**
0213       * The plain-language description of what the date range should be locked
0214       * to.  'userDefined' means NO locking, in any other case, the report
0215       * will be adjusted to match the date lock.  So if the date lock is
0216       * 'currentMonth', the start and end dates of the underlying filter will
0217       * be updated to whatever the current month is.  This updating happens
0218       * automatically when the report is loaded, and should also be done
0219       * manually by calling updateDateFilter() before generating the report
0220       */
0221     eMyMoney::TransactionFilter::Date m_dateLock;
0222     /**
0223       * Which account groups should be included in the report.  This filter
0224       * is applied to the individual splits AFTER a transaction has been
0225       * matched using the underlying filter.
0226       */
0227     QList<eMyMoney::Account::Type> m_accountGroups;
0228     /**
0229       * Whether an account group filter has been set (see m_accountGroups)
0230       */
0231     bool m_accountGroupFilter;
0232     /**
0233       * What format should be used to draw this report as a chart
0234       */
0235     eMyMoney::Report::ChartType m_chartType;
0236     /**
0237       * What color palette should be used to draw this report as a chart
0238       */
0239     eMyMoney::Report::ChartPalette m_chartPalette;
0240     /**
0241       * Whether the value of individual data points should be drawn on the chart
0242       */
0243     bool m_chartDataLabels;
0244     /**
0245       * Whether grid lines should be drawn on the chart
0246       */
0247     bool m_chartCHGridLines;
0248     bool m_chartSVGridLines;
0249     /**
0250       * Whether this report should be shown as a chart by default (otherwise it
0251       * should be shown as a textual report)
0252       */
0253     bool m_chartByDefault;
0254     /**
0255      * Width of the chart lines
0256      */
0257     uint m_chartLineWidth;
0258 
0259     /**
0260       * Whether Y axis is logarithmic or linear
0261       */
0262     bool m_logYaxis;
0263 
0264     /**
0265       * Whether expenses should be plotted downwards
0266       */
0267     bool m_negExpenses;
0268 
0269     /**
0270       * Y data range
0271       */
0272     QString m_dataRangeStart;
0273     QString m_dataRangeEnd;
0274 
0275     /**
0276       * Y data range division
0277       */
0278     QString m_dataMajorTick;
0279     QString m_dataMinorTick;
0280 
0281     /**
0282       * Y labels precision
0283       */
0284     uint m_yLabelsPrecision;
0285 
0286     /**
0287       * Whether data range should be calculated automatically or is user defined
0288       */
0289     eMyMoney::Report::DataLock m_dataLock;
0290 
0291     /**
0292       * Whether to include scheduled transactions
0293       */
0294     bool m_includeSchedules;
0295     /**
0296       * Whether to include transfers.  Only applies to Income/Expense reports
0297       */
0298     bool m_includeTransfers;
0299     /**
0300       * The id of the budget associated with this report.
0301       */
0302     QString m_budgetId;
0303     /**
0304       * Whether this report should print the actual data to go along with
0305       * the budget.  This is only valid if the report has a budget.
0306       */
0307     bool m_includeBudgetActuals;
0308     /**
0309       * Whether this report should include all accounts and not only
0310       * accounts with transactions.
0311       */
0312     bool m_includeUnusedAccounts;
0313     /**
0314      * Whether this report should include columns for row totals
0315      */
0316     bool m_showRowTotals;
0317     /**
0318      * Whether this report should include rows for column totals
0319      */
0320     bool m_showColumnTotals;
0321     /**
0322      * Whether this report should include forecast balance
0323      */
0324     bool m_includeForecast;
0325     /**
0326      * Whether this report should include moving average
0327      */
0328     bool m_includeMovingAverage;
0329     /**
0330      * The amount of days that spans each moving average
0331      */
0332     int m_movingAverageDays;
0333     /**
0334      * Whether this report should include prices
0335      */
0336     bool m_includePrice;
0337     /**
0338      * Whether this report should include moving average prices
0339      */
0340     bool m_includeAveragePrice;
0341     /**
0342      * Make the actual and forecast lines display as one
0343      */
0344     bool m_mixedTime;
0345     /**
0346      * This stores the column for the current date
0347      * This value is calculated dynamically and thus it is not saved in the file
0348      */
0349     int m_currentDateColumn;
0350     /**
0351      * Time in days between the settlement date and the transaction date.
0352      */
0353     uint m_settlementPeriod;
0354     /**
0355      * Controls showing short-term and long-term capital gains.
0356      */
0357     bool m_showSTLTCapitalGains;
0358     /**
0359      * Date separating shot-term from long-term gains.
0360      */
0361     QDate m_tseparator;
0362 
0363     /**
0364       * This option is for investments reports only which
0365       * show prices instead of balances as all other reports do.
0366       * <p>
0367       * Select this option to include prices for the given period (week, month,
0368       * quarter, ...) only.
0369       * </p>
0370       * <p>
0371       * If this option is off the last existing price is shown for a period, if
0372       * it is on, in a table the value is '0' shown and in a chart a linear
0373       * interpolation for the missing values will be performed.
0374       * <br>Example:
0375       * <br>There are prices for January and March, but there is no price for
0376       * February.
0377       * <ul>
0378       * <li><b>OFF</b>: shows the price for February as the last price of
0379       * January
0380       * <li><b>ON</b>: in a table the value is '0', in a chart a linear
0381       * interpolation for the February-price will be performed
0382       * (so it makes a kind of average-value using the January- and the
0383       * March-price in the chart)
0384       * </ul>
0385       * </p>
0386       */
0387     bool m_skipZero;
0388 };
0389 
0390 #endif