1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/***************************************************************************
kmymoneyaccounttreebudget.cpp - description
-------------------
begin : Tue Feb 21 2006
copyright : (C) 2005 by Darren Gould
email : Darren Gould <darren_gould@gmx.de>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoneyaccounttreebudget.h>
KMyMoneyAccountTreeBudget::KMyMoneyAccountTreeBudget(TQWidget* parent, const char* name) :
KMyMoneyAccountTreeBase::KMyMoneyAccountTreeBase(parent, name)
{
showType();
showValue();
}
void KMyMoneyAccountTreeBudget::slotSelectObject(const TQListViewItem* i)
{
emit selectObject(MyMoneyInstitution());
emit selectObject(MyMoneyAccount());
const KMyMoneyAccountTreeBaseItem* item = dynamic_cast<const KMyMoneyAccountTreeBaseItem*>(i);
if(item) {
emit openObject(item->itemObject());
}
}
KMyMoneyAccountTreeBudgetItem::KMyMoneyAccountTreeBudgetItem(KListView *parent, const MyMoneyAccount& account, const MyMoneyBudget &budget, const MyMoneySecurity& security, const TQString& name) :
KMyMoneyAccountTreeBaseItem(parent, account, security, name),
m_budget(budget)
{
updateAccount(true);
}
KMyMoneyAccountTreeBudgetItem::KMyMoneyAccountTreeBudgetItem(KMyMoneyAccountTreeBudgetItem *parent, const MyMoneyAccount& account, const MyMoneyBudget& budget, const TQValueList<MyMoneyPrice>& price, const MyMoneySecurity& security) :
KMyMoneyAccountTreeBaseItem(parent, account, price, security),
m_budget(budget)
{
updateAccount(true);
}
KMyMoneyAccountTreeBudgetItem::~KMyMoneyAccountTreeBudgetItem()
{
}
void KMyMoneyAccountTreeBudgetItem::setBudget(const MyMoneyBudget& budget)
{
m_budget = budget;
updateAccount();
}
MyMoneyMoney KMyMoneyAccountTreeBudgetItem::balance() const
{
MyMoneyMoney result = MyMoneyMoney();
// find out if the account is budgeted
MyMoneyBudget::AccountGroup budgetAccount = m_budget.account( m_account.id() );
if ( budgetAccount.id() == m_account.id() ) {
result = budgetAccount.balance();
switch(budgetAccount.budgetLevel()) {
case MyMoneyBudget::AccountGroup::eMonthly:
result = result * 12;
break;
default:
break;
}
}
return result;
}
#include "kmymoneyaccounttreebudget.moc"
|