Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/wizards/newaccountwizard/kcreditcardschedulepage.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | kcreditcardschedulepage.cpp | ||||
3 | ------------------- | ||||
4 | begin : Tue Sep 25 2006 | ||||
5 | copyright : (C) 2007 Thomas Baumgart | ||||
6 | email : Thomas Baumgart <ipwizard@users.sourceforge.net> | ||||
7 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
8 | ***************************************************************************/ | ||||
9 | | ||||
10 | /*************************************************************************** | ||||
11 | * * | ||||
12 | * This program is free software; you can redistribute it and/or modify * | ||||
13 | * it under the terms of the GNU General Public License as published by * | ||||
14 | * the Free Software Foundation; either version 2 of the License, or * | ||||
15 | * (at your option) any later version. * | ||||
16 | * * | ||||
17 | ***************************************************************************/ | ||||
18 | | ||||
19 | #include "kcreditcardschedulepage.h" | ||||
20 | #include "kcreditcardschedulepage_p.h" | ||||
21 | | ||||
22 | // ---------------------------------------------------------------------------- | ||||
23 | // QT Includes | ||||
24 | | ||||
25 | #include <QCheckBox> | ||||
26 | #include <QDate> | ||||
27 | #include <QPushButton> | ||||
28 | | ||||
29 | // ---------------------------------------------------------------------------- | ||||
30 | // KDE Includes | ||||
31 | | ||||
32 | #include <KLineEdit> | ||||
33 | #include <KLocalizedString> | ||||
34 | | ||||
35 | // ---------------------------------------------------------------------------- | ||||
36 | // Project Includes | ||||
37 | | ||||
38 | #include "ui_kcreditcardschedulepage.h" | ||||
39 | | ||||
40 | #include "kmymoneyaccountselector.h" | ||||
41 | #include "kmymoneycategory.h" | ||||
42 | #include "kmymoneydateinput.h" | ||||
43 | #include "kmymoneyedit.h" | ||||
44 | #include "kmymoneygeneralcombo.h" | ||||
45 | #include "kmymoneypayeecombo.h" | ||||
46 | #include "knewaccountwizard.h" | ||||
47 | #include "knewaccountwizard_p.h" | ||||
48 | #include "kaccounttypepage.h" | ||||
49 | #include "kaccounttypepage_p.h" | ||||
50 | #include "kcreditcardschedulepage_p.h" | ||||
51 | #include "khierarchypage.h" | ||||
52 | #include "mymoneyenums.h" | ||||
53 | #include "mymoneyfile.h" | ||||
54 | #include "mymoneypayee.h" | ||||
55 | #include "wizardpage.h" | ||||
56 | | ||||
57 | using namespace eMyMoney; | ||||
58 | | ||||
59 | namespace NewAccountWizard | ||||
60 | { | ||||
61 | CreditCardSchedulePage::CreditCardSchedulePage(Wizard* wizard) : | ||||
62 | QWidget(wizard), | ||||
63 | WizardPage<Wizard>(*new CreditCardSchedulePagePrivate(wizard), StepSchedule, this, wizard) | ||||
64 | { | ||||
65 | Q_D(CreditCardSchedulePage); | ||||
66 | d->ui->setupUi(this); | ||||
67 | d->m_mandatoryGroup->add(d->ui->m_name); | ||||
68 | d->m_mandatoryGroup->add(d->ui->m_payee); | ||||
69 | d->m_mandatoryGroup->add(d->ui->m_amount->lineedit()); | ||||
70 | d->m_mandatoryGroup->add(d->ui->m_paymentAccount); | ||||
71 | connect(d->ui->m_paymentAccount, &KMyMoneyCombo::itemSelected, object(), &KMyMoneyWizardPagePrivate::completeStateChanged); | ||||
72 | connect(d->ui->m_payee, &KMyMoneyMVCCombo::itemSelected, object(), &KMyMoneyWizardPagePrivate::completeStateChanged); | ||||
73 | connect(d->ui->m_date, &KMyMoneyDateInput::dateChanged, object(), &KMyMoneyWizardPagePrivate::completeStateChanged); | ||||
74 | | ||||
75 | connect(d->ui->m_payee, &KMyMoneyMVCCombo::createItem, wizard, &KMyMoneyWizard::createPayee); | ||||
76 | | ||||
77 | d->ui->m_reminderCheckBox->setChecked(true); | ||||
78 | connect(d->ui->m_reminderCheckBox, &QAbstractButton::toggled, object(), &KMyMoneyWizardPagePrivate::completeStateChanged); | ||||
79 | | ||||
80 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &CreditCardSchedulePage::slotLoadWidgets); | ||||
81 | | ||||
82 | d->ui->m_method->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); | ||||
83 | #if 0 | ||||
84 | d->ui->m_method->insertItem(i18n("Direct debit"), Schedule::PaymentType::DirectDebit); | ||||
85 | d->ui->m_method->insertItem(i18n("Bank transfer"), Schedule::PaymentType::BankTransfer); | ||||
86 | #endif | ||||
87 | d->ui->m_method->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); | ||||
88 | d->ui->m_method->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); | ||||
89 | d->ui->m_method->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); | ||||
90 | d->ui->m_method->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); | ||||
91 | d->ui->m_method->setCurrentItem((int)Schedule::PaymentType::DirectDebit); | ||||
92 | | ||||
93 | slotLoadWidgets(); | ||||
94 | } | ||||
95 | | ||||
96 | CreditCardSchedulePage::~CreditCardSchedulePage() | ||||
97 | { | ||||
98 | } | ||||
99 | | ||||
100 | void CreditCardSchedulePage::enterPage() | ||||
101 | { | ||||
102 | Q_D(CreditCardSchedulePage); | ||||
103 | if (d->ui->m_name->text().isEmpty()) | ||||
104 | d->ui->m_name->setText(i18n("Credit Card %1 monthly payment", d->m_wizard->d_func()->m_accountTypePage->d_func()->ui->m_accountName->text())); | ||||
105 | } | ||||
106 | | ||||
107 | QWidget* CreditCardSchedulePage::initialFocusWidget(void) const | ||||
108 | { | ||||
109 | Q_D(const CreditCardSchedulePage); | ||||
110 | return d->ui->m_reminderCheckBox; | ||||
111 | } | ||||
112 | | ||||
113 | bool CreditCardSchedulePage::isComplete() const | ||||
114 | { | ||||
115 | Q_D(const CreditCardSchedulePage); | ||||
116 | bool rc = true; | ||||
117 | QString msg = i18n("Finish entry and create account"); | ||||
118 | if (d->ui->m_reminderCheckBox->isChecked()) { | ||||
119 | msg = i18n("Finish entry and create account and schedule"); | ||||
120 | if (d->ui->m_date->date() < d->m_wizard->d_func()->m_accountTypePage->d_func()->ui->m_openingDate->date()) { | ||||
121 | rc = false; | ||||
122 | msg = i18n("Next due date is prior to opening date"); | ||||
123 | } | ||||
124 | if (d->ui->m_paymentAccount->selectedItem().isEmpty()) { | ||||
125 | rc = false; | ||||
126 | msg = i18n("No account selected"); | ||||
127 | } | ||||
128 | if (d->ui->m_amount->lineedit()->text().isEmpty()) { | ||||
129 | rc = false; | ||||
130 | msg = i18n("No amount for payment selected"); | ||||
131 | } | ||||
132 | if (d->ui->m_payee->selectedItem().isEmpty()) { | ||||
133 | rc = false; | ||||
134 | msg = i18n("No payee for payment selected"); | ||||
135 | } | ||||
136 | if (d->ui->m_name->text().isEmpty()) { | ||||
137 | rc = false; | ||||
138 | msg = i18n("No name assigned for schedule"); | ||||
139 | } | ||||
140 | } | ||||
141 | d->m_wizard->d_func()->m_finishButton->setToolTip(msg); | ||||
142 | | ||||
143 | return rc; | ||||
144 | } | ||||
145 | | ||||
146 | void CreditCardSchedulePage::slotLoadWidgets() | ||||
147 | { | ||||
148 | Q_D(CreditCardSchedulePage); | ||||
149 | AccountSet set; | ||||
150 | set.addAccountGroup(Account::Asset); | ||||
151 | set.load(d->ui->m_paymentAccount->selector()); | ||||
152 | | ||||
153 | d->ui->m_payee->loadPayees(MyMoneyFile::instance()->payeeList()); | ||||
154 | } | ||||
155 | | ||||
156 | KMyMoneyWizardPage* CreditCardSchedulePage::nextPage() const | ||||
157 | { | ||||
158 | Q_D(const CreditCardSchedulePage); | ||||
159 | return d->m_wizard->d_func()->m_hierarchyPage; | ||||
160 | } | ||||
161 | } |