Commit 84112ff0 authored by Łukasz Wojniłowicz's avatar Łukasz Wojniłowicz
Browse files

Respect fiscal year's start setting for budgets



BUG:297873
BUG:337836
FIXED-IN:5.0
Signed-off-by: Łukasz Wojniłowicz's avatarŁukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
parent bc9c7202
......@@ -5284,8 +5284,8 @@ void KMyMoneyApp::slotCurrencySetBase()
void KMyMoneyApp::slotBudgetNew()
{
QDate date = QDate::currentDate();
date.setDate(date.year(), 1, 1);
QString newname = i18n("Budget <numid>%1</numid>", date.year());
date.setDate(date.year(), KMyMoneyGlobalSettings::firstFiscalMonth(), KMyMoneyGlobalSettings::firstFiscalDay());
QString newname = i18n("Budget %1", date.year());
MyMoneyBudget budget;
......@@ -5295,7 +5295,7 @@ void KMyMoneyApp::slotBudgetNew()
// Exception thrown when the name is not found
while (1) {
MyMoneyFile::instance()->budgetByName(newname);
newname = i18n("Budget <numid>%1</numid> (<numid>%2</numid>)", date.year(), i++);
newname = i18n("Budget %1 %2", date.year(), i++);
}
} catch (const MyMoneyException &) {
// all ok, the name is unique
......@@ -5384,7 +5384,7 @@ void KMyMoneyApp::slotBudgetChangeYear()
if (ok) {
int year = yearString.toInt(0, 0);
QDate newYear = QDate(year, 1, 1);
QDate newYear = QDate(year, budget.budgetStart().month(), budget.budgetStart().day());
if (newYear != budget.budgetStart()) {
MyMoneyFileTransaction ft;
try {
......
......@@ -649,12 +649,16 @@ void KBudgetView::slotStartRename()
void KBudgetView::slotItemChanged(QTreeWidgetItem* p, int col)
{
// if we don't have an item or something changed in the year column
// we actually don't care about it
if (!p || col != 0)
// if we don't have an item we actually don't care about it
if (!p)
return;
KBudgetListItem *pBudget = dynamic_cast<KBudgetListItem*>(p);
if (col == 1) {
pBudget->setText(1, QString().setNum(pBudget->budget().budgetStart().year()));
return;
}
// create a copy of the new name without leading and trailing whitespaces
QString new_name = p->text(0).trimmed();
......
......@@ -39,6 +39,7 @@
#include <KLocalizedString>
#include <kmessagebox.h>
#include <kstandardguiitem.h>
#include <kmymoneyglobalsettings.h>
// ----------------------------------------------------------------------------
// Project Includes
......@@ -49,7 +50,7 @@ KBudgetValues::KBudgetValues(QWidget* parent) :
KBudgetValuesDecl(parent),
m_currentTab(m_monthlyButton)
{
m_budgetDate = QDate(2007, 1, 1);
m_budgetDate = QDate(2007, KMyMoneyGlobalSettings::firstFiscalMonth(), KMyMoneyGlobalSettings::firstFiscalDay());
m_field[0] = m_amount1;
m_field[1] = m_amount2;
......@@ -290,7 +291,7 @@ void KBudgetValues::setBudgetValues(const MyMoneyBudget& budget, const MyMoneyBu
case MyMoneyBudget::AccountGroup::eMonthByMonth:
m_individualButton->setChecked(true);
slotChangePeriod(m_periodGroup->id(m_individualButton));
date.setDate(m_budgetDate.year(), 1, 1);
date.setDate(m_budgetDate.year(), m_budgetDate.month(), m_budgetDate.day());
for (int i = 0; i < 12; ++i) {
m_field[i]->setValue(budgetAccount.period(date).amount());
date = date.addMonths(1);
......@@ -320,7 +321,7 @@ void KBudgetValues::budgetValues(const MyMoneyBudget& budget, MyMoneyBudget::Acc
budgetAccount.addPeriod(m_budgetDate, period);
} else if (tab == m_periodGroup->id(m_individualButton)) {
budgetAccount.setBudgetLevel(MyMoneyBudget::AccountGroup::eMonthByMonth);
date.setDate(m_budgetDate.year(), 1, 1);
date.setDate(m_budgetDate.year(), m_budgetDate.month(), m_budgetDate.day());
for (int i = 0; i < 12; ++i) {
period.setStartDate(date);
period.setAmount(m_field[i]->value());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment