summaryrefslogtreecommitdiffstats
path: root/kmymoney2/wizards/newaccountwizard/knewaccountwizard.h
blob: 69e8aa7165f7141ab780950b66518b2078fc62ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/***************************************************************************
                             knewaccountwizard.h
                             -------------------
    begin                : Tue Sep 25 2007
    copyright            : (C) 2007 Thomas Baumgart
    email                : Thomas Baumgart <ipwizard@users.sourceforge.net>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KNEWACCOUNTWIZARD_H
#define KNEWACCOUNTWIZARD_H

// ----------------------------------------------------------------------------
// QT Includes

class TQString;

// ----------------------------------------------------------------------------
// Project Includes

#include <kmymoney/kmymoneywizard.h>
class MyMoneyPrice;

/**
  * @author Thomas Baumgart
  */
namespace NewAccountWizard {

class AccountTypePage;
class InstitutionPage;
class BrokeragePage;
class CreditCardSchedulePage;
class GeneralLoanInfoPage;
class LoanDetailsPage;
class LoanPaymentPage;
class LoanSchedulePage;
class LoanPayoutPage;
class HierarchyPage;
class AccountSummaryPage;

/**
  * @author Thomas Baumgart
  *
  * This class implements the new account wizard which is used to gather
  * the required information from the user to create a new account
  */
class Wizard : public KMyMoneyWizard
{
  friend class AccountTypePage;
  friend class InstitutionPage;
  friend class BrokeragePage;
  friend class CreditCardSchedulePage;
  friend class GeneralLoanInfoPage;
  friend class LoanDetailsPage;
  friend class LoanPaymentPage;
  friend class LoanSchedulePage;
  friend class LoanPayoutPage;
  friend class HierarchyPage;
  friend class AccountSummaryPage;

  Q_OBJECT
  TQ_OBJECT
public:
  Wizard(TQWidget* tqparent = 0, const char* name = 0, bool modal = false, WFlags flags = 0);

  /**
    * Returns the information about the account as entered by
    * the user.
    */
  const MyMoneyAccount& account(void);

  /**
   * Method to load the generated account information back into the widget
   */
  void setAccount(const MyMoneyAccount& acc);

  /**
    * Returns the information about the tqparent account as entered by
    * the user.
    * @note For now it's either fixed as Asset or Liability. We will provide
    * user selected tqparent accounts later.
    */
  const MyMoneyAccount& tqparentAccount(void);

  /**
   * Returns information about the schedule. If the returned value
   * equals MyMoneySchedule() then the user did not select to create
   * a schedule.
   */
  const MyMoneySchedule& schedule(void);

  /**
   * This method returns the value of the opening balance
   * entered by the user
   */
  MyMoneyMoney openingBalance(void) const;

  /**
   * This method returns the interest rate as factor, ie an
   * interest rate of 6.5% will be returned as 0.065
   */
  MyMoneyMoney interestRate(void) const;

  /**
   * This method returns the payout transaction for loans.
   * If the account to be created is not a loan or no
   * payout transaction should be generated, this method
   * returns an emtpy transaction.
   */
  MyMoneyTransaction payoutTransaction(void);

  /**
   * This method returns a MyMoneyAccount() object filled
   * with the data to create a brokerage account. If the
   * user selected not to create a brokerage account or
   * the account type is not able to create a brokerage
   * account, an empty MyMoneyAccount() object is returned.
   *
   * @note Make sure to call the account() method before you call this method.
   * Otherwise the returned object might contain unexpected results.
   */
  MyMoneyAccount brokerageAccount(void) const;

  /**
   * This method returns the conversion rate
   */
  MyMoneyPrice conversionRate(void) const;

protected:
  /**
   * This method returns the currently selected currency for the account
   */
  const MyMoneySecurity& currency(void) const;

  /**
   * This method returns the precision in digits for the selected currency.
   * @sa currency()
   */
  int precision(void) const;

  /**
   * This method returns information about the selection of the user
   * if the loan is for borrowing or lending money.
   *
   * @retval true loan is for money borrowed
   * @retval false loan is for money lent
   */
  bool moneyBorrowed() const;

signals:
  void createInstitution(MyMoneyInstitution& institution);
  void createAccount(MyMoneyAccount& account);
  void createCategory(MyMoneyAccount&, const MyMoneyAccount&);

private:
  InstitutionPage*         m_institutionPage;
  AccountTypePage*         m_accountTypePage;
  BrokeragePage*           m_brokeragepage;
  CreditCardSchedulePage*  m_schedulePage;
  GeneralLoanInfoPage*     m_generalLoanInfoPage;
  LoanDetailsPage*         m_loanDetailsPage;
  LoanPaymentPage*         m_loanPaymentPage;
  LoanSchedulePage*        m_loanSchedulePage;
  LoanPayoutPage*          m_loanPayoutPage;
  HierarchyPage*           m_hierarchyPage;
  AccountSummaryPage*      m_accountSummaryPage;

  MyMoneyAccountLoan       m_account;
  MyMoneySchedule          m_schedule;
};

}; // namespace


#endif