File indexing completed on 2024-05-12 16:42:41
0001 /* 0002 SPDX-FileCopyrightText: 2004-2006 Ace Jones <acejones@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2005-2018 Thomas Baumgart <tbaumgart@kde.org> 0004 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef MYMONEYSTATEMENT_H 0009 #define MYMONEYSTATEMENT_H 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 #include <QString> 0015 #include <QList> 0016 #include <QDate> 0017 0018 // ---------------------------------------------------------------------------- 0019 // Project Includes 0020 0021 #include "kmm_mymoney_export.h" 0022 #include "mymoneymoney.h" 0023 #include "mymoneyenums.h" 0024 0025 class QDomElement; 0026 class QDomDocument; 0027 0028 /** 0029 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 (preferably NONE). 0030 0031 @author ace jones 0032 */ 0033 class KMM_MYMONEY_EXPORT MyMoneyStatement 0034 { 0035 public: 0036 struct Split 0037 { 0038 QString m_strCategoryName; 0039 QString m_strMemo; 0040 QString m_accountId; 0041 eMyMoney::Split::State m_reconcile = eMyMoney::Split::State::NotReconciled; 0042 MyMoneyMoney m_amount; 0043 }; 0044 0045 struct Transaction 0046 { 0047 QDate m_datePosted; 0048 QString m_strPayee; 0049 QString m_strMemo; 0050 QString m_strNumber; 0051 QString m_strBankID; 0052 MyMoneyMoney m_amount; 0053 eMyMoney::Split::State m_reconcile = eMyMoney::Split::State::NotReconciled; 0054 0055 eMyMoney::Transaction::Action m_eAction = eMyMoney::Transaction::Action::None; 0056 MyMoneyMoney m_shares; 0057 MyMoneyMoney m_fees; 0058 MyMoneyMoney m_price; 0059 QString m_strInterestCategory; 0060 QString m_strBrokerageAccount; 0061 QString m_strSymbol; 0062 QString m_strSecurity; 0063 QList<Split> m_listSplits; 0064 }; 0065 0066 struct Price { 0067 QDate m_date; 0068 QString m_sourceName; 0069 QString m_strSecurity; 0070 QString m_strCurrency; 0071 MyMoneyMoney m_amount; 0072 }; 0073 0074 struct Security { 0075 QString m_strName; 0076 QString m_strSymbol; 0077 QString m_strId; 0078 }; 0079 0080 QString m_strAccountName; 0081 QString m_strAccountNumber; 0082 QString m_strRoutingNumber; 0083 0084 /** 0085 * The statement provider's information for the statement reader how to find the 0086 * account. The provider usually leaves some value with a key unique to the provider in the KVP of the 0087 * MyMoneyAccount object when setting up the connection or at a later point in time. 0088 * Using the KMyMoneyPlugin::KMMStatementInterface::account() method it can retrieve the 0089 * MyMoneyAccount object for this key. The account id of that account should be returned 0090 * here. If no id is available, leave it empty. 0091 */ 0092 QString m_accountId; 0093 0094 QString m_strCurrency; 0095 QDate m_dateBegin; 0096 QDate m_dateEnd; 0097 MyMoneyMoney m_closingBalance = MyMoneyMoney::autoCalc; 0098 eMyMoney::Statement::Type m_eType = eMyMoney::Statement::Type::None; 0099 0100 QList<Transaction> m_listTransactions; 0101 QList<Price> m_listPrices; 0102 QList<Security> m_listSecurities; 0103 0104 bool m_skipCategoryMatching = false; 0105 0106 void write(QDomElement&, QDomDocument*) const; 0107 bool read(const QDomElement&); 0108 0109 /** 0110 * This method returns the date provided as the end date of the statement. 0111 * In case this is not provided, we return the date of the youngest transaction 0112 * instead. In case there are no transactions found, an invalid date is 0113 * returned. 0114 * 0115 * @sa m_dateEnd 0116 */ 0117 QDate statementEndDate() const; 0118 0119 static bool isStatementFile(const QString&); 0120 static bool readXMLFile(MyMoneyStatement&, const QString&); 0121 static void writeXMLFile(const MyMoneyStatement&, const QString&); 0122 }; 0123 0124 /** 0125 * Make it possible to hold @ref MyMoneyStatement objects inside @ref QVariant objects. 0126 */ 0127 Q_DECLARE_METATYPE(MyMoneyStatement) 0128 0129 #endif