From 8654cea10f6902719006d5975db7dc07b2fcc713 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 14 Jan 2012 14:08:52 -0600 Subject: Update to upstream stable version 1.0.5 --- kmymoney2/converter/mymoneystatementreader.cpp | 4 ++++ kmymoney2/mymoney/mymoneyforecast.cpp | 19 ++++++++++++++++--- kmymoney2/reports/pivottable.cpp | 25 ++++++++++++++++++++----- kmymoney2/views/kgloballedgerview.cpp | 7 ++++++- kmymoney2/views/khomeview.cpp | 7 +++++++ kmymoney2/views/kinstitutionsview.cpp | 11 +++++++++-- kmymoney2/widgets/stdtransactionmatched.cpp | 2 ++ 7 files changed, 64 insertions(+), 11 deletions(-) (limited to 'kmymoney2') diff --git a/kmymoney2/converter/mymoneystatementreader.cpp b/kmymoney2/converter/mymoneystatementreader.cpp index 6756767..c08dcff 100644 --- a/kmymoney2/converter/mymoneystatementreader.cpp +++ b/kmymoney2/converter/mymoneystatementreader.cpp @@ -664,6 +664,10 @@ void MyMoneyStatementReader::processTransactionEntry(const MyMoneyStatement::Tra if(!t_in.m_price.isZero()) { s1.setPrice(t_in.m_price); } else { + if(t_in.m_shares.isZero()) { + KMessageBox::information(0, i18n("This imported statement contains investment transactions with no share amount. These transactions will be ignored."), i18n("No share amount provided"), TQString("BlankAmount")); + return; + } s1.setPrice(((t_in.m_amount - t_in.m_fees) / t_in.m_shares).convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision()))); } diff --git a/kmymoney2/mymoney/mymoneyforecast.cpp b/kmymoney2/mymoney/mymoneyforecast.cpp index bfecce0..c1c88c7 100644 --- a/kmymoney2/mymoney/mymoneyforecast.cpp +++ b/kmymoney2/mymoney/mymoneyforecast.cpp @@ -651,7 +651,7 @@ void MyMoneyForecast::addScheduledTransactions (void) TQValueList schedule; schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY, - TQDate::currentDate(), forecastEndDate()); + TQDate(), forecastEndDate()); if(schedule.count() > 0) { TQValueList::Iterator it; do { @@ -871,8 +871,21 @@ MyMoneyMoney MyMoneyForecast::accountCycleVariation(const MyMoneyAccount& acc) MyMoneyMoney cycleVariation; if (forecastMethod() == eHistoric) { - for(int t_day = 1; t_day <= accountsCycle() ; ++t_day) { - cycleVariation += m_accountTrendList[acc.id()][t_day]; + switch(historyMethod()) { + case 0: + case 1: + { + for(int t_day = 1; t_day <= accountsCycle() ; ++t_day) { + cycleVariation += m_accountTrendList[acc.id()][t_day]; + } + } + break; + + case 2: + { + cycleVariation = m_accountList[acc.id()][TQDate::currentDate().addDays(accountsCycle())] - m_accountList[acc.id()][TQDate::currentDate()]; + } + break; } } return cycleVariation; diff --git a/kmymoney2/reports/pivottable.cpp b/kmymoney2/reports/pivottable.cpp index db73062..b75ffb9 100644 --- a/kmymoney2/reports/pivottable.cpp +++ b/kmymoney2/reports/pivottable.cpp @@ -825,9 +825,27 @@ void PivotTable::calculateBudgetMapping( void ) // // It will choose the first budget in the list for the start year of the report if no budget is select MyMoneyBudget budget = MyMoneyBudget(); + + TQValueList budgets = file->budgetList(); + bool validBudget = false; + + //check that the selected budget is valid + if (m_config_f.budget() != "Any") { + TQValueList::const_iterator budgets_it = budgets.begin(); + while( budgets_it != budgets.end() ) { + //pick the budget by id + if ((*budgets_it).id() == m_config_f.budget()) { + budget = file->budget((*budgets_it).id()); + validBudget = true; + break; + } + ++budgets_it; + } + } + //if no budget has been selected - if (m_config_f.budget() == "Any" ) { - TQValueList budgets = file->budgetList(); + if (!validBudget ) { + TQValueList::const_iterator budgets_it = budgets.begin(); while( budgets_it != budgets.end() ) { //pick the first budget that matches the report start year @@ -843,9 +861,6 @@ void PivotTable::calculateBudgetMapping( void ) //assign the budget to the report m_config_f.setBudget(budget.id(), m_config_f.isIncludingBudgetActuals()); - } else { - //pick the budget selected by the user - budget = file->budget( m_config_f.budget()); } // Dump the budget diff --git a/kmymoney2/views/kgloballedgerview.cpp b/kmymoney2/views/kgloballedgerview.cpp index 8209d3f..e82459a 100644 --- a/kmymoney2/views/kgloballedgerview.cpp +++ b/kmymoney2/views/kgloballedgerview.cpp @@ -485,7 +485,12 @@ void KGlobalLedgerView::loadView(void) break; // for all others, we check if the next payment date is still 'in range' - s.setNextDueDate(s.nextPayment(s.nextDueDate())); + TQDate nextDueDate = s.nextPayment(s.nextDueDate()); + if (nextDueDate.isValid()) { + s.setNextDueDate(nextDueDate); + } else { + break; + } } scheduleList.pop_front(); } diff --git a/kmymoney2/views/khomeview.cpp b/kmymoney2/views/khomeview.cpp index 60bb173..8745d64 100644 --- a/kmymoney2/views/khomeview.cpp +++ b/kmymoney2/views/khomeview.cpp @@ -595,6 +595,13 @@ void KHomeView::showPayments(void) schedule.remove(it); continue; } + + //if nextPayment returns an invalid date, setNextDueDate will just skip it, resulting in a loop + //we check the resulting date and erase the schedule if invalid + if(!((*it).nextPayment((*it).nextDueDate())).isValid()) { + schedule.remove(it); + continue; + } (*it).setNextDueDate((*it).nextPayment((*it).nextDueDate())); qBubbleSort(schedule); diff --git a/kmymoney2/views/kinstitutionsview.cpp b/kmymoney2/views/kinstitutionsview.cpp index 0b9258f..87c0fc1 100644 --- a/kmymoney2/views/kinstitutionsview.cpp +++ b/kmymoney2/views/kinstitutionsview.cpp @@ -161,6 +161,9 @@ void KInstitutionsView::loadAccounts(void) // hide it, if unused noInstitutionItem->setVisible(noInstitutionItem->childCount() != 0); + + bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked() + || !KMyMoneyGlobalSettings::hideClosedAccounts(); TQValueList list = file->institutionList(); TQValueList::const_iterator it_i; @@ -168,6 +171,8 @@ void KInstitutionsView::loadAccounts(void) KMyMoneyAccountTreeItem* item = new KMyMoneyAccountTreeItem(m_accountTree, *it_i); item->setPixmap(0, none.pixmap()); loadSubAccounts(item, (*it_i).id()); + if(!showClosedAccounts) + item->setVisible(item->childCount() != 0); } } catch(MyMoneyException *e) { @@ -201,7 +206,8 @@ void KInstitutionsView::loadAccounts(void) void KInstitutionsView::loadSubAccounts(KMyMoneyAccountTreeItem* parent) { - bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked(); + bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked() + || !KMyMoneyGlobalSettings::hideClosedAccounts(); const MyMoneyAccount& account = dynamic_cast(parent->itemObject()); TQValueList::const_iterator it_a; MyMoneyFile* file = MyMoneyFile::instance(); @@ -230,7 +236,8 @@ void KInstitutionsView::loadSubAccounts(KMyMoneyAccountTreeItem* parent, const T TQMap::const_iterator it_a; MyMoneyMoney value; - bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked(); + bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked() + || !KMyMoneyGlobalSettings::hideClosedAccounts(); for(it_a = m_accountMap.begin(); it_a != m_accountMap.end(); ++it_a) { const MyMoneyAccount& acc = *it_a; diff --git a/kmymoney2/widgets/stdtransactionmatched.cpp b/kmymoney2/widgets/stdtransactionmatched.cpp index 833c88e..9900c3c 100644 --- a/kmymoney2/widgets/stdtransactionmatched.cpp +++ b/kmymoney2/widgets/stdtransactionmatched.cpp @@ -179,6 +179,8 @@ void StdTransactionMatched::registerCellText(TQString& txt, int& align, int row, memo = memo.left(pos); if(memo.endsWith("\n")) memo = memo.left(pos-1); + // replace all new line characters because we only have one line available for the displayed data + memo.replace('\n', " "); } } txt = TQString("%1 %2").arg(postDate.toString(Qt::ISODate)).arg(memo); -- cgit v1.2.1