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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/***************************************************************************
investactivities.h
----------
begin : Fri Dec 15 2006
copyright : (C) 2006 by Thomas Baumgart
email : Thomas Baumgart <[email protected]>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef INVESTACTIVITIES_H
#define INVESTACTIVITIES_H
// ----------------------------------------------------------------------------
// QT Includes
// ----------------------------------------------------------------------------
// KDE Includes
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/register.h>
#include <kmymoney/investtransactioneditor.h>
namespace Invest {
class Activity
{
public:
virtual MyMoneySplit::investTransactionTypeE type(void) const = 0;
virtual void showWidgets(void) const = 0;
virtual bool isComplete(QString& reason) const = 0;
/**
* Create a transaction @p t based on the split @p s0 and the data contained
* in the widgets. In multiselection mode, @p assetAccountSplit, @p feeSplits, @p
* interestSplits, @p security and @p currency are taken from the original
* transaction and should be used as well.
*
* @return @p true if creation was successful, @p false otherwise
*/
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency) = 0;
virtual void preloadAssetAccount(void);
virtual ~Activity() {}
protected:
Activity(InvestTransactionEditor* editor) { m_parent = editor; }
QWidget* haveWidget(const QString& name) const { return m_parent->haveWidget(name); }
bool haveAssetAccount(void) const;
bool haveFees(bool optional = false) const { return haveCategoryAndAmount("fee-account", "fee-amount", optional); }
bool haveInterest(bool optional = false) const { return haveCategoryAndAmount("interest-account", "interest-amount", optional); }
bool haveShares(void) const;
bool havePrice(void) const;
bool isMultiSelection(void) const { return m_parent->isMultiSelection(); }
bool createCategorySplits(const MyMoneyTransaction& t, KMyMoneyCategory* cat, kMyMoneyEdit* amount, MyMoneyMoney factor, QValueList<MyMoneySplit>&splits, const QValueList<MyMoneySplit>& osplits ) const;
void createAssetAccountSplit(MyMoneySplit& split, const MyMoneySplit& stockSplit) const;
MyMoneyMoney sumSplits(const MyMoneySplit& s0, const QValueList<MyMoneySplit>& feeSplits, const QValueList<MyMoneySplit>& interestSplits) const;
bool haveCategoryAndAmount(const QString& category, const QString& amount, bool optional) const;
void setLabelText(const QString& idx, const QString& txt) const;
InvestTransactionEditor::priceModeE priceMode(void) const { return m_parent->priceMode(); }
protected:
InvestTransactionEditor* m_parent;
QMap<QString, MyMoneyMoney> m_priceInfo;
};
class Buy : public Activity
{
public:
Buy(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Buy() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::BuyShares; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Sell : public Activity
{
public:
Sell(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Sell() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::SellShares; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Div : public Activity
{
public:
Div(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Div() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::Dividend; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Reinvest : public Activity
{
public:
Reinvest(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Reinvest() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::ReinvestDividend; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Add : public Activity
{
public:
Add(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Add() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::AddShares; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Remove : public Activity
{
public:
Remove(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Remove() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::RemoveShares; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
class Split : public Activity
{
public:
Split(InvestTransactionEditor* editor) : Activity(editor) {}
virtual ~Split() {}
virtual MyMoneySplit::investTransactionTypeE type(void) const { return MyMoneySplit::SplitShares; }
virtual void showWidgets(void) const;
virtual bool isComplete(QString& reason) const;
virtual bool createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QValueList<MyMoneySplit>& feeSplits, QValueList<MyMoneySplit>& m_feeSplits, QValueList<MyMoneySplit>& interestSplits, QValueList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency);
};
} // namespace Invest
#endif // INVESTACTIVITIES_H
|