Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/tests/pivottable-test.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
94 | file->detachStorage(storage); | 94 | file->detachStorage(storage); | ||
95 | delete storage; | 95 | delete storage; | ||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | void PivotTableTest::testNetWorthSingle() | 98 | void PivotTableTest::testNetWorthSingle() | ||
99 | { | 99 | { | ||
100 | try { | 100 | try { | ||
101 | MyMoneyReport filter; | 101 | MyMoneyReport filter; | ||
102 | filter.setRowType(MyMoneyReport::eAssetLiability); | 102 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
103 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 7, 1).addDays(-1)); | 103 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 7, 1).addDays(-1)); | ||
104 | XMLandback(filter); | 104 | XMLandback(filter); | ||
105 | PivotTable networth_f(filter); | 105 | PivotTable networth_f(filter); | ||
106 | writeTabletoCSV(networth_f); | 106 | writeTabletoCSV(networth_f); | ||
107 | 107 | | |||
108 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][ReportAccount(acChecking)][eActual][5] == moCheckingOpen); | 108 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][ReportAccount(acChecking)][eActual][5] == moCheckingOpen); | ||
109 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][ReportAccount(acChecking)][eActual][6] == moCheckingOpen); | 109 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"][ReportAccount(acChecking)][eActual][6] == moCheckingOpen); | ||
110 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][5] == moCheckingOpen); | 110 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][5] == moCheckingOpen); | ||
111 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | 111 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | ||
112 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == moZero); | 112 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == moZero); | ||
113 | QVERIFY(networth_f.m_grid.m_total[eActual][5] == moCheckingOpen); | 113 | QVERIFY(networth_f.m_grid.m_total[eActual][5] == moCheckingOpen); | ||
114 | QVERIFY(networth_f.m_grid.m_total[eActual][6] == moCheckingOpen); | 114 | QVERIFY(networth_f.m_grid.m_total[eActual][6] == moCheckingOpen); | ||
115 | } catch (const MyMoneyException &e) { | 115 | } catch (const MyMoneyException &e) { | ||
116 | QFAIL(qPrintable(e.what())); | 116 | QFAIL(qPrintable(e.what())); | ||
117 | } | 117 | } | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | void PivotTableTest::testNetWorthOfsetting() | 120 | void PivotTableTest::testNetWorthOfsetting() | ||
121 | { | 121 | { | ||
122 | // Test the net worth report to make sure it picks up the opening balance for two | 122 | // Test the net worth report to make sure it picks up the opening balance for two | ||
123 | // accounts opened during the period of the report, one asset & one liability. Test | 123 | // accounts opened during the period of the report, one asset & one liability. Test | ||
124 | // that it calculates the totals correctly. | 124 | // that it calculates the totals correctly. | ||
125 | 125 | | |||
126 | MyMoneyReport filter; | 126 | MyMoneyReport filter; | ||
127 | filter.setRowType(MyMoneyReport::eAssetLiability); | 127 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
128 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 128 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
129 | XMLandback(filter); | 129 | XMLandback(filter); | ||
130 | PivotTable networth_f(filter); | 130 | PivotTable networth_f(filter); | ||
131 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"][ReportAccount(acCredit)][eActual][7] == -moCreditOpen); | 131 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"][ReportAccount(acCredit)][eActual][7] == -moCreditOpen); | ||
132 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | 132 | QVERIFY(networth_f.m_grid.m_total[eActual][0] == moZero); | ||
133 | QVERIFY(networth_f.m_grid.m_total[eActual][12] == moCheckingOpen + moCreditOpen); | 133 | QVERIFY(networth_f.m_grid.m_total[eActual][12] == moCheckingOpen + moCreditOpen); | ||
134 | 134 | | |||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | void PivotTableTest::testNetWorthOpeningPrior() | 137 | void PivotTableTest::testNetWorthOpeningPrior() | ||
138 | { | 138 | { | ||
139 | // Test the net worth report to make sure it's picking up opening balances PRIOR to | 139 | // Test the net worth report to make sure it's picking up opening balances PRIOR to | ||
140 | // the period of the report. | 140 | // the period of the report. | ||
141 | 141 | | |||
142 | MyMoneyReport filter; | 142 | MyMoneyReport filter; | ||
143 | filter.setRowType(MyMoneyReport::eAssetLiability); | 143 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
144 | filter.setDateFilter(QDate(2005, 8, 1), QDate(2005, 12, 31)); | 144 | filter.setDateFilter(QDate(2005, 8, 1), QDate(2005, 12, 31)); | ||
145 | filter.setName("Net Worth Opening Prior 1"); | 145 | filter.setName("Net Worth Opening Prior 1"); | ||
146 | XMLandback(filter); | 146 | XMLandback(filter); | ||
147 | PivotTable networth_f(filter); | 147 | PivotTable networth_f(filter); | ||
148 | writeTabletoCSV(networth_f); | 148 | writeTabletoCSV(networth_f); | ||
149 | 149 | | |||
150 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][0] == -moCreditOpen); | 150 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][0] == -moCreditOpen); | ||
151 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][0] == moCheckingOpen); | 151 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][0] == moCheckingOpen); | ||
Show All 20 Lines | |||||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | void PivotTableTest::testNetWorthDateFilter() | 174 | void PivotTableTest::testNetWorthDateFilter() | ||
175 | { | 175 | { | ||
176 | // Test a net worth report whose period is prior to the time any accounts are open, | 176 | // Test a net worth report whose period is prior to the time any accounts are open, | ||
177 | // so the report should be zero. | 177 | // so the report should be zero. | ||
178 | 178 | | |||
179 | MyMoneyReport filter; | 179 | MyMoneyReport filter; | ||
180 | filter.setRowType(MyMoneyReport::eAssetLiability); | 180 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
181 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 2, 1).addDays(-1)); | 181 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 2, 1).addDays(-1)); | ||
182 | XMLandback(filter); | 182 | XMLandback(filter); | ||
183 | PivotTable networth_f(filter); | 183 | PivotTable networth_f(filter); | ||
184 | QVERIFY(networth_f.m_grid.m_total[eActual][1] == moZero); | 184 | QVERIFY(networth_f.m_grid.m_total[eActual][1] == moZero); | ||
185 | 185 | | |||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | void PivotTableTest::testNetWorthOpening() | 188 | void PivotTableTest::testNetWorthOpening() | ||
Show All 13 Lines | 189 | { | |||
202 | TransactionHelper t8(QDate(2017, 2, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | 202 | TransactionHelper t8(QDate(2017, 2, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | ||
203 | TransactionHelper t9(QDate(2017, 3, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | 203 | TransactionHelper t9(QDate(2017, 3, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | ||
204 | TransactionHelper t10(QDate(2017, 4, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | 204 | TransactionHelper t10(QDate(2017, 4, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | ||
205 | TransactionHelper t11(QDate(2017, 5, 1), MyMoneySplit::ActionWithdrawal, MyMoneyMoney(4500000), acBasicAccount, ctBasicExpense); | 205 | TransactionHelper t11(QDate(2017, 5, 1), MyMoneySplit::ActionWithdrawal, MyMoneyMoney(4500000), acBasicAccount, ctBasicExpense); | ||
206 | TransactionHelper t12(QDate(2017, 6, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | 206 | TransactionHelper t12(QDate(2017, 6, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | ||
207 | TransactionHelper t13(QDate(2017, 7, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | 207 | TransactionHelper t13(QDate(2017, 7, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-100000), acBasicAccount, ctBasicIncome); | ||
208 | 208 | | |||
209 | MyMoneyReport filter; | 209 | MyMoneyReport filter; | ||
210 | filter.setRowType(MyMoneyReport::eAssetLiability); | 210 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
211 | filter.setDateFilter(QDate(2016, 1, 1), QDate(2017, 12, 31)); | 211 | filter.setDateFilter(QDate(2016, 1, 1), QDate(2017, 12, 31)); | ||
212 | filter.addAccount(acBasicAccount); | 212 | filter.addAccount(acBasicAccount); | ||
213 | XMLandback(filter); | 213 | XMLandback(filter); | ||
214 | PivotTable nt_opening1(filter); | 214 | PivotTable nt_opening1(filter); | ||
215 | writeTabletoCSV(nt_opening1, "networth-opening-1.csv"); | 215 | writeTabletoCSV(nt_opening1, "networth-opening-1.csv"); | ||
216 | 216 | | |||
217 | QVERIFY(nt_opening1.m_grid["Asset"]["Basic Account"][ReportAccount(acBasicAccount)][eActual][0] == MyMoneyMoney()); // opening value on 1st Jan 2016 is 12000000, but before that i.e. 31st Dec 2015 opening value is 0 | 217 | QVERIFY(nt_opening1.m_grid["Asset"]["Basic Account"][ReportAccount(acBasicAccount)][eActual][0] == MyMoneyMoney()); // opening value on 1st Jan 2016 is 12000000, but before that i.e. 31st Dec 2015 opening value is 0 | ||
218 | for (auto i = 1; i <= 6; ++i) | 218 | for (auto i = 1; i <= 6; ++i) | ||
Show All 10 Lines | |||||
229 | QVERIFY(nt_opening2.m_grid["Asset"]["Basic Account"][ReportAccount(acBasicAccount)][eActual][12] == MyMoneyMoney(14800000)); | 229 | QVERIFY(nt_opening2.m_grid["Asset"]["Basic Account"][ReportAccount(acBasicAccount)][eActual][12] == MyMoneyMoney(14800000)); | ||
230 | } | 230 | } | ||
231 | 231 | | |||
232 | void PivotTableTest::testSpendingEmpty() | 232 | void PivotTableTest::testSpendingEmpty() | ||
233 | { | 233 | { | ||
234 | // test a spending report with no entries | 234 | // test a spending report with no entries | ||
235 | 235 | | |||
236 | MyMoneyReport filter; | 236 | MyMoneyReport filter; | ||
237 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 237 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
238 | XMLandback(filter); | 238 | XMLandback(filter); | ||
239 | PivotTable spending_f1(filter); | 239 | PivotTable spending_f1(filter); | ||
240 | QVERIFY(spending_f1.m_grid.m_total[eActual].m_total == moZero); | 240 | QVERIFY(spending_f1.m_grid.m_total[eActual].m_total == moZero); | ||
241 | 241 | | |||
242 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 242 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
243 | PivotTable spending_f2(filter); | 243 | PivotTable spending_f2(filter); | ||
244 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moZero); | 244 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moZero); | ||
245 | } | 245 | } | ||
246 | 246 | | |||
247 | void PivotTableTest::testSingleTransaction() | 247 | void PivotTableTest::testSingleTransaction() | ||
248 | { | 248 | { | ||
249 | // Test a single transaction | 249 | // Test a single transaction | ||
250 | TransactionHelper t(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 250 | TransactionHelper t(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
251 | 251 | | |||
252 | MyMoneyReport filter; | 252 | MyMoneyReport filter; | ||
253 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 253 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
254 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 254 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
255 | filter.setName("Spending with Single Transaction.html"); | 255 | filter.setName("Spending with Single Transaction.html"); | ||
256 | XMLandback(filter); | 256 | XMLandback(filter); | ||
257 | PivotTable spending_f(filter); | 257 | PivotTable spending_f(filter); | ||
258 | writeTabletoHTML(spending_f, "Spending with Single Transaction.html"); | 258 | writeTabletoHTML(spending_f, "Spending with Single Transaction.html"); | ||
259 | 259 | | |||
260 | QVERIFY(spending_f.m_grid["Expense"]["Solo"][ReportAccount(acSolo)][eActual][1] == moSolo); | 260 | QVERIFY(spending_f.m_grid["Expense"]["Solo"][ReportAccount(acSolo)][eActual][1] == moSolo); | ||
261 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][1] == moSolo); | 261 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][1] == moSolo); | ||
262 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][0] == moZero); | 262 | QVERIFY(spending_f.m_grid["Expense"]["Solo"].m_total[eActual][0] == moZero); | ||
263 | QVERIFY(spending_f.m_grid.m_total[eActual][1] == (-moSolo)); | 263 | QVERIFY(spending_f.m_grid.m_total[eActual][1] == (-moSolo)); | ||
264 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moSolo)); | 264 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moSolo)); | ||
265 | 265 | | |||
266 | filter.clearTransactionFilter(); | 266 | filter.clearTransactionFilter(); | ||
267 | filter.setRowType(MyMoneyReport::eAssetLiability); | 267 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
268 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 268 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
269 | XMLandback(filter); | 269 | XMLandback(filter); | ||
270 | PivotTable networth_f(filter); | 270 | PivotTable networth_f(filter); | ||
271 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][2] == (moCheckingOpen - moSolo)); | 271 | QVERIFY(networth_f.m_grid["Asset"]["Checking Account"].m_total[eActual][2] == (moCheckingOpen - moSolo)); | ||
272 | } | 272 | } | ||
273 | 273 | | |||
274 | void PivotTableTest::testSubAccount() | 274 | void PivotTableTest::testSubAccount() | ||
275 | { | 275 | { | ||
276 | // Test a sub-account with a value, under an account with a value | 276 | // Test a sub-account with a value, under an account with a value | ||
277 | 277 | | |||
278 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 278 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
279 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 279 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
280 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 280 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
281 | 281 | | |||
282 | MyMoneyReport filter; | 282 | MyMoneyReport filter; | ||
283 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 283 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
284 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 284 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
285 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | 285 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | ||
286 | filter.setName("Spending with Sub-Account"); | 286 | filter.setName("Spending with Sub-Account"); | ||
287 | XMLandback(filter); | 287 | XMLandback(filter); | ||
288 | PivotTable spending_f(filter); | 288 | PivotTable spending_f(filter); | ||
289 | writeTabletoHTML(spending_f, "Spending with Sub-Account.html"); | 289 | writeTabletoHTML(spending_f, "Spending with Sub-Account.html"); | ||
290 | 290 | | |||
291 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][2] == moParent); | 291 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][2] == moParent); | ||
292 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acChild)][eActual][2] == moChild); | 292 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acChild)][eActual][2] == moChild); | ||
293 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moParent + moChild); | 293 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moParent + moChild); | ||
294 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][1] == moZero); | 294 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][1] == moZero); | ||
295 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual].m_total == moParent + moChild); | 295 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual].m_total == moParent + moChild); | ||
296 | QVERIFY(spending_f.m_grid.m_total[eActual][2] == (-moParent - moChild)); | 296 | QVERIFY(spending_f.m_grid.m_total[eActual][2] == (-moParent - moChild)); | ||
297 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moParent - moChild)); | 297 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moParent - moChild)); | ||
298 | 298 | | |||
299 | filter.clearTransactionFilter(); | 299 | filter.clearTransactionFilter(); | ||
300 | filter.setRowType(MyMoneyReport::eAssetLiability); | 300 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
301 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 301 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
302 | filter.setName("Net Worth with Sub-Account"); | 302 | filter.setName("Net Worth with Sub-Account"); | ||
303 | XMLandback(filter); | 303 | XMLandback(filter); | ||
304 | PivotTable networth_f(filter); | 304 | PivotTable networth_f(filter); | ||
305 | writeTabletoHTML(networth_f, "Net Worth with Sub-Account.html"); | 305 | writeTabletoHTML(networth_f, "Net Worth with Sub-Account.html"); | ||
306 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][3] == moParent + moChild - moCreditOpen); | 306 | QVERIFY(networth_f.m_grid["Liability"]["Credit Card"].m_total[eActual][3] == moParent + moChild - moCreditOpen); | ||
307 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == -moParent - moChild + moCreditOpen + moCheckingOpen); | 307 | QVERIFY(networth_f.m_grid.m_total[eActual][4] == -moParent - moChild + moCreditOpen + moCheckingOpen); | ||
308 | 308 | | |||
309 | } | 309 | } | ||
310 | 310 | | |||
311 | void PivotTableTest::testFilterIEvsIE() | 311 | void PivotTableTest::testFilterIEvsIE() | ||
312 | { | 312 | { | ||
313 | // Test that removing an income/spending account will remove the entry from an income/spending report | 313 | // Test that removing an income/spending account will remove the entry from an income/spending report | ||
314 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 314 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
315 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 315 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
316 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 316 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
317 | 317 | | |||
318 | MyMoneyReport filter; | 318 | MyMoneyReport filter; | ||
319 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 319 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
320 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 320 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
321 | filter.addCategory(acChild); | 321 | filter.addCategory(acChild); | ||
322 | filter.addCategory(acSolo); | 322 | filter.addCategory(acSolo); | ||
323 | XMLandback(filter); | 323 | XMLandback(filter); | ||
324 | PivotTable spending_f(filter); | 324 | PivotTable spending_f(filter); | ||
325 | 325 | | |||
326 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moChild); | 326 | QVERIFY(spending_f.m_grid["Expense"]["Parent"].m_total[eActual][2] == moChild); | ||
327 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moSolo); | 327 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moSolo); | ||
328 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moChild); | 328 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moChild); | ||
329 | 329 | | |||
330 | } | 330 | } | ||
331 | 331 | | |||
332 | void PivotTableTest::testFilterALvsAL() | 332 | void PivotTableTest::testFilterALvsAL() | ||
333 | { | 333 | { | ||
334 | // Test that removing an asset/liability account will remove the entry from an asset/liability report | 334 | // Test that removing an asset/liability account will remove the entry from an asset/liability report | ||
335 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 335 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
336 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 336 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
337 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 337 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
338 | 338 | | |||
339 | MyMoneyReport filter; | 339 | MyMoneyReport filter; | ||
340 | filter.setRowType(MyMoneyReport::eAssetLiability); | 340 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
341 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 341 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
342 | filter.addAccount(acChecking); | 342 | filter.addAccount(acChecking); | ||
343 | filter.addCategory(acChild); | 343 | filter.addCategory(acChild); | ||
344 | filter.addCategory(acSolo); | 344 | filter.addCategory(acSolo); | ||
345 | XMLandback(filter); | 345 | XMLandback(filter); | ||
346 | PivotTable networth_f(filter); | 346 | PivotTable networth_f(filter); | ||
347 | QVERIFY(networth_f.m_grid.m_total[eActual][2] == -moSolo + moCheckingOpen); | 347 | QVERIFY(networth_f.m_grid.m_total[eActual][2] == -moSolo + moCheckingOpen); | ||
348 | } | 348 | } | ||
349 | 349 | | |||
350 | void PivotTableTest::testFilterALvsIE() | 350 | void PivotTableTest::testFilterALvsIE() | ||
351 | { | 351 | { | ||
352 | // Test that removing an asset/liability account will remove the entry from an income/spending report | 352 | // Test that removing an asset/liability account will remove the entry from an income/spending report | ||
353 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 353 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
354 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 354 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
355 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 355 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
356 | 356 | | |||
357 | MyMoneyReport filter; | 357 | MyMoneyReport filter; | ||
358 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 358 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
359 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 359 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
360 | filter.addAccount(acChecking); | 360 | filter.addAccount(acChecking); | ||
361 | QVERIFY(file->transactionList(filter).count() == 1); | 361 | QVERIFY(file->transactionList(filter).count() == 1); | ||
362 | 362 | | |||
363 | XMLandback(filter); | 363 | XMLandback(filter); | ||
364 | PivotTable spending_f(filter); | 364 | PivotTable spending_f(filter); | ||
365 | 365 | | |||
366 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moZero); | 366 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moZero); | ||
367 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moSolo); | 367 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moSolo); | ||
368 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 368 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
369 | } | 369 | } | ||
370 | 370 | | |||
371 | void PivotTableTest::testFilterAllvsIE() | 371 | void PivotTableTest::testFilterAllvsIE() | ||
372 | { | 372 | { | ||
373 | // Test that removing an asset/liability account AND an income/expense | 373 | // Test that removing an asset/liability account AND an income/expense | ||
374 | // category will remove the entry from an income/spending report | 374 | // category will remove the entry from an income/spending report | ||
375 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 375 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
376 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 376 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
377 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 377 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
378 | 378 | | |||
379 | MyMoneyReport filter; | 379 | MyMoneyReport filter; | ||
380 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 380 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
381 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | 381 | filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); | ||
382 | filter.addAccount(acCredit); | 382 | filter.addAccount(acCredit); | ||
383 | filter.addCategory(acChild); | 383 | filter.addCategory(acChild); | ||
384 | PivotTable spending_f(filter); | 384 | PivotTable spending_f(filter); | ||
385 | 385 | | |||
386 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moZero); | 386 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][1] == moZero); | ||
387 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moChild); | 387 | QVERIFY(spending_f.m_grid["Expense"].m_total[eActual][2] == moChild); | ||
388 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | 388 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 456 | #if 0 | |||
458 | g.open(QIODevice::WriteOnly); | 458 | g.open(QIODevice::WriteOnly); | ||
459 | MyMoneyStorageXML xml; | 459 | MyMoneyStorageXML xml; | ||
460 | IMyMoneyStorageFormat& interface = xml; | 460 | IMyMoneyStorageFormat& interface = xml; | ||
461 | interface.writeFile(&g, dynamic_cast<IMyMoneySerialize*>(MyMoneyFile::instance()->storage())); | 461 | interface.writeFile(&g, dynamic_cast<IMyMoneySerialize*>(MyMoneyFile::instance()->storage())); | ||
462 | g.close(); | 462 | g.close(); | ||
463 | #endif | 463 | #endif | ||
464 | 464 | | |||
465 | MyMoneyReport filter; | 465 | MyMoneyReport filter; | ||
466 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 466 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
467 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 467 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
468 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | 468 | filter.setDetailLevel(MyMoneyReport::eDetailAll); | ||
469 | filter.setConvertCurrency(true); | 469 | filter.setConvertCurrency(true); | ||
470 | filter.setName("Multiple Currency Spending Rerport (with currency conversion)"); | 470 | filter.setName("Multiple Currency Spending Rerport (with currency conversion)"); | ||
471 | XMLandback(filter); | 471 | XMLandback(filter); | ||
472 | 472 | | |||
473 | PivotTable spending_f(filter); | 473 | PivotTable spending_f(filter); | ||
474 | 474 | | |||
Show All 24 Lines | |||||
499 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acCanCash)][eActual][3] == (moCanTransaction)); | 499 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acCanCash)][eActual][3] == (moCanTransaction)); | ||
500 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][1] == (moJpyTransaction)); | 500 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][1] == (moJpyTransaction)); | ||
501 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][2] == (moJpyTransaction)); | 501 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][2] == (moJpyTransaction)); | ||
502 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][3] == (moJpyTransaction)); | 502 | QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][ReportAccount(acJpyCash)][eActual][3] == (moJpyTransaction)); | ||
503 | 503 | | |||
504 | filter.setConvertCurrency(true); | 504 | filter.setConvertCurrency(true); | ||
505 | filter.clearTransactionFilter(); | 505 | filter.clearTransactionFilter(); | ||
506 | filter.setName("Multiple currency net worth"); | 506 | filter.setName("Multiple currency net worth"); | ||
507 | filter.setRowType(MyMoneyReport::eAssetLiability); | 507 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
508 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 508 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
509 | XMLandback(filter); | 509 | XMLandback(filter); | ||
510 | PivotTable networth_f(filter); | 510 | PivotTable networth_f(filter); | ||
511 | writeTabletoCSV(networth_f); | 511 | writeTabletoCSV(networth_f); | ||
512 | 512 | | |||
513 | // test single foreign currency | 513 | // test single foreign currency | ||
514 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][ReportAccount(acCanChecking)][eActual][1] == (moCanOpening*moCanPrice)); | 514 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][ReportAccount(acCanChecking)][eActual][1] == (moCanOpening*moCanPrice)); | ||
515 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][ReportAccount(acCanChecking)][eActual][2] == ((moCanOpening - moCanTransaction)*moCanPrice)); | 515 | QVERIFY(networth_f.m_grid["Asset"]["Canadian Checking"][ReportAccount(acCanChecking)][eActual][2] == ((moCanOpening - moCanTransaction)*moCanPrice)); | ||
Show All 23 Lines | 538 | { | |||
539 | // test more advanced filtering capabilities | 539 | // test more advanced filtering capabilities | ||
540 | 540 | | |||
541 | // amount | 541 | // amount | ||
542 | { | 542 | { | ||
543 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 543 | TransactionHelper t1(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
544 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 544 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
545 | 545 | | |||
546 | MyMoneyReport filter; | 546 | MyMoneyReport filter; | ||
547 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 547 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
548 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 548 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
549 | filter.setAmountFilter(moChild, moChild); | 549 | filter.setAmountFilter(moChild, moChild); | ||
550 | XMLandback(filter); | 550 | XMLandback(filter); | ||
551 | PivotTable spending_f(filter); | 551 | PivotTable spending_f(filter); | ||
552 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | 552 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moChild); | ||
553 | } | 553 | } | ||
554 | 554 | | |||
555 | // payee (specific) | 555 | // payee (specific) | ||
556 | { | 556 | { | ||
557 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 557 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
558 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 558 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
559 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 559 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
560 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | 560 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | ||
561 | 561 | | |||
562 | MyMoneyReport filter; | 562 | MyMoneyReport filter; | ||
563 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 563 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
564 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 564 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
565 | filter.addPayee(MyMoneyFile::instance()->payeeByName("Thomas Baumgart").id()); | 565 | filter.addPayee(MyMoneyFile::instance()->payeeByName("Thomas Baumgart").id()); | ||
566 | filter.setName("Spending with Payee Filter"); | 566 | filter.setName("Spending with Payee Filter"); | ||
567 | XMLandback(filter); | 567 | XMLandback(filter); | ||
568 | PivotTable spending_f(filter); | 568 | PivotTable spending_f(filter); | ||
569 | writeTabletoHTML(spending_f, "Spending with Payee Filter.html"); | 569 | writeTabletoHTML(spending_f, "Spending with Payee Filter.html"); | ||
570 | 570 | | |||
571 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][10] == moThomas); | 571 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][10] == moThomas); | ||
572 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moThomas); | 572 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moThomas); | ||
573 | } | 573 | } | ||
574 | // payee (no payee) | 574 | // payee (no payee) | ||
575 | { | 575 | { | ||
576 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 576 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
577 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 577 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
578 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 578 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
579 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moNoPayee, acCredit, acParent, QString(), QString()); | 579 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moNoPayee, acCredit, acParent, QString(), QString()); | ||
580 | 580 | | |||
581 | MyMoneyReport filter; | 581 | MyMoneyReport filter; | ||
582 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 582 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
583 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 583 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
584 | filter.addPayee(QString()); | 584 | filter.addPayee(QString()); | ||
585 | XMLandback(filter); | 585 | XMLandback(filter); | ||
586 | PivotTable spending_f(filter); | 586 | PivotTable spending_f(filter); | ||
587 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][10] == moNoPayee); | 587 | QVERIFY(spending_f.m_grid["Expense"]["Parent"][ReportAccount(acParent)][eActual][10] == moNoPayee); | ||
588 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moNoPayee); | 588 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moNoPayee); | ||
589 | } | 589 | } | ||
590 | 590 | | |||
591 | // text | 591 | // text | ||
592 | { | 592 | { | ||
593 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 593 | TransactionHelper t1(QDate(2004, 10, 31), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
594 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 594 | TransactionHelper t2(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
595 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | 595 | TransactionHelper t3(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moChild, acCredit, acChild); | ||
596 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | 596 | TransactionHelper t4(QDate(2004, 11, 7), MyMoneySplit::ActionWithdrawal, moThomas, acCredit, acParent, QString(), "Thomas Baumgart"); | ||
597 | 597 | | |||
598 | MyMoneyReport filter; | 598 | MyMoneyReport filter; | ||
599 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 599 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
600 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 600 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
601 | filter.setTextFilter(QRegExp("Thomas")); | 601 | filter.setTextFilter(QRegExp("Thomas")); | ||
602 | XMLandback(filter); | 602 | XMLandback(filter); | ||
603 | PivotTable spending_f(filter); | 603 | PivotTable spending_f(filter); | ||
604 | } | 604 | } | ||
605 | 605 | | |||
606 | // type (payment, deposit, transfer) | 606 | // type (payment, deposit, transfer) | ||
607 | { | 607 | { | ||
608 | TransactionHelper t1(QDate(2004, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 608 | TransactionHelper t1(QDate(2004, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
609 | TransactionHelper t2(QDate(2004, 2, 1), MyMoneySplit::ActionDeposit, -moParent1, acCredit, acParent); | 609 | TransactionHelper t2(QDate(2004, 2, 1), MyMoneySplit::ActionDeposit, -moParent1, acCredit, acParent); | ||
610 | TransactionHelper t3(QDate(2004, 11, 1), MyMoneySplit::ActionTransfer, moChild, acCredit, acChecking); | 610 | TransactionHelper t3(QDate(2004, 11, 1), MyMoneySplit::ActionTransfer, moChild, acCredit, acChecking); | ||
611 | 611 | | |||
612 | MyMoneyReport filter; | 612 | MyMoneyReport filter; | ||
613 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 613 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
614 | filter.addType((int)eMyMoney::TransactionFilter::Type::Payments); | 614 | filter.addType((int)eMyMoney::TransactionFilter::Type::Payments); | ||
615 | XMLandback(filter); | 615 | XMLandback(filter); | ||
616 | PivotTable spending_f(filter); | 616 | PivotTable spending_f(filter); | ||
617 | 617 | | |||
618 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 618 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
619 | 619 | | |||
620 | filter.clearTransactionFilter(); | 620 | filter.clearTransactionFilter(); | ||
621 | filter.addType((int)eMyMoney::TransactionFilter::Type::Deposits); | 621 | filter.addType((int)eMyMoney::TransactionFilter::Type::Deposits); | ||
622 | XMLandback(filter); | 622 | XMLandback(filter); | ||
623 | PivotTable spending_f2(filter); | 623 | PivotTable spending_f2(filter); | ||
624 | 624 | | |||
625 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moParent1); | 625 | QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moParent1); | ||
626 | 626 | | |||
627 | filter.clearTransactionFilter(); | 627 | filter.clearTransactionFilter(); | ||
628 | filter.addType((int)eMyMoney::TransactionFilter::Type::Transfers); | 628 | filter.addType((int)eMyMoney::TransactionFilter::Type::Transfers); | ||
629 | XMLandback(filter); | 629 | XMLandback(filter); | ||
630 | PivotTable spending_f3(filter); | 630 | PivotTable spending_f3(filter); | ||
631 | 631 | | |||
632 | QVERIFY(spending_f3.m_grid.m_total[eActual].m_total == moZero); | 632 | QVERIFY(spending_f3.m_grid.m_total[eActual].m_total == moZero); | ||
633 | 633 | | |||
634 | filter.setRowType(MyMoneyReport::eAssetLiability); | 634 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
635 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31)); | 635 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31)); | ||
636 | XMLandback(filter); | 636 | XMLandback(filter); | ||
637 | PivotTable networth_f4(filter); | 637 | PivotTable networth_f4(filter); | ||
638 | 638 | | |||
639 | QVERIFY(networth_f4.m_grid["Asset"].m_total[eActual][11] == moCheckingOpen + moChild); | 639 | QVERIFY(networth_f4.m_grid["Asset"].m_total[eActual][11] == moCheckingOpen + moChild); | ||
640 | QVERIFY(networth_f4.m_grid["Liability"].m_total[eActual][11] == - moCreditOpen + moChild); | 640 | QVERIFY(networth_f4.m_grid["Liability"].m_total[eActual][11] == - moCreditOpen + moChild); | ||
641 | QVERIFY(networth_f4.m_grid.m_total[eActual][9] == moCheckingOpen + moCreditOpen); | 641 | QVERIFY(networth_f4.m_grid.m_total[eActual][9] == moCheckingOpen + moCreditOpen); | ||
642 | QVERIFY(networth_f4.m_grid.m_total[eActual][10] == moCheckingOpen + moCreditOpen); | 642 | QVERIFY(networth_f4.m_grid.m_total[eActual][10] == moCheckingOpen + moCreditOpen); | ||
Show All 17 Lines | 646 | { | |||
660 | splits = t2.splits(); | 660 | splits = t2.splits(); | ||
661 | splits[0].setReconcileFlag(eMyMoney::Split::State::Reconciled); | 661 | splits[0].setReconcileFlag(eMyMoney::Split::State::Reconciled); | ||
662 | splits[1].setReconcileFlag(eMyMoney::Split::State::Reconciled); | 662 | splits[1].setReconcileFlag(eMyMoney::Split::State::Reconciled); | ||
663 | t2.modifySplit(splits[0]); | 663 | t2.modifySplit(splits[0]); | ||
664 | t2.modifySplit(splits[1]); | 664 | t2.modifySplit(splits[1]); | ||
665 | t2.update(); | 665 | t2.update(); | ||
666 | 666 | | |||
667 | MyMoneyReport filter; | 667 | MyMoneyReport filter; | ||
668 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 668 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
669 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 669 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
670 | filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); | 670 | filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); | ||
671 | XMLandback(filter); | 671 | XMLandback(filter); | ||
672 | PivotTable spending_f(filter); | 672 | PivotTable spending_f(filter); | ||
673 | 673 | | |||
674 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | 674 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); | ||
675 | 675 | | |||
676 | filter.addState((int)eMyMoney::TransactionFilter::State::Reconciled); | 676 | filter.addState((int)eMyMoney::TransactionFilter::State::Reconciled); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 691 | { | |||
721 | splits = t2.splits(); | 721 | splits = t2.splits(); | ||
722 | splits[0].setNumber("4"); | 722 | splits[0].setNumber("4"); | ||
723 | splits[1].setNumber("4"); | 723 | splits[1].setNumber("4"); | ||
724 | t4.modifySplit(splits[0]); | 724 | t4.modifySplit(splits[0]); | ||
725 | t4.modifySplit(splits[1]); | 725 | t4.modifySplit(splits[1]); | ||
726 | t4.update(); | 726 | t4.update(); | ||
727 | 727 | | |||
728 | MyMoneyReport filter; | 728 | MyMoneyReport filter; | ||
729 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 729 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
730 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 730 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
731 | filter.setNumberFilter("1", "3"); | 731 | filter.setNumberFilter("1", "3"); | ||
732 | XMLandback(filter); | 732 | XMLandback(filter); | ||
733 | PivotTable spending_f(filter); | 733 | PivotTable spending_f(filter); | ||
734 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2); | 734 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2); | ||
735 | } | 735 | } | ||
736 | 736 | | |||
737 | // blank dates | 737 | // blank dates | ||
738 | { | 738 | { | ||
739 | TransactionHelper t1y1(QDate(2003, 10, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 739 | TransactionHelper t1y1(QDate(2003, 10, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
740 | TransactionHelper t2y1(QDate(2003, 11, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 740 | TransactionHelper t2y1(QDate(2003, 11, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
741 | TransactionHelper t3y1(QDate(2003, 12, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 741 | TransactionHelper t3y1(QDate(2003, 12, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
742 | 742 | | |||
743 | TransactionHelper t1y2(QDate(2004, 4, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 743 | TransactionHelper t1y2(QDate(2004, 4, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
744 | TransactionHelper t2y2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 744 | TransactionHelper t2y2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
745 | TransactionHelper t3y2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 745 | TransactionHelper t3y2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
746 | 746 | | |||
747 | TransactionHelper t1y3(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 747 | TransactionHelper t1y3(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
748 | TransactionHelper t2y3(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 748 | TransactionHelper t2y3(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
749 | TransactionHelper t3y3(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 749 | TransactionHelper t3y3(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
750 | 750 | | |||
751 | MyMoneyReport filter; | 751 | MyMoneyReport filter; | ||
752 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 752 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
753 | filter.setDateFilter(QDate(), QDate(2004, 7, 1)); | 753 | filter.setDateFilter(QDate(), QDate(2004, 7, 1)); | ||
754 | XMLandback(filter); | 754 | XMLandback(filter); | ||
755 | PivotTable spending_f(filter); | 755 | PivotTable spending_f(filter); | ||
756 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2); | 756 | QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2); | ||
757 | 757 | | |||
758 | filter.clearTransactionFilter(); | 758 | filter.clearTransactionFilter(); | ||
759 | XMLandback(filter); | 759 | XMLandback(filter); | ||
760 | PivotTable spending_f2(filter); | 760 | PivotTable spending_f2(filter); | ||
Show All 15 Lines | 768 | { | |||
776 | TransactionHelper t2q2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 776 | TransactionHelper t2q2(QDate(2004, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
777 | TransactionHelper t3q2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 777 | TransactionHelper t3q2(QDate(2004, 6, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
778 | 778 | | |||
779 | TransactionHelper t1y2(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 779 | TransactionHelper t1y2(QDate(2005, 1, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
780 | TransactionHelper t2y2(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 780 | TransactionHelper t2y2(QDate(2005, 5, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
781 | TransactionHelper t3y2(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 781 | TransactionHelper t3y2(QDate(2005, 9, 1), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
782 | 782 | | |||
783 | MyMoneyReport filter; | 783 | MyMoneyReport filter; | ||
784 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 784 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
785 | filter.setDateFilter(QDate(2003, 12, 31), QDate(2005, 12, 31)); | 785 | filter.setDateFilter(QDate(2003, 12, 31), QDate(2005, 12, 31)); | ||
786 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 786 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
787 | filter.setColumnType(MyMoneyReport::eBiMonths); | 787 | filter.setColumnType(MyMoneyReport::Column::BiMonths); | ||
788 | XMLandback(filter); | 788 | XMLandback(filter); | ||
789 | PivotTable spending_b(filter); | 789 | PivotTable spending_b(filter); | ||
790 | 790 | | |||
791 | QVERIFY(spending_b.m_grid.m_total[eActual][0] == moZero); | 791 | QVERIFY(spending_b.m_grid.m_total[eActual][0] == moZero); | ||
792 | QVERIFY(spending_b.m_grid.m_total[eActual][1] == -moParent1 - moSolo); | 792 | QVERIFY(spending_b.m_grid.m_total[eActual][1] == -moParent1 - moSolo); | ||
793 | QVERIFY(spending_b.m_grid.m_total[eActual][2] == -moParent2 - moSolo); | 793 | QVERIFY(spending_b.m_grid.m_total[eActual][2] == -moParent2 - moSolo); | ||
794 | QVERIFY(spending_b.m_grid.m_total[eActual][3] == -moParent); | 794 | QVERIFY(spending_b.m_grid.m_total[eActual][3] == -moParent); | ||
795 | QVERIFY(spending_b.m_grid.m_total[eActual][4] == moZero); | 795 | QVERIFY(spending_b.m_grid.m_total[eActual][4] == moZero); | ||
796 | QVERIFY(spending_b.m_grid.m_total[eActual][5] == moZero); | 796 | QVERIFY(spending_b.m_grid.m_total[eActual][5] == moZero); | ||
797 | QVERIFY(spending_b.m_grid.m_total[eActual][6] == moZero); | 797 | QVERIFY(spending_b.m_grid.m_total[eActual][6] == moZero); | ||
798 | QVERIFY(spending_b.m_grid.m_total[eActual][7] == -moSolo); | 798 | QVERIFY(spending_b.m_grid.m_total[eActual][7] == -moSolo); | ||
799 | QVERIFY(spending_b.m_grid.m_total[eActual][8] == moZero); | 799 | QVERIFY(spending_b.m_grid.m_total[eActual][8] == moZero); | ||
800 | QVERIFY(spending_b.m_grid.m_total[eActual][9] == -moParent1); | 800 | QVERIFY(spending_b.m_grid.m_total[eActual][9] == -moParent1); | ||
801 | QVERIFY(spending_b.m_grid.m_total[eActual][10] == moZero); | 801 | QVERIFY(spending_b.m_grid.m_total[eActual][10] == moZero); | ||
802 | QVERIFY(spending_b.m_grid.m_total[eActual][11] == -moParent2); | 802 | QVERIFY(spending_b.m_grid.m_total[eActual][11] == -moParent2); | ||
803 | QVERIFY(spending_b.m_grid.m_total[eActual][12] == moZero); | 803 | QVERIFY(spending_b.m_grid.m_total[eActual][12] == moZero); | ||
804 | 804 | | |||
805 | filter.setColumnType(MyMoneyReport::eQuarters); | 805 | filter.setColumnType(MyMoneyReport::Column::Quarters); | ||
806 | XMLandback(filter); | 806 | XMLandback(filter); | ||
807 | PivotTable spending_q(filter); | 807 | PivotTable spending_q(filter); | ||
808 | 808 | | |||
809 | QVERIFY(spending_q.m_grid.m_total[eActual][0] == moZero); | 809 | QVERIFY(spending_q.m_grid.m_total[eActual][0] == moZero); | ||
810 | QVERIFY(spending_q.m_grid.m_total[eActual][1] == -moSolo - moParent); | 810 | QVERIFY(spending_q.m_grid.m_total[eActual][1] == -moSolo - moParent); | ||
811 | QVERIFY(spending_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | 811 | QVERIFY(spending_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | ||
812 | QVERIFY(spending_q.m_grid.m_total[eActual][3] == moZero); | 812 | QVERIFY(spending_q.m_grid.m_total[eActual][3] == moZero); | ||
813 | QVERIFY(spending_q.m_grid.m_total[eActual][4] == moZero); | 813 | QVERIFY(spending_q.m_grid.m_total[eActual][4] == moZero); | ||
814 | QVERIFY(spending_q.m_grid.m_total[eActual][5] == -moSolo); | 814 | QVERIFY(spending_q.m_grid.m_total[eActual][5] == -moSolo); | ||
815 | QVERIFY(spending_q.m_grid.m_total[eActual][6] == -moParent1); | 815 | QVERIFY(spending_q.m_grid.m_total[eActual][6] == -moParent1); | ||
816 | QVERIFY(spending_q.m_grid.m_total[eActual][7] == -moParent2); | 816 | QVERIFY(spending_q.m_grid.m_total[eActual][7] == -moParent2); | ||
817 | QVERIFY(spending_q.m_grid.m_total[eActual][8] == moZero); | 817 | QVERIFY(spending_q.m_grid.m_total[eActual][8] == moZero); | ||
818 | 818 | | |||
819 | filter.setRowType(MyMoneyReport::eAssetLiability); | 819 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
820 | filter.setName("Net Worth by Quarter"); | 820 | filter.setName("Net Worth by Quarter"); | ||
821 | XMLandback(filter); | 821 | XMLandback(filter); | ||
822 | PivotTable networth_q(filter); | 822 | PivotTable networth_q(filter); | ||
823 | writeTabletoHTML(networth_q, "Net Worth by Quarter.html"); | 823 | writeTabletoHTML(networth_q, "Net Worth by Quarter.html"); | ||
824 | 824 | | |||
825 | QVERIFY(networth_q.m_grid.m_total[eActual][1] == moZero); | 825 | QVERIFY(networth_q.m_grid.m_total[eActual][1] == moZero); | ||
826 | QVERIFY(networth_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | 826 | QVERIFY(networth_q.m_grid.m_total[eActual][2] == -moSolo - moParent); | ||
827 | QVERIFY(networth_q.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent + moCheckingOpen); | 827 | QVERIFY(networth_q.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent + moCheckingOpen); | ||
828 | QVERIFY(networth_q.m_grid.m_total[eActual][4] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 828 | QVERIFY(networth_q.m_grid.m_total[eActual][4] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
829 | QVERIFY(networth_q.m_grid.m_total[eActual][5] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 829 | QVERIFY(networth_q.m_grid.m_total[eActual][5] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
830 | QVERIFY(networth_q.m_grid.m_total[eActual][6] == -moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 830 | QVERIFY(networth_q.m_grid.m_total[eActual][6] == -moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
831 | QVERIFY(networth_q.m_grid.m_total[eActual][7] == -moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 831 | QVERIFY(networth_q.m_grid.m_total[eActual][7] == -moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
832 | QVERIFY(networth_q.m_grid.m_total[eActual][8] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 832 | QVERIFY(networth_q.m_grid.m_total[eActual][8] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
833 | QVERIFY(networth_q.m_grid.m_total[eActual][9] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 833 | QVERIFY(networth_q.m_grid.m_total[eActual][9] == -moParent2 - moParent1 - moSolo - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
834 | 834 | | |||
835 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 835 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
836 | filter.setColumnType(MyMoneyReport::eYears); | 836 | filter.setColumnType(MyMoneyReport::Column::Years); | ||
837 | XMLandback(filter); | 837 | XMLandback(filter); | ||
838 | PivotTable spending_y(filter); | 838 | PivotTable spending_y(filter); | ||
839 | 839 | | |||
840 | QVERIFY(spending_y.m_grid.m_total[eActual][0] == moZero); | 840 | QVERIFY(spending_y.m_grid.m_total[eActual][0] == moZero); | ||
841 | QVERIFY(spending_y.m_grid.m_total[eActual][1] == -moSolo - moParent - moSolo - moParent); | 841 | QVERIFY(spending_y.m_grid.m_total[eActual][1] == -moSolo - moParent - moSolo - moParent); | ||
842 | QVERIFY(spending_y.m_grid.m_total[eActual][2] == -moSolo - moParent); | 842 | QVERIFY(spending_y.m_grid.m_total[eActual][2] == -moSolo - moParent); | ||
843 | QVERIFY(spending_y.m_grid.m_total[eActual].m_total == -moSolo - moParent - moSolo - moParent - moSolo - moParent); | 843 | QVERIFY(spending_y.m_grid.m_total[eActual].m_total == -moSolo - moParent - moSolo - moParent - moSolo - moParent); | ||
844 | 844 | | |||
845 | filter.setRowType(MyMoneyReport::eAssetLiability); | 845 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
846 | XMLandback(filter); | 846 | XMLandback(filter); | ||
847 | PivotTable networth_y(filter); | 847 | PivotTable networth_y(filter); | ||
848 | 848 | | |||
849 | QVERIFY(networth_y.m_grid.m_total[eActual][1] == moZero); | 849 | QVERIFY(networth_y.m_grid.m_total[eActual][1] == moZero); | ||
850 | QVERIFY(networth_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 850 | QVERIFY(networth_y.m_grid.m_total[eActual][2] == -moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
851 | QVERIFY(networth_y.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | 851 | QVERIFY(networth_y.m_grid.m_total[eActual][3] == -moSolo - moParent - moSolo - moParent - moSolo - moParent + moCheckingOpen + moCreditOpen); | ||
852 | 852 | | |||
853 | // Test days-based reports | 853 | // Test days-based reports | ||
854 | 854 | | |||
855 | TransactionHelper t1d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 855 | TransactionHelper t1d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
856 | TransactionHelper t2d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 856 | TransactionHelper t2d1(QDate(2004, 7, 1), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
857 | TransactionHelper t3d1(QDate(2004, 7, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 857 | TransactionHelper t3d1(QDate(2004, 7, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
858 | 858 | | |||
859 | TransactionHelper t1d2(QDate(2004, 7, 14), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 859 | TransactionHelper t1d2(QDate(2004, 7, 14), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
860 | TransactionHelper t2d2(QDate(2004, 7, 15), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 860 | TransactionHelper t2d2(QDate(2004, 7, 15), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
861 | TransactionHelper t3d2(QDate(2004, 7, 20), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 861 | TransactionHelper t3d2(QDate(2004, 7, 20), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
862 | 862 | | |||
863 | TransactionHelper t1d3(QDate(2004, 8, 2), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | 863 | TransactionHelper t1d3(QDate(2004, 8, 2), MyMoneySplit::ActionWithdrawal, moSolo, acChecking, acSolo); | ||
864 | TransactionHelper t2d3(QDate(2004, 8, 3), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | 864 | TransactionHelper t2d3(QDate(2004, 8, 3), MyMoneySplit::ActionWithdrawal, moParent1, acCredit, acParent); | ||
865 | TransactionHelper t3d3(QDate(2004, 8, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | 865 | TransactionHelper t3d3(QDate(2004, 8, 4), MyMoneySplit::ActionWithdrawal, moParent2, acCredit, acParent); | ||
866 | 866 | | |||
867 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 7, 14)); | 867 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 7, 14)); | ||
868 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 868 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
869 | filter.setColumnType(MyMoneyReport::eMonths); | 869 | filter.setColumnType(MyMoneyReport::Column::Months); | ||
870 | filter.setColumnsAreDays(true); | 870 | filter.setColumnsAreDays(true); | ||
871 | filter.setName("Spending by Days"); | 871 | filter.setName("Spending by Days"); | ||
872 | 872 | | |||
873 | XMLandback(filter); | 873 | XMLandback(filter); | ||
874 | PivotTable spending_days(filter); | 874 | PivotTable spending_days(filter); | ||
875 | writeTabletoHTML(spending_days, "Spending by Days.html"); | 875 | writeTabletoHTML(spending_days, "Spending by Days.html"); | ||
876 | 876 | | |||
877 | QVERIFY(spending_days.m_grid.m_total[eActual][2] == -moParent2); | 877 | QVERIFY(spending_days.m_grid.m_total[eActual][2] == -moParent2); | ||
878 | QVERIFY(spending_days.m_grid.m_total[eActual][12] == -moSolo); | 878 | QVERIFY(spending_days.m_grid.m_total[eActual][12] == -moSolo); | ||
879 | QVERIFY(spending_days.m_grid.m_total[eActual].m_total == -moSolo - moParent2); | 879 | QVERIFY(spending_days.m_grid.m_total[eActual].m_total == -moSolo - moParent2); | ||
880 | 880 | | |||
881 | // set the first day of the week to 1 | 881 | // set the first day of the week to 1 | ||
882 | QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); | 882 | QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); | ||
883 | 883 | | |||
884 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 8, 1)); | 884 | filter.setDateFilter(QDate(2004, 7, 2), QDate(2004, 8, 1)); | ||
885 | filter.setRowType(MyMoneyReport::eExpenseIncome); | 885 | filter.setRowType(MyMoneyReport::Row::ExpenseIncome); | ||
886 | filter.setColumnType(static_cast<MyMoneyReport::EColumnType>(7)); | 886 | filter.setColumnType(static_cast<MyMoneyReport::Column::Type>(7)); | ||
887 | filter.setColumnsAreDays(true); | 887 | filter.setColumnsAreDays(true); | ||
888 | filter.setName("Spending by Weeks"); | 888 | filter.setName("Spending by Weeks"); | ||
889 | 889 | | |||
890 | XMLandback(filter); | 890 | XMLandback(filter); | ||
891 | PivotTable spending_weeks(filter); | 891 | PivotTable spending_weeks(filter); | ||
892 | writeTabletoHTML(spending_weeks, "Spending by Weeks.html"); | 892 | writeTabletoHTML(spending_weeks, "Spending by Weeks.html"); | ||
893 | 893 | | |||
894 | // restore the locale | 894 | // restore the locale | ||
Show All 34 Lines | 908 | try { | |||
929 | 929 | | |||
930 | makeEquityPrice(eqStock1, QDate(2004, 10, 1), MyMoneyMoney(100.00)); | 930 | makeEquityPrice(eqStock1, QDate(2004, 10, 1), MyMoneyMoney(100.00)); | ||
931 | 931 | | |||
932 | // | 932 | // | ||
933 | // Net Worth Report (with investments) | 933 | // Net Worth Report (with investments) | ||
934 | // | 934 | // | ||
935 | 935 | | |||
936 | MyMoneyReport networth_r; | 936 | MyMoneyReport networth_r; | ||
937 | networth_r.setRowType(MyMoneyReport::eAssetLiability); | 937 | networth_r.setRowType(MyMoneyReport::Row::AssetLiability); | ||
938 | networth_r.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31).addDays(-1)); | 938 | networth_r.setDateFilter(QDate(2004, 1, 1), QDate(2004, 12, 31).addDays(-1)); | ||
939 | XMLandback(networth_r); | 939 | XMLandback(networth_r); | ||
940 | PivotTable networth(networth_r); | 940 | PivotTable networth(networth_r); | ||
941 | 941 | | |||
942 | networth.dump("networth_i.html"); | 942 | networth.dump("networth_i.html"); | ||
943 | 943 | | |||
944 | QVERIFY(networth.m_grid["Asset"]["Investment"].m_total[eActual][1] == moZero); | 944 | QVERIFY(networth.m_grid["Asset"]["Investment"].m_total[eActual][1] == moZero); | ||
945 | // 1000 shares @ $100.00 | 945 | // 1000 shares @ $100.00 | ||
Show All 36 Lines | |||||
982 | void PivotTableTest::testBudget() | 982 | void PivotTableTest::testBudget() | ||
983 | { | 983 | { | ||
984 | 984 | | |||
985 | // 1. Budget on A, transactions on A | 985 | // 1. Budget on A, transactions on A | ||
986 | { | 986 | { | ||
987 | BudgetHelper budget; | 987 | BudgetHelper budget; | ||
988 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | 988 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | ||
989 | 989 | | |||
990 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 990 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
991 | MyMoneyReport::eMonths, | 991 | MyMoneyReport::Column::Months, | ||
992 | eMyMoney::TransactionFilter::Date::YearToDate, | 992 | eMyMoney::TransactionFilter::Date::YearToDate, | ||
993 | MyMoneyReport::eDetailTop, | 993 | MyMoneyReport::eDetailTop, | ||
994 | "Yearly Budgeted vs. Actual", "Default Report"); | 994 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
995 | PivotTable table(report); | 995 | PivotTable table(report); | ||
996 | } | 996 | } | ||
997 | 997 | | |||
998 | // 2. Budget on B, not applying to sub accounts, transactions on B and B:1 | 998 | // 2. Budget on B, not applying to sub accounts, transactions on B and B:1 | ||
999 | { | 999 | { | ||
1000 | BudgetHelper budget; | 1000 | BudgetHelper budget; | ||
1001 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | 1001 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | ||
1002 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 1002 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
1003 | MyMoneyReport::eMonths, | 1003 | MyMoneyReport::Column::Months, | ||
1004 | eMyMoney::TransactionFilter::Date::YearToDate, | 1004 | eMyMoney::TransactionFilter::Date::YearToDate, | ||
1005 | MyMoneyReport::eDetailTop, | 1005 | MyMoneyReport::eDetailTop, | ||
1006 | "Yearly Budgeted vs. Actual", "Default Report"); | 1006 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
1007 | PivotTable table(report); | 1007 | PivotTable table(report); | ||
1008 | } | 1008 | } | ||
1009 | 1009 | | |||
1010 | // - Both B and B:1 totals should show up | 1010 | // - Both B and B:1 totals should show up | ||
1011 | // - B actuals compare against B budget | 1011 | // - B actuals compare against B budget | ||
1012 | // - B:1 actuals compare against 0 | 1012 | // - B:1 actuals compare against 0 | ||
1013 | 1013 | | |||
1014 | // 3. Budget on C, applying to sub accounts, transactions on C and C:1 and C:1:a | 1014 | // 3. Budget on C, applying to sub accounts, transactions on C and C:1 and C:1:a | ||
1015 | { | 1015 | { | ||
1016 | BudgetHelper budget; | 1016 | BudgetHelper budget; | ||
1017 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, true, MyMoneyMoney(100.0)); | 1017 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, true, MyMoneyMoney(100.0)); | ||
1018 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 1018 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
1019 | MyMoneyReport::eMonths, | 1019 | MyMoneyReport::Column::Months, | ||
1020 | eMyMoney::TransactionFilter::Date::YearToDate, | 1020 | eMyMoney::TransactionFilter::Date::YearToDate, | ||
1021 | MyMoneyReport::eDetailTop , | 1021 | MyMoneyReport::eDetailTop , | ||
1022 | "Yearly Budgeted vs. Actual", "Default Report"); | 1022 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
1023 | PivotTable table(report); | 1023 | PivotTable table(report); | ||
1024 | } | 1024 | } | ||
1025 | 1025 | | |||
1026 | // - Only C totals show up, not C:1 or C:1:a totals | 1026 | // - Only C totals show up, not C:1 or C:1:a totals | ||
1027 | // - C + C:1 totals compare against C budget | 1027 | // - C + C:1 totals compare against C budget | ||
1028 | 1028 | | |||
1029 | // 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 | 1029 | // 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 | ||
1030 | { | 1030 | { | ||
1031 | BudgetHelper budget; | 1031 | BudgetHelper budget; | ||
1032 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | 1032 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acParent, false, MyMoneyMoney(100.0)); | ||
1033 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acChild, false, MyMoneyMoney(100.0)); | 1033 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acChild, false, MyMoneyMoney(100.0)); | ||
1034 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSecondChild, true, MyMoneyMoney(100.0)); | 1034 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSecondChild, true, MyMoneyMoney(100.0)); | ||
1035 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 1035 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
1036 | MyMoneyReport::eMonths, | 1036 | MyMoneyReport::Column::Months, | ||
1037 | eMyMoney::TransactionFilter::Date::YearToDate, | 1037 | eMyMoney::TransactionFilter::Date::YearToDate, | ||
1038 | MyMoneyReport::eDetailTop, | 1038 | MyMoneyReport::eDetailTop, | ||
1039 | "Yearly Budgeted vs. Actual", "Default Report"); | 1039 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
1040 | PivotTable table(report); | 1040 | PivotTable table(report); | ||
1041 | } | 1041 | } | ||
1042 | 1042 | | |||
1043 | // - Totals for D, D:1, D:2 show up. D:2:a and D:2:b do not | 1043 | // - Totals for D, D:1, D:2 show up. D:2:a and D:2:b do not | ||
1044 | // - D actuals (only) compare against D budget | 1044 | // - D actuals (only) compare against D budget | ||
1045 | // - Ditto for D:1 | 1045 | // - Ditto for D:1 | ||
1046 | // - D:2 acutals and children compare against D:2 budget | 1046 | // - D:2 acutals and children compare against D:2 budget | ||
1047 | 1047 | | |||
1048 | // 5. Budget on E, no transactions on E | 1048 | // 5. Budget on E, no transactions on E | ||
1049 | { | 1049 | { | ||
1050 | BudgetHelper budget; | 1050 | BudgetHelper budget; | ||
1051 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | 1051 | budget += BudgetEntryHelper(QDate(2006, 1, 1), acSolo, false, MyMoneyMoney(100.0)); | ||
1052 | MyMoneyReport report(MyMoneyReport::eBudgetActual, | 1052 | MyMoneyReport report(MyMoneyReport::Row::BudgetActual, | ||
1053 | MyMoneyReport::eMonths, | 1053 | MyMoneyReport::Column::Months, | ||
1054 | eMyMoney::TransactionFilter::Date::YearToDate, | 1054 | eMyMoney::TransactionFilter::Date::YearToDate, | ||
1055 | MyMoneyReport::eDetailTop, | 1055 | MyMoneyReport::eDetailTop, | ||
1056 | "Yearly Budgeted vs. Actual", "Default Report"); | 1056 | "Yearly Budgeted vs. Actual", "Default Report"); | ||
1057 | PivotTable table(report); | 1057 | PivotTable table(report); | ||
1058 | } | 1058 | } | ||
1059 | } | 1059 | } | ||
1060 | 1060 | | |||
1061 | void PivotTableTest::testHtmlEncoding() | 1061 | void PivotTableTest::testHtmlEncoding() | ||
1062 | { | 1062 | { | ||
1063 | MyMoneyReport filter; | 1063 | MyMoneyReport filter; | ||
1064 | filter.setRowType(MyMoneyReport::eAssetLiability); | 1064 | filter.setRowType(MyMoneyReport::Row::AssetLiability); | ||
1065 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | 1065 | filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); | ||
1066 | XMLandback(filter); | 1066 | XMLandback(filter); | ||
1067 | PivotTable networth_f(filter); | 1067 | PivotTable networth_f(filter); | ||
1068 | 1068 | | |||
1069 | QByteArray encoding = QTextCodec::codecForLocale()->name(); | 1069 | QByteArray encoding = QTextCodec::codecForLocale()->name(); | ||
1070 | 1070 | | |||
1071 | QString html = networth_f.renderReport(QLatin1String("html"), encoding, | 1071 | QString html = networth_f.renderReport(QLatin1String("html"), encoding, | ||
1072 | filter.name(), false); | 1072 | filter.name(), false); | ||
1073 | 1073 | | |||
1074 | QRegExp rx(QString::fromLatin1("*<meta * charset=" + encoding + "*>*")); | 1074 | QRegExp rx(QString::fromLatin1("*<meta * charset=" + encoding + "*>*")); | ||
1075 | rx.setPatternSyntax(QRegExp::Wildcard); | 1075 | rx.setPatternSyntax(QRegExp::Wildcard); | ||
1076 | rx.setCaseSensitivity(Qt::CaseInsensitive); | 1076 | rx.setCaseSensitivity(Qt::CaseInsensitive); | ||
1077 | QVERIFY(rx.exactMatch(html)); | 1077 | QVERIFY(rx.exactMatch(html)); | ||
1078 | } | 1078 | } |