File indexing completed on 2024-05-12 16:42:18

0001 /*
0002     SPDX-FileCopyrightText: 2016-2018 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef LEDGERITEM_H
0008 #define LEDGERITEM_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 #include <qnamespace.h>
0014 
0015 // ----------------------------------------------------------------------------
0016 // KDE Includes
0017 
0018 // ----------------------------------------------------------------------------
0019 // Project Includes
0020 
0021 class QString;
0022 class QDate;
0023 
0024 class MyMoneyMoney;
0025 class MyMoneySplit;
0026 class MyMoneyTransaction;
0027 
0028 namespace eMyMoney {
0029 namespace Split {
0030 enum class State;
0031 }
0032 }
0033 
0034 class LedgerItem
0035 {
0036 public:
0037     explicit LedgerItem();
0038     virtual ~LedgerItem();
0039 
0040     /**
0041      * This method returns the complete raw transaction from the engine
0042      */
0043     virtual MyMoneyTransaction transaction() const = 0;
0044 
0045     /**
0046      * This method returns the complete raw split from the engine
0047      */
0048     virtual const MyMoneySplit& split() const = 0;
0049 
0050     /**
0051      * Returns the postDate of the object. This can be used for sorting purposes.
0052      */
0053     virtual QDate postDate() const = 0;
0054 
0055     /**
0056      * Returns the account id that this entry references. Default is
0057      * to return an empty string.
0058      */
0059     virtual QString accountId() const;
0060 
0061     /**
0062      * Returns the id of the counter account. If no counter split is present,
0063      * it returns an empty string, in case more than one counter
0064      * split is present it returns the fixed string '????'.
0065      * @todo figure out how to handle the three+ split case.
0066      */
0067     virtual QString counterAccountId() const = 0;
0068 
0069     /**
0070      * Returns the cost center id. This depends on how many slits the transaction has:
0071      *
0072      * two splits - returns the costcenter entry which is set in one of the splits
0073      * otherwise  - returns the costcenter entry of the split
0074      */
0075     virtual QString costCenterId() const = 0;
0076 
0077     /**
0078      * Returns the full name and hierarchy of the account.
0079      */
0080     virtual QString account() const = 0;
0081 
0082     /**
0083      * Returns the full name and hierarchy of the counter account. If no counter
0084      * split is present, it returns an empty string, in case more than one counter
0085      * split is present it returns the fixed string 'Split transaction'.
0086      */
0087     virtual QString counterAccount() const = 0;
0088 
0089     /**
0090      * Returns the name of the payee that is assigned to the split
0091      * or one that is found with other splits.
0092      */
0093     virtual QString payeeName() const = 0;
0094 
0095     /**
0096      * Returns the id of the payee that is assigned to the split
0097      * or one that is found with other splits.
0098      */
0099     virtual QString payeeId() const = 0;
0100 
0101     /**
0102      * Returns the number of the transaction assigned by the user/institution
0103      */
0104     virtual QString transactionNumber() const = 0;
0105 
0106     /**
0107      * Return information if this item is selectable, editable, etc.
0108      * @sa QAbstractItemModel::flags()
0109      */
0110     virtual Qt::ItemFlags flags() const = 0;
0111 
0112     /**
0113      * Returns an id for the selected transaction.
0114      */
0115     virtual QString transactionId() const = 0;
0116 
0117     /**
0118      * Returns an id for the selected transaction and split.
0119      */
0120     virtual QString transactionSplitId() const = 0;
0121 
0122     /**
0123      * Returns the number of splits in this transaction
0124      */
0125     virtual int splitCount() const = 0;
0126 
0127     /**
0128      * Returns the internal reconciliation status for the selected transaction and split.
0129      */
0130     virtual eMyMoney::Split::State reconciliationState() const = 0;
0131 
0132     /**
0133      * Returns the short reconciliation status text for the selected transaction and split.
0134      */
0135     virtual QString reconciliationStateShort() const = 0;
0136 
0137     /**
0138      * Returns the full reconciliation status text for the selected transaction and split.
0139      */
0140     virtual QString reconciliationStateLong() const = 0;
0141 
0142     /**
0143      * Returns the display string for the payment column.
0144      */
0145     virtual QString payment() const = 0;
0146 
0147     /**
0148      * Returns the display string for the deposit column.
0149      */
0150     virtual QString deposit() const = 0;
0151 
0152     /**
0153      * Allows to set the display string for the balance column.
0154      */
0155     virtual void setBalance(QString txt) = 0;
0156 
0157     /**
0158      * Returns the display string for the balance column.
0159      */
0160     virtual QString balance() const = 0;
0161 
0162     /**
0163      * Returns the amount of the shares of the split
0164      */
0165     virtual MyMoneyMoney shares() const = 0;
0166 
0167     /**
0168      * Returns the amount of the shares of the split as QString (always positive)
0169      */
0170     virtual QString sharesAmount() const = 0;
0171 
0172     /**
0173      * Returns the amount of the shares of the split as QString (with sign)
0174      */
0175     virtual QString signedSharesAmount() const = 0;
0176 
0177     /**
0178      * Returns the suffix of the shares (Dr. or Cr.)
0179      */
0180     virtual QString sharesSuffix() const = 0;
0181 
0182     /**
0183      * Returns the value in the transaction commodity of the split
0184      */
0185     virtual MyMoneyMoney value() const = 0;
0186 
0187     /**
0188      * Returns the lines of a memo
0189      */
0190     virtual QString memo() const = 0;
0191 
0192     /**
0193      * Returns true if an item is erroneous
0194      */
0195     virtual bool isErroneous() const = 0;
0196 
0197     /**
0198      * Returns true if an item is imported
0199      */
0200     virtual bool isImported() const = 0;
0201 
0202     /**
0203      * Returns true if this is the empty entry at the end of the ledger
0204      */
0205     virtual bool isNewTransactionEntry() const = 0;
0206 
0207     /**
0208      * Returns the symbol of the commodity this transaction is kept in
0209      */
0210     virtual QString transactionCommodity() const = 0;
0211 
0212 };
0213 
0214 #endif // LEDGERITEM_H
0215