Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/querytable.cpp
Show First 20 Lines • Show All 263 Lines • ▼ Show 20 Line(s) | |||||
264 | 264 | | |||
265 | void QueryTable::init() | 265 | void QueryTable::init() | ||
266 | { | 266 | { | ||
267 | m_columns.clear(); | 267 | m_columns.clear(); | ||
268 | m_group.clear(); | 268 | m_group.clear(); | ||
269 | m_subtotal.clear(); | 269 | m_subtotal.clear(); | ||
270 | m_postcolumns.clear(); | 270 | m_postcolumns.clear(); | ||
271 | switch (m_config.rowType()) { | 271 | switch (m_config.rowType()) { | ||
272 | case MyMoneyReport::eAccountByTopAccount: | 272 | case MyMoneyReport::Row::AccountByTopAccount: | ||
273 | case MyMoneyReport::eEquityType: | 273 | case MyMoneyReport::Row::EquityType: | ||
274 | case MyMoneyReport::eAccountType: | 274 | case MyMoneyReport::Row::AccountType: | ||
275 | case MyMoneyReport::eInstitution: | 275 | case MyMoneyReport::Row::Institution: | ||
276 | constructAccountTable(); | 276 | constructAccountTable(); | ||
277 | m_columns << ctAccount; | 277 | m_columns << ctAccount; | ||
278 | break; | 278 | break; | ||
279 | 279 | | |||
280 | case MyMoneyReport::eAccount: | 280 | case MyMoneyReport::Row::Account: | ||
281 | constructTransactionTable(); | 281 | constructTransactionTable(); | ||
282 | m_columns << ctAccountID << ctPostDate; | 282 | m_columns << ctAccountID << ctPostDate; | ||
283 | break; | 283 | break; | ||
284 | 284 | | |||
285 | case MyMoneyReport::ePayee: | 285 | case MyMoneyReport::Row::Payee: | ||
286 | case MyMoneyReport::eTag: | 286 | case MyMoneyReport::Row::Tag: | ||
287 | case MyMoneyReport::eMonth: | 287 | case MyMoneyReport::Row::Month: | ||
288 | case MyMoneyReport::eWeek: | 288 | case MyMoneyReport::Row::Week: | ||
289 | constructTransactionTable(); | 289 | constructTransactionTable(); | ||
290 | m_columns << ctPostDate << ctAccount; | 290 | m_columns << ctPostDate << ctAccount; | ||
291 | break; | 291 | break; | ||
292 | case MyMoneyReport::eCashFlow: | 292 | case MyMoneyReport::Row::CashFlow: | ||
293 | constructSplitsTable(); | 293 | constructSplitsTable(); | ||
294 | m_columns << ctPostDate; | 294 | m_columns << ctPostDate; | ||
295 | break; | 295 | break; | ||
296 | default: | 296 | default: | ||
297 | constructTransactionTable(); | 297 | constructTransactionTable(); | ||
298 | m_columns << ctPostDate; | 298 | m_columns << ctPostDate; | ||
299 | } | 299 | } | ||
300 | 300 | | |||
301 | // Sort the data to match the report definition | 301 | // Sort the data to match the report definition | ||
302 | m_subtotal << ctValue; | 302 | m_subtotal << ctValue; | ||
303 | 303 | | |||
304 | switch (m_config.rowType()) { | 304 | switch (m_config.rowType()) { | ||
305 | case MyMoneyReport::eCashFlow: | 305 | case MyMoneyReport::Row::CashFlow: | ||
306 | m_group << ctCategoryType << ctTopCategory << ctCategory; | 306 | m_group << ctCategoryType << ctTopCategory << ctCategory; | ||
307 | break; | 307 | break; | ||
308 | case MyMoneyReport::eCategory: | 308 | case MyMoneyReport::Row::Category: | ||
309 | m_group << ctCategoryType << ctTopCategory << ctCategory; | 309 | m_group << ctCategoryType << ctTopCategory << ctCategory; | ||
310 | break; | 310 | break; | ||
311 | case MyMoneyReport::eTopCategory: | 311 | case MyMoneyReport::Row::TopCategory: | ||
312 | m_group << ctCategoryType << ctTopCategory; | 312 | m_group << ctCategoryType << ctTopCategory; | ||
313 | break; | 313 | break; | ||
314 | case MyMoneyReport::eTopAccount: | 314 | case MyMoneyReport::Row::TopAccount: | ||
315 | m_group << ctTopAccount << ctAccount; | 315 | m_group << ctTopAccount << ctAccount; | ||
316 | break; | 316 | break; | ||
317 | case MyMoneyReport::eAccount: | 317 | case MyMoneyReport::Row::Account: | ||
318 | m_group << ctAccount; | 318 | m_group << ctAccount; | ||
319 | break; | 319 | break; | ||
320 | case MyMoneyReport::eAccountReconcile: | 320 | case MyMoneyReport::Row::AccountReconcile: | ||
321 | m_group << ctAccount << ctReconcileFlag; | 321 | m_group << ctAccount << ctReconcileFlag; | ||
322 | break; | 322 | break; | ||
323 | case MyMoneyReport::ePayee: | 323 | case MyMoneyReport::Row::Payee: | ||
324 | m_group << ctPayee; | 324 | m_group << ctPayee; | ||
325 | break; | 325 | break; | ||
326 | case MyMoneyReport::eTag: | 326 | case MyMoneyReport::Row::Tag: | ||
327 | m_group << ctTag; | 327 | m_group << ctTag; | ||
328 | break; | 328 | break; | ||
329 | case MyMoneyReport::eMonth: | 329 | case MyMoneyReport::Row::Month: | ||
330 | m_group << ctMonth; | 330 | m_group << ctMonth; | ||
331 | break; | 331 | break; | ||
332 | case MyMoneyReport::eWeek: | 332 | case MyMoneyReport::Row::Week: | ||
333 | m_group << ctWeek; | 333 | m_group << ctWeek; | ||
334 | break; | 334 | break; | ||
335 | case MyMoneyReport::eAccountByTopAccount: | 335 | case MyMoneyReport::Row::AccountByTopAccount: | ||
336 | m_group << ctTopAccount; | 336 | m_group << ctTopAccount; | ||
337 | break; | 337 | break; | ||
338 | case MyMoneyReport::eEquityType: | 338 | case MyMoneyReport::Row::EquityType: | ||
339 | m_group << ctEquityType; | 339 | m_group << ctEquityType; | ||
340 | break; | 340 | break; | ||
341 | case MyMoneyReport::eAccountType: | 341 | case MyMoneyReport::Row::AccountType: | ||
342 | m_group << ctType; | 342 | m_group << ctType; | ||
343 | break; | 343 | break; | ||
344 | case MyMoneyReport::eInstitution: | 344 | case MyMoneyReport::Row::Institution: | ||
345 | m_group << ctInstitution << ctTopAccount; | 345 | m_group << ctInstitution << ctTopAccount; | ||
346 | break; | 346 | break; | ||
347 | default: | 347 | default: | ||
348 | throw MYMONEYEXCEPTION("QueryTable::QueryTable(): unhandled row type"); | 348 | throw MYMONEYEXCEPTION("QueryTable::QueryTable(): unhandled row type"); | ||
349 | } | 349 | } | ||
350 | 350 | | |||
351 | QVector<cellTypeE> sort = QVector<cellTypeE>::fromList(m_group) << QVector<cellTypeE>::fromList(m_columns) << ctID << ctRank; | 351 | QVector<cellTypeE> sort = QVector<cellTypeE>::fromList(m_group) << QVector<cellTypeE>::fromList(m_columns) << ctID << ctRank; | ||
352 | 352 | | |||
353 | m_columns.clear(); | 353 | m_columns.clear(); | ||
354 | switch (m_config.rowType()) { | 354 | switch (m_config.rowType()) { | ||
355 | case MyMoneyReport::eAccountByTopAccount: | 355 | case MyMoneyReport::Row::AccountByTopAccount: | ||
356 | case MyMoneyReport::eEquityType: | 356 | case MyMoneyReport::Row::EquityType: | ||
357 | case MyMoneyReport::eAccountType: | 357 | case MyMoneyReport::Row::AccountType: | ||
358 | case MyMoneyReport::eInstitution: | 358 | case MyMoneyReport::Row::Institution: | ||
359 | m_columns << ctAccount; | 359 | m_columns << ctAccount; | ||
360 | break; | 360 | break; | ||
361 | 361 | | |||
362 | default: | 362 | default: | ||
363 | m_columns << ctPostDate; | 363 | m_columns << ctPostDate; | ||
364 | } | 364 | } | ||
365 | 365 | | |||
366 | unsigned qc = m_config.queryColumns(); | 366 | unsigned qc = m_config.queryColumns(); | ||
367 | 367 | | |||
368 | if (qc & MyMoneyReport::eQCnumber) | 368 | if (qc & MyMoneyReport::QueryColumns::Number) | ||
369 | m_columns << ctNumber; | 369 | m_columns << ctNumber; | ||
370 | if (qc & MyMoneyReport::eQCpayee) | 370 | if (qc & MyMoneyReport::QueryColumns::Payee) | ||
371 | m_columns << ctPayee; | 371 | m_columns << ctPayee; | ||
372 | if (qc & MyMoneyReport::eQCtag) | 372 | if (qc & MyMoneyReport::QueryColumns::Tag) | ||
373 | m_columns << ctTag; | 373 | m_columns << ctTag; | ||
374 | if (qc & MyMoneyReport::eQCcategory) | 374 | if (qc & MyMoneyReport::QueryColumns::Category) | ||
375 | m_columns << ctCategory; | 375 | m_columns << ctCategory; | ||
376 | if (qc & MyMoneyReport::eQCaccount) | 376 | if (qc & MyMoneyReport::QueryColumns::Account) | ||
377 | m_columns << ctAccount; | 377 | m_columns << ctAccount; | ||
378 | if (qc & MyMoneyReport::eQCreconciled) | 378 | if (qc & MyMoneyReport::QueryColumns::Reconciled) | ||
379 | m_columns << ctReconcileFlag; | 379 | m_columns << ctReconcileFlag; | ||
380 | if (qc & MyMoneyReport::eQCmemo) | 380 | if (qc & MyMoneyReport::QueryColumns::Memo) | ||
381 | m_columns << ctMemo; | 381 | m_columns << ctMemo; | ||
382 | if (qc & MyMoneyReport::eQCaction) | 382 | if (qc & MyMoneyReport::QueryColumns::Action) | ||
383 | m_columns << ctAction; | 383 | m_columns << ctAction; | ||
384 | if (qc & MyMoneyReport::eQCshares) | 384 | if (qc & MyMoneyReport::QueryColumns::Shares) | ||
385 | m_columns << ctShares; | 385 | m_columns << ctShares; | ||
386 | if (qc & MyMoneyReport::eQCprice) | 386 | if (qc & MyMoneyReport::QueryColumns::Price) | ||
387 | m_columns << ctPrice; | 387 | m_columns << ctPrice; | ||
388 | if (qc & MyMoneyReport::eQCperformance) { | 388 | if (qc & MyMoneyReport::QueryColumns::Performance) { | ||
389 | m_subtotal.clear(); | 389 | m_subtotal.clear(); | ||
390 | switch (m_config.investmentSum()) { | 390 | switch (m_config.investmentSum()) { | ||
391 | case MyMoneyReport::eSumOwnedAndSold: | 391 | case MyMoneyReport::eSumOwnedAndSold: | ||
392 | m_columns << ctBuys << ctSells << ctReinvestIncome << ctCashIncome | 392 | m_columns << ctBuys << ctSells << ctReinvestIncome << ctCashIncome | ||
393 | << ctEndingBalance << ctReturn << ctReturnInvestment; | 393 | << ctEndingBalance << ctReturn << ctReturnInvestment; | ||
394 | m_subtotal << ctBuys << ctSells << ctReinvestIncome << ctCashIncome | 394 | m_subtotal << ctBuys << ctSells << ctReinvestIncome << ctCashIncome | ||
395 | << ctEndingBalance << ctReturn << ctReturnInvestment; | 395 | << ctEndingBalance << ctReturn << ctReturnInvestment; | ||
396 | break; | 396 | break; | ||
Show All 15 Lines | 411 | m_columns << ctStartingBalance << ctBuys << ctSells | |||
412 | << ctReinvestIncome << ctCashIncome << ctEndingBalance | 412 | << ctReinvestIncome << ctCashIncome << ctEndingBalance | ||
413 | << ctReturn << ctReturnInvestment; | 413 | << ctReturn << ctReturnInvestment; | ||
414 | m_subtotal << ctStartingBalance << ctBuys << ctSells | 414 | m_subtotal << ctStartingBalance << ctBuys << ctSells | ||
415 | << ctReinvestIncome << ctCashIncome << ctEndingBalance | 415 | << ctReinvestIncome << ctCashIncome << ctEndingBalance | ||
416 | << ctReturn << ctReturnInvestment; | 416 | << ctReturn << ctReturnInvestment; | ||
417 | break; | 417 | break; | ||
418 | } | 418 | } | ||
419 | } | 419 | } | ||
420 | if (qc & MyMoneyReport::eQCcapitalgain) { | 420 | if (qc & MyMoneyReport::QueryColumns::Capitalgain) { | ||
421 | m_subtotal.clear(); | 421 | m_subtotal.clear(); | ||
422 | switch (m_config.investmentSum()) { | 422 | switch (m_config.investmentSum()) { | ||
423 | case MyMoneyReport::eSumOwned: | 423 | case MyMoneyReport::eSumOwned: | ||
424 | m_columns << ctShares << ctBuyPrice << ctLastPrice | 424 | m_columns << ctShares << ctBuyPrice << ctLastPrice | ||
425 | << ctBuys << ctMarketValue << ctPercentageGain | 425 | << ctBuys << ctMarketValue << ctPercentageGain | ||
426 | << ctCapitalGain; | 426 | << ctCapitalGain; | ||
427 | m_subtotal << ctShares << ctBuyPrice << ctLastPrice | 427 | m_subtotal << ctShares << ctBuyPrice << ctLastPrice | ||
428 | << ctBuys << ctMarketValue << ctPercentageGain | 428 | << ctBuys << ctMarketValue << ctPercentageGain | ||
429 | << ctCapitalGain; | 429 | << ctCapitalGain; | ||
430 | break; | 430 | break; | ||
431 | case MyMoneyReport::eSumSold: | 431 | case MyMoneyReport::eSumSold: | ||
432 | default: | 432 | default: | ||
433 | m_columns << ctBuys << ctSells << ctCapitalGain; | 433 | m_columns << ctBuys << ctSells << ctCapitalGain; | ||
434 | m_subtotal << ctBuys << ctSells << ctCapitalGain; | 434 | m_subtotal << ctBuys << ctSells << ctCapitalGain; | ||
435 | if (m_config.isShowingSTLTCapitalGains()) { | 435 | if (m_config.isShowingSTLTCapitalGains()) { | ||
436 | m_columns << ctBuysST << ctSellsST << ctCapitalGainST | 436 | m_columns << ctBuysST << ctSellsST << ctCapitalGainST | ||
437 | << ctBuysLT << ctSellsLT << ctCapitalGainLT; | 437 | << ctBuysLT << ctSellsLT << ctCapitalGainLT; | ||
438 | m_subtotal << ctBuysST << ctSellsST << ctCapitalGainST | 438 | m_subtotal << ctBuysST << ctSellsST << ctCapitalGainST | ||
439 | << ctBuysLT << ctSellsLT << ctCapitalGainLT; | 439 | << ctBuysLT << ctSellsLT << ctCapitalGainLT; | ||
440 | } | 440 | } | ||
441 | break; | 441 | break; | ||
442 | } | 442 | } | ||
443 | } | 443 | } | ||
444 | if (qc & MyMoneyReport::eQCloan) { | 444 | if (qc & MyMoneyReport::QueryColumns::Loan) { | ||
445 | m_columns << ctPayment << ctInterest << ctFees; | 445 | m_columns << ctPayment << ctInterest << ctFees; | ||
446 | m_postcolumns << ctBalance; | 446 | m_postcolumns << ctBalance; | ||
447 | } | 447 | } | ||
448 | if (qc & MyMoneyReport::eQCbalance) | 448 | if (qc & MyMoneyReport::QueryColumns::Balance) | ||
449 | m_postcolumns << ctBalance; | 449 | m_postcolumns << ctBalance; | ||
450 | 450 | | |||
451 | TableRow::setSortCriteria(sort); | 451 | TableRow::setSortCriteria(sort); | ||
452 | qSort(m_rows); | 452 | qSort(m_rows); | ||
453 | if (m_config.isShowingColumnTotals()) | 453 | if (m_config.isShowingColumnTotals()) | ||
454 | constructTotalRows(); // adds total rows to m_rows | 454 | constructTotalRows(); // adds total rows to m_rows | ||
455 | } | 455 | } | ||
456 | 456 | | |||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 646 | { | |||
654 | report.setConsiderCategory(true); | 654 | report.setConsiderCategory(true); | ||
655 | 655 | | |||
656 | bool use_transfers; | 656 | bool use_transfers; | ||
657 | bool use_summary; | 657 | bool use_summary; | ||
658 | bool hide_details; | 658 | bool hide_details; | ||
659 | bool tag_special_case = false; | 659 | bool tag_special_case = false; | ||
660 | 660 | | |||
661 | switch (m_config.rowType()) { | 661 | switch (m_config.rowType()) { | ||
662 | case MyMoneyReport::eCategory: | 662 | case MyMoneyReport::Row::Category: | ||
663 | case MyMoneyReport::eTopCategory: | 663 | case MyMoneyReport::Row::TopCategory: | ||
664 | use_summary = false; | 664 | use_summary = false; | ||
665 | use_transfers = false; | 665 | use_transfers = false; | ||
666 | hide_details = false; | 666 | hide_details = false; | ||
667 | break; | 667 | break; | ||
668 | case MyMoneyReport::ePayee: | 668 | case MyMoneyReport::Row::Payee: | ||
669 | use_summary = false; | 669 | use_summary = false; | ||
670 | use_transfers = false; | 670 | use_transfers = false; | ||
671 | hide_details = (m_config.detailLevel() == MyMoneyReport::eDetailNone); | 671 | hide_details = (m_config.detailLevel() == MyMoneyReport::eDetailNone); | ||
672 | break; | 672 | break; | ||
673 | case MyMoneyReport::eTag: | 673 | case MyMoneyReport::Row::Tag: | ||
674 | use_summary = false; | 674 | use_summary = false; | ||
675 | use_transfers = false; | 675 | use_transfers = false; | ||
676 | hide_details = (m_config.detailLevel() == MyMoneyReport::eDetailNone); | 676 | hide_details = (m_config.detailLevel() == MyMoneyReport::eDetailNone); | ||
677 | tag_special_case = true; | 677 | tag_special_case = true; | ||
678 | break; | 678 | break; | ||
679 | default: | 679 | default: | ||
680 | use_summary = true; | 680 | use_summary = true; | ||
681 | use_transfers = true; | 681 | use_transfers = true; | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 691 | for (QList<MyMoneyTransaction>::const_iterator it_transaction = transactions.constBegin(); it_transaction != transactions.constEnd(); ++it_transaction) { | |||
757 | } | 757 | } | ||
758 | 758 | | |||
759 | // for "loan" reports, the loan transaction gets special treatment. | 759 | // for "loan" reports, the loan transaction gets special treatment. | ||
760 | // the splits of a loan transaction are placed on one line in the | 760 | // the splits of a loan transaction are placed on one line in the | ||
761 | // reference (loan) account (qA). however, we process the matching | 761 | // reference (loan) account (qA). however, we process the matching | ||
762 | // split entries (qS) normally. | 762 | // split entries (qS) normally. | ||
763 | 763 | | |||
764 | bool loan_special_case = false; | 764 | bool loan_special_case = false; | ||
765 | if (m_config.queryColumns() & MyMoneyReport::eQCloan) { | 765 | if (m_config.queryColumns() & MyMoneyReport::QueryColumns::Loan) { | ||
766 | ReportAccount splitAcc((*it_split).accountId()); | 766 | ReportAccount splitAcc((*it_split).accountId()); | ||
767 | loan_special_case = splitAcc.isLoan(); | 767 | loan_special_case = splitAcc.isLoan(); | ||
768 | } | 768 | } | ||
769 | 769 | | |||
770 | bool include_me = true; | 770 | bool include_me = true; | ||
771 | bool transaction_text = false; //indicates whether a text should be considered as a match for the transaction or for a split only | 771 | bool transaction_text = false; //indicates whether a text should be considered as a match for the transaction or for a split only | ||
772 | QString a_fullname; | 772 | QString a_fullname; | ||
773 | QString a_memo; | 773 | QString a_memo; | ||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Line(s) | 997 | if ((splits.count() > 2) && use_summary) { | |||
999 | 999 | | |||
1000 | //convert to lowest fraction | 1000 | //convert to lowest fraction | ||
1001 | qA[ctSplit] = (-(*it_split).shares() * xr).convert(fraction).toString(); | 1001 | qA[ctSplit] = (-(*it_split).shares() * xr).convert(fraction).toString(); | ||
1002 | qA[ctRank] = QLatin1Char('2'); | 1002 | qA[ctRank] = QLatin1Char('2'); | ||
1003 | } else { | 1003 | } else { | ||
1004 | //this applies when the transaction has only 2 splits, or each split is going to be | 1004 | //this applies when the transaction has only 2 splits, or each split is going to be | ||
1005 | //shown separately, eg. transactions by category | 1005 | //shown separately, eg. transactions by category | ||
1006 | switch (m_config.rowType()) { | 1006 | switch (m_config.rowType()) { | ||
1007 | case MyMoneyReport::eCategory: | 1007 | case MyMoneyReport::Row::Category: | ||
1008 | case MyMoneyReport::eTopCategory: | 1008 | case MyMoneyReport::Row::TopCategory: | ||
1009 | if (splitAcc.isIncomeExpense()) | 1009 | if (splitAcc.isIncomeExpense()) | ||
1010 | qA[ctValue] = (-(*it_split).shares() * xr).convert(fraction).toString(); // needed for category reports, in case of multicurrency transaction it breaks it | 1010 | qA[ctValue] = (-(*it_split).shares() * xr).convert(fraction).toString(); // needed for category reports, in case of multicurrency transaction it breaks it | ||
1011 | break; | 1011 | break; | ||
1012 | default: | 1012 | default: | ||
1013 | break; | 1013 | break; | ||
1014 | } | 1014 | } | ||
1015 | qA[ctSplit].clear(); | 1015 | qA[ctSplit].clear(); | ||
1016 | qA[ctRank] = QLatin1Char('1'); | 1016 | qA[ctRank] = QLatin1Char('1'); | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | |||||
1137 | if (loan_special_case) { | 1137 | if (loan_special_case) { | ||
1138 | m_rows += qA; | 1138 | m_rows += qA; | ||
1139 | } | 1139 | } | ||
1140 | } | 1140 | } | ||
1141 | 1141 | | |||
1142 | // now run through our accts list and add opening and closing balances | 1142 | // now run through our accts list and add opening and closing balances | ||
1143 | 1143 | | |||
1144 | switch (m_config.rowType()) { | 1144 | switch (m_config.rowType()) { | ||
1145 | case MyMoneyReport::eAccount: | 1145 | case MyMoneyReport::Row::Account: | ||
1146 | case MyMoneyReport::eTopAccount: | 1146 | case MyMoneyReport::Row::TopAccount: | ||
1147 | break; | 1147 | break; | ||
1148 | 1148 | | |||
1149 | // case MyMoneyReport::eCategory: | 1149 | // case MyMoneyReport::Row::Category: | ||
1150 | // case MyMoneyReport::eTopCategory: | 1150 | // case MyMoneyReport::Row::TopCategory: | ||
1151 | // case MyMoneyReport::ePayee: | 1151 | // case MyMoneyReport::Row::Payee: | ||
1152 | // case MyMoneyReport::eMonth: | 1152 | // case MyMoneyReport::Row::Month: | ||
1153 | // case MyMoneyReport::eWeek: | 1153 | // case MyMoneyReport::Row::Week: | ||
1154 | default: | 1154 | default: | ||
1155 | return; | 1155 | return; | ||
1156 | } | 1156 | } | ||
1157 | 1157 | | |||
1158 | QDate startDate, endDate; | 1158 | QDate startDate, endDate; | ||
1159 | 1159 | | |||
1160 | report.validDateRange(startDate, endDate); | 1160 | report.validDateRange(startDate, endDate); | ||
1161 | QString strStartDate = startDate.toString(Qt::ISODate); | 1161 | QString strStartDate = startDate.toString(Qt::ISODate); | ||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 1271 | { | |||
1283 | QDate newEndingDate; | 1283 | QDate newEndingDate; | ||
1284 | const bool isSTLT = report.isShowingSTLTCapitalGains(); | 1284 | const bool isSTLT = report.isShowingSTLTCapitalGains(); | ||
1285 | const int settlementPeriod = report.settlementPeriod(); | 1285 | const int settlementPeriod = report.settlementPeriod(); | ||
1286 | QDate termSeparator = report.termSeparator().addDays(-settlementPeriod); | 1286 | QDate termSeparator = report.termSeparator().addDays(-settlementPeriod); | ||
1287 | report.validDateRange(startingDate, endingDate); | 1287 | report.validDateRange(startingDate, endingDate); | ||
1288 | newStartingDate = startingDate; | 1288 | newStartingDate = startingDate; | ||
1289 | newEndingDate = endingDate; | 1289 | newEndingDate = endingDate; | ||
1290 | 1290 | | |||
1291 | if (report.queryColumns() & MyMoneyReport::eQCcapitalgain) { | 1291 | if (report.queryColumns() & MyMoneyReport::QueryColumns::Capitalgain) { | ||
1292 | // Saturday and Sunday aren't valid settlement dates | 1292 | // Saturday and Sunday aren't valid settlement dates | ||
1293 | if (endingDate.dayOfWeek() == Qt::Saturday) | 1293 | if (endingDate.dayOfWeek() == Qt::Saturday) | ||
1294 | endingDate = endingDate.addDays(-1); | 1294 | endingDate = endingDate.addDays(-1); | ||
1295 | else if (endingDate.dayOfWeek() == Qt::Sunday) | 1295 | else if (endingDate.dayOfWeek() == Qt::Sunday) | ||
1296 | endingDate = endingDate.addDays(-2); | 1296 | endingDate = endingDate.addDays(-2); | ||
1297 | 1297 | | |||
1298 | if (termSeparator.dayOfWeek() == Qt::Saturday) | 1298 | if (termSeparator.dayOfWeek() == Qt::Saturday) | ||
1299 | termSeparator = termSeparator.addDays(-1); | 1299 | termSeparator = termSeparator.addDays(-1); | ||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | 1699 | if ((*it_account).isAssetLiability() && m_config.includes((*it_account)) && (*it_account).accountType() != eMyMoney::Account::Type::Investment) { | |||
1703 | MyMoneyMoney shares = file->balance((*it_account).id(), m_config.toDate()); | 1703 | MyMoneyMoney shares = file->balance((*it_account).id(), m_config.toDate()); | ||
1704 | if (shares.isZero() && (*it_account).isClosed()) | 1704 | if (shares.isZero() && (*it_account).isClosed()) | ||
1705 | continue; | 1705 | continue; | ||
1706 | 1706 | | |||
1707 | ReportAccount account(*it_account); | 1707 | ReportAccount account(*it_account); | ||
1708 | TableRow qaccountrow; | 1708 | TableRow qaccountrow; | ||
1709 | CashFlowList accountCashflow; // for total calculation | 1709 | CashFlowList accountCashflow; // for total calculation | ||
1710 | switch(m_config.queryColumns()) { | 1710 | switch(m_config.queryColumns()) { | ||
1711 | case MyMoneyReport::eQCperformance: | 1711 | case MyMoneyReport::QueryColumns::Performance: | ||
1712 | { | 1712 | { | ||
1713 | constructPerformanceRow(account, qaccountrow, accountCashflow); | 1713 | constructPerformanceRow(account, qaccountrow, accountCashflow); | ||
1714 | if (!qaccountrow.isEmpty()) { | 1714 | if (!qaccountrow.isEmpty()) { | ||
1715 | // assuming that that report is grouped by topaccount | 1715 | // assuming that that report is grouped by topaccount | ||
1716 | qaccountrow[ctTopAccount] = account.topParentName(); | 1716 | qaccountrow[ctTopAccount] = account.topParentName(); | ||
1717 | if (!m_containsNonBaseCurrency && account.currency().id() != file->baseCurrency().id()) | 1717 | if (!m_containsNonBaseCurrency && account.currency().id() != file->baseCurrency().id()) | ||
1718 | m_containsNonBaseCurrency = true; | 1718 | m_containsNonBaseCurrency = true; | ||
1719 | if (m_config.isConvertCurrency()) | 1719 | if (m_config.isConvertCurrency()) | ||
1720 | qaccountrow[ctCurrency] = file->baseCurrency().id(); | 1720 | qaccountrow[ctCurrency] = file->baseCurrency().id(); | ||
1721 | else | 1721 | else | ||
1722 | qaccountrow[ctCurrency] = account.currency().id(); | 1722 | qaccountrow[ctCurrency] = account.currency().id(); | ||
1723 | 1723 | | |||
1724 | if (!currencyCashFlow.value(qaccountrow.value(ctCurrency)).contains(qaccountrow.value(ctTopAccount))) | 1724 | if (!currencyCashFlow.value(qaccountrow.value(ctCurrency)).contains(qaccountrow.value(ctTopAccount))) | ||
1725 | currencyCashFlow[qaccountrow.value(ctCurrency)].insert(qaccountrow.value(ctTopAccount), accountCashflow); // create cashflow for unknown account... | 1725 | currencyCashFlow[qaccountrow.value(ctCurrency)].insert(qaccountrow.value(ctTopAccount), accountCashflow); // create cashflow for unknown account... | ||
1726 | else | 1726 | else | ||
1727 | currencyCashFlow[qaccountrow.value(ctCurrency)][qaccountrow.value(ctTopAccount)] += accountCashflow; // ...or add cashflow for known account | 1727 | currencyCashFlow[qaccountrow.value(ctCurrency)][qaccountrow.value(ctTopAccount)] += accountCashflow; // ...or add cashflow for known account | ||
1728 | } | 1728 | } | ||
1729 | break; | 1729 | break; | ||
1730 | } | 1730 | } | ||
1731 | case MyMoneyReport::eQCcapitalgain: | 1731 | case MyMoneyReport::QueryColumns::Capitalgain: | ||
1732 | constructCapitalGainRow(account, qaccountrow); | 1732 | constructCapitalGainRow(account, qaccountrow); | ||
1733 | break; | 1733 | break; | ||
1734 | default: | 1734 | default: | ||
1735 | { | 1735 | { | ||
1736 | //get fraction for account | 1736 | //get fraction for account | ||
1737 | int fraction = account.currency().smallestAccountFraction() != -1 ? | 1737 | int fraction = account.currency().smallestAccountFraction() != -1 ? | ||
1738 | account.currency().smallestAccountFraction() : file->baseCurrency().smallestAccountFraction(); | 1738 | account.currency().smallestAccountFraction() : file->baseCurrency().smallestAccountFraction(); | ||
1739 | 1739 | | |||
Show All 35 Lines | |||||
1775 | if (m_config.isConvertCurrency()) | 1775 | if (m_config.isConvertCurrency()) | ||
1776 | qaccountrow[ctCurrency] = file->baseCurrency().id(); | 1776 | qaccountrow[ctCurrency] = file->baseCurrency().id(); | ||
1777 | else | 1777 | else | ||
1778 | qaccountrow[ctCurrency] = account.currency().id(); | 1778 | qaccountrow[ctCurrency] = account.currency().id(); | ||
1779 | m_rows.append(qaccountrow); | 1779 | m_rows.append(qaccountrow); | ||
1780 | } | 1780 | } | ||
1781 | } | 1781 | } | ||
1782 | 1782 | | |||
1783 | if (m_config.queryColumns() == MyMoneyReport::eQCperformance && m_config.isShowingColumnTotals()) { | 1783 | if (m_config.queryColumns() == MyMoneyReport::QueryColumns::Performance && m_config.isShowingColumnTotals()) { | ||
1784 | TableRow qtotalsrow; | 1784 | TableRow qtotalsrow; | ||
1785 | qtotalsrow[ctRank] = QLatin1Char('4'); // add identification of row as total | 1785 | qtotalsrow[ctRank] = QLatin1Char('4'); // add identification of row as total | ||
1786 | QMap<QString, CashFlowList> currencyGrandCashFlow; | 1786 | QMap<QString, CashFlowList> currencyGrandCashFlow; | ||
1787 | 1787 | | |||
1788 | QMap<QString, QMap<QString, CashFlowList>>::iterator currencyAccGrp = currencyCashFlow.begin(); | 1788 | QMap<QString, QMap<QString, CashFlowList>>::iterator currencyAccGrp = currencyCashFlow.begin(); | ||
1789 | while (currencyAccGrp != currencyCashFlow.end()) { | 1789 | while (currencyAccGrp != currencyCashFlow.end()) { | ||
1790 | // convert map of top accounts with cashflows to TableRow | 1790 | // convert map of top accounts with cashflows to TableRow | ||
1791 | for (QMap<QString, CashFlowList>::iterator topAccount = (*currencyAccGrp).begin(); topAccount != (*currencyAccGrp).end(); ++topAccount) { | 1791 | for (QMap<QString, CashFlowList>::iterator topAccount = (*currencyAccGrp).begin(); topAccount != (*currencyAccGrp).end(); ++topAccount) { | ||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 1885 | if (it_split == splits.end()) { | |||
1886 | it_split = splits.begin(); | 1886 | it_split = splits.begin(); | ||
1887 | } | 1887 | } | ||
1888 | 1888 | | |||
1889 | // for "loan" reports, the loan transaction gets special treatment. | 1889 | // for "loan" reports, the loan transaction gets special treatment. | ||
1890 | // the splits of a loan transaction are placed on one line in the | 1890 | // the splits of a loan transaction are placed on one line in the | ||
1891 | // reference (loan) account (qA). however, we process the matching | 1891 | // reference (loan) account (qA). however, we process the matching | ||
1892 | // split entries (qS) normally. | 1892 | // split entries (qS) normally. | ||
1893 | bool loan_special_case = false; | 1893 | bool loan_special_case = false; | ||
1894 | if (m_config.queryColumns() & MyMoneyReport::eQCloan) { | 1894 | if (m_config.queryColumns() & MyMoneyReport::QueryColumns::Loan) { | ||
1895 | ReportAccount splitAcc((*it_split).accountId()); | 1895 | ReportAccount splitAcc((*it_split).accountId()); | ||
1896 | loan_special_case = splitAcc.isLoan(); | 1896 | loan_special_case = splitAcc.isLoan(); | ||
1897 | } | 1897 | } | ||
1898 | 1898 | | |||
1899 | // There is a slight chance that at this point myBegin is still pointing to splits.end() if the | 1899 | // There is a slight chance that at this point myBegin is still pointing to splits.end() if the | ||
1900 | // transaction only has income and expense splits (which should not happen). In that case, point | 1900 | // transaction only has income and expense splits (which should not happen). In that case, point | ||
1901 | // it to the first split | 1901 | // it to the first split | ||
1902 | if (myBegin == splits.end()) { | 1902 | if (myBegin == splits.end()) { | ||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | |||||
2059 | if (loan_special_case) { | 2059 | if (loan_special_case) { | ||
2060 | m_rows += qA; | 2060 | m_rows += qA; | ||
2061 | } | 2061 | } | ||
2062 | } | 2062 | } | ||
2063 | 2063 | | |||
2064 | // now run through our accts list and add opening and closing balances | 2064 | // now run through our accts list and add opening and closing balances | ||
2065 | 2065 | | |||
2066 | switch (m_config.rowType()) { | 2066 | switch (m_config.rowType()) { | ||
2067 | case MyMoneyReport::eAccount: | 2067 | case MyMoneyReport::Row::Account: | ||
2068 | case MyMoneyReport::eTopAccount: | 2068 | case MyMoneyReport::Row::TopAccount: | ||
2069 | break; | 2069 | break; | ||
2070 | 2070 | | |||
2071 | // case MyMoneyReport::eCategory: | 2071 | // case MyMoneyReport::Row::Category: | ||
2072 | // case MyMoneyReport::eTopCategory: | 2072 | // case MyMoneyReport::Row::TopCategory: | ||
2073 | // case MyMoneyReport::ePayee: | 2073 | // case MyMoneyReport::Row::Payee: | ||
2074 | // case MyMoneyReport::eMonth: | 2074 | // case MyMoneyReport::Row::Month: | ||
2075 | // case MyMoneyReport::eWeek: | 2075 | // case MyMoneyReport::Row::Week: | ||
2076 | default: | 2076 | default: | ||
2077 | return; | 2077 | return; | ||
2078 | } | 2078 | } | ||
2079 | 2079 | | |||
2080 | QDate startDate, endDate; | 2080 | QDate startDate, endDate; | ||
2081 | 2081 | | |||
2082 | report.validDateRange(startDate, endDate); | 2082 | report.validDateRange(startDate, endDate); | ||
2083 | QString strStartDate = startDate.toString(Qt::ISODate); | 2083 | QString strStartDate = startDate.toString(Qt::ISODate); | ||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |