File indexing completed on 2024-05-12 05:06:45
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; // valuta date 0048 QDate m_dateProcessed; // entry date 0049 QString m_strPayee; 0050 QString m_strMemo; 0051 QString m_strNumber; 0052 QString m_strBankID; 0053 MyMoneyMoney m_amount; 0054 eMyMoney::Split::State m_reconcile = eMyMoney::Split::State::NotReconciled; 0055 0056 eMyMoney::Transaction::Action m_eAction = eMyMoney::Transaction::Action::None; 0057 MyMoneyMoney m_shares; 0058 MyMoneyMoney m_shareDenominator; 0059 MyMoneyMoney m_fees; 0060 MyMoneyMoney m_price; 0061 QString m_strInterestCategory; 0062 QString m_strBrokerageAccount; 0063 QString m_strSecurityId; 0064 QString m_strSymbol; 0065 QString m_strSecurity; 0066 QList<Split> m_listSplits; 0067 }; 0068 0069 struct Price { 0070 QDate m_date; 0071 QString m_sourceName; 0072 QString m_strSecurity; 0073 QString m_strCurrency; 0074 MyMoneyMoney m_amount; 0075 }; 0076 0077 struct Security { 0078 QString m_strName; 0079 QString m_strSymbol; 0080 QString m_strId; 0081 MyMoneyMoney m_smallestFraction = MyMoneyMoney(100, 1); 0082 }; 0083 0084 QString m_strAccountName; 0085 QString m_strAccountNumber; 0086 QString m_strBankCode; 0087 0088 /** 0089 * The statement provider's information for the statement reader how to find the 0090 * account. The provider usually leaves some value with a key unique to the provider in the KVP of the 0091 * MyMoneyAccount object when setting up the connection or at a later point in time. 0092 * Using the KMyMoneyPlugin::KMMStatementInterface::account() method it can retrieve the 0093 * MyMoneyAccount object for this key. The account id of that account should be returned 0094 * here. If no id is available, leave it empty. 0095 */ 0096 QString m_accountId; 0097 0098 QString m_strCurrency; 0099 QDate m_dateBegin; 0100 QDate m_dateEnd; 0101 MyMoneyMoney m_closingBalance = MyMoneyMoney::autoCalc; 0102 eMyMoney::Statement::Type m_eType = eMyMoney::Statement::Type::None; 0103 0104 QList<Transaction> m_listTransactions; 0105 QList<Price> m_listPrices; 0106 QList<Security> m_listSecurities; 0107 0108 bool m_skipCategoryMatching = false; 0109 0110 void write(QDomElement&, QDomDocument*) const; 0111 bool read(const QDomElement&); 0112 0113 /** 0114 * This method returns the date provided as the end date of the statement. 0115 * In case this is not provided, we return the date of the youngest transaction 0116 * instead. In case there are no transactions found, an invalid date is 0117 * returned. 0118 * 0119 * @sa m_dateEnd 0120 */ 0121 QDate statementEndDate() const; 0122 0123 static bool isStatementFile(const QString&); 0124 static bool readXMLFile(MyMoneyStatement&, const QString&); 0125 static void writeXMLFile(const MyMoneyStatement&, const QString&); 0126 }; 0127 0128 /** 0129 * Make it possible to hold @ref MyMoneyStatement objects inside @ref QVariant objects. 0130 */ 0131 Q_DECLARE_METATYPE(MyMoneyStatement) 0132 0133 #endif