bool MyMoneyReport::includes( const MyMoneyAccount& acc ) const { bool result = false; if ( includesAccountGroup ( acc.accountGroup() ) ) { switch ( acc.accountGroup() ) { case MyMoneyAccount::Income: case MyMoneyAccount::Expense: if ( isTax() ) result = ( acc.value ( "Tax" ) == "Yes" ) && includesCategory ( acc.id() ); else result = includesCategory ( acc.id() ); break; case MyMoneyAccount::Asset: case MyMoneyAccount::Liability: if ( isLoansOnly() ) result = acc.isLoan() && includesAccount ( acc.id() ); else if ( isInvestmentsOnly() ) result = acc.isInvest() && includesAccount ( acc.id() ); else if ( isIncludingTransfers() && m_rowType == MyMoneyReport::eExpenseIncome ) // If transfers are included, ONLY include this account if it is NOT // included in the report itself!! result = ! includesAccount ( acc.id() ); else result = includesAccount ( acc.id() ); break; default: result = includesAccount ( acc.id() ); } } return result; }
void MyMoneyAccountTest::testAssignmentConstructor() { MyMoneyAccount a; a.setAccountType(MyMoneyAccount::Checkings); a.setName("Account"); a.setInstitutionId("Inst1"); a.setDescription("Bla"); a.setNumber("assigned Number"); a.setValue("Key", "Value"); a.addAccountId("ChildAccount"); MyMoneyAccount b; b.setLastModified(QDate::currentDate()); b = a; QVERIFY(b.name() == "Account"); QVERIFY(b.institutionId() == "Inst1"); QVERIFY(b.accountType() == MyMoneyAccount::Checkings); QVERIFY(b.lastModified() == QDate()); QVERIFY(b.openingDate() == a.openingDate()); QVERIFY(b.description() == "Bla"); QVERIFY(b.number() == "assigned Number"); QVERIFY(b.value("Key") == "Value"); QVERIFY(b.accountList().count() == 1); QVERIFY(b.accountList()[0] == "ChildAccount"); }
QString KMyMoneyUtils::nextCheckNumber(const MyMoneyAccount& acc) { QString number; // +-#1--+ +#2++-#3-++-#4--+ QRegExp exp(QString("(.*\\D)?(0*)(\\d+)(\\D.*)?")); if (exp.indexIn(acc.value("lastNumberUsed")) != -1) { setLastNumberUsed(acc.value("lastNumberUsed")); QString arg1 = exp.cap(1); QString arg2 = exp.cap(2); QString arg3 = QString::number(exp.cap(3).toULong() + 1); QString arg4 = exp.cap(4); number = QString("%1%2%3%4").arg(arg1).arg(arg2).arg(arg3).arg(arg4); // if new number is longer than previous one and we identified // preceding 0s, then remove one of the preceding zeros if (arg2.length() > 0 && (number.length() != acc.value("lastNumberUsed").length())) { arg2 = arg2.mid(1); number = QString("%1%2%3%4").arg(arg1).arg(arg2).arg(arg3).arg(arg4); } } else { number = '1'; } return number; }
int MyMoneyForecast::daysToMinimumBalance(const MyMoneyAccount& acc) { QString minimumBalance = acc.value("minBalanceAbsolute"); MyMoneyMoney minBalance = MyMoneyMoney(minimumBalance); dailyBalances balance; //Check if acc is not a forecast account, return -1 if(!isForecastAccount(acc)) { return -1; } balance = m_accountList[acc.id()]; for(QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate(); ) { if(minBalance > balance[it_day]) { return QDate::currentDate().daysTo(it_day); } it_day = it_day.addDays(1); } return -1; }
void MyMoneyAccountTest::testConstructor() { QString id = "A000001"; QString institutionid = "B000001"; QString parent = "Parent"; MyMoneyAccount r; MyMoneySplit s; r.setAccountType(MyMoneyAccount::Asset); r.setOpeningDate(QDate::currentDate()); r.setLastModified(QDate::currentDate()); r.setDescription("Desc"); r.setNumber("465500"); r.setParentAccountId(parent); r.setValue(QString("key"), "value"); s.setShares(MyMoneyMoney::ONE); r.adjustBalance(s); QVERIFY(r.m_kvp.count() == 1); QVERIFY(r.value("key") == "value"); MyMoneyAccount a(id, r); QVERIFY(a.id() == id); QVERIFY(a.institutionId().isEmpty()); QVERIFY(a.accountType() == MyMoneyAccount::Asset); QVERIFY(a.openingDate() == QDate::currentDate()); QVERIFY(a.lastModified() == QDate::currentDate()); QVERIFY(a.number() == "465500"); QVERIFY(a.description() == "Desc"); QVERIFY(a.accountList().count() == 0); QVERIFY(a.parentAccountId() == "Parent"); QVERIFY(a.balance() == MyMoneyMoney::ONE); QMap<QString, QString> copy; copy = r.pairs(); QVERIFY(copy.count() == 1); QVERIFY(copy[QString("key")] == "value"); }
void MyMoneyAccountTest::testReadXML() { MyMoneyAccount a; QString ref_ok = QString( "<!DOCTYPE TEST>\n" "<ACCOUNT-CONTAINER>\n" " <ACCOUNT parentaccount=\"Parent\" lastmodified=\"%1\" lastreconciled=\"\" institution=\"B000001\" number=\"465500\" opened=\"%2\" type=\"9\" id=\"A000001\" name=\"AccountName\" description=\"Desc\" >\n" " <SUBACCOUNTS>\n" " <SUBACCOUNT id=\"A000002\" />\n" " <SUBACCOUNT id=\"A000003\" />\n" " </SUBACCOUNTS>\n" " <KEYVALUEPAIRS>\n" " <PAIR key=\"key\" value=\"value\" />\n" " <PAIR key=\"Key\" value=\"Value\" />\n" " <PAIR key=\"reconciliationHistory\" value=\"2011-01-01:123/100;2011-02-01:114/25\"/>\n" " </KEYVALUEPAIRS>\n" " </ACCOUNT>\n" "</ACCOUNT-CONTAINER>\n"). arg(QDate::currentDate().toString(Qt::ISODate)).arg(QDate::currentDate().toString(Qt::ISODate)); QString ref_false = QString( "<!DOCTYPE TEST>\n" "<ACCOUNT-CONTAINER>\n" " <KACCOUNT parentaccount=\"Parent\" lastmodified=\"%1\" lastreconciled=\"\" institution=\"B000001\" number=\"465500\" opened=\"%2\" type=\"9\" id=\"A000001\" name=\"AccountName\" description=\"Desc\" >\n" " <SUBACCOUNTS>\n" " <SUBACCOUNT id=\"A000002\" />\n" " <SUBACCOUNT id=\"A000003\" />\n" " </SUBACCOUNTS>\n" " <KEYVALUEPAIRS>\n" " <PAIR key=\"key\" value=\"value\" />\n" " <PAIR key=\"Key\" value=\"Value\" />\n" " </KEYVALUEPAIRS>\n" " </KACCOUNT>\n" "</ACCOUNT-CONTAINER>\n"). arg(QDate::currentDate().toString(Qt::ISODate)).arg(QDate::currentDate().toString(Qt::ISODate)); QDomDocument doc; QDomElement node; doc.setContent(ref_false); node = doc.documentElement().firstChild().toElement(); try { a = MyMoneyAccount(node); QFAIL("Missing expected exception"); } catch (const MyMoneyException &) { } doc.setContent(ref_ok); node = doc.documentElement().firstChild().toElement(); a.addAccountId("TEST"); a.setValue("KEY", "VALUE"); try { a = MyMoneyAccount(node); QVERIFY(a.id() == "A000001"); QVERIFY(a.m_name == "AccountName"); QVERIFY(a.m_parentAccount == "Parent"); QVERIFY(a.m_lastModified == QDate::currentDate()); QVERIFY(a.m_lastReconciliationDate == QDate()); QVERIFY(a.m_institution == "B000001"); QVERIFY(a.m_number == "465500"); QVERIFY(a.m_openingDate == QDate::currentDate()); QVERIFY(a.m_accountType == MyMoneyAccount::Asset); QVERIFY(a.m_description == "Desc"); QVERIFY(a.accountList().count() == 2); QVERIFY(a.accountList()[0] == "A000002"); QVERIFY(a.accountList()[1] == "A000003"); QVERIFY(a.pairs().count() == 4); QVERIFY(a.value("key") == "value"); QVERIFY(a.value("Key") == "Value"); QVERIFY(a.value("lastStatementDate").isEmpty()); QVERIFY(a.reconciliationHistory().count() == 2); QVERIFY(a.reconciliationHistory()[QDate(2011, 1, 1)] == MyMoneyMoney(123, 100)); QVERIFY(a.reconciliationHistory()[QDate(2011, 2, 1)] == MyMoneyMoney(456, 100)); } catch (const MyMoneyException &) { QFAIL("Unexpected exception"); } }
void MyMoneyAccountTest::testWriteXML() { QString id = "A000001"; QString institutionid = "B000001"; QString parent = "Parent"; MyMoneyAccount r; r.setAccountType(MyMoneyAccount::Asset); r.setOpeningDate(QDate::currentDate()); r.setLastModified(QDate::currentDate()); r.setDescription("Desc"); r.setName("AccountName"); r.setNumber("465500"); r.setParentAccountId(parent); r.setInstitutionId(institutionid); r.setValue(QString("key"), "value"); r.addAccountId("A000002"); r.addReconciliation(QDate(2011, 1, 1), MyMoneyMoney(123, 100)); r.addReconciliation(QDate(2011, 2, 1), MyMoneyMoney(456, 100)); QCOMPARE(r.m_kvp.count(), 2); QCOMPARE(r.value("key"), QLatin1String("value")); QCOMPARE(r.value("reconciliationHistory"), QLatin1String("2011-01-01:123/100;2011-02-01:114/25")); MyMoneyAccount a(id, r); QDomDocument doc("TEST"); QDomElement el = doc.createElement("ACCOUNT-CONTAINER"); doc.appendChild(el); a.writeXML(doc, el); QCOMPARE(doc.doctype().name(), QLatin1String("TEST")); QDomElement accountContainer = doc.documentElement(); QVERIFY(accountContainer.isElement()); QCOMPARE(accountContainer.tagName(), QLatin1String("ACCOUNT-CONTAINER")); QVERIFY(accountContainer.childNodes().size() == 1); QVERIFY(accountContainer.childNodes().at(0).isElement()); QDomElement account = accountContainer.childNodes().at(0).toElement(); QCOMPARE(account.tagName(), QLatin1String("ACCOUNT")); QCOMPARE(account.attribute("id"), QLatin1String("A000001")); QCOMPARE(account.attribute("lastreconciled"), QString()); QCOMPARE(account.attribute("institution"), QLatin1String("B000001")); QCOMPARE(account.attribute("name"), QLatin1String("AccountName")); QCOMPARE(account.attribute("number"), QLatin1String("465500")); QCOMPARE(account.attribute("description"), QLatin1String("Desc")); QCOMPARE(account.attribute("parentaccount"), QLatin1String("Parent")); QCOMPARE(account.attribute("opened"), QDate::currentDate().toString(Qt::ISODate)); QCOMPARE(account.attribute("type"), QLatin1String("9")); QCOMPARE(account.attribute("lastmodified"), QDate::currentDate().toString(Qt::ISODate)); QCOMPARE(account.attribute("id"), QLatin1String("A000001")); QCOMPARE(account.childNodes().size(), 2); QVERIFY(account.childNodes().at(0).isElement()); QDomElement subAccounts = account.childNodes().at(0).toElement(); QCOMPARE(subAccounts.tagName(), QLatin1String("SUBACCOUNTS")); QCOMPARE(subAccounts.childNodes().size(), 1); QVERIFY(subAccounts.childNodes().at(0).isElement()); QDomElement subAccount = subAccounts.childNodes().at(0).toElement(); QCOMPARE(subAccount.tagName(), QLatin1String("SUBACCOUNT")); QCOMPARE(subAccount.attribute("id"), QLatin1String("A000002")); QCOMPARE(subAccount.childNodes().size(), 0); QDomElement keyValuePairs = account.childNodes().at(1).toElement(); QCOMPARE(keyValuePairs.tagName(), QLatin1String("KEYVALUEPAIRS")); QCOMPARE(keyValuePairs.childNodes().size(), 2); QVERIFY(keyValuePairs.childNodes().at(0).isElement()); QDomElement keyValuePair1 = keyValuePairs.childNodes().at(0).toElement(); QCOMPARE(keyValuePair1.tagName(), QLatin1String("PAIR")); QCOMPARE(keyValuePair1.attribute("key"), QLatin1String("key")); QCOMPARE(keyValuePair1.attribute("value"), QLatin1String("value")); QCOMPARE(keyValuePair1.childNodes().size(), 0); QVERIFY(keyValuePairs.childNodes().at(1).isElement()); QDomElement keyValuePair2 = keyValuePairs.childNodes().at(1).toElement(); QCOMPARE(keyValuePair2.tagName(), QLatin1String("PAIR")); QCOMPARE(keyValuePair2.attribute("key"), QLatin1String("reconciliationHistory")); QCOMPARE(keyValuePair2.attribute("value"), QLatin1String("2011-01-01:123/100;2011-02-01:114/25")); QCOMPARE(keyValuePair2.childNodes().size(), 0); }
KNewAccountDlg::KNewAccountDlg(const MyMoneyAccount& account, bool isEditing, bool categoryEditor, QWidget *parent, const char *name, const QString& title) : KNewAccountDlgDecl(parent,name,true), m_account(account), m_bSelectedParentAccount(false), m_categoryEditor(categoryEditor), m_isEditing(isEditing) { QString columnName = ( (categoryEditor) ? i18n("Categories") : i18n("Accounts") ); m_qlistviewParentAccounts->setRootIsDecorated(true); m_qlistviewParentAccounts->setAllColumnsShowFocus(true); m_qlistviewParentAccounts->setSectionHeader(columnName); m_qlistviewParentAccounts->setMultiSelection(false); m_qlistviewParentAccounts->header()->setResizeEnabled(true); m_qlistviewParentAccounts->setColumnWidthMode(0, QListView::Maximum); m_qlistviewParentAccounts->setEnabled(false); // never show the horizontal scroll bar m_qlistviewParentAccounts->setHScrollBarMode(QScrollView::AlwaysOff); m_subAccountLabel->setText(i18n("Is a sub account")); m_qlistviewParentAccounts->header()->setFont(KMyMoneyGlobalSettings::listHeaderFont()); accountNameEdit->setText(account.name()); descriptionEdit->setText(account.description()); typeCombo->setEnabled(true); MyMoneyFile *file = MyMoneyFile::instance(); // load the price mode combo m_priceMode->insertItem(i18n("default price mode", "<default>"), 0); m_priceMode->insertItem(i18n("Price per share"), 1); m_priceMode->insertItem(i18n("Total for all shares"), 2); int priceMode = 0; if(m_account.accountType() == MyMoneyAccount::Investment) { m_priceMode->setEnabled(true); if(!m_account.value("priceMode").isEmpty()) priceMode = m_account.value("priceMode").toInt(); } m_priceMode->setCurrentItem(priceMode); bool haveMinBalance = false; bool haveMaxCredit = false; if (categoryEditor) { // get rid of the tabs that are not used for categories QWidget* tab = m_tab->page(m_tab->indexOf(m_institutionTab)); if(tab) m_tab->removePage(tab); tab = m_tab->page(m_tab->indexOf(m_limitsTab)); if(tab) m_tab->removePage(tab); //m_qlistviewParentAccounts->setEnabled(true); startDateEdit->setEnabled(false); accountNoEdit->setEnabled(false); m_institutionBox->hide(); m_qcheckboxNoVat->hide(); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense)); // Hardcoded but acceptable switch (account.accountType()) { case MyMoneyAccount::Income: typeCombo->setCurrentItem(0); break; case MyMoneyAccount::Expense: default: typeCombo->setCurrentItem(1); break; } m_currency->setEnabled(true); if (m_isEditing) { typeCombo->setEnabled(false); m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account)); } m_qcheckboxPreferred->hide(); m_qcheckboxTax->setChecked(account.value("Tax") == "Yes"); loadVatAccounts(); } else { // get rid of the tabs that are not used for accounts QWidget* taxtab = m_tab->page(m_tab->indexOf(m_taxTab)); if (taxtab) { if(m_account.isAssetLiability()) { m_vatCategory->setText(i18n( "VAT account")); m_vatAssignmentFrame->hide(); m_qcheckboxTax->setChecked(account.value("Tax") == "Yes"); } else { m_tab->removePage(taxtab); } } switch(m_account.accountType()) { case MyMoneyAccount::Savings: case MyMoneyAccount::Cash: haveMinBalance = true; break; case MyMoneyAccount::Checkings: haveMinBalance = true; haveMaxCredit = true; break; case MyMoneyAccount::CreditCard: haveMaxCredit = true; break; default: // no limit available, so we might get rid of the tab QWidget* tab = m_tab->page(m_tab->indexOf(m_limitsTab)); if(tab) m_tab->removePage(tab); // don't try to hide the widgets we just wiped // in the next step haveMaxCredit = haveMinBalance = true; break; } if(!haveMaxCredit) { m_maxCreditLabel->setEnabled(false); m_maxCreditLabel->hide(); m_maxCreditEarlyEdit->hide(); m_maxCreditAbsoluteEdit->hide(); } if(!haveMinBalance) { m_minBalanceLabel->setEnabled(false); m_minBalanceLabel->hide(); m_minBalanceEarlyEdit->hide(); m_minBalanceAbsoluteEdit->hide(); } typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Savings)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Cash)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CreditCard)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Loan)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Investment)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Stock)); /* typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CertificateDep)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::MoneyMarket)); typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Currency)); */ // Hardcoded but acceptable switch (account.accountType()) { default: case MyMoneyAccount::Checkings: typeCombo->setCurrentItem(0); break; case MyMoneyAccount::Savings: typeCombo->setCurrentItem(1); break; case MyMoneyAccount::Cash: typeCombo->setCurrentItem(2); break; case MyMoneyAccount::CreditCard: typeCombo->setCurrentItem(3); break; case MyMoneyAccount::Loan: typeCombo->setCurrentItem(4); break; case MyMoneyAccount::Investment: typeCombo->setCurrentItem(5); break; case MyMoneyAccount::Asset: typeCombo->setCurrentItem(6); break; case MyMoneyAccount::Liability: typeCombo->setCurrentItem(7); break; case MyMoneyAccount::Stock: m_institutionBox->hide(); typeCombo->setCurrentItem(8); break; /* case MyMoneyAccount::CertificateDep: typeCombo->setCurrentItem(5); break; case MyMoneyAccount::MoneyMarket: typeCombo->setCurrentItem(7); break; case MyMoneyAccount::Currency: typeCombo->setCurrentItem(8); break; */ } if(!m_account.openingDate().isValid()) m_account.setOpeningDate(QDate::currentDate()); startDateEdit->setDate(m_account.openingDate()); accountNoEdit->setText(account.number()); m_qcheckboxPreferred->setChecked(account.value("PreferredAccount") == "Yes"); m_qcheckboxNoVat->setChecked(account.value("NoVat") == "Yes"); loadKVP("iban", ibanEdit); loadKVP("minBalanceAbsolute", m_minBalanceAbsoluteEdit); loadKVP("minBalanceEarly", m_minBalanceEarlyEdit); loadKVP("maxCreditAbsolute", m_maxCreditAbsoluteEdit); loadKVP("maxCreditEarly", m_maxCreditEarlyEdit); // reverse the sign for display purposes if(!m_maxCreditAbsoluteEdit->lineedit()->text().isEmpty()) m_maxCreditAbsoluteEdit->setValue(m_maxCreditAbsoluteEdit->value()*MyMoneyMoney(-1,1)); if(!m_maxCreditEarlyEdit->lineedit()->text().isEmpty()) m_maxCreditEarlyEdit->setValue(m_maxCreditEarlyEdit->value()*MyMoneyMoney(-1,1)); loadKVP("lastNumberUsed", m_lastCheckNumberUsed); // we do not allow to change the account type once an account // was created. Same applies to currency if it is referenced. if (m_isEditing) { typeCombo->setEnabled(false); m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account)); } if(m_account.isInvest()) { typeCombo->setEnabled(false); m_qcheckboxPreferred->hide(); m_currencyText->hide(); m_currency->hide(); } else { // use the old field and override a possible new value if(!MyMoneyMoney(account.value("minimumBalance")).isZero()) { m_minBalanceAbsoluteEdit->setValue(MyMoneyMoney(account.value("minimumBalance"))); } } // m_qcheckboxTax->hide(); TODO should only be visible for VAT category/account } m_currency->setSecurity(file->currency(account.currencyId())); // Load the institutions // then the accounts QString institutionName; try { if (m_isEditing && !account.institutionId().isEmpty()) institutionName = file->institution(account.institutionId()).name(); else institutionName = QString(); } catch (MyMoneyException *e) { qDebug("exception in init for account dialog: %s", e->what().latin1()); delete e; } initParentWidget(account.parentAccountId(), account.id()); if(m_account.isInvest()) m_qlistviewParentAccounts->setEnabled(false); if (!categoryEditor) slotLoadInstitutions(institutionName); accountNameEdit->setFocus(); if (title) setCaption(title); // load button icons KIconLoader* il = KGlobal::iconLoader(); cancelButton->setGuiItem(KStdGuiItem::cancel()); createButton->setGuiItem(KStdGuiItem::ok()); connect(cancelButton, SIGNAL(clicked()), SLOT(reject())); connect(createButton, SIGNAL(clicked()), this, SLOT(okClicked())); connect(m_qlistviewParentAccounts, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelectionChanged(QListViewItem*))); connect(m_qbuttonNew, SIGNAL(clicked()), this, SLOT(slotNewClicked())); connect(typeCombo, SIGNAL(activated(const QString&)), this, SLOT(slotAccountTypeChanged(const QString&))); connect(accountNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotCheckFinished())); connect(m_vatCategory, SIGNAL(toggled(bool)), this, SLOT(slotVatChanged(bool))); connect(m_vatAssignment, SIGNAL(toggled(bool)), this, SLOT(slotVatAssignmentChanged(bool))); connect(m_vatCategory, SIGNAL(toggled(bool)), this, SLOT(slotCheckFinished())); connect(m_vatAssignment, SIGNAL(toggled(bool)), this, SLOT(slotCheckFinished())); connect(m_vatRate, SIGNAL(textChanged(const QString&)), this, SLOT(slotCheckFinished())); connect(m_vatAccount, SIGNAL(stateChanged()), this, SLOT(slotCheckFinished())); connect(m_minBalanceEarlyEdit, SIGNAL(valueChanged(const QString&)), this, SLOT(slotAdjustMinBalanceAbsoluteEdit(const QString&))); connect(m_minBalanceAbsoluteEdit, SIGNAL(valueChanged(const QString&)), this, SLOT(slotAdjustMinBalanceEarlyEdit(const QString&))); connect(m_maxCreditEarlyEdit, SIGNAL(valueChanged(const QString&)), this, SLOT(slotAdjustMaxCreditAbsoluteEdit(const QString&))); connect(m_maxCreditAbsoluteEdit, SIGNAL(valueChanged(const QString&)), this, SLOT(slotAdjustMaxCreditEarlyEdit(const QString&))); connect(m_qcomboboxInstitutions, SIGNAL(activated(const QString&)), this, SLOT(slotLoadInstitutions(const QString&))); m_vatCategory->setChecked(false); m_vatAssignment->setChecked(false); // make sure our account does not have an id and no parent assigned // and certainly no children in case we create a new account if(!m_isEditing) { m_account.clearId(); m_account.setParentAccountId(QString()); QStringList::ConstIterator it; while((it = m_account.accountList().begin()) != m_account.accountList().end()) m_account.removeAccountId(*it); if(m_parentItem == 0) { // force loading of initial parent m_account.setAccountType(MyMoneyAccount::UnknownAccountType); MyMoneyAccount::_accountTypeE type = account.accountType(); if(type == MyMoneyAccount::UnknownAccountType) type = MyMoneyAccount::Checkings; slotAccountTypeChanged(KMyMoneyUtils::accountTypeToString(type)); } } else { if(!m_account.value("VatRate").isEmpty()) { m_vatCategory->setChecked(true); m_vatRate->setValue(MyMoneyMoney(m_account.value("VatRate"))*MyMoneyMoney(100,1)); } else { if(!m_account.value("VatAccount").isEmpty()) { QString accId = m_account.value("VatAccount").latin1(); try { // make sure account exists MyMoneyFile::instance()->account(accId); m_vatAssignment->setChecked(true); m_vatAccount->setSelected(accId); m_grossAmount->setChecked(true); if(m_account.value("VatAmount") == "Net") m_netAmount->setChecked(true); } catch(MyMoneyException *e) { delete e; } } } } slotVatChanged(m_vatCategory->isChecked()); slotVatAssignmentChanged(m_vatAssignment->isChecked()); slotCheckFinished(); kMandatoryFieldGroup* requiredFields = new kMandatoryFieldGroup (this); requiredFields->setOkButton(createButton); // button to be enabled when all fields present requiredFields->add(accountNameEdit); // using a timeout is the only way, I got the 'ensureItemVisible' // working when creating the dialog. I assume, this // has something to do with the delayed update of the display somehow. QTimer::singleShot(50, this, SLOT(timerDone())); }
KEndingBalanceDlg::KEndingBalanceDlg(const MyMoneyAccount& account, QWidget *parent) : KEndingBalanceDlgDecl(parent), d(new Private(Page_InterestChargeCheckings + 1)) { setModal(true); QString value; MyMoneyMoney endBalance, startBalance; d->m_account = account; MyMoneySecurity currency = MyMoneyFile::instance()->security(account.currencyId()); //FIXME: port m_statementInfoPageCheckings->m_enterInformationLabel->setText(QString("<qt>") + i18n("Please enter the following fields with the information as you find them on your statement. Make sure to enter all values in <b>%1</b>.", currency.name()) + QString("</qt>")); // If the previous reconciliation was postponed, // we show a different first page value = account.value("lastReconciledBalance"); if (value.isEmpty()) { // if the last statement has been entered long enough ago (more than one month), // then take the last statement date and add one month and use that as statement // date. QDate lastStatementDate = account.lastReconciliationDate(); if (lastStatementDate.addMonths(1) < QDate::currentDate()) { setField("statementDate", lastStatementDate.addMonths(1)); } slotUpdateBalances(); d->m_pages.clearBit(Page_PreviousPostpone); } else { d->m_pages.clearBit(Page_CheckingStart); d->m_pages.clearBit(Page_InterestChargeCheckings); //removePage(m_interestChargeCheckings); // make sure, we show the correct start page setStartId(Page_PreviousPostpone); MyMoneyMoney factor(1, 1); if (d->m_account.accountGroup() == MyMoneyAccount::Liability) factor = -factor; startBalance = MyMoneyMoney(value) * factor; value = account.value("statementBalance"); endBalance = MyMoneyMoney(value) * factor; //FIXME: port m_statementInfoPageCheckings->m_previousBalance->setValue(startBalance); m_statementInfoPageCheckings->m_endingBalance->setValue(endBalance); } // We don't need to add the default into the list (see ::help() why) // m_helpAnchor[m_startPageCheckings] = QString(""); d->m_helpAnchor[m_interestChargeCheckings] = QString("details.reconcile.wizard.interest"); d->m_helpAnchor[m_statementInfoPageCheckings] = QString("details.reconcile.wizard.statement"); value = account.value("statementDate"); if (!value.isEmpty()) setField("statementDate", QDate::fromString(value, Qt::ISODate)); //FIXME: port m_statementInfoPageCheckings->m_lastStatementDate->setText(QString()); if (account.lastReconciliationDate().isValid()) { m_statementInfoPageCheckings->m_lastStatementDate->setText(i18n("Last reconciled statement: %1", QLocale().toString(account.lastReconciliationDate()))); } // connect the signals with the slots connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), this, SLOT(slotReloadEditWidgets())); connect(m_statementInfoPageCheckings->m_statementDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotUpdateBalances())); connect(m_interestChargeCheckings->m_interestCategoryEdit, SIGNAL(createItem(QString,QString&)), this, SLOT(slotCreateInterestCategory(QString,QString&))); connect(m_interestChargeCheckings->m_chargesCategoryEdit, SIGNAL(createItem(QString,QString&)), this, SLOT(slotCreateChargesCategory(QString,QString&))); connect(m_interestChargeCheckings->m_payeeEdit, SIGNAL(createItem(QString,QString&)), this, SIGNAL(createPayee(QString,QString&))); KMyMoneyMVCCombo::setSubstringSearchForChildren(m_interestChargeCheckings, !KMyMoneySettings::stringMatchFromStart()); slotReloadEditWidgets(); // preset payee if possible try { // if we find a payee with the same name as the institution, // than this is what we use as payee. if (!d->m_account.institutionId().isEmpty()) { MyMoneyInstitution inst = MyMoneyFile::instance()->institution(d->m_account.institutionId()); MyMoneyPayee payee = MyMoneyFile::instance()->payeeByName(inst.name()); setField("payeeEdit", payee.id()); } } catch (const MyMoneyException &) { } KMyMoneyUtils::updateWizardButtons(this); // setup different text and icon on finish button setButtonText(QWizard::FinishButton, KStandardGuiItem::cont().text()); button(QWizard::FinishButton)->setIcon(KStandardGuiItem::cont().icon()); }