File indexing completed on 2024-05-12 05:08:01

0001 /*
0002     SPDX-FileCopyrightText: 2000 Michael Edwardes <mte@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2023 Thomas Baumgart <tbaumgart@kde.org>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KENDINGBALANCEDLG_H
0008 #define KENDINGBALANCEDLG_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 #include <QWizard>
0014 
0015 // ----------------------------------------------------------------------------
0016 // KDE Includes
0017 
0018 // ----------------------------------------------------------------------------
0019 // Project Includes
0020 
0021 class QDate;
0022 
0023 class MyMoneyMoney;
0024 class MyMoneyAccount;
0025 class MyMoneyTransaction;
0026 
0027 /**
0028   * This dialog is wizard based and used to enter additional
0029   * information required to start the reconciliation process.
0030   * This version implements the behaviour for checkings,
0031   * savings and credit card accounts.
0032   *
0033   * @author Thomas Baumgart
0034   */
0035 
0036 class KEndingBalanceDlgPrivate;
0037 class KEndingBalanceDlg : public QWizard
0038 {
0039     Q_OBJECT
0040     Q_DISABLE_COPY(KEndingBalanceDlg)
0041 
0042 public:
0043     enum { Page_CheckingStart, Page_PreviousPostpone,
0044            Page_CheckingStatementInfo, Page_InterestChargeCheckings
0045          };
0046 
0047     explicit KEndingBalanceDlg(const MyMoneyAccount& account, QWidget *parent = nullptr);
0048     ~KEndingBalanceDlg();
0049 
0050     MyMoneyMoney endingBalance() const;
0051     MyMoneyMoney previousBalance() const;
0052 
0053     QDate statementDate() const;
0054 
0055     /**
0056      * This returns the date of the last statement or the
0057      * first non-cleared, non-reconciled transaction
0058      * whichever is older.
0059      */
0060     QDate startDate() const;
0061 
0062     MyMoneyTransaction interestTransaction();
0063     MyMoneyTransaction chargeTransaction();
0064 
0065     /**
0066      * This method returns the id of the next page in the wizard.
0067      * It is overloaded here to support the dynamic nature of this wizard.
0068      *
0069      * @return id of the next page or -1 if there is no next page
0070      */
0071     int nextId() const final override;
0072 
0073 protected:
0074     bool createTransaction(MyMoneyTransaction& t, const int sign, const MyMoneyMoney& amount, const QString& category, const QDate& date);
0075     MyMoneyMoney adjustedReturnValue(const MyMoneyMoney& v) const;
0076     void createCategory(const QString& txt, QString& id, const MyMoneyAccount& parent);
0077 
0078 protected Q_SLOTS:
0079     void slotReloadEditWidgets();
0080     void help();
0081     void slotCreateInterestCategory(const QString& txt, QString& id);
0082     void slotCreateChargesCategory(const QString& txt, QString& id);
0083     void accept() final override;
0084     void slotUpdateBalances();
0085 
0086 Q_SIGNALS:
0087     /**
0088       * proxy signal for KMyMoneyPayeeCombo::createItem(const QString&, QString&)
0089       */
0090     void createPayee(const QString&, QString&);
0091 
0092     /**
0093       * Q_EMIT when a category is about to be created
0094       */
0095     void createCategory(MyMoneyAccount& acc, const MyMoneyAccount& parent);
0096 
0097 private:
0098     KEndingBalanceDlgPrivate * const d_ptr;
0099     Q_DECLARE_PRIVATE(KEndingBalanceDlg)
0100 
0101 private Q_SLOTS:
0102     void slotNewPayee(const QString& newnameBase, QString& id);
0103 };
0104 
0105 #endif