Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/pivottable.cpp
Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Line(s) | 895 | switch ((*it_bacc).budgetLevel()) { | |||
---|---|---|---|---|---|
896 | case MyMoneyBudget::AccountGroup::eYearly: | 896 | case MyMoneyBudget::AccountGroup::eYearly: | ||
897 | // divide the single yearly value by 12 and place it in each column | 897 | // divide the single yearly value by 12 and place it in each column | ||
898 | value /= MyMoneyMoney(12, 1); | 898 | value /= MyMoneyMoney(12, 1); | ||
899 | case MyMoneyBudget::AccountGroup::eNone: | 899 | case MyMoneyBudget::AccountGroup::eNone: | ||
900 | case MyMoneyBudget::AccountGroup::eMax: | 900 | case MyMoneyBudget::AccountGroup::eMax: | ||
901 | case MyMoneyBudget::AccountGroup::eMonthly: | 901 | case MyMoneyBudget::AccountGroup::eMonthly: | ||
902 | // place the single monthly value in each column of the report | 902 | // place the single monthly value in each column of the report | ||
903 | // only add the value if columns are monthly or longer | 903 | // only add the value if columns are monthly or longer | ||
904 | if (m_config_f.columnType() == MyMoneyReport::eBiMonths | 904 | if (m_config_f.columnType() == MyMoneyReport::Column::BiMonths | ||
905 | || m_config_f.columnType() == MyMoneyReport::eMonths | 905 | || m_config_f.columnType() == MyMoneyReport::Column::Months | ||
906 | || m_config_f.columnType() == MyMoneyReport::eYears | 906 | || m_config_f.columnType() == MyMoneyReport::Column::Years | ||
907 | || m_config_f.columnType() == MyMoneyReport::eQuarters) { | 907 | || m_config_f.columnType() == MyMoneyReport::Column::Quarters) { | ||
908 | QDate budgetDate = budget.budgetStart(); | 908 | QDate budgetDate = budget.budgetStart(); | ||
909 | while (column < m_numColumns && budget.budgetStart().addYears(1) > budgetDate) { | 909 | while (column < m_numColumns && budget.budgetStart().addYears(1) > budgetDate) { | ||
910 | //only show budget values if the budget year and the column date match | 910 | //only show budget values if the budget year and the column date match | ||
911 | //no currency conversion is done here because that is done for all columns later | 911 | //no currency conversion is done here because that is done for all columns later | ||
912 | if (budgetDate > columnDate(column)) { | 912 | if (budgetDate > columnDate(column)) { | ||
913 | ++column; | 913 | ++column; | ||
914 | } else { | 914 | } else { | ||
915 | if (budgetDate >= m_beginDate.addDays(-m_beginDate.day() + 1) | 915 | if (budgetDate >= m_beginDate.addDays(-m_beginDate.day() + 1) | ||
Show All 11 Lines | 925 | case MyMoneyBudget::AccountGroup::eMonthByMonth: | |||
927 | // budget periods are supposed to come in order just like columns | 927 | // budget periods are supposed to come in order just like columns | ||
928 | { | 928 | { | ||
929 | QMap<QDate, MyMoneyBudget::PeriodGroup>::const_iterator it_period = periods.begin(); | 929 | QMap<QDate, MyMoneyBudget::PeriodGroup>::const_iterator it_period = periods.begin(); | ||
930 | while (it_period != periods.end() && column < m_numColumns) { | 930 | while (it_period != periods.end() && column < m_numColumns) { | ||
931 | if ((*it_period).startDate() > columnDate(column)) { | 931 | if ((*it_period).startDate() > columnDate(column)) { | ||
932 | ++column; | 932 | ++column; | ||
933 | } else { | 933 | } else { | ||
934 | switch (m_config_f.columnType()) { | 934 | switch (m_config_f.columnType()) { | ||
935 | case MyMoneyReport::eYears: | 935 | case MyMoneyReport::Column::Years: | ||
936 | case MyMoneyReport::eBiMonths: | 936 | case MyMoneyReport::Column::BiMonths: | ||
937 | case MyMoneyReport::eQuarters: | 937 | case MyMoneyReport::Column::Quarters: | ||
938 | case MyMoneyReport::eMonths: { | 938 | case MyMoneyReport::Column::Months: { | ||
939 | if ((*it_period).startDate() >= m_beginDate.addDays(-m_beginDate.day() + 1) | 939 | if ((*it_period).startDate() >= m_beginDate.addDays(-m_beginDate.day() + 1) | ||
940 | && (*it_period).startDate() <= m_endDate.addDays(m_endDate.daysInMonth() - m_endDate.day()) | 940 | && (*it_period).startDate() <= m_endDate.addDays(m_endDate.daysInMonth() - m_endDate.day()) | ||
941 | && (*it_period).startDate() > (columnDate(column).addMonths(-m_config_f.columnType()))) { | 941 | && (*it_period).startDate() > (columnDate(column).addMonths(-m_config_f.columnType()))) { | ||
942 | //no currency conversion is done here because that is done for all columns later | 942 | //no currency conversion is done here because that is done for all columns later | ||
943 | value = (*it_period).amount() * reverse; | 943 | value = (*it_period).amount() * reverse; | ||
944 | assignCell(outergroup, splitAccount, column, value, true /*budget*/); | 944 | assignCell(outergroup, splitAccount, column, value, true /*budget*/); | ||
945 | } | 945 | } | ||
946 | ++it_period; | 946 | ++it_period; | ||
▲ Show 20 Lines • Show All 1127 Lines • ▼ Show 20 Line(s) | 2069 | { | |||
2074 | while (it_outergroup != m_grid.end()) { | 2074 | while (it_outergroup != m_grid.end()) { | ||
2075 | PivotOuterGroup::iterator it_innergroup = (*it_outergroup).begin(); | 2075 | PivotOuterGroup::iterator it_innergroup = (*it_outergroup).begin(); | ||
2076 | while (it_innergroup != (*it_outergroup).end()) { | 2076 | while (it_innergroup != (*it_outergroup).end()) { | ||
2077 | PivotInnerGroup::iterator it_row = (*it_innergroup).begin(); | 2077 | PivotInnerGroup::iterator it_row = (*it_innergroup).begin(); | ||
2078 | while (it_row != (*it_innergroup).end()) { | 2078 | while (it_row != (*it_innergroup).end()) { | ||
2079 | int column = 1; | 2079 | int column = 1; | ||
2080 | 2080 | | |||
2081 | //check whether columns are days or months | 2081 | //check whether columns are days or months | ||
2082 | if (m_config_f.columnType() == MyMoneyReport::eDays) { | 2082 | if (m_config_f.columnType() == MyMoneyReport::Column::Days) { | ||
2083 | while (column < m_numColumns) { | 2083 | while (column < m_numColumns) { | ||
2084 | MyMoneyMoney totalPrice = MyMoneyMoney(); | 2084 | MyMoneyMoney totalPrice = MyMoneyMoney(); | ||
2085 | 2085 | | |||
2086 | QDate averageStart = columnDate(column).addDays(-delta); | 2086 | QDate averageStart = columnDate(column).addDays(-delta); | ||
2087 | QDate averageEnd = columnDate(column).addDays(delta); | 2087 | QDate averageEnd = columnDate(column).addDays(delta); | ||
2088 | for (QDate averageDate = averageStart; averageDate <= averageEnd; averageDate = averageDate.addDays(1)) { | 2088 | for (QDate averageDate = averageStart; averageDate <= averageEnd; averageDate = averageDate.addDays(1)) { | ||
2089 | if (m_config_f.isConvertCurrency()) { | 2089 | if (m_config_f.isConvertCurrency()) { | ||
2090 | totalPrice += it_row.key().deepCurrencyPrice(averageDate) * it_row.key().baseCurrencyPrice(averageDate); | 2090 | totalPrice += it_row.key().deepCurrencyPrice(averageDate) * it_row.key().baseCurrencyPrice(averageDate); | ||
Show All 14 Lines | |||||
2105 | } | 2105 | } | ||
2106 | } else { | 2106 | } else { | ||
2107 | //if columns are months | 2107 | //if columns are months | ||
2108 | while (column < m_numColumns) { | 2108 | while (column < m_numColumns) { | ||
2109 | QDate averageStart = columnDate(column); | 2109 | QDate averageStart = columnDate(column); | ||
2110 | 2110 | | |||
2111 | //set the right start date depending on the column type | 2111 | //set the right start date depending on the column type | ||
2112 | switch (m_config_f.columnType()) { | 2112 | switch (m_config_f.columnType()) { | ||
2113 | case MyMoneyReport::eYears: { | 2113 | case MyMoneyReport::Column::Years: { | ||
2114 | averageStart = QDate(columnDate(column).year(), 1, 1); | 2114 | averageStart = QDate(columnDate(column).year(), 1, 1); | ||
2115 | break; | 2115 | break; | ||
2116 | } | 2116 | } | ||
2117 | case MyMoneyReport::eBiMonths: { | 2117 | case MyMoneyReport::Column::BiMonths: { | ||
2118 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1).addMonths(-1); | 2118 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1).addMonths(-1); | ||
2119 | break; | 2119 | break; | ||
2120 | } | 2120 | } | ||
2121 | case MyMoneyReport::eQuarters: { | 2121 | case MyMoneyReport::Column::Quarters: { | ||
2122 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1).addMonths(-1); | 2122 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1).addMonths(-1); | ||
2123 | break; | 2123 | break; | ||
2124 | } | 2124 | } | ||
2125 | case MyMoneyReport::eMonths: { | 2125 | case MyMoneyReport::Column::Months: { | ||
2126 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1); | 2126 | averageStart = QDate(columnDate(column).year(), columnDate(column).month(), 1); | ||
2127 | break; | 2127 | break; | ||
2128 | } | 2128 | } | ||
2129 | case MyMoneyReport::eWeeks: { | 2129 | case MyMoneyReport::Column::Weeks: { | ||
2130 | averageStart = columnDate(column).addDays(-columnDate(column).dayOfWeek() + 1); | 2130 | averageStart = columnDate(column).addDays(-columnDate(column).dayOfWeek() + 1); | ||
2131 | break; | 2131 | break; | ||
2132 | } | 2132 | } | ||
2133 | default: | 2133 | default: | ||
2134 | break; | 2134 | break; | ||
2135 | } | 2135 | } | ||
2136 | 2136 | | |||
2137 | //gather the actual data and calculate the average | 2137 | //gather the actual data and calculate the average | ||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |