1 /***************************************************************************
2                           kendingbalancedlg.h
3                              -------------------
4     copyright            : (C) 2000 by Michael Edwardes
5     email                : mte@users.sourceforge.net
6  ***************************************************************************/
7 
8 /***************************************************************************
9  *                                                                         *
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  ***************************************************************************/
16 
17 #ifndef KENDINGBALANCEDLG_H
18 #define KENDINGBALANCEDLG_H
19 
20 // ----------------------------------------------------------------------------
21 // QT Includes
22 
23 #include <QWizard>
24 
25 // ----------------------------------------------------------------------------
26 // KDE Includes
27 
28 // ----------------------------------------------------------------------------
29 // Project Includes
30 
31 class QDate;
32 
33 class MyMoneyMoney;
34 class MyMoneyAccount;
35 class MyMoneyTransaction;
36 
37 /**
38   * This dialog is wizard based and used to enter additional
39   * information required to start the reconciliation process.
40   * This version implements the behaviour for checkings,
41   * savings and credit card accounts.
42   *
43   * @author Thomas Baumgart
44   */
45 
46 class KEndingBalanceDlgPrivate;
47 class KEndingBalanceDlg : public QWizard
48 {
49   Q_OBJECT
50   Q_DISABLE_COPY(KEndingBalanceDlg)
51 
52 public:
53   enum { Page_CheckingStart, Page_PreviousPostpone,
54          Page_CheckingStatementInfo, Page_InterestChargeCheckings
55        };
56 
57   explicit KEndingBalanceDlg(const MyMoneyAccount& account, QWidget *parent = nullptr);
58   ~KEndingBalanceDlg();
59 
60   MyMoneyMoney endingBalance() const;
61   MyMoneyMoney previousBalance() const;
62   QDate statementDate() const;
63 
64   MyMoneyTransaction interestTransaction();
65   MyMoneyTransaction chargeTransaction();
66 
67   /**
68    * This method returns the id of the next page in the wizard.
69    * It is overloaded here to support the dynamic nature of this wizard.
70    *
71    * @return id of the next page or -1 if there is no next page
72    */
73   int nextId() const final override;
74 
75 protected:
76   bool createTransaction(MyMoneyTransaction& t, const int sign, const MyMoneyMoney& amount, const QString& category, const QDate& date);
77   MyMoneyMoney adjustedReturnValue(const MyMoneyMoney& v) const;
78   void createCategory(const QString& txt, QString& id, const MyMoneyAccount& parent);
79 
80 protected Q_SLOTS:
81   void slotReloadEditWidgets();
82   void help();
83   void slotCreateInterestCategory(const QString& txt, QString& id);
84   void slotCreateChargesCategory(const QString& txt, QString& id);
85   void accept() final override;
86   void slotUpdateBalances();
87 
88 Q_SIGNALS:
89   /**
90     * proxy signal for KMyMoneyPayeeCombo::createItem(const QString&, QString&)
91     */
92   void createPayee(const QString&, QString&);
93 
94   /**
95     * emit when a category is about to be created
96     */
97   void createCategory(MyMoneyAccount& acc, const MyMoneyAccount& parent);
98 
99 private:
100   KEndingBalanceDlgPrivate * const d_ptr;
101   Q_DECLARE_PRIVATE(KEndingBalanceDlg)
102 
103 private Q_SLOTS:
104   void slotNewPayee(const QString& newnameBase, QString& id);
105 };
106 
107 #endif
108