1 /***************************************************************************
2                           knewloanwizard.h  -  description
3                              -------------------
4     begin                : Wed Oct 8 2003
5     copyright            : (C) 2000-2003 by Thomas Baumgart
6     email                : mte@users.sourceforge.net
7                            Javier Campos Morales <javi_c@users.sourceforge.net>
8                            Felix Rodriguez <frodriguez@users.sourceforge.net>
9                            John C <thetacoturtle@users.sourceforge.net>
10                            Thomas Baumgart <ipwizard@users.sourceforge.net>
11                            Kevin Tambascio <ktambascio@users.sourceforge.net>
12  ***************************************************************************/
13 
14 /***************************************************************************
15  *                                                                         *
16  *   This program is free software; you can redistribute it and/or modify  *
17  *   it under the terms of the GNU General Public License as published by  *
18  *   the Free Software Foundation; either version 2 of the License, or     *
19  *   (at your option) any later version.                                   *
20  *                                                                         *
21  ***************************************************************************/
22 
23 #ifndef KNEWLOANWIZARD_H
24 #define KNEWLOANWIZARD_H
25 
26 // ----------------------------------------------------------------------------
27 // QT Includes
28 
29 #include <QWizard>
30 
31 // ----------------------------------------------------------------------------
32 // KDE Includes
33 
34 // ----------------------------------------------------------------------------
35 // Project Includes
36 
37 class QString;
38 
39 class MyMoneyAccount;
40 class MyMoneySchedule;
41 class MyMoneyAccountLoan;
42 class MyMoneyTransaction;
43 
44 /**
45   * @author Thomas Baumgart
46   */
47 
48 /**
49   * This class implements a wizard for the creation of loan accounts.
50   * The user is asked a set of questions and according to the answers
51   * the respective MyMoneyAccount object can be requested from the
52   * wizard when accept() has been called. A MyMoneySchedule is also
53   * available to create a schedule entry for the payments to the newly
54   * created loan.
55   *
56   */
57 class KNewLoanWizardPrivate;
58 class KNewLoanWizard : public QWizard
59 {
60   Q_OBJECT
61 
62   //TODO: find a way to make this not a friend class
63   friend class AdditionalFeesWizardPage;
64 public:
65   enum { Page_Intro, Page_EditIntro, Page_NewGeneralInfo,
66          Page_EditSelection, Page_LoanAttributes,
67          Page_EffectiveDate, Page_LendBorrow, Page_Name, Page_InterestType,
68          Page_PreviousPayments, Page_RecordPayment, Page_VariableInterestDate,
69          Page_PaymentEdit, Page_InterestEdit, Page_FirstPayment,
70          Page_NewCalculateLoan, Page_PaymentFrequency,
71          Page_InterestCalculation, Page_LoanAmount, Page_Interest,
72          Page_Duration, Page_Payment, Page_FinalPayment,
73          Page_CalculationOverview, Page_NewPayments, Page_InterestCategory,
74          Page_AdditionalFees, Page_Schedule, Page_SummaryEdit,
75          Page_AssetAccount, Page_Summary
76        };
77 
78   explicit KNewLoanWizard(QWidget *parent = nullptr);
79   ~KNewLoanWizard();
80 
81   /**
82     * This method returns the schedule for the payments. The account
83     * where the amortization should be transferred to is the one
84     * we currently try to create with this wizard. The appropriate split
85     * will be returned as the first split of the transaction inside
86     *
87     * as parameter @p accountId as this is the account that was created
88     * after this wizard was left via the accept() method.
89     *
90     * @return MyMoneySchedule object for payments
91     */
92   MyMoneySchedule schedule() const;
93 
94   /**
95     * This method returns the id of the account to/from which
96     * the payout should be created. If the checkbox that allows
97     * to skip the creation of this transaction is checked, this
98     * method returns QString()
99     *
100     * @return id of account or empty QString
101     */
102   QString initialPaymentAccount() const;
103 
104   /**
105     * This method returns the date of the payout transaction.
106     * If the checkbox that allows to skip the creation of
107     * this transaction is checked, this method returns QDate()
108     *
109     * @return selected date or invalid QDate if checkbox is selected.
110     */
111   QDate initialPaymentDate() const;
112 
113   bool validateCurrentPage() override;
114 
115   const MyMoneyAccountLoan account() const;
116 
117   /**
118    * This method returns the id of the next page in the wizard.
119    * It is overloaded here to support the dynamic nature of this wizard.
120    *
121    * @return id of the next page or -1 if there is no next page
122    */
123   int nextId() const final override;
124 
125 protected Q_SLOTS:
126 
127   // void slotNewPayee(const QString&);
128   void slotReloadEditWidgets();
129 
130 Q_SIGNALS:
131   /**
132     * This signal is emitted, when a new category name has been
133     * entered by the user and this name is not known as account
134     * by the MyMoneyFile object.
135     * Before the signal is emitted, a MyMoneyAccount is constructed
136     * by this object and filled with the desired name. All other members
137     * of MyMoneyAccount will remain in their default state. Upon return,
138     * the connected slot should have created the object in the MyMoneyFile
139     * engine and filled the member @p id.
140     *
141     * @param acc reference to MyMoneyAccount object that caries the name
142     *            and will return information about the created category.
143     */
144   void newCategory(MyMoneyAccount& acc);
145 
146   /**
147     * This signal is sent out, when a new payee needs to be created
148     * @sa KMyMoneyCombo::createItem()
149     *
150     * @param txt The name of the payee to be created
151     * @param id A connected slot should store the id of the created object
152     * in this variable
153     */
154   void createPayee(const QString& txt, QString& id);
155 
156 protected:
157   const QScopedPointer<KNewLoanWizardPrivate> d_ptr;
158   KNewLoanWizard(KNewLoanWizardPrivate &dd, QWidget *parent);
159 
160 private:
161   Q_DISABLE_COPY(KNewLoanWizard)
162   Q_DECLARE_PRIVATE(KNewLoanWizard)
163 
164 private Q_SLOTS:
165   void slotNewCategory(MyMoneyAccount &acc);
166   void slotNewPayee(const QString& newnameBase, QString& id);
167 };
168 
169 #endif
170