commit 8654cea10f6902719006d5975db7dc07b2fcc713
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   1326571732 -0600

    Update to upstream stable version 1.0.5

diff --git a/ChangeLog b/ChangeLog
index d250496..c996acb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,40 @@
 
+2010-05-15 Thomas Baumgart <ipwizard@users.sourceforge.net>
+  * Released 1.0.5
+
+2010-05-12 Thomas Baumgart <ipwizard@users.sourceforge.net>
+  * Fixed the way to calculate balance variation for the linear regression
+    forecast method (backported from KDE4)
+
+2010-05-09 Alvaro Soliverez <asoliverez@gmail.com>
+  * Fixed a crash when a budget selected for a report is no longer present
+
+2010-05-04 Thomas Baumgart <ipwizard@users.sourceforge.net>
+  * replace all new line characters because we only have one line
+    available for the displayed data (backported from KDE4)
+  * Don't allow import of investment transactions that don't have a share
+    amount. This used to end in a div by zero when calculating the price.
+    (Backported from KDE4)
+
+2010-05-03 Alvaro Soliverez <asoliverez@gmail.com>
+  * Add all overdue schedules when calculating forecast
+  * Do not show accounts of institutions if it has been selected
+    in the general settings to Do not show closed accounts
+  * Do not show an institution if it has no visible accounts and
+    it has been selected to not show closed accounts
+
+2010-04-20 Thomas Baumgart <ipwizard@users.sourceforge.net>
+  * Backported fix from Ian Neal to solve problems when opening the ledger
+    with specific scheduled transactions
+
+2010-04-03 Alvaro Soliverez <asoliverez@gmail.com>
+  * Fixed loop in payments of the home page when a schedule is set to
+    end by date
+
 2010-03-30 Thomas Baumgart <ipwizard@users.sourceforge.net>
   * Backported encoding patch from KDE4 version
   * Bumped version number
+  * Released 1.0.4
 
 2010-03-29 Thomas Baumgart <ipwizard@users.sourceforge.net>
   * Updated Finnish translation by Mikael Kujanpaa
diff --git a/configure.in b/configure.in
index 8a6c1b8..1a8dd02 100644
--- a/configure.in
+++ b/configure.in
@@ -40,7 +40,7 @@ dnl Perform program name transformation
 AC_ARG_PROGRAM
 
 dnl Automake doc recommends to do this only here. (Janos)
-AM_INIT_AUTOMAKE(kmymoney2, 1.0.4) dnl searches for some needed programs
+AM_INIT_AUTOMAKE(kmymoney2, 1.0.5) dnl searches for some needed programs
 
 KDE_SET_PREFIX
 
diff --git a/configure.in.in b/configure.in.in
index 3f82103..a90f40f 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -1,6 +1,6 @@
 #MIN_CONFIG(3.3.1)
 
-AM_INIT_AUTOMAKE(kmymoney2,1.0.4)
+AM_INIT_AUTOMAKE(kmymoney2,1.0.5)
 
 KDE_ENABLE_HIDDEN_VISIBILITY
 
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<MyMoneySchedule> schedule;
 
   schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY,
-                                TQDate::tqcurrentDate(), forecastEndDate());
+                                TQDate(), forecastEndDate());
   if(schedule.count() > 0) {
     TQValueList<MyMoneySchedule>::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<MyMoneyBudget> budgets = file->budgetList();
+    bool validBudget = false;
+    
+    //check that the selected budget is valid
+    if (m_config_f.budget() != "Any") {
+      TQValueList<MyMoneyBudget>::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<MyMoneyBudget> budgets = file->budgetList();
+    if (!validBudget ) {
+      
       TQValueList<MyMoneyBudget>::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<MyMoneyInstitution> list = file->institutionList();
     TQValueList<MyMoneyInstitution>::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<const MyMoneyAccount&>(parent->itemObject());
   TQValueList<TQString>::const_iterator it_a;
   MyMoneyFile* file = MyMoneyFile::instance();
@@ -230,7 +236,8 @@ void KInstitutionsView::loadSubAccounts(KMyMoneyAccountTreeItem* parent, const T
 
   TQMap<TQString, MyMoneyAccount>::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 @@
                 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").tqarg(postDate.toString(Qt::ISODate)).tqarg(memo);