GnuCashew ~ GnuCash Enabled Web
GCW
SessionGnuCash.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/SessionGnucash.h"
2 
3 #ifdef NEVER
4 #ifndef __DBO_SESSIONGNUCASH_H___
5 #define __DBO_SESSIONGNUCASH_H___
6 
7 //#include <gnucash/gnc-session.h>
8 //#include <gnucash/Account.h>
9 //#include <gnucash/Transaction.h>
10 //#include <gnucash/qofsession.h>
11 
12 #include "AbstractSession.h"
13 
14 namespace GCW {
15  namespace Dbo {
16  namespace GnuCash {
17 
18 class Session;
19 class Account;
20 class Book;
21 
22 class Account
23 {
24  public:
25 
26  /*
27  ** standard constructor
28  **
29  */
30  Account(){}
31  Account( ::Account * _gncAccount, Book * _book );
32 
33  /*
34  ** copy constructor
35  **
36  */
37  Account( const Account & );
38 
39  std::string guid();
40  std::string name();
41  std::string code();
42  std::string description();
43  std::string notes();
44 
45  std::vector< Account > children();
46 
47  Book * book();
48  ::Account * gncAccount();
49 
50 #ifdef ALL_THESE_FUNCTIONS_NEED_TO_BE_PACKED_INTO_THIS_OBJECT
51 
52 // Set the account's notes.
53 void xaccAccountSetNotes (Account *account, const char *notes);
54 
55 // Set the account's type.
56 void xaccAccountSetType (Account *account, GNCAccountType)
57 
58 // Set the account's name.
59 void xaccAccountSetName (Account *account, const char *name)
60 
61 // Set the account's accounting code.
62 void xaccAccountSetCode (Account *account, const char *code)
63 
64 // Set the account's description.
65 void xaccAccountSetDescription (Account *account, const char *desc)
66 
67 // Set the account's Color.
68 void xaccAccountSetColor (Account *account, const char *color)
69 
70 // Set the account's Filter.
71 void xaccAccountSetFilter (Account *account, const char *filter)
72 
73 // Set the account's Sort Order.
74 void xaccAccountSetSortOrder (Account *account, const char *sortorder)
75 
76 // Set the account's Sort Order direction.
77 void xaccAccountSetSortReversed (Account *account, gboolean sortreversed)
78 
79 // Set the account's associated account e.g. More...
80 void xaccAccountSetAssociatedAccount (Account *acc, const char *tag, const Account *assoc_acct)
81 
82 // Set the last num field of an Account.
83 void xaccAccountSetLastNum (Account *account, const char *num)
84 
85 // Set the account's lot order policy.
86 void gnc_account_set_policy (Account *account, GNCPolicy *policy)
87 
88 // Returns the account's account type. More...
89 GNCAccountType xaccAccountGetType (const Account *account)
90 
91 // Returns true if the account is a stock, mutual fund or currency, otherwise false. More...
92 gboolean xaccAccountIsPriced (const Account *acc)
93 
94 // This function will set the starting commodity balance for this account. More...
95 void gnc_account_set_start_balance (Account *acc, const gnc_numeric start_baln)
96 
97 // This function will set the starting cleared commodity balance for this account. More...
98 void gnc_account_set_start_cleared_balance (Account *acc, const gnc_numeric start_baln)
99 
100 // This function will set the starting reconciled commodity balance for this account. More...
101 void gnc_account_set_start_reconciled_balance (Account *acc, const gnc_numeric start_baln)
102 
103 // Tell the account that the running balances may be incorrect and need to be recomputed. More...
104 void gnc_account_set_balance_dirty (Account *acc)
105 
106 // Tell the account believes that the splits may be incorrectly sorted and need to be resorted. More...
107 void gnc_account_set_sort_dirty (Account *acc)
108 
109 // Set the defer balance flag. More...
110 void gnc_account_set_defer_bal_computation (Account *acc, gboolean defer)
111 
112 // Insert the given split from an account. More...
113 gboolean gnc_account_insert_split (Account *acc, Split *s)
114 
115 // Remove the given split from an account. More...
116 gboolean gnc_account_remove_split (Account *acc, Split *s)
117 
118 // Get the account's name.
119 const char * xaccAccountGetName (const Account *account);
120 
121 // Get the account's accounting code.
122 const char * xaccAccountGetCode (const Account *account)
123 
124 // Get the account's description.
125 const char * xaccAccountGetDescription (const Account *account)
126 
127 // Get the account's color.
128 const char * xaccAccountGetColor (const Account *account)
129 
130 // Get the account's filter.
131 const char * xaccAccountGetFilter (const Account *account)
132 
133 // Get the account's Sort Order.
134 const char * xaccAccountGetSortOrder (const Account *account)
135 
136 // Get the account's Sort Order direction.
137 gboolean xaccAccountGetSortReversed (const Account *account)
138 
139 // Get the account's associated account e.g. More...
140 Account * xaccAccountGetAssociatedAccount (const Account *acc, const char *tag)
141 
142 // Get the last num field of an Account.
143 const char * xaccAccountGetLastNum (const Account *account)
144 
145 // Get the account's lot order policy.
146 GNCPolicy * gnc_account_get_policy (Account *account)
147 
148 // Get the account's flag for deferred balance computation.
149 gboolean gnc_account_get_defer_bal_computation (Account *acc)
150 
151 // The following recompute the partial balances (stored with the transaction) and the total balance, for this account.
152 void xaccAccountRecomputeBalance (Account *)
153 
154 // The xaccAccountSortSplits() routine will resort the account's splits if the sort is dirty. More...
155 void xaccAccountSortSplits (Account *acc, gboolean force)
156 
157 // The gnc_account_get_full_name routine returns the fully qualified name of the account using the given separator char. More...
158 gchar * gnc_account_get_full_name (const Account *account)
159 
160 // Retrieve the gains account used by this account for the indicated currency, creating and recording a new one if necessary. More...
161 Account * xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
162 
163 // Set a string that identifies the Finance::Quote backend that should be used to retrieve online prices. More...
164 void dxaccAccountSetPriceSrc (Account *account, const char *src)
165 
166 // Get a string that identifies the Finance::Quote backend that should be used to retrieve online prices. More...
167 const char * dxaccAccountGetPriceSrc (const Account *account)
168 
169 #endif
170 
171  private:
172 
173  Book * m_book = nullptr;
174 
175  ::Account * m_gncAccount = nullptr;
176 
177 }; // endclass Account
178 
179 class Book
180 {
181  public:
182 
183  Book( Session * _session );
184 
185  Account rootAccount();
186  Account accountByGuid( const std::string _guid );
187 
188  guint count_transactions();
189 
190  private:
191 
192  QofBook * m_book = nullptr;
193  Session * m_session = nullptr;
194 
195 }; // endclass Book
196 
197 /*!
198 ** \brief GnuCash Native Session
199 **
200 ** This session controller is designed to work through the
201 ** libgnucash back-end library.
202 **
203 */
204 class Session
206 {
207  public:
208 
209  Session() {}
210  ~Session();
211 
212  QofSession * qofSession();
213 
214  /*!
215  ** \brief Open a database
216  **
217  */
218  bool open( const std::string & _path );
219 
220  Book book();
221 
222  private:
223 
224  void closeGnuCash();
225 
226  void init();
227 
228  QofSession * m_session = nullptr;
229 
230 }; // endclass Session
231 
232 } // endnamespace GnuCash {
233 
234 
235  } // endnamespace Dbo {
236 } // endnamespace GCW {
237 
238 #endif // end#ifndef __SESSIONGNUCASH_H___
239 #endif
240 
const Wt::WFormModel::Field name
Definition: Accounts.cpp:47
const Wt::WFormModel::Field guid
Definition: Accounts.cpp:46
const Wt::WFormModel::Field description
Definition: Accounts.cpp:54
const Wt::WFormModel::Field code
Definition: Accounts.cpp:53
auto rootAccount() -> Item::Ptr
Load Root Account.
Definition: Accounts.cpp:126
const Wt::WFormModel::Field notes
Definition: Definition.h:20
Definition: App.h:17