GnuCash  5.6-150-g038405b370+
split-register-copy-ops.h
1 /********************************************************************\
2  * split-register-copy-ops.c -- copy/paste semantics for *
3  * transactions and splits *
4  * Port to C of engine-interface *
5  * originally written by Dave Peticolas <dave@krondo.com> *
6  * © 2019 Geert Janssens
7  * *
8  * This program is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License as *
10  * published by the Free Software Foundation; either version 2 of *
11  * the License, or (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License*
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * \********************************************************************/
22 
23 #ifndef SPLIT_REGISTER_COPY_OPS_H
24 #define SPLIT_REGISTER_COPY_OPS_H
25 
26 #include <glib.h>
27 
28 #include "gnc-engine.h" /* for typedefs */
29 #include "qof.h"
30 
31 #include "guid.h"
32 #include "Split.h"
33 #include "Account.h"
34 #include "Transaction.h"
35 
36 typedef struct
37 {
38  GncGUID *m_account_guid;
39  const char *m_credit_formula;
40  const char *m_debit_formula;
41  gnc_numeric *m_credit_numeric;
42  gnc_numeric *m_debit_numeric;
43  const char *m_shares;
44 
46 
47 typedef struct
48 {
49  Split *m_split;
50  Account *m_account;
51  Transaction *m_transaction;
52  const char *m_memo;
53  const char *m_action;
54  time64 m_reconcile_date;
55  char m_reconcile_state;
56  gnc_numeric m_value;
57  gnc_numeric m_amount;
58 
59  FloatingTemplateSxData *m_template_sx_data;
60 
62 
63 typedef struct
64 {
65  Transaction *m_txn;
66  gnc_commodity *m_currency;
67  time64 m_date_entered;
68  time64 m_date_posted;
69  const char *m_num;
70  const char *m_description;
71  const char *m_notes;
72  const char *m_doclink;
73  SplitList *m_splits;
74 } FloatingTxn;
75 
76 /* accessors */
77 Split *gnc_float_split_get_split(const FloatingSplit* fs);
78 Account *gnc_float_split_get_account (const FloatingSplit *fs); /* direct account pointer rather than account guid */
79 Transaction *gnc_float_split_get_transaction (const FloatingSplit *fs); /* direct transaction pointer rather than transaction guid */
80 const char *gnc_float_split_get_memo (const FloatingSplit *fs);
81 const char *gnc_float_split_get_action (const FloatingSplit *fs);
82 char gnc_float_split_get_reconcile_state (const FloatingSplit *fs);
83 time64 gnc_float_split_get_reconcile_date (const FloatingSplit *fs);
84 gnc_numeric gnc_float_split_get_amount (const FloatingSplit *fs);
85 gnc_numeric gnc_float_split_get_value (const FloatingSplit *fs);
86 
87 /* modifiers */
88 void gnc_float_split_set_split (FloatingSplit *fs, Split *split);
89 void gnc_float_split_set_account (FloatingSplit *fs, Account *account); /* direct account pointer rather than account guid */
90 void gnc_float_split_set_transaction (FloatingSplit *fs, Transaction *transaction); /* direct transaction pointer rather than transaction guid */
91 void gnc_float_split_set_memo (FloatingSplit *fs, const char *memo);
92 void gnc_float_split_set_action (FloatingSplit *fs, const char *action);
93 void gnc_float_split_set_reconcile_state (FloatingSplit *fs, char reconcile_state);
94 void gnc_float_split_set_reconcile_date (FloatingSplit *fs, time64 reconcile_date);
95 void gnc_float_split_set_amount (FloatingSplit *fs, gnc_numeric amount);
96 void gnc_float_split_set_value (FloatingSplit *fs, gnc_numeric value);
97 
98 FloatingSplit *gnc_split_to_float_split (Split *split, gboolean is_template);
99 void gnc_float_split_to_split (const FloatingSplit *fs, Split *split, Account *template_account);
100 
101 void gnc_float_split_free (FloatingSplit *fs);
102 
103 /* accessors */
104 Transaction *gnc_float_txn_get_txn (const FloatingTxn *ft);
105 gnc_commodity *gnc_float_txn_get_currency (const FloatingTxn *ft);
106 time64 gnc_float_txn_get_date_entered (const FloatingTxn *ft);
107 time64 gnc_float_txn_get_date_posted (const FloatingTxn *ft);
108 const char *gnc_float_txn_get_num (const FloatingTxn *ft);
109 const char *gnc_float_txn_get_description (const FloatingTxn *ft);
110 const char *gnc_float_txn_get_notes (const FloatingTxn *ft);
111 const char *gnc_float_txn_get_doclink (const FloatingTxn *ft);
112 SplitList *gnc_float_txn_get_splits (const FloatingTxn *ft);
113 
114 FloatingSplit *gnc_float_txn_get_float_split (const FloatingTxn *ft, guint index);
115 FloatingSplit *gnc_float_txn_get_other_float_split (const FloatingTxn *ft, FloatingSplit *fs);
116 
117 /* modifiers */
118 void gnc_float_txn_set_txn (FloatingTxn *ft, Transaction *txn);
119 void gnc_float_txn_set_currency (FloatingTxn *ft, gnc_commodity *currency);
120 void gnc_float_txn_set_date_entered (FloatingTxn *ft, time64 date_entered);
121 void gnc_float_txn_set_date_posted (FloatingTxn *ft, time64 date_posted);
122 void gnc_float_txn_set_num (FloatingTxn *ft, const char *num);
123 void gnc_float_txn_set_description (FloatingTxn *ft, const char *description);
124 void gnc_float_txn_set_notes (FloatingTxn *ft, const char *notes);
125 void gnc_float_txn_set_doclink (FloatingTxn *ft, const char *doclink);
126 void gnc_float_txn_set_splits (FloatingTxn *ft, SplitList *splits);
127 
128 void gnc_float_txn_append_float_split (FloatingTxn *ft, FloatingSplit *fs);
129 
130 gboolean gnc_float_txn_has_template (const FloatingTxn *ft);
131 
132 FloatingTxn *gnc_txn_to_float_txn (Transaction *txn, gboolean use_cut_semantics, gboolean is_template);
133 
134 void gnc_float_txn_to_template_txn (const FloatingTxn *ft, Transaction *txn,
135  Account *template_account, gboolean do_commit);
136 
137 void gnc_float_txn_to_txn (const FloatingTxn *ft, Transaction *txn, gboolean do_commit);
138 void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn,
139  Account *acct1, Account *acct2,
140  gboolean do_commit);
141 
142 void gnc_float_txn_free (FloatingTxn *ft);
143 
144 #endif
STRUCTS.
globally unique ID User API
API for Transactions and Splits (journal entries)
GList SplitList
GList of Split.
Definition: gnc-engine.h:207
Account handling public routines.
All type declarations for the whole Gnucash engine.
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)
The type used to store guids in C.
Definition: guid.h:75