GnuCash  4.8a-176-g88ecf8dd1
gmock-Split.cpp
1 #include <config.h>
2 
3 #include <Transaction.h>
4 #include <Account.h>
5 
6 #include "gmock-Split.h"
7 #include "gmock-qofbook.h"
8 
9 
11 {
12  QofInstanceClass parent_class;
13 };
14 typedef struct _MockSplitClass MockSplitClass;
15 
16 G_DEFINE_TYPE(MockSplit, gnc_mocksplit, QOF_TYPE_INSTANCE);
17 
18 static void
19 gnc_mocksplit_init (MockSplit *inst)
20 {
21  // function is unused, initialization is done in the MockSplit's C++ constructor
22 }
23 
24 static void
25 gnc_mocksplit_class_init (MockSplitClass *klass)
26 {
27  // function is unused, class functions are defined in C++ code
28 }
29 
30 
31 GType gnc_split_get_type(void)
32 {
33  return gnc_mocksplit_get_type();
34 }
35 
36 Split *
37 xaccMallocSplit (QofBook *book)
38 {
39  SCOPED_TRACE("");
40  QofMockBook* mockbook = qof_mockbook(book);
41  return mockbook ? mockbook->malloc_split() : nullptr;
42 }
43 
44 QofBook *
45 xaccSplitGetBook (const Split *split)
46 {
47  SCOPED_TRACE("");
48  auto mocksplit = gnc_mocksplit(split);
49  return mocksplit ? mocksplit->get_book() : nullptr;
50 }
51 
52 Account *
53 xaccSplitGetAccount (const Split *split)
54 {
55  SCOPED_TRACE("");
56  auto mocksplit = gnc_mocksplit(split);
57  return mocksplit ? mocksplit->get_account() : nullptr;
58 }
59 
60 void
61 xaccSplitSetAccount (Split *split, Account *acc)
62 {
63  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
64  ASSERT_TRUE(GNC_IS_ACCOUNT(acc));
65  gnc_mocksplit(split)->set_account(acc);
66 }
67 
68 gnc_numeric
69 xaccSplitGetAmount (const Split *split)
70 {
71  SCOPED_TRACE("");
72  auto mocksplit = gnc_mocksplit(split);
73  return mocksplit ? mocksplit->get_amount() : gnc_numeric_zero();
74 }
75 
76 void
77 xaccSplitSetAmount (Split *split, gnc_numeric amt)
78 {
79  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
80  gnc_mocksplit(split)->set_amount(amt);
81 }
82 
83 gnc_numeric
84 xaccSplitGetValue (const Split *split)
85 {
86  SCOPED_TRACE("");
87  auto mocksplit = gnc_mocksplit(split);
88  return mocksplit ? mocksplit->get_value() : gnc_numeric_zero();
89 }
90 
91 void
92 xaccSplitSetValue (Split *split, gnc_numeric val)
93 {
94  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
95  gnc_mocksplit(split)->set_value(val);
96 }
97 
98 const char *
99 xaccSplitGetMemo (const Split *split)
100 {
101  SCOPED_TRACE("");
102  auto mocksplit = gnc_mocksplit(split);
103  return mocksplit ? mocksplit->get_memo() : "";
104 }
105 
106 char
107 xaccSplitGetReconcile (const Split *split)
108 {
109  SCOPED_TRACE("");
110  auto mocksplit = gnc_mocksplit(split);
111  return mocksplit ? mocksplit->get_reconcile() : VREC;
112 }
113 
114 void
115 xaccSplitSetReconcile (Split *split, char recn)
116 {
117  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
118  gnc_mocksplit(split)->set_reconcile(recn);
119 }
120 
121 void
123 {
124  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
125  gnc_mocksplit(split)->set_date_reconciled_secs(secs);
126 }
127 
128 const char *
129 xaccSplitGetAction (const Split *split)
130 {
131  SCOPED_TRACE("");
132  auto mocksplit = gnc_mocksplit(split);
133  return mocksplit ? mocksplit->get_action() : "";
134 }
135 
136 Split *
137 xaccSplitGetOtherSplit (const Split *split)
138 {
139  SCOPED_TRACE("");
140  auto mocksplit = gnc_mocksplit(split);
141  return mocksplit ? mocksplit->get_other_split() : nullptr;
142 }
143 
144 Transaction *
145 xaccSplitGetParent (const Split *split)
146 {
147  SCOPED_TRACE("");
148  auto mocksplit = gnc_mocksplit(split);
149  return mocksplit ? mocksplit->get_parent() : nullptr;
150 }
151 
152 void
153 xaccSplitSetParent(Split *split, Transaction *trans)
154 {
155  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
156  ASSERT_TRUE(GNC_IS_TRANSACTION(trans));
157  gnc_mocksplit(split)->set_parent(trans);
158 }
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction&#39;s commodity.
Definition: gmock-Split.cpp:92
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
QofBook * xaccSplitGetBook(const Split *split)
Returns the book of this split, i.e.
Definition: gmock-Split.cpp:45
#define VREC
split is void
Definition: Split.h:75
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account&#39;s commodity that the split should have...
Definition: gmock-Split.cpp:77
Account handling public routines.
Split * xaccMallocSplit(QofBook *book)
Constructor.
Definition: gmock-Split.cpp:37
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64. ...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction&#39;s commodity.
Definition: gmock-Split.cpp:84
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
Definition: gmock-Split.cpp:53
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
Definition: gmock-Split.cpp:99
const char * xaccSplitGetAction(const Split *split)
Returns the action string.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93
API for Transactions and Splits (journal entries)
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account&#39;s commodity.
Definition: gmock-Split.cpp:69