GnuCash c935c2f+
Loading...
Searching...
No Matches
split-register-copy-ops.c
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#include <glib.h>
24
25#include "config.h"
26#include "split-register-copy-ops.h"
27#include "gnc-ui-util.h"
28#include "SX-book.h"
29
30/* accessors */
31Split *gnc_float_split_get_split (const FloatingSplit *fs)
32{
33 g_return_val_if_fail (fs, NULL);
34 return fs->m_split;
35}
36
37Account *gnc_float_split_get_account (const FloatingSplit *fs) /* direct account pointer rather than account guid */
38{
39 g_return_val_if_fail (fs, NULL);
40 return fs->m_account;
41}
42
43Transaction *gnc_float_split_get_transaction (const FloatingSplit *fs) /* direct transaction pointer rather than transaction guid */
44{
45 g_return_val_if_fail (fs, NULL);
46 return fs->m_transaction;
47}
48
49const char *gnc_float_split_get_memo (const FloatingSplit *fs)
50{
51 g_return_val_if_fail (fs, NULL);
52 return fs->m_memo;
53}
54
55const char *gnc_float_split_get_action (const FloatingSplit *fs)
56{
57 g_return_val_if_fail (fs, NULL);
58 return fs->m_action;
59}
60
61char gnc_float_split_get_reconcile_state (const FloatingSplit *fs)
62{
63 g_return_val_if_fail (fs, '\0');
64 return fs->m_reconcile_state;
65}
66
67time64 gnc_float_split_get_reconcile_date (const FloatingSplit *fs)
68{
69 g_return_val_if_fail (fs, G_MAXINT64);
70 return fs->m_reconcile_date;
71}
72
73gnc_numeric gnc_float_split_get_amount (const FloatingSplit *fs)
74{
75 g_return_val_if_fail (fs, gnc_numeric_zero());
76 return fs->m_amount;
77}
78
79gnc_numeric gnc_float_split_get_value (const FloatingSplit *fs)
80{
81 g_return_val_if_fail (fs, gnc_numeric_zero());
82 return fs->m_value;
83}
84
85gboolean gnc_float_split_get_stock_split (const FloatingSplit *fs)
86{
87 g_return_val_if_fail (fs, FALSE);
88 return fs->m_stock_split;
89}
90
91
92/* modifiers */
93void gnc_float_split_set_split(FloatingSplit *fs, Split *split)
94{
95 g_return_if_fail (fs);
96 fs->m_split = split;
97}
98
99void gnc_float_split_set_account (FloatingSplit *fs, Account *account) /* direct account pointer rather than account guid */
100{
101 g_return_if_fail (fs);
102 fs->m_account = account;
103}
104
105void gnc_float_split_set_transaction (FloatingSplit *fs, Transaction *transaction) /* direct transaction pointer rather than transaction guid */
106{
107 g_return_if_fail (fs);
108 fs->m_transaction = transaction;
109}
110
111void gnc_float_split_set_memo (FloatingSplit *fs, const char *memo)
112{
113 g_return_if_fail (fs);
114 CACHE_REPLACE (fs->m_memo, memo);
115}
116
117void gnc_float_split_set_action (FloatingSplit *fs, const char *action)
118{
119 g_return_if_fail (fs);
120 CACHE_REPLACE (fs->m_action, action);
121}
122
123void gnc_float_split_set_reconcile_state (FloatingSplit *fs, char reconcile_state)
124{
125 g_return_if_fail (fs);
126 fs->m_reconcile_state = reconcile_state;
127}
128
129void gnc_float_split_set_reconcile_date (FloatingSplit *fs, time64 reconcile_date)
130{
131 g_return_if_fail (fs);
132 fs->m_reconcile_date = reconcile_date;
133}
134
135void gnc_float_split_set_amount (FloatingSplit *fs, const gnc_numeric amount)
136{
137 g_return_if_fail (fs);
138 fs->m_amount = amount;
139}
140
141void gnc_float_split_set_value (FloatingSplit *fs, const gnc_numeric value)
142{
143 g_return_if_fail (fs);
144 fs->m_value = value;
145}
146
147void gnc_float_split_set_stock_split (FloatingSplit *fs, gboolean stock_split)
148{
149 g_return_if_fail (fs);
150 fs->m_stock_split = stock_split;
151}
152
153static void
154gnc_float_template_sx_data_free (FloatingTemplateSxData *ftsd)
155{
156 g_return_if_fail (ftsd);
157
158 guid_free (ftsd->m_account_guid);
159 g_free (ftsd->m_credit_numeric);
160 g_free (ftsd->m_debit_numeric);
161
162 g_free (ftsd);
163}
164
166gnc_split_to_float_template_sx_data (Split *split)
167{
169 GncGUID* guid = NULL;
170 const gchar *cf, *df, *shares;
171 gnc_numeric *cn, *dn;
172
173 g_return_val_if_fail (split, NULL);
174
175 ftsd = g_new0 (FloatingTemplateSxData, 1);
176
177 qof_instance_get (QOF_INSTANCE (split), "sx-account", &guid, NULL);
178 ftsd->m_account_guid = guid;
179
180 qof_instance_get (QOF_INSTANCE (split), "sx-credit-formula", &cf, NULL);
181 ftsd->m_credit_formula = cf;
182
183 qof_instance_get (QOF_INSTANCE (split), "sx-credit-numeric", &cn, NULL);
184 ftsd->m_credit_numeric = cn;
185
186 qof_instance_get (QOF_INSTANCE (split), "sx-debit-formula", &df, NULL);
187 ftsd->m_debit_formula = df;
188
189 qof_instance_get (QOF_INSTANCE (split), "sx-debit-numeric", &dn, NULL);
190 ftsd->m_debit_numeric = dn;
191
192 qof_instance_get (QOF_INSTANCE (split), "sx-shares", &shares, NULL);
193 ftsd->m_shares = shares;
194
195 return ftsd;
196}
197
198static void
199gnc_split_set_sx_settings (Split *split, const char *cf, gnc_numeric cn,
200 const char *df, gnc_numeric dn)
201{
202 qof_instance_set (QOF_INSTANCE (split), "sx-credit-formula", cf, NULL);
203 qof_instance_set (QOF_INSTANCE (split), "sx-debit-formula", df, NULL);
204 qof_instance_set (QOF_INSTANCE (split), "sx-credit-numeric", &cn, NULL);
205 qof_instance_set (QOF_INSTANCE (split), "sx-debit-numeric", &dn, NULL);
206}
207
208static void
209gnc_float_template_sx_data_to_split (const FloatingSplit *fs, Split *split)
210{
211 g_return_if_fail (fs);
212 g_return_if_fail (split);
213
214 FloatingTemplateSxData *ftsd = fs->m_template_sx_data;
215
216 const gchar *cf = "", *df = "";
217 gnc_numeric cn = gnc_numeric_zero(), dn = gnc_numeric_zero();
218
219 if (ftsd->m_account_guid)
220 qof_instance_set (QOF_INSTANCE (split), "sx-account", ftsd->m_account_guid, NULL);
221
222 if (ftsd->m_credit_formula)
223 cf = ftsd->m_credit_formula;
224
225 if (ftsd->m_credit_numeric && !gnc_numeric_zero_p (*ftsd->m_credit_numeric))
226 cn = *ftsd->m_credit_numeric;
227
228 if (ftsd->m_debit_formula)
229 df = ftsd->m_debit_formula;
230
231 if (ftsd->m_debit_numeric && !gnc_numeric_zero_p (*ftsd->m_debit_numeric))
232 dn = *ftsd->m_debit_numeric;
233
234 gnc_split_set_sx_settings (split, cf, cn, df, dn);
235
236 if (ftsd->m_shares)
237 qof_instance_set (QOF_INSTANCE (split), "sx-shares", ftsd->m_shares, NULL);
238}
239
240/* This function takes a split and returns a representation
241 of it as a floating_split structure. Assumes the transaction is open
242 for editing.
243*/
244FloatingSplit *gnc_split_to_float_split (Split *split, gboolean is_template)
245{
246 FloatingSplit *fs;
247
248 g_return_val_if_fail (split, NULL);
249
250 fs = g_new0 (FloatingSplit, 1);
251 fs->m_split = split;
252 fs->m_account = xaccSplitGetAccount (split);
253 fs->m_transaction = xaccSplitGetParent (split);
254 fs->m_memo = CACHE_INSERT (xaccSplitGetMemo (split));
255 fs->m_action = CACHE_INSERT (xaccSplitGetAction (split));
256 fs->m_reconcile_state = xaccSplitGetReconcile (split);
257 fs->m_reconcile_date = xaccSplitGetDateReconciled (split);
258 fs->m_amount = xaccSplitGetAmount (split);
259 fs->m_value = xaccSplitGetValue (split);
260 fs->m_stock_split = xaccSplitIsStockSplit (split);
261
262 if (is_template)
263 fs->m_template_sx_data = gnc_split_to_float_template_sx_data (split);
264 else
265 fs->m_template_sx_data = NULL;
266
267 return fs;
268}
269
270static void
271register_fs_to_template_split (const FloatingSplit *fs, Split *split)
272{
273 const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (fs->m_account));
274 qof_instance_set (QOF_INSTANCE(split), "sx-account", guid, NULL);
275
276 char string[32];
277 gnc_commodity *acount_commodity = xaccAccountGetCommodity (fs->m_account);
278 GNCPrintAmountInfo print_info = gnc_commodity_print_info (acount_commodity, FALSE);
279 gnc_numeric zero = gnc_numeric_zero ();
280 gnc_numeric abs_diff = gnc_numeric_abs (fs->m_amount);
281 xaccSPrintAmount (string, abs_diff, print_info);
282
283 if (gnc_numeric_negative_p (fs->m_amount))
284 gnc_split_set_sx_settings (split, string, abs_diff, "", zero);
285
286 if (!gnc_numeric_negative_p (fs->m_amount))
287 gnc_split_set_sx_settings (split, "", zero, string, abs_diff);
288}
289
290static Account*
291template_fs_to_register_split (const FloatingSplit *fs, Split *split, Account *split_account)
292{
293 FloatingTemplateSxData *ftsd = fs->m_template_sx_data;
294
295 if (ftsd->m_credit_numeric && !gnc_numeric_zero_p (*ftsd->m_credit_numeric))
296 {
297 xaccSplitSetAmount (split, gnc_numeric_neg(*ftsd->m_credit_numeric));
298 xaccSplitSetValue (split, gnc_numeric_neg(*ftsd->m_credit_numeric));
299 }
300
301 if (ftsd->m_debit_numeric && !gnc_numeric_zero_p (*ftsd->m_debit_numeric))
302 {
303 xaccSplitSetAmount (split, *ftsd->m_debit_numeric);
304 xaccSplitSetValue (split, *ftsd->m_debit_numeric);
305 }
306
307 if (ftsd->m_account_guid)
308 split_account = xaccAccountLookup (ftsd->m_account_guid,
309 qof_instance_get_book (QOF_INSTANCE(split)));
310
311 return split_account;
312}
313
314/* Copy a temporary split representation onto a real split.
315 If possible, insert the split into the account of the
316 split representation. Not all values are copied. The reconcile
317 status and date are not copied. The split's guid is,
318 of course, unchanged.
319*/
320void
321gnc_float_split_to_split (const FloatingSplit *fs, Split *split, Account *template_account)
322{
323 g_return_if_fail (split);
324
325 Account *split_account = fs->m_account;
326
327 if (fs->m_memo)
328 xaccSplitSetMemo (split, fs->m_memo);
329 if (fs->m_action)
330 xaccSplitSetAction (split, fs->m_action);
331
332 if (template_account && fs->m_template_sx_data) // From Sched to Sched
333 {
334 split_account = template_account;
335 gnc_float_template_sx_data_to_split (fs, split);
336 }
337 else if (template_account && !fs->m_template_sx_data) // From Reg to Sched
338 {
339 split_account = template_account;
340 register_fs_to_template_split (fs, split);
341 }
342 else if (!template_account && fs->m_template_sx_data) // From Sched to Reg
343 {
344 split_account = template_fs_to_register_split (fs, split, split_account);
345 }
346 else // From Reg to Reg
347 {
348 xaccSplitSetAmount (split, fs->m_amount);
349 xaccSplitSetValue (split, fs->m_value);
350 if (fs->m_stock_split)
352 }
353
354 if (split_account)
355 {
356 xaccAccountBeginEdit (split_account);
357 xaccSplitSetAccount (split, split_account);
358 xaccAccountCommitEdit (split_account);
359 }
360}
361
362void gnc_float_split_free (FloatingSplit *fs)
363{
364 g_return_if_fail (fs);
365
366 CACHE_REMOVE (fs->m_memo);
367 CACHE_REMOVE (fs->m_action);
368
369 if (fs->m_template_sx_data)
370 gnc_float_template_sx_data_free (fs->m_template_sx_data);
371
372 g_free (fs);
373}
374
375/* accessors */
376Transaction *gnc_float_txn_get_txn (const FloatingTxn *ft)
377{
378 g_return_val_if_fail (ft, NULL);
379 return ft->m_txn;
380}
381
382gnc_commodity *gnc_float_txn_get_currency (const FloatingTxn *ft)
383{
384 g_return_val_if_fail (ft, NULL);
385 return ft->m_currency;
386}
387
388time64 gnc_float_txn_get_date_entered (const FloatingTxn *ft)
389{
390 g_return_val_if_fail (ft, G_MAXINT64);
391 return ft->m_date_entered;
392}
393
394time64 gnc_float_txn_get_date_posted (const FloatingTxn *ft)
395{
396 g_return_val_if_fail (ft, G_MAXINT64);
397 return ft->m_date_posted;
398}
399
400const char *gnc_float_txn_get_num (const FloatingTxn *ft)
401{
402 g_return_val_if_fail (ft, NULL);
403 return ft->m_num;
404}
405
406const char *gnc_float_txn_get_description (const FloatingTxn *ft)
407{
408 g_return_val_if_fail (ft, NULL);
409 return ft->m_description;
410}
411
412const char *gnc_float_txn_get_notes (const FloatingTxn *ft)
413{
414 g_return_val_if_fail (ft, NULL);
415 return ft->m_notes;
416}
417
418const char *gnc_float_txn_get_doclink (const FloatingTxn *ft)
419{
420 g_return_val_if_fail (ft, NULL);
421 return ft->m_doclink;
422}
423
424SplitList *gnc_float_txn_get_splits (const FloatingTxn *ft)
425{
426 g_return_val_if_fail (ft, NULL);
427 return ft->m_splits;
428}
429
430FloatingSplit *gnc_float_txn_get_float_split (const FloatingTxn *ft, guint index)
431{
432 g_return_val_if_fail (ft, NULL);
433 g_return_val_if_fail (ft->m_splits, NULL);
434 g_return_val_if_fail (index < g_list_length (ft->m_splits) , NULL);
435 return g_list_nth_data (ft->m_splits, index);
436}
437
438FloatingSplit *gnc_float_txn_get_other_float_split (const FloatingTxn *ft, FloatingSplit *fs)
439{
440 guint other = 0;
441
442 g_return_val_if_fail (ft, NULL);
443 g_return_val_if_fail (ft->m_splits, NULL);
444 g_return_val_if_fail (g_list_length (ft->m_splits) == 2 , NULL);
445
446 if (g_list_nth_data (ft->m_splits, 0) == fs)
447 other = 1;
448
449 return g_list_nth_data (ft->m_splits, other);
450}
451
452/* modifiers */
453void gnc_float_txn_set_txn (FloatingTxn *ft, Transaction *txn)
454{
455 g_return_if_fail (ft);
456 ft->m_txn = txn;
457}
458
459void gnc_float_txn_set_currency (FloatingTxn *ft, gnc_commodity *currency)
460{
461 g_return_if_fail (ft);
462 ft->m_currency = currency;
463}
464
465void gnc_float_txn_set_date_entered (FloatingTxn *ft, time64 date_entered)
466{
467 g_return_if_fail (ft);
468 ft->m_date_entered = date_entered;
469}
470
471void gnc_float_txn_set_date_posted (FloatingTxn *ft, time64 date_posted)
472{
473 g_return_if_fail (ft);
474 ft->m_date_posted = date_posted;
475}
476
477void gnc_float_txn_set_num (FloatingTxn *ft, const char *num)
478{
479 g_return_if_fail (ft);
480 CACHE_REPLACE (ft->m_num, num);
481}
482
483void gnc_float_txn_set_description (FloatingTxn *ft, const char *description)
484{
485 g_return_if_fail (ft);
486 CACHE_REPLACE (ft->m_description, description);
487}
488
489void gnc_float_txn_set_notes (FloatingTxn *ft, const char *notes)
490{
491 g_return_if_fail (ft);
492 CACHE_REPLACE (ft->m_notes, notes);
493}
494
495void gnc_float_txn_set_doclink (FloatingTxn *ft, const char *doclink)
496{
497 g_return_if_fail (ft);
498 CACHE_REPLACE (ft->m_doclink, doclink);
499}
500
501void gnc_float_txn_set_splits (FloatingTxn *ft, SplitList *splits)
502{
503 g_return_if_fail (ft);
504 ft->m_splits = splits;
505}
506
507void gnc_float_txn_append_float_split (FloatingTxn *ft, FloatingSplit *fs)
508{
509 g_return_if_fail (ft);
510 g_return_if_fail (fs);
511 ft->m_splits = g_list_append (ft->m_splits, fs);
512}
513
514/* This function takes a C transaction and returns
515 a representation of it as a floating_txn. */
516FloatingTxn *gnc_txn_to_float_txn (Transaction *txn, gboolean use_cut_semantics, gboolean is_template)
517{
518 GList *iter;
519
520 FloatingTxn *ft = g_new0 (FloatingTxn, 1);
521
522 ft->m_txn = txn;
523 ft->m_currency = xaccTransGetCurrency (txn);
524 ft->m_date_entered = xaccTransGetDateEntered (txn);
525 if (use_cut_semantics)
526 {
527 ft->m_date_posted = xaccTransGetDate (txn);
528 ft->m_num = CACHE_INSERT (xaccTransGetNum (txn));
529 }
530 ft->m_description = CACHE_INSERT (xaccTransGetDescription (txn));
531 ft->m_notes = CACHE_INSERT (xaccTransGetNotes (txn));
532 ft->m_doclink = CACHE_INSERT (xaccTransGetDocLink (txn));
533
534 for (iter = xaccTransGetSplitList (txn); iter ; iter = iter->next)
535 {
536 Split *split = iter->data;
537 if (split && xaccTransStillHasSplit (txn, split))
538 {
539 FloatingSplit *fs = gnc_split_to_float_split (split, is_template);
540 ft->m_splits = g_list_prepend (ft->m_splits, fs);
541 }
542 }
543 ft->m_splits = g_list_reverse (ft->m_splits);
544
545 return ft;
546}
547
548gboolean
549gnc_float_txn_has_template (const FloatingTxn *ft)
550{
551 GList *iter;
552 gboolean ftsd_exists = FALSE;
553
554 g_return_val_if_fail (ft, FALSE);
555
556 for (iter = ft->m_splits; iter; iter = iter->next)
557 {
558 FloatingSplit *fs = iter->data;
559 if (!fs)
560 continue;
561 if (fs->m_template_sx_data)
562 ftsd_exists = TRUE;
563 }
564 return ftsd_exists;
565}
566
567void
568gnc_float_txn_to_template_txn (const FloatingTxn *ft, Transaction *txn, Account *template_account, gboolean do_commit)
569{
570 GList *iter;
571
572 g_return_if_fail (ft);
573 g_return_if_fail (txn);
574
575 if (!xaccTransIsOpen (txn))
576 xaccTransBeginEdit (txn);
577
578 if (ft->m_currency)
579 xaccTransSetCurrency (txn, ft->m_currency);
580 if (ft->m_description)
581 xaccTransSetDescription (txn, ft->m_description);
582 if (ft->m_num)
583 xaccTransSetNum (txn, ft->m_num);
584 if (ft->m_notes)
585 xaccTransSetNotes (txn, ft->m_notes);
586 if (ft->m_doclink)
587 xaccTransSetDocLink (txn, ft->m_doclink);
588 if (ft->m_date_posted)
589 xaccTransSetDatePostedSecs (txn, ft->m_date_posted);
590
591 /* strip off the old splits */
593
594 /* and put on the new ones! Please note they go in the *same*
595 order as in the original transaction. This is important. */
596 for (iter = ft->m_splits; iter; iter = iter->next)
597 {
598 FloatingSplit *fs = iter->data;
599 if (!fs)
600 continue;
601
602 Split *split = xaccMallocSplit (xaccTransGetBook (txn));
603
604 gnc_float_split_to_split (fs, split, template_account);
605
606 xaccSplitSetParent (split, txn);
607 }
608
609 /* close the transaction */
610 if (do_commit)
612}
613
614
615void gnc_float_txn_to_txn (const FloatingTxn *ft, Transaction *txn, gboolean do_commit)
616{
617 gnc_float_txn_to_txn_swap_accounts (ft, txn, NULL, NULL, do_commit);
618}
619
620/* Copy a temporary representation of a transaction onto a real transaction.
621 I f they exist the two account*s (acct1 and acct2) are used to swap accounts
622 when when creating splits. */
623void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn,
624 Account *acct1, Account *acct2,
625 gboolean do_commit)
626{
627 GList *iter;
628
629 g_return_if_fail (ft);
630 g_return_if_fail (txn);
631
632 if (!xaccTransIsOpen (txn))
633 xaccTransBeginEdit (txn);
634
635 if (ft->m_currency)
636 xaccTransSetCurrency (txn, ft->m_currency);
637 if (ft->m_description)
638 xaccTransSetDescription (txn, ft->m_description);
639 if (ft->m_num)
640 xaccTransSetNum (txn, ft->m_num);
641 if (ft->m_notes)
642 xaccTransSetNotes (txn, ft->m_notes);
643 if (ft->m_doclink)
644 xaccTransSetDocLink (txn, ft->m_doclink);
645 if (ft->m_date_posted)
646 xaccTransSetDatePostedSecs (txn, ft->m_date_posted);
647
648 /* strip off the old splits */
650
651 /* and put on the new ones! Please note they go in the *same*
652 order as in the original transaction. This is important. */
653 for (iter = ft->m_splits; iter; iter = iter->next)
654 {
655 Account *old_acc, *new_acc;
656 Split *split;
657 FloatingSplit *fs = iter->data;
658 if (!fs)
659 continue;
660
661 split = xaccMallocSplit (xaccTransGetBook (txn));
662
663 old_acc = fs->m_account;
664 if (fs->m_account == acct1)
665 new_acc = acct2;
666 else if (fs->m_account == acct2)
667 new_acc = acct1;
668 else
669 new_acc = fs->m_account;
670
671 fs->m_account = new_acc;
672
673 gnc_float_split_to_split (fs, split, NULL);
674 fs->m_account = old_acc;
675 xaccSplitSetParent (split, txn);
676 }
677
678 /* close the transaction */
679 if (do_commit)
681}
682
683void gnc_float_txn_free (FloatingTxn *ft)
684{
685 g_return_if_fail (ft);
686
687 CACHE_REMOVE (ft->m_num);
688 CACHE_REMOVE (ft->m_description);
689 CACHE_REMOVE (ft->m_notes);
690 CACHE_REMOVE (ft->m_doclink);
691 g_list_free_full (ft->m_splits, (GDestroyNotify)gnc_float_split_free);
692 g_free (ft);
693}
Anchor Scheduled Transaction info in a book.
utility functions for the GnuCash UI
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition Account.cpp:1516
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition Account.cpp:1475
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3408
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id,...
Definition Account.cpp:2050
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
Returns the valuation commodity of this transaction.
void xaccTransSetNum(Transaction *trans, const char *xnum)
Sets the transaction Number (or ID) field; rather than use this function directly,...
const char * xaccTransGetDocLink(const Transaction *trans)
Gets the transaction Document Link.
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
void xaccTransClearSplits(Transaction *trans)
Remove all splits from the transaction.
gboolean xaccTransIsOpen(const Transaction *trans)
The xaccTransIsOpen() method returns TRUE if the transaction is open for editing.
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
time64 xaccTransGetDateEntered(const Transaction *trans)
Retrieve the date of when the transaction was entered.
void xaccTransSetDatePostedSecs(Transaction *trans, time64 secs)
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction,...
void xaccTransSetDocLink(Transaction *trans, const char *doclink)
Sets the transaction Document Link.
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
#define xaccTransGetBook(X)
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
const char * xaccTransGetNum(const Transaction *trans)
Gets the transaction Number (or ID) field; rather than use this function directly,...
GList SplitList
GList of Split.
Definition gnc-engine.h:207
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
void xaccTransSetNotes(Transaction *trans, const char *notes)
Sets the transaction Notes.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
Split * xaccMallocSplit(QofBook *book)
Constructor.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
const char * xaccSplitGetAction(const Split *split)
Returns the action string.
time64 xaccSplitGetDateReconciled(const Split *split)
Retrieve the date when the Split was reconciled.
Definition Split.cpp:1859
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
void xaccSplitSetAction(Split *split, const char *actn)
The Action is an arbitrary user-assigned string.
Definition Split.cpp:1786
gboolean xaccSplitIsStockSplit(Split *s)
Returns true if the split is of type stock split.
Definition Split.cpp:2078
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
void xaccSplitMakeStockSplit(Split *s)
Mark a split to be of type stock split - after this, you shouldn't modify the value anymore,...
Definition Split.cpp:2063
STRUCTS.
The type used to store guids in C.
Definition guid.h:75