File indexing completed on 2024-05-12 16:44:12

0001 /*
0002     SPDX-FileCopyrightText: 2007 Thomas Baumgart <ipwizard@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KNEWACCOUNTWIZARD_H
0008 #define KNEWACCOUNTWIZARD_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 // ----------------------------------------------------------------------------
0014 // Project Includes
0015 
0016 #include "kmymoneywizard.h"
0017 
0018 class MyMoneyMoney;
0019 class MyMoneyPrice;
0020 class MyMoneyInstitution;
0021 class MyMoneyTransaction;
0022 class MyMoneySchedule;
0023 class MyMoneyAccount;
0024 
0025 /**
0026   * @author Thomas Baumgart
0027   */
0028 namespace NewAccountWizard
0029 {
0030 enum steps {
0031     StepInstitution = 1,
0032     StepAccount,
0033     StepBroker,
0034     StepDetails,
0035     StepPayments,
0036     StepFees,
0037     StepSchedule,
0038     StepPayout,
0039     StepParentAccount,
0040     StepFinish,
0041 };
0042 
0043 /**
0044 * @author Thomas Baumgart
0045 *
0046 * This class implements the new account wizard which is used to gather
0047 * the required information from the user to create a new account
0048 */
0049 class WizardPrivate;
0050 class Wizard : public KMyMoneyWizard
0051 {
0052     friend class AccountTypePage;
0053     friend class InstitutionPage;
0054     friend class BrokeragePage;
0055     friend class CreditCardSchedulePage;
0056     friend class GeneralLoanInfoPage;
0057     friend class LoanDetailsPage;
0058     friend class LoanPaymentPage;
0059     friend class LoanSchedulePage;
0060     friend class LoanPayoutPage;
0061     friend class HierarchyPage;
0062     friend class AccountSummaryPage;
0063 
0064     Q_OBJECT
0065     Q_DISABLE_COPY(Wizard)
0066 
0067 public:
0068     explicit Wizard(QWidget *parent = nullptr, bool modal = false, Qt::WindowFlags flags = 0);
0069     ~Wizard() override;
0070 
0071     /**
0072     * Returns the information about the account as entered by
0073     * the user.
0074     */
0075     const MyMoneyAccount& account();
0076 
0077     /**
0078     * Method to load the generated account information back into the widget
0079     */
0080     void setAccount(const MyMoneyAccount& acc);
0081 
0082     /**
0083     * Returns the information about the parent account as entered by
0084     * the user.
0085     * @note For now it's either fixed as Asset or Liability. We will provide
0086     * user selected parent accounts later.
0087     */
0088     MyMoneyAccount parentAccount();
0089 
0090     /**
0091     * Returns information about the schedule. If the returned value
0092     * equals MyMoneySchedule() then the user did not select to create
0093     * a schedule.
0094     */
0095     const MyMoneySchedule& schedule();
0096 
0097     /**
0098     * This method returns the value of the opening balance
0099     * entered by the user
0100     */
0101     MyMoneyMoney openingBalance() const;
0102 
0103     /**
0104     * This method returns the interest rate as factor, ie an
0105     * interest rate of 6.5% will be returned as 0.065
0106     */
0107     MyMoneyMoney interestRate() const;
0108 
0109     /**
0110     * This method returns the payout transaction for loans.
0111     * If the account to be created is not a loan or no
0112     * payout transaction should be generated, this method
0113     * returns an empty transaction.
0114     */
0115     MyMoneyTransaction payoutTransaction();
0116 
0117     /**
0118     * This method returns a MyMoneyAccount() object filled
0119     * with the data to create a brokerage account. If the
0120     * user selected not to create a brokerage account or
0121     * the account type is not able to create a brokerage
0122     * account, an empty MyMoneyAccount() object is returned.
0123     *
0124     * @note Make sure to call the account() method before you call this method.
0125     * Otherwise the returned object might contain unexpected results.
0126     */
0127     MyMoneyAccount brokerageAccount() const;
0128 
0129     /**
0130     * This method returns the conversion rate
0131     */
0132     MyMoneyPrice conversionRate() const;
0133 
0134     static void newAccount(MyMoneyAccount& account);
0135 
0136 Q_SIGNALS:
0137     void createAccount(MyMoneyAccount& account);
0138 
0139 public Q_SLOTS:
0140     void slotPayeeNew(const QString& txt, QString& id);
0141     void slotAccountNew(MyMoneyAccount& account);
0142 
0143 protected:
0144     /**
0145     * This method returns information about the selection of the user
0146     * if the loan is for borrowing or lending money.
0147     *
0148     * @retval true loan is for money borrowed
0149     * @retval false loan is for money lent
0150     */
0151     bool moneyBorrowed() const;
0152 
0153 private:
0154     Q_DECLARE_PRIVATE(Wizard)
0155 };
0156 
0157 } // namespace
0158 
0159 
0160 #endif