GnuCash  5.6-150-g038405b370+
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 void
107 xaccSplitSetMemo (Split *split, const char *memo)
108 {
109  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
110  gnc_mocksplit(split)->set_memo(memo);
111 }
112 
113 char
114 xaccSplitGetReconcile (const Split *split)
115 {
116  SCOPED_TRACE("");
117  auto mocksplit = gnc_mocksplit(split);
118  return mocksplit ? mocksplit->get_reconcile() : VREC;
119 }
120 
121 void
122 xaccSplitSetReconcile (Split *split, char recn)
123 {
124  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
125  gnc_mocksplit(split)->set_reconcile(recn);
126 }
127 
128 void
130 {
131  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
132  gnc_mocksplit(split)->set_date_reconciled_secs(secs);
133 }
134 
135 const char *
136 xaccSplitGetAction (const Split *split)
137 {
138  SCOPED_TRACE("");
139  auto mocksplit = gnc_mocksplit(split);
140  return mocksplit ? mocksplit->get_action() : "";
141 }
142 
143 Split *
144 xaccSplitGetOtherSplit (const Split *split)
145 {
146  SCOPED_TRACE("");
147  auto mocksplit = gnc_mocksplit(split);
148  return mocksplit ? mocksplit->get_other_split() : nullptr;
149 }
150 
151 Transaction *
152 xaccSplitGetParent (const Split *split)
153 {
154  SCOPED_TRACE("");
155  auto mocksplit = gnc_mocksplit(split);
156  return mocksplit ? mocksplit->get_parent() : nullptr;
157 }
158 
159 void
160 xaccSplitSetParent(Split *split, Transaction *trans)
161 {
162  ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
163  ASSERT_TRUE(GNC_IS_TRANSACTION(trans));
164  gnc_mocksplit(split)->set_parent(trans);
165 }
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
STRUCTS.
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:77
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.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
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
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
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