Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/pivottabletest.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 89 | { | |||
---|---|---|---|---|---|
90 | file->detachStorage(storage); | 90 | file->detachStorage(storage); | ||
91 | delete storage; | 91 | delete storage; | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | void PivotTableTest::testNetWorthSingle() | 94 | void PivotTableTest::testNetWorthSingle() | ||
95 | { | 95 | { | ||
96 | try { | 96 | try { | ||
97 | MyMoneyReport filter; | 97 | MyMoneyReport filter; | ||
98 | filter.setRowType(MyMoneyReport::eAssetLiability); | 98 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
99 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 7, 1).addDays(-1)); | 99 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 7, 1).addDays(-1)); | ||
100 | XMLandback(filter); | 100 | XMLandback(filter); | ||
101 | PivotTable networth_f(filter); | 101 | PivotTable networth_f(filter); | ||
102 | writeTabletoCSV(networth_f); | 102 | writeTabletoCSV(networth_f); | ||
103 | 103 | | |||
104 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][acChecking][eActual][5] == moCheckingOpen); | 104 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][acChecking][eActual][5] == moCheckingOpen); | ||
105 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][acChecking][eActual][6] == moCheckingOpen); | 105 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][acChecking][eActual][6] == moCheckingOpen); | ||
106 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][5] == moCheckingOpen); | 106 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][5] == moCheckingOpen); | ||
107 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | 107 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | ||
108 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == moZero); | 108 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == moZero); | ||
109 | QVERIFY(networth_f.m_grid.m_total[eActual][5] == moCheckingOpen); | 109 | QVERIFY(networth_f.m_grid.m_total[eActual][5] == moCheckingOpen); | ||
110 | QVERIFY(networth_f.m_grid.m_total[eActual][6] == moCheckingOpen); | 110 | QVERIFY(networth_f.m_grid.m_total[eActual][6] == moCheckingOpen); | ||
111 | } catch (const MyMoneyException &e) { | 111 | } catch (const MyMoneyException &e) { | ||
112 | QFAIL(qPrintable(e.what())); | 112 | QFAIL(qPrintable(e.what())); | ||
113 | } | 113 | } | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | void PivotTableTest::testNetWorthOfsetting() | 116 | void PivotTableTest::testNetWorthOfsetting() | ||
117 | { | 117 | { | ||
118 | // Test the net worth report to make sure it picks up the opening balance for two | 118 | // Test the net worth report to make sure it picks up the opening balance for two | ||
119 | // accounts opened during the period of the report, one asset & one liability. Test | 119 | // accounts opened during the period of the report, one asset & one liability. Test | ||
120 | // that it calculates the totals correctly. | 120 | // that it calculates the totals correctly. | ||
121 | 121 | | |||
122 | MyMoneyReport filter; | 122 | MyMoneyReport filter; | ||
123 | filter.setRowType(MyMoneyReport::eAssetLiability); | 123 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
124 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 124 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
125 | XMLandback(filter); | 125 | XMLandback(filter); | ||
126 | PivotTable networth_f(filter); | 126 | PivotTable networth_f(filter); | ||
127 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"][acCredit][eActual][7] == -moCreditOpen); | 127 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"][acCredit][eActual][7] == -moCreditOpen); | ||
128 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | 128 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | ||
129 | QVERIFY(networth_f.m_grid.m_total[eActual][12] == moCheckingOpen + moCreditOpen); | 129 | QVERIFY(networth_f.m_grid.m_total[eActual][12] == moCheckingOpen + moCreditOpen); | ||
130 | 130 | | |||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | void PivotTableTest::testNetWorthOpeningPrior() | 133 | void PivotTableTest::testNetWorthOpeningPrior() | ||
134 | { | 134 | { | ||
135 | // Test the net worth report to make sure it's picking up opening balances PRIOR to | 135 | // Test the net worth report to make sure it's picking up opening balances PRIOR to | ||
136 | // the period of the report. | 136 | // the period of the report. | ||
137 | 137 | | |||
138 | MyMoneyReport filter; | 138 | MyMoneyReport filter; | ||
139 | filter.setRowType(MyMoneyReport::eAssetLiability); | 139 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
140 | filter.setDateFilter(QDate(2005, 8, 1), QDate(2005, 12, 31)); | 140 | filter.setDateFilter(QDate(2005, 8, 1), QDate(2005, 12, 31)); | ||
141 | filter.setName("Net Worth Opening Prior 1"); | 141 | filter.setName("Net Worth Opening Prior 1"); | ||
142 | XMLandback(filter); | 142 | XMLandback(filter); | ||
143 | PivotTable networth_f(filter); | 143 | PivotTable networth_f(filter); | ||
144 | writeTabletoCSV(networth_f); | 144 | writeTabletoCSV(networth_f); | ||
145 | 145 | | |||
146 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][0] == -moCreditOpen); | 146 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][0] == -moCreditOpen); | ||
147 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][0] == moCheckingOpen); | 147 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][0] == moCheckingOpen); | ||
Show All 20 Lines | |||||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | void PivotTableTest::testNetWorthDateFilter() | 170 | void PivotTableTest::testNetWorthDateFilter() | ||
171 | { | 171 | { | ||
172 | // Test a net worth report whose period is prior to the time any accounts are open, | 172 | // Test a net worth report whose period is prior to the time any accounts are open, | ||
173 | // so the report should be zero. | 173 | // so the report should be zero. | ||
174 | 174 | | |||
175 | MyMoneyReport filter; | 175 | MyMoneyReport filter; | ||
176 | filter.setRowType(MyMoneyReport::eAssetLiability); | 176 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
177 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 2, 1).addDays(-1)); | 177 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 2, 1).addDays(-1)); | ||
178 | XMLandback(filter); | 178 | XMLandback(filter); | ||
179 | PivotTable networth_f(filter); | 179 | PivotTable networth_f(filter); | ||
180 | QVERIFY(networth_f.m_grid.m_total[eActual][1] == moZero); | 180 | QVERIFY(networth_f.m_grid.m_total[eActual][1] == moZero); | ||
181 | 181 | | |||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | void PivotTableTest::testSpendingEmpty() | 184 | void PivotTableTest::testSpendingEmpty() | ||
185 | { | 185 | { | ||
186 | // test a spending report with no entries | 186 | // test a spending report with no entries | ||
187 | 187 | | |||
188 | MyMoneyReport filter; | 188 | MyMoneyReport filter; | ||
189 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 189 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
190 | XMLandback(filter); | 190 | XMLandback(filter); | ||
191 | PivotTable spending_f1(filter); | 191 | PivotTable spending_f1(filter); | ||
192 | QVERIFY(spending_f1.m_grid.m_total[eActual].m_total == moZero); | 192 | QVERIFY(spending_f1.m_grid.m_total[eActual].m_total == moZero); | ||
193 | 193 | | |||
194 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 194 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
195 | PivotTable spending_f2(filter); | 195 | PivotTable spending_f2(filter); | ||
196 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moZero); | 196 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moZero); | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | void PivotTableTest::testSingleTransaction() | 199 | void PivotTableTest::testSingleTransaction() | ||
200 | { | 200 | { | ||
201 | // Test a single transaction | 201 | // Test a single transaction | ||
202 | TransactionHelper t(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 202 | TransactionHelper t(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
203 | 203 | | |||
204 | MyMoneyReport filter; | 204 | MyMoneyReport filter; | ||
205 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 205 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
206 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 206 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
207 | filter.setName("Spending with Single Transaction.html"); | 207 | filter.setName("Spending with Single Transaction.html"); | ||
208 | XMLandback(filter); | 208 | XMLandback(filter); | ||
209 | PivotTable spending_f(filter); | 209 | PivotTable spending_f(filter); | ||
210 | writeTabletoHTML(spending_f, "Spending with Single Transaction.html"); | 210 | writeTabletoHTML(spending_f, "Spending with Single Transaction.html"); | ||
211 | 211 | | |||
212 | QVERIFY(spending_f.m_grid["Expense"]["Solo"][acSolo][eActual][2] == moSolo); | 212 | QVERIFY(spending_f.m_grid["Expense"]["Solo"][acSolo][eActual][2] == moSolo); | ||
213 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][2] == moSolo); | 213 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][2] == moSolo); | ||
214 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][1] == moZero); | 214 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][1] == moZero); | ||
215 | QVERIFY(spending_f.m_grid.m_total[eActual][2] == (-moSolo)); | 215 | QVERIFY(spending_f.m_grid.m_total[eActual][2] == (-moSolo)); | ||
216 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moSolo)); | 216 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moSolo)); | ||
217 | 217 | | |||
218 | filter.clear(); | 218 | filter.clear(); | ||
219 | filter.setRowType(MyMoneyReport::eAssetLiability); | 219 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
220 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 220 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
221 | XMLandback(filter); | 221 | XMLandback(filter); | ||
222 | PivotTable networth_f(filter); | 222 | PivotTable networth_f(filter); | ||
223 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][2] == (moCheckingOpen - moSolo)); | 223 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][2] == (moCheckingOpen - moSolo)); | ||
224 | } | 224 | } | ||
225 | 225 | | |||
226 | void PivotTableTest::testSubAccount() | 226 | void PivotTableTest::testSubAccount() | ||
227 | { | 227 | { | ||
228 | // Test a sub-account with a value, under an account with a value | 228 | // Test a sub-account with a value, under an account with a value | ||
229 | 229 | | |||
230 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 230 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
231 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 231 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
232 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 232 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
233 | 233 | | |||
234 | MyMoneyReport filter; | 234 | MyMoneyReport filter; | ||
235 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 235 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
236 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 236 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
237 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | 237 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | ||
238 | filter.setName("Spending with Sub-Account"); | 238 | filter.setName("Spending with Sub-Account"); | ||
239 | XMLandback(filter); | 239 | XMLandback(filter); | ||
240 | PivotTable spending_f(filter); | 240 | PivotTable spending_f(filter); | ||
241 | writeTabletoHTML(spending_f, "Spending with Sub-Account.html"); | 241 | writeTabletoHTML(spending_f, "Spending with Sub-Account.html"); | ||
242 | 242 | | |||
243 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][3] == moParent); | 243 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][3] == moParent); | ||
244 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acChild][eActual][3] == moChild); | 244 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acChild][eActual][3] == moChild); | ||
245 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][3] == moParent + moChild); | 245 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][3] == moParent + moChild); | ||
246 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moZero); | 246 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moZero); | ||
247 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual].m_total == moParent + moChild); | 247 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual].m_total == moParent + moChild); | ||
248 | QVERIFY(spending_f.m_grid.m_total[eActual][3] == (-moParent - moChild)); | 248 | QVERIFY(spending_f.m_grid.m_total[eActual][3] == (-moParent - moChild)); | ||
249 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moParent - moChild)); | 249 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moParent - moChild)); | ||
250 | 250 | | |||
251 | filter.clear(); | 251 | filter.clear(); | ||
252 | filter.setRowType(MyMoneyReport::eAssetLiability); | 252 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
253 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 253 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
254 | filter.setName("Net Worth with Sub-Account"); | 254 | filter.setName("Net Worth with Sub-Account"); | ||
255 | XMLandback(filter); | 255 | XMLandback(filter); | ||
256 | PivotTable networth_f(filter); | 256 | PivotTable networth_f(filter); | ||
257 | writeTabletoHTML(networth_f, "Net Worth with Sub-Account.html"); | 257 | writeTabletoHTML(networth_f, "Net Worth with Sub-Account.html"); | ||
258 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][3] == moParent + moChild - moCreditOpen); | 258 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][3] == moParent + moChild - moCreditOpen); | ||
259 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == -moParent - moChild + moCreditOpen + moCheckingOpen); | 259 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == -moParent - moChild + moCreditOpen + moCheckingOpen); | ||
260 | 260 | | |||
261 | } | 261 | } | ||
262 | 262 | | |||
263 | void PivotTableTest::testFilterIEvsIE() | 263 | void PivotTableTest::testFilterIEvsIE() | ||
264 | { | 264 | { | ||
265 | // Test that removing an income/spending account will remove the entry from an income/spending report | 265 | // Test that removing an income/spending account will remove the entry from an income/spending report | ||
266 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 266 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
267 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 267 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
268 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 268 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
269 | 269 | | |||
270 | MyMoneyReport filter; | 270 | MyMoneyReport filter; | ||
271 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 271 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
272 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 272 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
273 | filter.addCategory(acChild); | 273 | filter.addCategory(acChild); | ||
274 | filter.addCategory(acSolo); | 274 | filter.addCategory(acSolo); | ||
275 | XMLandback(filter); | 275 | XMLandback(filter); | ||
276 | PivotTable spending_f(filter); | 276 | PivotTable spending_f(filter); | ||
277 | 277 | | |||
278 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][3] == moChild); | 278 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][3] == moChild); | ||
279 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moSolo); | 279 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moSolo); | ||
280 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moChild); | 280 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moChild); | ||
281 | 281 | | |||
282 | } | 282 | } | ||
283 | 283 | | |||
284 | void PivotTableTest::testFilterALvsAL() | 284 | void PivotTableTest::testFilterALvsAL() | ||
285 | { | 285 | { | ||
286 | // Test that removing an asset/liability account will remove the entry from an asset/liability report | 286 | // Test that removing an asset/liability account will remove the entry from an asset/liability report | ||
287 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 287 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
288 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 288 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
289 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 289 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
290 | 290 | | |||
291 | MyMoneyReport filter; | 291 | MyMoneyReport filter; | ||
292 | filter.setRowType(MyMoneyReport::eAssetLiability); | 292 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
293 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 293 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
294 | filter.addAccount(acChecking); | 294 | filter.addAccount(acChecking); | ||
295 | filter.addCategory(acChild); | 295 | filter.addCategory(acChild); | ||
296 | filter.addCategory(acSolo); | 296 | filter.addCategory(acSolo); | ||
297 | XMLandback(filter); | 297 | XMLandback(filter); | ||
298 | PivotTable networth_f(filter); | 298 | PivotTable networth_f(filter); | ||
299 | QVERIFY(networth_f.m_grid.m_total[eActual][3] == -moSolo + moCheckingOpen); | 299 | QVERIFY(networth_f.m_grid.m_total[eActual][3] == -moSolo + moCheckingOpen); | ||
300 | } | 300 | } | ||
301 | 301 | | |||
302 | void PivotTableTest::testFilterALvsIE() | 302 | void PivotTableTest::testFilterALvsIE() | ||
303 | { | 303 | { | ||
304 | // Test that removing an asset/liability account will remove the entry from an income/spending report | 304 | // Test that removing an asset/liability account will remove the entry from an income/spending report | ||
305 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 305 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
306 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 306 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
307 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 307 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
308 | 308 | | |||
309 | MyMoneyReport filter; | 309 | MyMoneyReport filter; | ||
310 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 310 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
311 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 311 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
312 | filter.addAccount(acChecking); | 312 | filter.addAccount(acChecking); | ||
313 | QVERIFY(file->transactionList(filter).count() == 1); | 313 | QVERIFY(file->transactionList(filter).count() == 1); | ||
314 | 314 | | |||
315 | XMLandback(filter); | 315 | XMLandback(filter); | ||
316 | PivotTable spending_f(filter); | 316 | PivotTable spending_f(filter); | ||
317 | 317 | | |||
318 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][3] == moZero); | 318 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][3] == moZero); | ||
319 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moSolo); | 319 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moSolo); | ||
320 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 320 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | void PivotTableTest::testFilterAllvsIE() | 323 | void PivotTableTest::testFilterAllvsIE() | ||
324 | { | 324 | { | ||
325 | // Test that removing an asset/liability account AND an income/expense | 325 | // Test that removing an asset/liability account AND an income/expense | ||
326 | // category will remove the entry from an income/spending report | 326 | // category will remove the entry from an income/spending report | ||
327 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 327 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
328 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 328 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
329 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 329 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
330 | 330 | | |||
331 | MyMoneyReport filter; | 331 | MyMoneyReport filter; | ||
332 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 332 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
333 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 333 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
334 | filter.addAccount(acCredit); | 334 | filter.addAccount(acCredit); | ||
335 | filter.addCategory(acChild); | 335 | filter.addCategory(acChild); | ||
336 | PivotTable spending_f(filter); | 336 | PivotTable spending_f(filter); | ||
337 | 337 | | |||
338 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moZero); | 338 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moZero); | ||
339 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][3] == moChild); | 339 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][3] == moChild); | ||
340 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | 340 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 408 | #if 0 | |||
410 | g.open(QIODevice::WriteOnly); | 410 | g.open(QIODevice::WriteOnly); | ||
411 | MyMoneyStorageXML xml; | 411 | MyMoneyStorageXML xml; | ||
412 | IMyMoneyStorageFormat& interface = xml; | 412 | IMyMoneyStorageFormat& interface = xml; | ||
413 | interface.writeFile(&g, dynamic_cast<IMyMoneySerialize*>(MyMoneyFile::instance()->storage())); | 413 | interface.writeFile(&g, dynamic_cast<IMyMoneySerialize*>(MyMoneyFile::instance()->storage())); | ||
414 | g.close(); | 414 | g.close(); | ||
415 | #endif | 415 | #endif | ||
416 | 416 | | |||
417 | MyMoneyReport filter; | 417 | MyMoneyReport filter; | ||
418 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 418 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
419 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 419 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
420 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | 420 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | ||
421 | filter.setConvertCurrency(true); | 421 | filter.setConvertCurrency(true); | ||
422 | filter.setName("Multiple Currency Spending Rerport (with currency conversion)"); | 422 | filter.setName("Multiple Currency Spending Rerport (with currency conversion)"); | ||
423 | XMLandback(filter); | 423 | XMLandback(filter); | ||
424 | 424 | | |||
425 | PivotTable spending_f(filter); | 425 | PivotTable spending_f(filter); | ||
426 | 426 | | |||
Show All 24 Lines | |||||
451 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acCanCash][eActual][4] == (moCanTransaction)); | 451 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acCanCash][eActual][4] == (moCanTransaction)); | ||
452 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][2] == (moJpyTransaction)); | 452 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][2] == (moJpyTransaction)); | ||
453 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][3] == (moJpyTransaction)); | 453 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][3] == (moJpyTransaction)); | ||
454 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][4] == (moJpyTransaction)); | 454 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][4] == (moJpyTransaction)); | ||
455 | 455 | | |||
456 | filter.setConvertCurrency(true); | 456 | filter.setConvertCurrency(true); | ||
457 | filter.clear(); | 457 | filter.clear(); | ||
458 | filter.setName("Multiple currency net worth"); | 458 | filter.setName("Multiple currency net worth"); | ||
459 | filter.setRowType(MyMoneyReport::eAssetLiability); | 459 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
460 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 460 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
461 | XMLandback(filter); | 461 | XMLandback(filter); | ||
462 | PivotTable networth_f(filter); | 462 | PivotTable networth_f(filter); | ||
463 | writeTabletoCSV(networth_f); | 463 | writeTabletoCSV(networth_f); | ||
464 | 464 | | |||
465 | // test single foreign currency | 465 | // test single foreign currency | ||
466 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][acCanChecking][eActual][1] == (moCanOpening*moCanPrice)); | 466 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][acCanChecking][eActual][1] == (moCanOpening*moCanPrice)); | ||
467 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][acCanChecking][eActual][2] == ((moCanOpening - moCanTransaction)*moCanPrice)); | 467 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][acCanChecking][eActual][2] == ((moCanOpening - moCanTransaction)*moCanPrice)); | ||
Show All 23 Lines | 490 | { | |||
491 | // test more advanced filtering capabilities | 491 | // test more advanced filtering capabilities | ||
492 | 492 | | |||
493 | // amount | 493 | // amount | ||
494 | { | 494 | { | ||
495 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 495 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
496 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 496 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
497 | 497 | | |||
498 | MyMoneyReport filter; | 498 | MyMoneyReport filter; | ||
499 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 499 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
500 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 500 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
501 | filter.setAmountFilter(moChild, moChild); | 501 | filter.setAmountFilter(moChild, moChild); | ||
502 | XMLandback(filter); | 502 | XMLandback(filter); | ||
503 | PivotTable spending_f(filter); | 503 | PivotTable spending_f(filter); | ||
504 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | 504 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | ||
505 | } | 505 | } | ||
506 | 506 | | |||
507 | // payee (specific) | 507 | // payee (specific) | ||
508 | { | 508 | { | ||
509 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 509 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
510 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 510 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
511 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 511 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
512 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | 512 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | ||
513 | 513 | | |||
514 | MyMoneyReport filter; | 514 | MyMoneyReport filter; | ||
515 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 515 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
516 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 516 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
517 | filter.addPayee(MyMoneyFile::instance()->payeeByName("Thomas Baumgart").id()); | 517 | filter.addPayee(MyMoneyFile::instance()->payeeByName("Thomas Baumgart").id()); | ||
518 | filter.setName("Spending with Payee Filter"); | 518 | filter.setName("Spending with Payee Filter"); | ||
519 | XMLandback(filter); | 519 | XMLandback(filter); | ||
520 | PivotTable spending_f(filter); | 520 | PivotTable spending_f(filter); | ||
521 | writeTabletoHTML(spending_f, "Spending with Payee Filter.html"); | 521 | writeTabletoHTML(spending_f, "Spending with Payee Filter.html"); | ||
522 | 522 | | |||
523 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][11] == moThomas); | 523 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][11] == moThomas); | ||
524 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moThomas); | 524 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moThomas); | ||
525 | } | 525 | } | ||
526 | // payee (no payee) | 526 | // payee (no payee) | ||
527 | { | 527 | { | ||
528 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 528 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
529 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 529 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
530 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 530 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
531 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moNoPayee, acCredit, acParent, QString(), QString()); | 531 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moNoPayee, acCredit, acParent, QString(), QString()); | ||
532 | 532 | | |||
533 | MyMoneyReport filter; | 533 | MyMoneyReport filter; | ||
534 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 534 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
535 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 535 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
536 | filter.addPayee(QString()); | 536 | filter.addPayee(QString()); | ||
537 | XMLandback(filter); | 537 | XMLandback(filter); | ||
538 | PivotTable spending_f(filter); | 538 | PivotTable spending_f(filter); | ||
539 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][11] == moNoPayee); | 539 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][acParent][eActual][11] == moNoPayee); | ||
540 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moNoPayee); | 540 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moNoPayee); | ||
541 | } | 541 | } | ||
542 | 542 | | |||
543 | // text | 543 | // text | ||
544 | { | 544 | { | ||
545 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 545 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
546 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 546 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
547 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 547 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
548 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | 548 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | ||
549 | 549 | | |||
550 | MyMoneyReport filter; | 550 | MyMoneyReport filter; | ||
551 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 551 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
552 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 552 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
553 | filter.setTextFilter(QRegExp("Thomas")); | 553 | filter.setTextFilter(QRegExp("Thomas")); | ||
554 | XMLandback(filter); | 554 | XMLandback(filter); | ||
555 | PivotTable spending_f(filter); | 555 | PivotTable spending_f(filter); | ||
556 | } | 556 | } | ||
557 | 557 | | |||
558 | // type (payment, deposit, transfer) | 558 | // type (payment, deposit, transfer) | ||
559 | { | 559 | { | ||
560 | TransactionHelper t1(QDate(2004, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 560 | TransactionHelper t1(QDate(2004, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
561 | TransactionHelper t2(QDate(2004, 2, 1), MyMoneySplit::ActionDeposit, -moParent1, acCredit, acParent); | 561 | TransactionHelper t2(QDate(2004, 2, 1), MyMoneySplit::ActionDeposit, -moParent1, acCredit, acParent); | ||
562 | TransactionHelper t3(QDate(2004, 11, 1), MyMoneySplit::ActionTransfer, moChild, acCredit, acChecking); | 562 | TransactionHelper t3(QDate(2004, 11, 1), MyMoneySplit::ActionTransfer, moChild, acCredit, acChecking); | ||
563 | 563 | | |||
564 | MyMoneyReport filter; | 564 | MyMoneyReport filter; | ||
565 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 565 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
566 | filter.addType(MyMoneyTransactionFilter::payments); | 566 | filter.addType(MyMoneyTransactionFilter::payments); | ||
567 | XMLandback(filter); | 567 | XMLandback(filter); | ||
568 | PivotTable spending_f(filter); | 568 | PivotTable spending_f(filter); | ||
569 | 569 | | |||
570 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 570 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
571 | 571 | | |||
572 | filter.clear(); | 572 | filter.clear(); | ||
573 | filter.addType(MyMoneyTransactionFilter::deposits); | 573 | filter.addType(MyMoneyTransactionFilter::deposits); | ||
574 | XMLandback(filter); | 574 | XMLandback(filter); | ||
575 | PivotTable spending_f2(filter); | 575 | PivotTable spending_f2(filter); | ||
576 | 576 | | |||
577 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moParent1); | 577 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moParent1); | ||
578 | 578 | | |||
579 | filter.clear(); | 579 | filter.clear(); | ||
580 | filter.addType(MyMoneyTransactionFilter::transfers); | 580 | filter.addType(MyMoneyTransactionFilter::transfers); | ||
581 | XMLandback(filter); | 581 | XMLandback(filter); | ||
582 | PivotTable spending_f3(filter); | 582 | PivotTable spending_f3(filter); | ||
583 | 583 | | |||
584 | QVERIFY(spending_f3.m_grid.m_total[eActual].m_total == moZero); | 584 | QVERIFY(spending_f3.m_grid.m_total[eActual].m_total == moZero); | ||
585 | 585 | | |||
586 | filter.setRowType(MyMoneyReport::eAssetLiability); | 586 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
587 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31)); | 587 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31)); | ||
588 | XMLandback(filter); | 588 | XMLandback(filter); | ||
589 | PivotTable networth_f4(filter); | 589 | PivotTable networth_f4(filter); | ||
590 | 590 | | |||
591 | QVERIFY(networth_f4.m_grid["Asset"].m_total[eActual][11] == moCheckingOpen + moChild); | 591 | QVERIFY(networth_f4.m_grid["Asset"].m_total[eActual][11] == moCheckingOpen + moChild); | ||
592 | QVERIFY(networth_f4.m_grid["Liability"].m_total[eActual][11] == - moCreditOpen + moChild); | 592 | QVERIFY(networth_f4.m_grid["Liability"].m_total[eActual][11] == - moCreditOpen + moChild); | ||
593 | QVERIFY(networth_f4.m_grid.m_total[eActual][10] == moCheckingOpen + moCreditOpen); | 593 | QVERIFY(networth_f4.m_grid.m_total[eActual][10] == moCheckingOpen + moCreditOpen); | ||
594 | QVERIFY(networth_f4.m_grid.m_total[eActual][11] == moCheckingOpen + moCreditOpen); | 594 | QVERIFY(networth_f4.m_grid.m_total[eActual][11] == moCheckingOpen + moCreditOpen); | ||
Show All 17 Lines | 598 | { | |||
612 | splits = t2.splits(); | 612 | splits = t2.splits(); | ||
613 | splits[0].setReconcileFlag(MyMoneySplit::Reconciled); | 613 | splits[0].setReconcileFlag(MyMoneySplit::Reconciled); | ||
614 | splits[1].setReconcileFlag(MyMoneySplit::Reconciled); | 614 | splits[1].setReconcileFlag(MyMoneySplit::Reconciled); | ||
615 | t2.modifySplit(splits[0]); | 615 | t2.modifySplit(splits[0]); | ||
616 | t2.modifySplit(splits[1]); | 616 | t2.modifySplit(splits[1]); | ||
617 | t2.update(); | 617 | t2.update(); | ||
618 | 618 | | |||
619 | MyMoneyReport filter; | 619 | MyMoneyReport filter; | ||
620 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 620 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
621 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 621 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
622 | filter.addState(MyMoneyTransactionFilter::cleared); | 622 | filter.addState(MyMoneyTransactionFilter::cleared); | ||
623 | XMLandback(filter); | 623 | XMLandback(filter); | ||
624 | PivotTable spending_f(filter); | 624 | PivotTable spending_f(filter); | ||
625 | 625 | | |||
626 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 626 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
627 | 627 | | |||
628 | filter.addState(MyMoneyTransactionFilter::reconciled); | 628 | filter.addState(MyMoneyTransactionFilter::reconciled); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 643 | { | |||
673 | splits = t2.splits(); | 673 | splits = t2.splits(); | ||
674 | splits[0].setNumber("4"); | 674 | splits[0].setNumber("4"); | ||
675 | splits[1].setNumber("4"); | 675 | splits[1].setNumber("4"); | ||
676 | t4.modifySplit(splits[0]); | 676 | t4.modifySplit(splits[0]); | ||
677 | t4.modifySplit(splits[1]); | 677 | t4.modifySplit(splits[1]); | ||
678 | t4.update(); | 678 | t4.update(); | ||
679 | 679 | | |||
680 | MyMoneyReport filter; | 680 | MyMoneyReport filter; | ||
681 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 681 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
682 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 682 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
683 | filter.setNumberFilter("1", "3"); | 683 | filter.setNumberFilter("1", "3"); | ||
684 | XMLandback(filter); | 684 | XMLandback(filter); | ||
685 | PivotTable spending_f(filter); | 685 | PivotTable spending_f(filter); | ||
686 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2); | 686 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2); | ||
687 | } | 687 | } | ||
688 | 688 | | |||
689 | // blank dates | 689 | // blank dates | ||
690 | { | 690 | { | ||
691 | TransactionHelper t1y1(QDate(2003, 10, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 691 | TransactionHelper t1y1(QDate(2003, 10, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
692 | TransactionHelper t2y1(QDate(2003, 11, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 692 | TransactionHelper t2y1(QDate(2003, 11, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
693 | TransactionHelper t3y1(QDate(2003, 12, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 693 | TransactionHelper t3y1(QDate(2003, 12, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
694 | 694 | | |||
695 | TransactionHelper t1y2(QDate(2004, 4, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 695 | TransactionHelper t1y2(QDate(2004, 4, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
696 | TransactionHelper t2y2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 696 | TransactionHelper t2y2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
697 | TransactionHelper t3y2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 697 | TransactionHelper t3y2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
698 | 698 | | |||
699 | TransactionHelper t1y3(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 699 | TransactionHelper t1y3(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
700 | TransactionHelper t2y3(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 700 | TransactionHelper t2y3(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
701 | TransactionHelper t3y3(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 701 | TransactionHelper t3y3(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
702 | 702 | | |||
703 | MyMoneyReport filter; | 703 | MyMoneyReport filter; | ||
704 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 704 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
705 | filter.setDateFilter(QDate(), QDate(2004, 7, 1)); | 705 | filter.setDateFilter(QDate(), QDate(2004, 7, 1)); | ||
706 | XMLandback(filter); | 706 | XMLandback(filter); | ||
707 | PivotTable spending_f(filter); | 707 | PivotTable spending_f(filter); | ||
708 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2); | 708 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2); | ||
709 | 709 | | |||
710 | filter.clear(); | 710 | filter.clear(); | ||
711 | XMLandback(filter); | 711 | XMLandback(filter); | ||
712 | PivotTable spending_f2(filter); | 712 | PivotTable spending_f2(filter); | ||
Show All 15 Lines | 720 | { | |||
728 | TransactionHelper t2q2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 728 | TransactionHelper t2q2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
729 | TransactionHelper t3q2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 729 | TransactionHelper t3q2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
730 | 730 | | |||
731 | TransactionHelper t1y2(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 731 | TransactionHelper t1y2(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
732 | TransactionHelper t2y2(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 732 | TransactionHelper t2y2(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
733 | TransactionHelper t3y2(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 733 | TransactionHelper t3y2(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
734 | 734 | | |||
735 | MyMoneyReport filter; | 735 | MyMoneyReport filter; | ||
736 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 736 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
737 | filter.setDateFilter(QDate(2003, 12, 31), QDate(2005, 12, 31)); | 737 | filter.setDateFilter(QDate(2003, 12, 31), QDate(2005, 12, 31)); | ||
738 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 738 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
739 | filter.setColumnType(MyMoneyReport::Column::BiMonths); | 739 | filter.setColumnType(MyMoneyReport::Column::BiMonths); | ||
740 | XMLandback(filter); | 740 | XMLandback(filter); | ||
741 | PivotTable spending_b(filter); | 741 | PivotTable spending_b(filter); | ||
742 | 742 | | |||
743 | QVERIFY(spending_b.m_grid.m_total[eActual][1] == moZero); | 743 | QVERIFY(spending_b.m_grid.m_total[eActual][1] == moZero); | ||
744 | QVERIFY(spending_b.m_grid.m_total[eActual][2] == -moParent1 - moSolo); | 744 | QVERIFY(spending_b.m_grid.m_total[eActual][2] == -moParent1 - moSolo); | ||
745 | QVERIFY(spending_b.m_grid.m_total[eActual][3] == -moParent2 - moSolo); | 745 | QVERIFY(spending_b.m_grid.m_total[eActual][3] == -moParent2 - moSolo); | ||
746 | QVERIFY(spending_b.m_grid.m_total[eActual][4] == -moParent); | 746 | QVERIFY(spending_b.m_grid.m_total[eActual][4] == -moParent); | ||
Show All 16 Lines | |||||
763 | QVERIFY(spending_q.m_grid.m_total[eActual][3] == -moSolo - moParent); | 763 | QVERIFY(spending_q.m_grid.m_total[eActual][3] == -moSolo - moParent); | ||
764 | QVERIFY(spending_q.m_grid.m_total[eActual][4] == moZero); | 764 | QVERIFY(spending_q.m_grid.m_total[eActual][4] == moZero); | ||
765 | QVERIFY(spending_q.m_grid.m_total[eActual][5] == moZero); | 765 | QVERIFY(spending_q.m_grid.m_total[eActual][5] == moZero); | ||
766 | QVERIFY(spending_q.m_grid.m_total[eActual][6] == -moSolo); | 766 | QVERIFY(spending_q.m_grid.m_total[eActual][6] == -moSolo); | ||
767 | QVERIFY(spending_q.m_grid.m_total[eActual][7] == -moParent1); | 767 | QVERIFY(spending_q.m_grid.m_total[eActual][7] == -moParent1); | ||
768 | QVERIFY(spending_q.m_grid.m_total[eActual][8] == -moParent2); | 768 | QVERIFY(spending_q.m_grid.m_total[eActual][8] == -moParent2); | ||
769 | QVERIFY(spending_q.m_grid.m_total[eActual][9] == moZero); | 769 | QVERIFY(spending_q.m_grid.m_total[eActual][9] == moZero); | ||
770 | 770 | | |||
771 | filter.setRowType(MyMoneyReport::eAssetLiability); | 771 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
772 | filter.setName("Net Worth by Quarter"); | 772 | filter.setName("Net Worth by Quarter"); | ||
773 | XMLandback(filter); | 773 | XMLandback(filter); | ||
774 | PivotTable networth_q(filter); | 774 | PivotTable networth_q(filter); | ||
775 | writeTabletoHTML(networth_q, "Net Worth by Quarter.html"); | 775 | writeTabletoHTML(networth_q, "Net Worth by Quarter.html"); | ||
776 | 776 | | |||
777 | QVERIFY(networth_q.m_grid.m_total[eActual][1] == moZero); | 777 | QVERIFY(networth_q.m_grid.m_total[eActual][1] == moZero); | ||
778 | QVERIFY(networth_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | 778 | QVERIFY(networth_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | ||
779 | QVERIFY(networth_q.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent + moCheckingOpen); | 779 | QVERIFY(networth_q.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent + moCheckingOpen); | ||
780 | QVERIFY(networth_q.m_grid.m_total[eActual][4] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 780 | QVERIFY(networth_q.m_grid.m_total[eActual][4] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
781 | QVERIFY(networth_q.m_grid.m_total[eActual][5] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 781 | QVERIFY(networth_q.m_grid.m_total[eActual][5] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
782 | QVERIFY(networth_q.m_grid.m_total[eActual][6] == -moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 782 | QVERIFY(networth_q.m_grid.m_total[eActual][6] == -moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
783 | QVERIFY(networth_q.m_grid.m_total[eActual][7] == -moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 783 | QVERIFY(networth_q.m_grid.m_total[eActual][7] == -moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
784 | QVERIFY(networth_q.m_grid.m_total[eActual][8] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 784 | QVERIFY(networth_q.m_grid.m_total[eActual][8] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
785 | QVERIFY(networth_q.m_grid.m_total[eActual][9] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 785 | QVERIFY(networth_q.m_grid.m_total[eActual][9] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
786 | 786 | | |||
787 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 787 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
788 | filter.setColumnType(MyMoneyReport::Column::Years); | 788 | filter.setColumnType(MyMoneyReport::Column::Years); | ||
789 | XMLandback(filter); | 789 | XMLandback(filter); | ||
790 | PivotTable spending_y(filter); | 790 | PivotTable spending_y(filter); | ||
791 | 791 | | |||
792 | QVERIFY(spending_y.m_grid.m_total[eActual][1] == moZero); | 792 | QVERIFY(spending_y.m_grid.m_total[eActual][1] == moZero); | ||
793 | QVERIFY(spending_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent); | 793 | QVERIFY(spending_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent); | ||
794 | QVERIFY(spending_y.m_grid.m_total[eActual][3] == -moSolo - moParent); | 794 | QVERIFY(spending_y.m_grid.m_total[eActual][3] == -moSolo - moParent); | ||
795 | QVERIFY(spending_y.m_grid.m_total[eActual].m_total == -moSolo - moParent - moSolo - moParent - moSolo - moParent); | 795 | QVERIFY(spending_y.m_grid.m_total[eActual].m_total == -moSolo - moParent - moSolo - moParent - moSolo - moParent); | ||
796 | 796 | | |||
797 | filter.setRowType(MyMoneyReport::eAssetLiability); | 797 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
798 | XMLandback(filter); | 798 | XMLandback(filter); | ||
799 | PivotTable networth_y(filter); | 799 | PivotTable networth_y(filter); | ||
800 | 800 | | |||
801 | QVERIFY(networth_y.m_grid.m_total[eActual][1] == moZero); | 801 | QVERIFY(networth_y.m_grid.m_total[eActual][1] == moZero); | ||
802 | QVERIFY(networth_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 802 | QVERIFY(networth_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
803 | QVERIFY(networth_y.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 803 | QVERIFY(networth_y.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
804 | 804 | | |||
805 | // Test days-based reports | 805 | // Test days-based reports | ||
806 | 806 | | |||
807 | TransactionHelper t1d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 807 | TransactionHelper t1d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
808 | TransactionHelper t2d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 808 | TransactionHelper t2d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
809 | TransactionHelper t3d1(QDate(2004, 7, 5), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 809 | TransactionHelper t3d1(QDate(2004, 7, 5), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
810 | 810 | | |||
811 | TransactionHelper t1d2(QDate(2004, 7, 14), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 811 | TransactionHelper t1d2(QDate(2004, 7, 14), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
812 | TransactionHelper t2d2(QDate(2004, 7, 15), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 812 | TransactionHelper t2d2(QDate(2004, 7, 15), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
813 | TransactionHelper t3d2(QDate(2004, 7, 20), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 813 | TransactionHelper t3d2(QDate(2004, 7, 20), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
814 | 814 | | |||
815 | TransactionHelper t1d3(QDate(2004, 8, 2), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 815 | TransactionHelper t1d3(QDate(2004, 8, 2), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
816 | TransactionHelper t2d3(QDate(2004, 8, 3), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 816 | TransactionHelper t2d3(QDate(2004, 8, 3), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
817 | TransactionHelper t3d3(QDate(2004, 8, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 817 | TransactionHelper t3d3(QDate(2004, 8, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
818 | 818 | | |||
819 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 7, 14)); | 819 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 7, 14)); | ||
820 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 820 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
821 | filter.setColumnType(MyMoneyReport::Column::Months); | 821 | filter.setColumnType(MyMoneyReport::Column::Months); | ||
822 | filter.setColumnsAreDays(true); | 822 | filter.setColumnsAreDays(true); | ||
823 | filter.setName("Spending by Days"); | 823 | filter.setName("Spending by Days"); | ||
824 | 824 | | |||
825 | XMLandback(filter); | 825 | XMLandback(filter); | ||
826 | PivotTable spending_days(filter); | 826 | PivotTable spending_days(filter); | ||
827 | writeTabletoHTML(spending_days, "Spending by Days.html"); | 827 | writeTabletoHTML(spending_days, "Spending by Days.html"); | ||
828 | 828 | | |||
829 | QVERIFY(spending_days.m_grid.m_total[eActual][4] == -moParent2); | 829 | QVERIFY(spending_days.m_grid.m_total[eActual][4] == -moParent2); | ||
830 | QVERIFY(spending_days.m_grid.m_total[eActual][13] == -moSolo); | 830 | QVERIFY(spending_days.m_grid.m_total[eActual][13] == -moSolo); | ||
831 | QVERIFY(spending_days.m_grid.m_total[eActual].m_total == -moSolo - moParent2); | 831 | QVERIFY(spending_days.m_grid.m_total[eActual].m_total == -moSolo - moParent2); | ||
832 | 832 | | |||
833 | unsigned save_dayweekstart = KGlobal::locale()->weekStartDay(); | 833 | unsigned save_dayweekstart = KGlobal::locale()->weekStartDay(); | ||
834 | KGlobal::locale()->setWeekStartDay(2); | 834 | KGlobal::locale()->setWeekStartDay(2); | ||
835 | 835 | | |||
836 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 8, 1)); | 836 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 8, 1)); | ||
837 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 837 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
838 | filter.setColumnType(static_cast<MyMoneyReport::Column::Type>(7)); | 838 | filter.setColumnType(static_cast<MyMoneyReport::Column::Type>(7)); | ||
839 | filter.setColumnsAreDays(true); | 839 | filter.setColumnsAreDays(true); | ||
840 | filter.setName("Spending by Weeks"); | 840 | filter.setName("Spending by Weeks"); | ||
841 | 841 | | |||
842 | XMLandback(filter); | 842 | XMLandback(filter); | ||
843 | PivotTable spending_weeks(filter); | 843 | PivotTable spending_weeks(filter); | ||
844 | writeTabletoHTML(spending_weeks, "Spending by Weeks.html"); | 844 | writeTabletoHTML(spending_weeks, "Spending by Weeks.html"); | ||
845 | 845 | | |||
Show All 36 Lines | 861 | try { | |||
882 | 882 | | |||
883 | makeEquityPrice(eqStock1, QDate(2004, 10, 1), MyMoneyMoney(100.00)); | 883 | makeEquityPrice(eqStock1, QDate(2004, 10, 1), MyMoneyMoney(100.00)); | ||
884 | 884 | | |||
885 | // | 885 | // | ||
886 | // Net Worth Report (with investments) | 886 | // Net Worth Report (with investments) | ||
887 | // | 887 | // | ||
888 | 888 | | |||
889 | MyMoneyReport networth_r; | 889 | MyMoneyReport networth_r; | ||
890 | networth_r.setRowType(MyMoneyReport::eAssetLiability); | 890 | networth_r.setRowType(MyMoneyReport::Row::AssetLiability); | ||
891 | networth_r.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31).addDays(-1)); | 891 | networth_r.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31).addDays(-1)); | ||
892 | XMLandback(networth_r); | 892 | XMLandback(networth_r); | ||
893 | PivotTable networth(networth_r); | 893 | PivotTable networth(networth_r); | ||
894 | 894 | | |||
895 | networth.dump("networth_i.html"); | 895 | networth.dump("networth_i.html"); | ||
896 | 896 | | |||
897 | QVERIFY(networth.m_grid["Asset"]["Investment"].m_total[eActual][1] == moZero); | 897 | QVERIFY(networth.m_grid["Asset"]["Investment"].m_total[eActual][1] == moZero); | ||
898 | // 1000 shares @ $100.00 | 898 | // 1000 shares @ $100.00 | ||
Show All 36 Lines | |||||
935 | void PivotTableTest::testBudget() | 935 | void PivotTableTest::testBudget() | ||
936 | { | 936 | { | ||
937 | 937 | | |||
938 | // 1. Budget on A, transactions on A | 938 | // 1. Budget on A, transactions on A | ||
939 | { | 939 | { | ||
940 | BudgetHelper budget; | 940 | BudgetHelper budget; | ||
941 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | 941 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | ||
942 | 942 | | |||
943 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 943 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
944 | MyMoneyReport::Column::Months, | 944 | MyMoneyReport::Column::Months, | ||
945 | MyMoneyTransactionFilter::yearToDate, | 945 | MyMoneyTransactionFilter::yearToDate, | ||
946 | MyMoneyReport::eDetailTop, | 946 | MyMoneyReport::eDetailTop, | ||
947 | "Yearly Budgeted vs. Actual", "Default Report"); | 947 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
948 | PivotTable table(report); | 948 | PivotTable table(report); | ||
949 | } | 949 | } | ||
950 | 950 | | |||
951 | // 2. Budget on B, not applying to sub accounts, transactions on B and B:1 | 951 | // 2. Budget on B, not applying to sub accounts, transactions on B and B:1 | ||
952 | { | 952 | { | ||
953 | BudgetHelper budget; | 953 | BudgetHelper budget; | ||
954 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | 954 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | ||
955 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 955 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
956 | MyMoneyReport::Column::Months, | 956 | MyMoneyReport::Column::Months, | ||
957 | MyMoneyTransactionFilter::yearToDate, | 957 | MyMoneyTransactionFilter::yearToDate, | ||
958 | MyMoneyReport::eDetailTop, | 958 | MyMoneyReport::eDetailTop, | ||
959 | "Yearly Budgeted vs. Actual", "Default Report"); | 959 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
960 | PivotTable table(report); | 960 | PivotTable table(report); | ||
961 | } | 961 | } | ||
962 | 962 | | |||
963 | // - Both B and B:1 totals should show up | 963 | // - Both B and B:1 totals should show up | ||
964 | // - B actuals compare against B budget | 964 | // - B actuals compare against B budget | ||
965 | // - B:1 actuals compare against 0 | 965 | // - B:1 actuals compare against 0 | ||
966 | 966 | | |||
967 | // 3. Budget on C, applying to sub accounts, transactions on C and C:1 and C:1:a | 967 | // 3. Budget on C, applying to sub accounts, transactions on C and C:1 and C:1:a | ||
968 | { | 968 | { | ||
969 | BudgetHelper budget; | 969 | BudgetHelper budget; | ||
970 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, true, MyMoneyMoney(100.0)); | 970 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, true, MyMoneyMoney(100.0)); | ||
971 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 971 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
972 | MyMoneyReport::Column::Months, | 972 | MyMoneyReport::Column::Months, | ||
973 | MyMoneyTransactionFilter::yearToDate, | 973 | MyMoneyTransactionFilter::yearToDate, | ||
974 | MyMoneyReport::eDetailTop , | 974 | MyMoneyReport::eDetailTop , | ||
975 | "Yearly Budgeted vs. Actual", "Default Report"); | 975 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
976 | PivotTable table(report); | 976 | PivotTable table(report); | ||
977 | } | 977 | } | ||
978 | 978 | | |||
979 | // - Only C totals show up, not C:1 or C:1:a totals | 979 | // - Only C totals show up, not C:1 or C:1:a totals | ||
980 | // - C + C:1 totals compare against C budget | 980 | // - C + C:1 totals compare against C budget | ||
981 | 981 | | |||
982 | // 4. Budget on D, not applying to sub accounts, budget on D:1 not applying, budget on D:2 applying. Transactions on D, D:1, D:2, D:2:a, D:2:b | 982 | // 4. Budget on D, not applying to sub accounts, budget on D:1 not applying, budget on D:2 applying. Transactions on D, D:1, D:2, D:2:a, D:2:b | ||
983 | { | 983 | { | ||
984 | BudgetHelper budget; | 984 | BudgetHelper budget; | ||
985 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | 985 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | ||
986 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acChild, false, MyMoneyMoney(100.0)); | 986 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acChild, false, MyMoneyMoney(100.0)); | ||
987 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSecondChild, true, MyMoneyMoney(100.0)); | 987 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSecondChild, true, MyMoneyMoney(100.0)); | ||
988 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 988 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
989 | MyMoneyReport::Column::Months, | 989 | MyMoneyReport::Column::Months, | ||
990 | MyMoneyTransactionFilter::yearToDate, | 990 | MyMoneyTransactionFilter::yearToDate, | ||
991 | MyMoneyReport::eDetailTop, | 991 | MyMoneyReport::eDetailTop, | ||
992 | "Yearly Budgeted vs. Actual", "Default Report"); | 992 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
993 | PivotTable table(report); | 993 | PivotTable table(report); | ||
994 | } | 994 | } | ||
995 | 995 | | |||
996 | // - Totals for D, D:1, D:2 show up. D:2:a and D:2:b do not | 996 | // - Totals for D, D:1, D:2 show up. D:2:a and D:2:b do not | ||
997 | // - D actuals (only) compare against D budget | 997 | // - D actuals (only) compare against D budget | ||
998 | // - Ditto for D:1 | 998 | // - Ditto for D:1 | ||
999 | // - D:2 acutals and children compare against D:2 budget | 999 | // - D:2 acutals and children compare against D:2 budget | ||
1000 | 1000 | | |||
1001 | // 5. Budget on E, no transactions on E | 1001 | // 5. Budget on E, no transactions on E | ||
1002 | { | 1002 | { | ||
1003 | BudgetHelper budget; | 1003 | BudgetHelper budget; | ||
1004 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | 1004 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | ||
1005 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 1005 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
1006 | MyMoneyReport::Column::Months, | 1006 | MyMoneyReport::Column::Months, | ||
1007 | MyMoneyTransactionFilter::yearToDate, | 1007 | MyMoneyTransactionFilter::yearToDate, | ||
1008 | MyMoneyReport::eDetailTop, | 1008 | MyMoneyReport::eDetailTop, | ||
1009 | "Yearly Budgeted vs. Actual", "Default Report"); | 1009 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
1010 | PivotTable table(report); | 1010 | PivotTable table(report); | ||
1011 | } | 1011 | } | ||
1012 | } | 1012 | } | ||
1013 | 1013 | | |||
1014 | void PivotTableTest::testHtmlEncoding() | 1014 | void PivotTableTest::testHtmlEncoding() | ||
1015 | { | 1015 | { | ||
1016 | MyMoneyReport filter; | 1016 | MyMoneyReport filter; | ||
1017 | filter.setRowType(MyMoneyReport::eAssetLiability); | 1017 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
1018 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 1018 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
1019 | XMLandback(filter); | 1019 | XMLandback(filter); | ||
1020 | PivotTable networth_f(filter); | 1020 | PivotTable networth_f(filter); | ||
1021 | 1021 | | |||
1022 | QByteArray encoding = KGlobal::locale()->encoding(); | 1022 | QByteArray encoding = KGlobal::locale()->encoding(); | ||
1023 | 1023 | | |||
1024 | QString html = networth_f.renderHTML(0, encoding, filter.name(), false); | 1024 | QString html = networth_f.renderHTML(0, encoding, filter.name(), false); | ||
1025 | 1025 | | |||
1026 | QRegExp rx("*<meta * charset=" + encoding + "*>*"); | 1026 | QRegExp rx("*<meta * charset=" + encoding + "*>*"); | ||
1027 | rx.setPatternSyntax(QRegExp::Wildcard); | 1027 | rx.setPatternSyntax(QRegExp::Wildcard); | ||
1028 | rx.setCaseSensitivity(Qt::CaseInsensitive); | 1028 | rx.setCaseSensitivity(Qt::CaseInsensitive); | ||
1029 | QVERIFY(rx.exactMatch(html)); | 1029 | QVERIFY(rx.exactMatch(html)); | ||
1030 | } | 1030 | } |