Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/pivottable.cpp
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 98 | { | |||
---|---|---|---|---|---|
129 | m_numColumns = columnValue(m_endDate) - columnValue(m_beginDate) + 2; | 129 | m_numColumns = columnValue(m_endDate) - columnValue(m_beginDate) + 2; | ||
130 | 130 | | |||
131 | //Load what types of row the report is going to show | 131 | //Load what types of row the report is going to show | ||
132 | loadRowTypeList(); | 132 | loadRowTypeList(); | ||
133 | 133 | | |||
134 | // | 134 | // | ||
135 | // Initialize outer groups of the grid | 135 | // Initialize outer groups of the grid | ||
136 | // | 136 | // | ||
137 | if (m_config_f.rowType() == MyMoneyReport::eAssetLiability) { | 137 | if (m_config_f.rowType() == MyMoneyReport::Row::AssetLiability) { | ||
138 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset), PivotOuterGroup(m_numColumns)); | 138 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset), PivotOuterGroup(m_numColumns)); | ||
139 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder, true /* inverted */)); | 139 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder, true /* inverted */)); | ||
140 | } else { | 140 | } else { | ||
141 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 2)); | 141 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 2)); | ||
142 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 1, true /* inverted */)); | 142 | m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 1, true /* inverted */)); | ||
143 | // | 143 | // | ||
144 | // Create rows for income/expense reports with all accounts included | 144 | // Create rows for income/expense reports with all accounts included | ||
145 | // | 145 | // | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 200 | while (it_schedule != schedules.constEnd()) { | |||
231 | } | 231 | } | ||
232 | 232 | | |||
233 | ++it_schedule; | 233 | ++it_schedule; | ||
234 | } | 234 | } | ||
235 | } | 235 | } | ||
236 | 236 | | |||
237 | // whether asset & liability transactions are actually to be considered | 237 | // whether asset & liability transactions are actually to be considered | ||
238 | // transfers | 238 | // transfers | ||
239 | bool al_transfers = (m_config_f.rowType() == MyMoneyReport::eExpenseIncome) && (m_config_f.isIncludingTransfers()); | 239 | bool al_transfers = (m_config_f.rowType() == MyMoneyReport::Row::ExpenseIncome) && (m_config_f.isIncludingTransfers()); | ||
240 | 240 | | |||
241 | //this is to store balance for loan accounts when not included in the report | 241 | //this is to store balance for loan accounts when not included in the report | ||
242 | QMap<QString, MyMoneyMoney> loanBalances; | 242 | QMap<QString, MyMoneyMoney> loanBalances; | ||
243 | 243 | | |||
244 | QList<MyMoneyTransaction>::const_iterator it_transaction = transactions.constBegin(); | 244 | QList<MyMoneyTransaction>::const_iterator it_transaction = transactions.constBegin(); | ||
245 | int colofs = columnValue(m_beginDate) - 1; | 245 | int colofs = columnValue(m_beginDate) - 1; | ||
246 | while (it_transaction != transactions.constEnd()) { | 246 | while (it_transaction != transactions.constEnd()) { | ||
247 | MyMoneyTransaction tx = (*it_transaction); | 247 | MyMoneyTransaction tx = (*it_transaction); | ||
▲ Show 20 Lines • Show All 893 Lines • ▼ Show 20 Line(s) | 1088 | while (it_innergroup != (*it_outergroup).end()) { | |||
1141 | 1141 | | |||
1142 | ++it_innergroup; | 1142 | ++it_innergroup; | ||
1143 | } | 1143 | } | ||
1144 | 1144 | | |||
1145 | // | 1145 | // | ||
1146 | // Outer Row Group Totals | 1146 | // Outer Row Group Totals | ||
1147 | // | 1147 | // | ||
1148 | 1148 | | |||
1149 | const bool isIncomeExpense = (m_config_f.rowType() == MyMoneyReport::eExpenseIncome); | 1149 | const bool isIncomeExpense = (m_config_f.rowType() == MyMoneyReport::Row::ExpenseIncome); | ||
1150 | const bool invert_total = (*it_outergroup).m_inverted; | 1150 | const bool invert_total = (*it_outergroup).m_inverted; | ||
1151 | int column = 1; | 1151 | int column = 1; | ||
1152 | while (column < m_numColumns) { | 1152 | while (column < m_numColumns) { | ||
1153 | for (int i = 0; i < m_rowTypeList.size(); ++i) { | 1153 | for (int i = 0; i < m_rowTypeList.size(); ++i) { | ||
1154 | if (m_grid.m_total[ m_rowTypeList[i] ].count() <= column) | 1154 | if (m_grid.m_total[ m_rowTypeList[i] ].count() <= column) | ||
1155 | throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count())); | 1155 | throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count())); | ||
1156 | 1156 | | |||
1157 | //calculate actual totals | 1157 | //calculate actual totals | ||
▲ Show 20 Lines • Show All 809 Lines • ▼ Show 20 Line(s) | 1950 | { | |||
1967 | 1967 | | |||
1968 | //adjust history dates if beginning date is before today | 1968 | //adjust history dates if beginning date is before today | ||
1969 | if (m_beginDate < QDate::currentDate()) { | 1969 | if (m_beginDate < QDate::currentDate()) { | ||
1970 | forecast.setHistoryEndDate(m_beginDate.addDays(-1)); | 1970 | forecast.setHistoryEndDate(m_beginDate.addDays(-1)); | ||
1971 | forecast.setHistoryStartDate(forecast.historyEndDate().addDays(-forecast.accountsCycle()*forecast.forecastCycles())); | 1971 | forecast.setHistoryStartDate(forecast.historyEndDate().addDays(-forecast.accountsCycle()*forecast.forecastCycles())); | ||
1972 | } | 1972 | } | ||
1973 | 1973 | | |||
1974 | //run forecast | 1974 | //run forecast | ||
1975 | if (m_config_f.rowType() == MyMoneyReport::eAssetLiability) { //asset and liability | 1975 | if (m_config_f.rowType() == MyMoneyReport::Row::AssetLiability) { //asset and liability | ||
1976 | forecast.doForecast(); | 1976 | forecast.doForecast(); | ||
1977 | } else { //income and expenses | 1977 | } else { //income and expenses | ||
1978 | MyMoneyBudget budget; | 1978 | MyMoneyBudget budget; | ||
1979 | forecast.createBudget(budget, m_beginDate.addYears(-1), m_beginDate.addDays(-1), m_beginDate, m_endDate, false); | 1979 | forecast.createBudget(budget, m_beginDate.addYears(-1), m_beginDate.addDays(-1), m_beginDate, m_endDate, false); | ||
1980 | } | 1980 | } | ||
1981 | 1981 | | |||
1982 | //go through the data and add forecast | 1982 | //go through the data and add forecast | ||
1983 | PivotGrid::iterator it_outergroup = m_grid.begin(); | 1983 | PivotGrid::iterator it_outergroup = m_grid.begin(); | ||
▲ Show 20 Lines • Show All 311 Lines • Show Last 20 Lines |