File indexing completed on 2024-05-12 16:41:56

0001 /*
0002     KMyMoney transaction importing module - searches for a matching transaction in the ledger
0003 
0004     SPDX-FileCopyrightText: 2012 Lukasz Maszczynski <lukasz@maszczynski.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef EXISTINGTRANSACTIONMATCHFINDER_H
0009 #define EXISTINGTRANSACTIONMATCHFINDER_H
0010 
0011 #include <QPair>
0012 #include <QList>
0013 
0014 #include "transactionmatchfinder.h"
0015 
0016 /** Implements searching for a matching transaction in the ledger
0017  */
0018 class ExistingTransactionMatchFinder : public TransactionMatchFinder
0019 {
0020 public:
0021     /** Ctor, initializes the match finder
0022      * @param matchWindow max number of days the transactions may vary and still be considered to be matching
0023      */
0024     explicit ExistingTransactionMatchFinder(int m_matchWindow = 3);
0025 
0026 protected:
0027     typedef QPair<MyMoneyTransaction, MyMoneySplit> TransactionAndSplitPair;
0028     QList<TransactionAndSplitPair> listOfMatchCandidates;
0029 
0030     /** Creates a list of transactions within matchWindow range and with the same amount as the imported transaction we're trying to match
0031      */
0032     void createListOfMatchCandidates() final override;
0033 
0034     /** Searches for a matching transaction in the ledger
0035      *
0036      * Match result can be set to any value described in @ref TransactionMatchFinder::findMatch().
0037      * @ref MatchDuplicate is set if the imported transaction has the same bank id as the existing transaction;
0038      * @ref MatchImprecise is set when transaction dates are not equal, but within matchWindow range
0039      */
0040     void findMatchInMatchCandidatesList() final override;
0041 };
0042 
0043 #endif // EXISTINGTRANSACTIONMATCHFINDER_H