From dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 4 Jul 2011 22:38:03 +0000 Subject: Added kmymoney git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmymoney2/dialogs/kconfirmmanualenterdlg.cpp | 202 +++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 kmymoney2/dialogs/kconfirmmanualenterdlg.cpp (limited to 'kmymoney2/dialogs/kconfirmmanualenterdlg.cpp') diff --git a/kmymoney2/dialogs/kconfirmmanualenterdlg.cpp b/kmymoney2/dialogs/kconfirmmanualenterdlg.cpp new file mode 100644 index 0000000..3c20a48 --- /dev/null +++ b/kmymoney2/dialogs/kconfirmmanualenterdlg.cpp @@ -0,0 +1,202 @@ +/*************************************************************************** + kconfirmmanualenterdlg.cpp + ------------------- + begin : Mon Apr 9 2007 + copyright : (C) 2007 by Thomas Baumgart + email : Thomas Baumgart + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +// ---------------------------------------------------------------------------- +// QT Includes + +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// Project Includes + +#include +#include +#include "kconfirmmanualenterdlg.h" + +KConfirmManualEnterDlg::KConfirmManualEnterDlg(const MyMoneySchedule& schedule, QWidget* parent, const char* name) : + KConfirmManualEnterDlgDecl(parent, name) +{ + buttonOk->setGuiItem(KStdGuiItem::ok()); + buttonCancel->setGuiItem(KStdGuiItem::cancel()); + m_onceRadio->setChecked(true); + m_onceRadio->setFocus(); + + if(schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + m_setRadio->setEnabled(false); + m_discardRadio->setEnabled(false); + } + +} + +void KConfirmManualEnterDlg::loadTransactions(const MyMoneyTransaction& to, const MyMoneyTransaction& tn) +{ + QString messageDetail(""); + MyMoneyFile* file = MyMoneyFile::instance(); + int noItemsChanged=0; + +#if 0 + // if no schedule is present, we cannot enter it + if(m_schedule.id().isEmpty()) + return false; + + if (m_fromAccountId == m_toAccountId) + { + KMessageBox::error(this, i18n("Account and transfer account are the same. Please change one.")); + m_from->setFocus(); + return false; + } + + if (!checkDateInPeriod(m_date->date())) + return false; +#endif + + try + { + QString po, pn; + if(to.splits()[0].payeeId()) + po = file->payee(to.splits()[0].payeeId()).name(); + if(tn.splits()[0].payeeId()) + pn = file->payee(tn.splits()[0].payeeId()).name(); + + if (po != pn) { + noItemsChanged++; + messageDetail += i18n("Payee changed.
   Old: %1, New: %2

").arg(po).arg(pn); + } +#if 0 + if ( (m_schedule.type() == MyMoneySchedule::TYPE_TRANSFER || + m_schedule.type() == MyMoneySchedule::TYPE_BILL) && + m_from->currentText() != m_schedule.account().name()) + { + noItemsChanged++; + messageDetail += i18n("Account changed. Old: \"%1\", New: \"%2\"") + .arg(m_schedule.account().name()).arg(m_from->currentText()) + QString("\n"); + } + + if ( m_schedule.type() == MyMoneySchedule::TYPE_DEPOSIT && + m_to->currentText() != m_schedule.account().name()) + { + noItemsChanged++; + messageDetail += i18n("Account changed. Old: \"%1\", New: \"%2\"") + .arg(m_schedule.account().name()).arg(m_to->currentText()) + QString("\n"); + } +#endif + + if(to.splits()[0].accountId() != tn.splits()[0].accountId()) { + noItemsChanged++; + messageDetail += i18n("Account changed.
   Old: %1, New: %2

") + .arg(file->account(to.splits()[0].accountId()).name()) + .arg(file->account(tn.splits()[0].accountId()).name()); + } + + if(file->isTransfer(to) && file->isTransfer(tn)) { + if(to.splits()[1].accountId() != tn.splits()[1].accountId()) { + noItemsChanged++; + messageDetail += i18n("Transfer account changed.
   Old: %1, New: %2

") + .arg(file->account(to.splits()[1].accountId()).name()) + .arg(file->account(tn.splits()[1].accountId()).name()); + } + } else { + QString co, cn; + switch(to.splitCount()) { + default: + co = i18n("Split transaction (category replacement)", "Split transaction"); + break; + case 2: + co = file->accountToCategory(to.splits()[1].accountId()); + case 1: + break; + } + + switch(tn.splitCount()) { + default: + cn = i18n("Split transaction (category replacement)", "Split transaction"); + break; + case 2: + cn = file->accountToCategory(tn.splits()[1].accountId()); + case 1: + break; + } + if (co != cn) + { + noItemsChanged++; + messageDetail += i18n("Category changed.
   Old: %1, New: %2

").arg(co).arg(cn); + } + } + + QString mo, mn; + mo = to.splits()[0].memo(); + mn = tn.splits()[0].memo(); + if(mo.isEmpty()) + mo = QString("")+i18n("empty")+QString(""); + if(mn.isEmpty()) + mn = QString("")+i18n("empty")+QString(""); + if (mo != mn) + { + noItemsChanged++; + messageDetail += i18n("Memo changed.
   Old: %1, New: %2

").arg(mo).arg(mn); + } + + const MyMoneySecurity& sec = MyMoneyFile::instance()->security(to.commodity()); + MyMoneyMoney ao, an; + ao = to.splits()[0].value(); + an = tn.splits()[0].value(); + if (ao != an) { + noItemsChanged++; + messageDetail += i18n("Amount changed.
   Old: %1, New: %2

") + .arg(ao.formatMoney(sec.smallestAccountFraction())).arg(an.formatMoney(sec.smallestAccountFraction())); + } + + MyMoneySplit::reconcileFlagE fo, fn; + fo = to.splits()[0].reconcileFlag(); + fn = tn.splits()[0].reconcileFlag(); + if(fo != fn) { + noItemsChanged++; + messageDetail += i18n("Reconciliation flag changed.
   Old: %1, New: %2

") + .arg(KMyMoneyUtils::reconcileStateToString(fo, true)) + .arg(KMyMoneyUtils::reconcileStateToString(fn, true)); + } + } + catch (MyMoneyException *e) + { + KMessageBox::error(this, i18n("Fatal error in determining data: ") + e->what()); + delete e; + } + + messageDetail += ""; + m_details->setText(messageDetail); + return; +} + +KConfirmManualEnterDlg::Action KConfirmManualEnterDlg::action(void) const +{ + if(m_discardRadio->isChecked()) + return UseOriginal; + if(m_setRadio->isChecked()) + return ModifyAlways; + return ModifyOnce; +} + +#include "kconfirmmanualenterdlg.moc" -- cgit v1.2.1