summaryrefslogtreecommitdiffstats
path: root/kmymoney2/mymoney/mymoneyinstitution.h
blob: a6a2eeb7aeced93f832dd144b80ed4738de4e36e (plain)
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
/***************************************************************************
                          mymoneyinstitution.h
                          -------------------
    copyright            : (C) 2002-2005 by Thomas Baumgart
    email                : 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 MYMONEYINSTITUTION_H
#define MYMONEYINSTITUTION_H

// ----------------------------------------------------------------------------
// TQt Includes

#include <tqstring.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tqpixmap.h>

// ----------------------------------------------------------------------------
// Project Includes

#include <kmymoney/export.h>
#include <kmymoney/mymoneykeyvaluecontainer.h>
#include <kmymoney/mymoneyobject.h>
#include <kmymoney/mymoneyutils.h>

class MyMoneyFile;
class MyMoneyMoney;

/**
  * This class represents a Bank contained within a MyMoneyFile object
  *
  * @author Thomas Baumgart
  */
class KMYMONEY_EXPORT MyMoneyInstitution : public MyMoneyObject, public MyMoneyKeyValueContainer
{
public:
  /**
    * This is the constructor for a new empty institution description
    */
  MyMoneyInstitution();

  /**
    * This is the constructor used by an application to fill the
    * values required for a new institution. This object should then be
    * passed to @see MyMoneyFile::addInstitution
    */
  MyMoneyInstitution(const TQString& name,
              const TQString& city,
              const TQString& street,
              const TQString& postcode,
              const TQString& telephone,
              const TQString& manager,
              const TQString& sortCode);

  /**
    * This is the destructor for any MyMoneyInstitution object
    */
  ~MyMoneyInstitution();

  /**
    * This is the constructor for a new institution known to the current file
    *
    * @param id id assigned to the new institution object
    * @param right institution definition
    */
  MyMoneyInstitution(const TQString& id, const MyMoneyInstitution& right);

  /**
    * This is the constructor for an institution that is described by a
    * TQDomElement (e.g. from a file).
    *
    * @param el const reference to the TQDomElement from which to
    *           create the object
    */
  MyMoneyInstitution(const TQDomElement& el);

  const TQString& manager(void) const { return m_manager; }
  const TQString& name(void) const { return m_name; }
  const TQString& postcode(void) const { return m_postcode; }
  const TQString& street(void) const { return m_street; }
  const TQString& telephone(void) const { return m_telephone; }
  const TQString& town(void) const { return m_town; }
  const TQString& city(void) const { return town(); }
  const TQString& sortcode(void) const { return m_sortcode; }

  void setManager(TQString manager) { m_manager = manager; }
  void setName(TQString name) { m_name = name; }
  void setPostcode(TQString code) { m_postcode = code; }
  void setStreet(TQString street) { m_street = street; }
  void setTelephone(TQString tel) { m_telephone = tel; }
  void setTown(TQString town) { m_town = town; }
  void setCity(TQString town) { setTown(town); }
  void setSortcode(TQString code) { m_sortcode = code; }

  /**
    * This method adds the id of an account to the account list of
    * this institution It is verified, that the account is only
    * mentioned once.
    *
    * @param account id of the account to be added
    */
  void addAccountId(const TQString& account);

  /**
    * This method deletes the id of an account from the account list
    * of this institution
    *
    * @param account id of the account to be deleted
    * @return id of account deleted, otherwise empty string
    */
  TQString removeAccountId(const TQString& account);

  /**
    * This method is used to return the set of accounts known to
    * this institution
    * return TQStringList of account ids
    */
  const TQStringList& accountList(void) const { return m_accountList; }

  /**
    * This method returns the number of accounts known to
    * this institution
    * @return number of accounts
    */
  unsigned int accountCount(void) const { return m_accountList.count(); }

  bool operator == (const MyMoneyInstitution&) const;
  bool operator < (const MyMoneyInstitution& right) const;

  void writeXML(TQDomDocument& document, TQDomElement& parent) const;

  /**
    * This method checks if a reference to the given object exists. It returns,
    * a @p true if the object is referencing the one requested by the
    * parameter @p id. If it does not, this method returns @p false.
    *
    * @param id id of the object to be checked for references
    * @retval true This object references object with id @p id.
    * @retval false This object does not reference the object with id @p id.
    */
  virtual bool hasReferenceTo(const TQString& id) const;

  TQPixmap pixmap() const;

private:
  // Bank 'fields'
  /**
    * This member variable keeps the name of the institution
    */
  TQString m_name;

  /**
    * This member variable keeps the city of the institution
    */
  TQString m_town;

  /**
    * This member variable keeps the street of the institution
    */
  TQString m_street;

  /**
    * This member variable keeps the zip-code of the institution
    */
  TQString m_postcode;

  /**
    * This member variable keeps the telephone number of the institution
    */
  TQString m_telephone;

  /**
    * This member variable keeps the name of the representative of
    * the institution
    */
  TQString m_manager;

  /**
    * This member variable keeps the sort code of the institution.
    * FIXME: I have no idea
    * what it is good for. I keep it because it was in the old engine.
    */
  TQString m_sortcode;

  /**
    * This member variable keeps the sorted list of the account ids
    * available at this institution
    */
  TQStringList m_accountList;
};

#endif