2 * CSVAccountReportElement.cpp - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #include "CSVAccountReportElement.h"
14 #include "TableLineInfo.h"
15 #include "tjlib-internal.h"
19 CSVAccountReportElement::CSVAccountReportElement(Report* r,
22 CSVReportElement(r, df, dl)
24 uint sc = r->getProject()->getMaxScenarios();
25 columns.append(new TableColumnInfo(sc, "no"));
26 columns.append(new TableColumnInfo(sc, "name"));
27 columns.append(new TableColumnInfo(sc, "total"));
29 accountSortCriteria[0] = CoreAttributesList::TreeMode;
30 accountSortCriteria[1] = CoreAttributesList::NameUp;
34 CSVAccountReportElement::generate()
38 generateTableHeader();
40 AccountList filteredList;
41 if (!filterAccountList(filteredList, AllAccounts, hideAccount,
44 maxDepthAccountList = filteredList.maxDepth();
46 /* Generate table of cost accounts. */
47 if (!filterAccountList(filteredList, Cost, hideAccount, rollUpAccount))
49 sortAccountList(filteredList);
50 maxDepthAccountList = filteredList.maxDepth();
54 for (AccountListIterator ali(filteredList); *ali != 0; ++ali, ++aNo)
56 tli.ca1 = tli.account = *ali;
57 for (uint sc = 0; sc < scenarios.count(); ++sc)
61 tli.sc = scenarios[sc];
62 generateLine(&tli, sc == 0 ? 6 : 7);
66 /* Generate summary line for cost accounts. */
68 tli.specialName = i18n("Total Costs");
69 for (uint sc = 0; sc < scenarios.count(); ++sc)
73 tli.sc = scenarios[sc];
74 generateLine(&tli, sc == 0 ? 8 : 9);
77 for (QPtrListIterator<TableColumnInfo> ci(columns); *ci != 0; ++ci)
79 (*ci)->addSumToMemory(true);
83 /* Generate table of revenue accounts. */
84 if (!filterAccountList(filteredList, Revenue, hideAccount, rollUpAccount))
86 sortAccountList(filteredList);
87 maxDepthAccountList = filteredList.maxDepth();
90 tli.specialName = QString::null;
91 for (AccountListIterator ali(filteredList); *ali != 0; ++ali, ++aNo)
93 tli.ca1 = tli.account = *ali;
94 for (uint sc = 0; sc < scenarios.count(); ++sc)
98 tli.sc = scenarios[sc];
99 generateLine(&tli, sc == 0 ? 6 : 7);
103 /* Generate summary line for revenue accounts. */
105 tli.specialName = i18n("Total Revenues");
106 for (uint sc = 0; sc < scenarios.count(); ++sc)
110 tli.sc = scenarios[sc];
111 generateLine(&tli, sc == 0 ? 8 : 9);
114 for (QPtrListIterator<TableColumnInfo> ci(columns); *ci != 0; ++ci)
116 (*ci)->addSumToMemory(false);
117 (*ci)->recallMemory();
120 /* Generate total summary line. */
121 tli.specialName = i18n("Total");
122 for (uint sc = 0; sc < scenarios.count(); ++sc)
126 tli.sc = scenarios[sc];
127 generateLine(&tli, sc == 0 ? 8 : 9);