1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
/***************************************************************************
reportaccount.h
-------------------
begin : Sat May 22 2004
copyright : (C) 2004-2005 by Ace Jones
email : <ace.j@hotpop.com>
Thomas Baumgart <ipwizard@users.sourceforge.net>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef REPORTACCOUNT_H
#define REPORTACCOUNT_H
// ----------------------------------------------------------------------------
// QT Includes
#include <tqstringlist.h>
// ----------------------------------------------------------------------------
// KDE Includes
// ----------------------------------------------------------------------------
// Project Includes
#include "../mymoney/mymoneyaccount.h"
namespace reports {
/**
* This is a MyMoneyAccount as viewed from the reporting engine.
*
* All reporting methods should use ReportAccount INSTEAD OF
* MyMoneyAccount at all times.
*
* The primary functionality this provides is a full chain of account
* hierarchy that is easy to traverse. It's needed because the PivotTable
* grid needs to store and sort by the full account hierarchy, while still
* having access to the account itself for currency conversion.
*
* In addition, several other convenience functions are provided that may
* be worth moving into MyMoneyAccount at some point.
*
* @author Ace Jones
*
* @short
**/
class ReportAccount: public MyMoneyAccount
{
private:
TQStringList m_nameHierarchy;
public:
/**
* Default constructor
*
* Needed to allow this object to be stored in a TQMap.
*/
ReportAccount( void );
/**
* Copy constructor
*
* Needed to allow this object to be stored in a TQMap.
*/
ReportAccount( const ReportAccount& );
/**
* Regular constructor
*
* @param accountid Account which this account descriptor should be based off of
*/
ReportAccount( const TQString& accountid );
/**
* Regular constructor
*
* @param accountid Account which this account descriptor should be based off of
*/
ReportAccount( const MyMoneyAccount& accountid );
/**
* @param right The object to compare against
* @return bool True if this account's fully-qualified hierarchy name
* is less than that of the given qccount
*/
bool operator<( const ReportAccount& right ) const;
/**
* Returns the price of this account's underlying currency on the indicated date,
* translated into the account's deep currency
*
* There are three different currencies in play with a single Account:
* - The underlying currency: What currency the account itself is denominated in
* - The deep currency: The underlying currency's own underlying currency. This
* is only a factor if the underlying currency of this account IS NOT a
* currency itself, but is some other kind of security. In that case, the
* underlying security has its own currency. The deep currency is the
* currency of the underlying security. On the other hand, if the account
* has a currency itself, then the deep currency == the underlying currency,
* and this function will return 1.0.
* - The base currency: The base currency of the user's overall file
*
* @param date The date in question
* @return MyMoneyMoney The value of the account's currency on that date
*/
MyMoneyMoney deepCurrencyPrice( const TQDate& date ) const;
/**
* Returns the price of this account's deep currency on the indicated date,
* translated into the base currency
*
* @param date The date in question
* @return MyMoneyMoney The value of the account's currency on that date
*/
MyMoneyMoney baseCurrencyPrice( const TQDate& date ) const;
/**
* Returns the price of this account's deep currency on the indicated date,
* translated into the base currency
*
* @param foreignCurrency The currency on which the price will be returned
* @param date The date in question
* @return MyMoneyMoney The value of the account's currency on that date
*/
MyMoneyMoney foreignCurrencyPrice( const TQString foreignCurrency, const TQDate& date ) const;
/**
* Fetch the trading symbol of this account's deep currency
*
* @return The account's currency trading currency object
*/
MyMoneySecurity currency( void ) const;
/**
* Determine if this account's deep currency is different from the file's
* base currency
*
* @return bool True if this account is in a foreign currency
*/
bool isForeignCurrency( void ) const;
/**
* The name of only this account. No matter how deep the hierarchy, this
* method only returns the last name in the list, which is the engine name]
* of this account.
*
* @return TQString The account's name
*/
TQString name( void ) const;
/**
* The entire hierarchy of this account descriptor
* This is similiar to debugName(), however debugName() is not guaranteed
* to always look pretty, while fullName() is. So if the user is ever
* going to see the results, use fullName().
*
* @return TQString The account's full hierarchy
*/
TQString fullName( void ) const;
/**
* The entire hierarchy of this account descriptor, suitable for displaying
* in debugging output
*
* @return TQString The account's full hierarchy (suitable for debugging)
*/
TQString debugName( void ) const;
/**
* Whether this account is a 'top level' parent account. This means that
* it's parent is an account class, like asset, liability, expense or income
*
* @return bool True if this account is a top level parent account
*/
/*inline*/ bool isTopLevel( void ) const;
/**
* Returns the name of the top level parent account
*
* (See isTopLevel for a definition of 'top level parent')
*
* @return TQString The name of the top level parent account
*/
/*inline*/ TQString topParentName( void ) const;
/**
* Returns a report account containing the top parent account
*
* @return ReportAccount The account of the top parent
*/
ReportAccount topParent( void ) const;
/**
* Returns a report account containing the immediate parent account
*
* @return ReportAccount The account of the immediate parent
*/
ReportAccount parent( void ) const;
/**
* Returns the number of accounts in this account's hierarchy. If this is a
* Top Category, it returns 1. If it's parent is a Top Category, returns 2,
* etc.
*
* @return unsigned Hierarchy depth
*/
unsigned hierarchyDepth( void ) const;
/**
* Returns whether this account is a liquid asset
*
*/
bool isLiquidAsset( void ) const;
/**
* Returns whether this account is a liquid liability
*
*/
bool isLiquidLiability( void ) const;
protected:
/**
* Calculates the full account hierarchy of this account
*/
void calculateAccountHierarchy( void );
};
} // end namespace reports
#endif // REPORTACCOUNT_H
|