summaryrefslogtreecommitdiffstats
path: root/kmymoney2/mymoney/mymoneystatement.h
blob: a7f8bfeaf990718add36dd3945e0abd7646cb178 (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
/***************************************************************************
                          mymoneystatement.h
                          -------------------
    begin                : Mon Aug 30 2004
    copyright            : (C) 2000-2004 by Michael Edwardes
    email                : mte@users.sourceforge.net
                           Javier Campos Morales <javi_c@users.sourceforge.net>
                           Felix Rodriguez <frodriguez@users.sourceforge.net>
                           John C <thetacoturtle@users.sourceforge.net>
                           Thomas Baumgart <ipwizard@users.sourceforge.net>
                           Kevin Tambascio <ktambascio@users.sourceforge.net>
                           Ace Jones <acejones@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 MYMONEYSTATEMENT_H
#define MYMONEYSTATEMENT_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// ----------------------------------------------------------------------------
// QT Includes

#include <tqstring.h>
#include <tqvaluelist.h>
#include <tqdatetime.h>

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

#include <kmymoney/export.h>
#include <kmymoney/mymoneymoney.h>
#include <kmymoney/mymoneysplit.h>

class TQDomElement;
class TQDomDocument;

/**
Represents the electronic analog of the paper bank statement just like we used to get in the regular mail.  This class is designed to be easy to extend and easy to create with minimal dependencies.  So the header file should include as few project files as possible (preferrably NONE).

@author ace jones
*/
class MyMoneyStatement
{
public:
  MyMoneyStatement() : m_closingBalance(MyMoneyMoney::autoCalc), m_eType(etNone), m_skipCategoryMatching(false) {}

  enum EType { etNone = 0, etCheckings, etSavings, etInvestment, etCreditCard, etEnd };

  class Split {
  public:
    Split() : m_reconcile(MyMoneySplit::NotReconciled) {}
    TQString      m_strCategoryName;
    TQString      m_strMemo;
    TQString      m_accountId;
    MyMoneySplit::reconcileFlagE m_reconcile;
    MyMoneyMoney m_amount;

  };

  class Transaction {
  public:
    Transaction() : m_reconcile(MyMoneySplit::NotReconciled), m_eAction(eaNone) {}
    TQDate m_datePosted;
    TQString m_strPayee;
    TQString m_strMemo;
    TQString m_strNumber;
    TQString m_strBankID;
    MyMoneyMoney m_amount;
    MyMoneySplit::reconcileFlagE m_reconcile;

    // the following members are only used for investment accounts (m_eType==etInvestment)
    // eaNone means the action, shares, and security can be ignored.
    enum EAction { eaNone = 0, eaBuy, eaSell, eaReinvestDividend, eaCashDividend, eaShrsin, eaShrsout, eaStksplit, eaFees, eaInterest, eaEnd };
    EAction m_eAction;
    MyMoneyMoney m_shares;
    MyMoneyMoney m_fees;
    MyMoneyMoney m_price;
    TQString m_strInterestCategory;
    TQString m_strBrokerageAccount;
    TQString m_strSymbol;
    TQString m_strSecurity;
    TQValueList<Split> m_listSplits;
  };

  struct Price
  {
    TQDate m_date;
    TQString m_strSecurity;
    MyMoneyMoney m_amount;
  };

  struct Security
  {
    TQString m_strName;
    TQString m_strSymbol;
    TQString m_strId;
  };

  TQString m_strAccountName;
  TQString m_strAccountNumber;
  TQString m_strRoutingNumber;

  /**
   * The statement provider's information for the statement reader how to find the
   * account. The provider usually leaves some value with a key unique to the provider in the KVP of the
   * MyMoneyAccount object when setting up the connection or at a later point in time.
   * Using the KMyMoneyPlugin::KMMStatementInterface::account() method it can retrieve the
   * MyMoneyAccount object for this key. The account id of that account should be returned
   * here. If no id is available, leave it empty.
   */
  TQString m_accountId;

  TQString m_strCurrency;
  TQDate m_dateBegin;
  TQDate m_dateEnd;
  MyMoneyMoney m_closingBalance;
  EType m_eType;

  TQValueList<Transaction> m_listTransactions;
  TQValueList<Price> m_listPrices;
  TQValueList<Security> m_listSecurities;

  bool m_skipCategoryMatching;

  void write(TQDomElement&,TQDomDocument*) const;
  bool read(const TQDomElement&);

  KMYMONEY_EXPORT static bool isStatementFile(const TQString&);
  KMYMONEY_EXPORT static bool readXMLFile( MyMoneyStatement&, const TQString& );
  KMYMONEY_EXPORT static void writeXMLFile( const MyMoneyStatement&, const TQString& );
};

#endif
// vim:cin:si:ai:et:ts=2:sw=2: