FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdItemCoa.hpp
Go to the documentation of this file.
1 // --------------------------------------------------------------------
2 // Copyright © 2011-2013 Mathieu Schopfer
3 //
4 // This file is part of FreeDebks.
5 //
6 // FreeDebks is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // FreeDebks is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with FreeDebks. If not, see <http://www.gnu.org/licenses/>.
18 // --------------------------------------------------------------------
19 
20 #ifndef FDITEMCOA_HPP
21 #define FDITEMCOA_HPP
22 
23 #include "dataDefinitions.hpp"
24 
25 #include <QtXml>
26 
28 
43 class FdItemCoa
44 {
45 private:
53  QString mId;
61  QString mLabel;
69  AccountSignature mSignature;
77  bool mOnBalanceSheet;
85  double mInitialBalance;
96  double mBalance;
104  double mPreviousBalance;
112  FdItemCoa_p mParent;
124  QList<FdItemCoa_p> mChildren;
125 
126 public:
127  FdItemCoa(FdItemCoa_p parent = FdItemCoa_p(0),
128  QString id = "",
129  QString label = "",
130  AccountSignature signature = PlusMinus,
131  double initial = 0,
132  double balance = 0,
133  double previous = 0);
134  static FdItemCoa_p pointer(QDomElement item, FdItemCoa_p parent = FdItemCoa_p(0));
135  static FdItemCoa_p pointer(FdItemCoa_p model, FdItemCoa_p parent = FdItemCoa_p(0));
136  CoaItemType type() const;
137  QString id() const;
138  QString label() const;
139  bool onBalanceSheet() const;
140  AccountSignature signature() const;
141  double initialBalance() const;
142  double balance() const;
143  double previousBalance() const;
144  void setId(QString id);
145  void setLabel(QString label);
146  void setOnBalanceSheet(bool var);
147  void setSignature(AccountSignature signature);
148  void setInitialBalance(double initial);
149  void setPreviousBalance(double previous);
150  bool wasUsed() const;
151  QString displayLabel() const;
152  FdItemCoa_p parent();
153  void setParent(FdItemCoa_p parent);
154  FdItemCoa_p child(int row);
155  QList<FdItemCoa_p> children();
156  QList<FdItemCoa_p> findChildren(QString text);
157  int childRow(const FdItemCoa* child) const;
158  int childrenCount() const;
159  int row() const;
160  void appendChild(FdItemCoa_p item);
161  bool insertChild(FdItemCoa_p item, int row);
162  bool removeChild(int row);
163  QStringList childrenAccountsIds() const;
164  QStringList childrenAccountsLabels() const;
165  QList<FdItemCoa_p> childrenAccounts() const;
166  FdItemCoa_p childById(QString id) const;
167  FdItemCoa_p childByLabel(QString label) const;
168  void resetBalance();
169  void computeBalances();
170  void debited(double amount);
171  void credited(double amount);
172  QDomElement toXml(QDomDocument& document) const;
173 };
174 
175 #endif // FDITEMCOA_HPP