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/reports/pivottable.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'kmymoney2/reports') 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 -- cgit v1.2.1