36 #include <glib/gi18n.h> 39 #ifdef HAVE_SYS_TIME_H 40 # include <sys/time.h> 53 #include "TransactionP.hpp" 60 #include "qofinstance-p.h" 62 const char *void_former_amt_str =
"void-former-amount";
63 const char *void_former_val_str =
"void-former-value";
66 static QofLogModule log_module = GNC_MOD_ENGINE;
69 #define GNC_SX_ID "sched-xaction" 70 #define GNC_SX_ACCOUNT "account" 71 #define GNC_SX_CREDIT_FORMULA "credit-formula" 72 #define GNC_SX_DEBIT_FORMULA "debit-formula" 73 #define GNC_SX_CREDIT_NUMERIC "credit-numeric" 74 #define GNC_SX_DEBIT_NUMERIC "debit-numeric" 75 #define GNC_SX_SHARES "shares" 88 PROP_SX_CREDIT_FORMULA,
89 PROP_SX_CREDIT_NUMERIC,
90 PROP_SX_DEBIT_FORMULA,
91 PROP_SX_DEBIT_NUMERIC,
102 static const char * split_type_normal =
"normal";
103 static const char * split_type_stock_split =
"stock-split";
104 static const char * split_online_id =
"online_id";
107 G_DEFINE_TYPE(Split, gnc_split, QOF_TYPE_INSTANCE)
110 gnc_split_init(Split* split)
113 split->acc =
nullptr;
114 split->orig_acc =
nullptr;
115 split->parent =
nullptr;
116 split->lot =
nullptr;
118 split->action = CACHE_INSERT(
"");
119 split->memo = CACHE_INSERT(
"");
120 split->reconciled =
NREC;
121 split->amount = gnc_numeric_zero();
122 split->value = gnc_numeric_zero();
124 split->date_reconciled = 0;
126 split->balance = gnc_numeric_zero();
127 split->cleared_balance = gnc_numeric_zero();
128 split->reconciled_balance = gnc_numeric_zero();
129 split->noclosing_balance = gnc_numeric_zero();
131 split->adjusted_amount = gnc_numeric_zero();
132 split->split_type =
nullptr;
134 split->gains = GAINS_STATUS_UNKNOWN;
135 split->gains_split =
nullptr;
139 gnc_split_dispose(GObject *splitp)
141 G_OBJECT_CLASS(gnc_split_parent_class)->dispose(splitp);
145 gnc_split_finalize(GObject* splitp)
147 G_OBJECT_CLASS(gnc_split_parent_class)->finalize(splitp);
156 gnc_split_get_property(GObject *
object,
164 g_return_if_fail(GNC_IS_SPLIT(
object));
166 split = GNC_SPLIT(
object);
170 g_value_set_string(value, split->action);
173 g_value_set_string(value, split->memo);
176 g_value_set_boxed(value, &split->value);
179 g_value_set_boxed(value, &split->amount);
181 case PROP_RECONCILE_DATE:
182 t.t = split->date_reconciled;
183 g_value_set_boxed(value, &t);
186 g_value_take_object(value, split->parent);
189 g_value_take_object(value, split->acc);
192 g_value_take_object(value, split->lot);
194 case PROP_SX_CREDIT_FORMULA:
197 case PROP_SX_CREDIT_NUMERIC:
200 case PROP_SX_DEBIT_FORMULA:
203 case PROP_SX_DEBIT_NUMERIC:
206 case PROP_SX_ACCOUNT:
212 case PROP_ONLINE_ACCOUNT:
215 case PROP_GAINS_SPLIT:
218 case PROP_GAINS_SOURCE:
222 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
228 gnc_split_set_property(GObject *
object,
236 g_return_if_fail(GNC_IS_SPLIT(
object));
238 split = GNC_SPLIT(
object);
239 if (prop_id < PROP_RUNTIME_0 && split->parent !=
nullptr)
240 g_assert (qof_instance_get_editlevel(split->parent));
251 number =
static_cast<gnc_numeric*
>(g_value_get_boxed(value));
255 number =
static_cast<gnc_numeric*
>(g_value_get_boxed(value));
258 case PROP_RECONCILE_DATE:
259 t =
static_cast<Time64*
>(g_value_get_boxed(value));
263 xaccSplitSetParent(split, GNC_TRANSACTION(g_value_get_object(value)));
266 xaccSplitSetAccount(split, GNC_ACCOUNT(g_value_get_object(value)));
271 case PROP_SX_CREDIT_FORMULA:
274 case PROP_SX_CREDIT_NUMERIC:
277 case PROP_SX_DEBIT_FORMULA:
280 case PROP_SX_DEBIT_NUMERIC:
283 case PROP_SX_ACCOUNT:
289 case PROP_ONLINE_ACCOUNT:
292 case PROP_GAINS_SPLIT:
295 case PROP_GAINS_SOURCE:
299 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
305 gnc_split_class_init(SplitClass* klass)
307 GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
309 gobject_class->dispose = gnc_split_dispose;
310 gobject_class->finalize = gnc_split_finalize;
311 gobject_class->set_property = gnc_split_set_property;
312 gobject_class->get_property = gnc_split_get_property;
314 g_object_class_install_property
317 g_param_spec_string(
"action",
319 "The action is an arbitrary string assigned " 320 "by the user. It is intended to be a short " 321 "string that contains extra information about " 326 g_object_class_install_property
329 g_param_spec_string(
"memo",
331 "The action is an arbitrary string assigned " 332 "by the user. It is intended to be a short " 333 "string that describes the purpose of " 338 g_object_class_install_property
341 g_param_spec_boxed(
"value",
343 "The value for this split in the common currency. " 344 "The value and the amount provide enough information to " 345 "calculate a conversion rate.",
349 g_object_class_install_property
352 g_param_spec_boxed(
"amount",
354 "The value for this split in the currency of its account. " 355 "The value and the amount provide enough information to " 356 "calculate a conversion rate.",
360 g_object_class_install_property
363 g_param_spec_boxed(
"reconcile-date",
365 "The date this split was reconciled.",
369 g_object_class_install_property
372 g_param_spec_object (
"transaction",
374 "The transaction that this split belongs to.",
375 GNC_TYPE_TRANSACTION,
378 g_object_class_install_property
381 g_param_spec_object (
"account",
383 "The account that this split belongs to.",
387 g_object_class_install_property
390 g_param_spec_object (
"lot",
392 "The lot that this split belongs to.",
396 g_object_class_install_property
398 PROP_SX_DEBIT_FORMULA,
399 g_param_spec_string(
"sx-debit-formula",
400 "Schedule Transaction Debit Formula",
401 "The formula used to calculate the actual debit " 402 "amount when a real split is generated from this " 407 g_object_class_install_property
409 PROP_SX_DEBIT_NUMERIC,
410 g_param_spec_boxed(
"sx-debit-numeric",
411 "Scheduled Transaction Debit Numeric",
412 "Numeric value to plug into the Debit Formula when a " 413 "real split is generated from this SX split.",
417 g_object_class_install_property
419 PROP_SX_CREDIT_FORMULA,
420 g_param_spec_string(
"sx-credit-formula",
421 "Schedule Transaction Credit Formula",
422 "The formula used to calculate the actual credit " 423 "amount when a real split is generated from this " 428 g_object_class_install_property
430 PROP_SX_CREDIT_NUMERIC,
431 g_param_spec_boxed(
"sx-credit-numeric",
432 "Scheduled Transaction Credit Numeric",
433 "Numeric value to plug into the Credit Formula when a " 434 "real split is generated from this SX split.",
442 g_object_class_install_property
445 g_param_spec_string(
"sx-shares",
446 "Scheduled Transaction Shares",
447 "Numeric value of shares to insert in a new split when " 448 "it's generated from this SX split.",
452 g_object_class_install_property
455 g_param_spec_boxed(
"sx-account",
456 "Scheduled Transaction Account",
457 "The target account for a scheduled transaction split.",
461 g_object_class_install_property
464 g_param_spec_string (
"online-id",
466 "The online account which corresponds to this " 467 "account for OFX/HCBI import",
471 g_object_class_install_property
474 g_param_spec_boxed (
"gains-split",
476 "The capital gains split associated with this " 477 "split when this split represents the proceeds " 478 "from the sale of a commodity inside a Lot.",
482 g_object_class_install_property
485 g_param_spec_boxed (
"gains-source",
487 "The source split for which this split this is " 499 xaccInitSplit(Split * split,
QofBook *book)
505 xaccSplitReinit(Split * split)
508 split->acc =
nullptr;
509 split->orig_acc =
nullptr;
510 split->parent =
nullptr;
511 split->lot =
nullptr;
513 CACHE_REPLACE(split->action,
"");
514 CACHE_REPLACE(split->memo,
"");
515 split->reconciled =
NREC;
516 split->amount = gnc_numeric_zero();
517 split->value = gnc_numeric_zero();
519 split->date_reconciled = 0;
521 split->balance = gnc_numeric_zero();
522 split->cleared_balance = gnc_numeric_zero();
523 split->reconciled_balance = gnc_numeric_zero();
524 split->noclosing_balance = gnc_numeric_zero();
526 split->adjusted_amount = gnc_numeric_zero();
527 split->split_type =
nullptr;
529 qof_instance_set_idata(split, 0);
531 split->gains = GAINS_STATUS_UNKNOWN;
532 split->gains_split =
nullptr;
542 g_return_val_if_fail (book,
nullptr);
544 split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT,
nullptr));
545 xaccInitSplit (split, book);
560 xaccDupeSplit (
const Split *s)
562 Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT,
nullptr));
568 split->inst.e_type =
nullptr;
569 qof_instance_copy_guid(split, s);
572 split->parent = s->parent;
574 split->orig_acc = s->orig_acc;
577 CACHE_REPLACE(split->memo, s->memo);
578 CACHE_REPLACE(split->action, s->action);
580 qof_instance_copy_kvp (QOF_INSTANCE (split), QOF_INSTANCE (s));
582 split->reconciled = s->reconciled;
583 split->date_reconciled = s->date_reconciled;
585 split->value = s->value;
586 split->amount = s->amount;
598 xaccSplitCloneNoKvp (
const Split *s)
600 Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT,
nullptr));
602 split->parent =
nullptr;
603 split->memo = CACHE_INSERT(s->memo);
604 split->action = CACHE_INSERT(s->action);
605 split->reconciled = s->reconciled;
606 split->date_reconciled = s->date_reconciled;
607 split->value = s->value;
608 split->amount = s->amount;
609 split->balance = s->balance;
610 split->cleared_balance = s->cleared_balance;
611 split->reconciled_balance = s->reconciled_balance;
612 split->noclosing_balance = s->noclosing_balance;
613 split->adjusted_amount = s->adjusted_amount;
614 split->split_type = s->split_type;
616 split->gains = GAINS_STATUS_UNKNOWN;
617 split->gains_split =
nullptr;
631 xaccSplitCopyKvp (
const Split *from, Split *to)
633 qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
650 if (!from_split || !to_split)
return;
663 qof_instance_set_dirty(QOF_INSTANCE(to_split));
670 #ifdef DUMP_FUNCTIONS 672 xaccSplitDump (
const Split *split,
const char *tag)
675 memset (datebuff, 0,
sizeof(datebuff));
677 printf(
" %s Split %p", tag, split);
679 printf(
" Account: %p (%s)\n", split->acc,
681 printf(
" Commod: %s\n",
685 printf(
" Lot: %p\n", split->lot);
686 printf(
" Parent: %p\n", split->parent);
687 printf(
" Gains: %p\n", split->gains_split);
688 printf(
" Memo: %s\n", split->memo ? split->memo :
"(null)");
689 printf(
" Action: %s\n", split->action ? split->action :
"(null)");
690 printf(
" KVP Data: %s\n", qof_instance_kvp_as_string (QOF_INSTANCE (split)));
691 printf(
" Recncld: %c (date %s)\n", split->reconciled, datebuff);
697 printf(
" RBalance: %s\n",
701 printf(
" Type: %s\n", split->split_type ? split->split_type :
"(null)");
711 xaccFreeSplit (GNC_SPLIT (inst));
715 xaccFreeSplit (Split *split)
720 if (((
char *) 1) == split->memo)
722 PERR (
"double-free %p", split);
725 CACHE_REMOVE(split->memo);
726 CACHE_REMOVE(split->action);
728 if (split->inst.e_type)
733 if (GNC_IS_ACCOUNT (split->acc)
752 split->memo = (
char *) 1;
753 split->action =
nullptr;
754 split->reconciled =
NREC;
755 split->amount = gnc_numeric_zero();
756 split->value = gnc_numeric_zero();
757 split->parent =
nullptr;
758 split->lot =
nullptr;
759 split->acc =
nullptr;
760 split->orig_acc =
nullptr;
762 split->balance = gnc_numeric_zero();
763 split->cleared_balance = gnc_numeric_zero();
764 split->reconciled_balance = gnc_numeric_zero();
765 split->noclosing_balance = gnc_numeric_zero();
766 split->adjusted_amount = gnc_numeric_zero();
767 split->split_type =
nullptr;
769 split->date_reconciled = 0;
770 G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split));
772 if (split->gains_split)
775 split->gains_split->gains_split =
nullptr;
777 other->gains_split =
nullptr;
780 g_object_unref(split);
783 void mark_split (Split *s)
786 g_object_set(s->acc,
"sort-dirty", TRUE,
"balance-dirty", TRUE,
nullptr);
797 xaccSplitEqualCheckBal (
const char *tag, gnc_numeric a, gnc_numeric b)
807 PINFO (
"%sbalances differ: %s vs %s", tag, str_a, str_b);
820 gboolean check_guids,
821 gboolean check_balances,
822 gboolean check_txn_splits)
826 if (!sa && !sb)
return TRUE;
830 PINFO (
"one is nullptr");
834 if (sa == sb)
return TRUE;
842 PINFO (
"GUIDs differ");
848 if ((same_book && sa->memo != sb->memo) || (!same_book && g_strcmp0(sa->memo, sb->memo) != 0))
850 PINFO (
"memos differ: (%p)%s vs (%p)%s",
851 sa->memo, sa->memo, sb->memo, sb->memo);
855 if ((same_book && sa->action != sb->action) || (!same_book && g_strcmp0(sa->action, sb->action) != 0))
857 PINFO (
"actions differ: %s vs %s", sa->action, sb->action);
861 if (qof_instance_compare_kvp (QOF_INSTANCE (sa), QOF_INSTANCE (sb)) != 0)
866 frame_a = qof_instance_kvp_as_string (QOF_INSTANCE (sa));
867 frame_b = qof_instance_kvp_as_string (QOF_INSTANCE (sb));
869 PINFO (
"kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
877 if (sa->reconciled != sb->reconciled)
879 PINFO (
"reconcile flags differ: %c vs %c", sa->reconciled, sb->reconciled);
883 if (sa->date_reconciled != sb->date_reconciled)
885 PINFO (
"reconciled date differs");
897 PINFO (
"amounts differ: %s vs %s", str_a, str_b);
913 PINFO (
"values differ: %s vs %s", str_a, str_b);
923 if (!xaccSplitEqualCheckBal (
"", sa->balance, sb->balance))
925 if (!xaccSplitEqualCheckBal (
"cleared ", sa->cleared_balance,
926 sb->cleared_balance))
928 if (!xaccSplitEqualCheckBal (
"reconciled ", sa->reconciled_balance,
929 sb->reconciled_balance))
931 if (!xaccSplitEqualCheckBal (
"noclosing ", sa->noclosing_balance,
932 sb->noclosing_balance))
934 if (!xaccSplitEqualCheckBal (
"adjusted ", sa->adjusted_amount,
935 sb->adjusted_amount))
939 if (!
xaccTransEqual(sa->parent, sb->parent, check_guids, check_txn_splits,
940 check_balances, FALSE))
942 PINFO (
"transactions differ");
958 return s ? s->acc :
nullptr;
962 xaccSplitSetAccount (Split *s,
Account *acc)
966 g_return_if_fail(s && acc);
974 qof_instance_set_dirty(QOF_INSTANCE(s));
982 PERR(
"commit error: %d", errcode);
983 gnc_engine_signal_commit_error( errcode );
988 xaccSplitCommitEdit(Split *s)
997 orig_acc = s->orig_acc;
999 if (GNC_IS_ACCOUNT(s->acc))
1012 PERR(
"Account lost track of moved or deleted split.");
1028 PERR(
"Account grabbed split prematurely.");
1033 if (s->parent != s->orig_parent)
1043 qof_event_gen (QOF_INSTANCE(s->lot), QOF_EVENT_MODIFY,
nullptr);
1049 s->orig_acc = s->acc;
1050 s->orig_parent = s->parent;
1056 g_object_set(acc,
"sort-dirty", TRUE,
"balance-dirty", TRUE,
nullptr);
1063 xaccSplitRollbackEdit(Split *s)
1069 if (s->acc != s->orig_acc)
1070 s->acc = s->orig_acc;
1076 qof_instance_set_destroying(s, FALSE);
1084 xaccSplitSetParent(s, s->orig_parent);
1094 if (!guid || !book)
return nullptr;
1110 xaccSplitDetermineGainStatus (Split *split)
1115 if (GAINS_STATUS_UNKNOWN != split->gains)
return;
1120 split->gains = GAINS_STATUS_A_VDIRTY | GAINS_STATUS_DATE_DIRTY;
1121 split->gains_split = other;
1125 if (
auto v = qof_instance_get_path_kvp<GncGUID*> (QOF_INSTANCE (split), {
"gains-source"}))
1126 guid =
const_cast<GncGUID*
>(*v);
1131 split->gains = GAINS_STATUS_A_VDIRTY | GAINS_STATUS_DATE_DIRTY;
1138 split->gains = GAINS_STATUS_GAINS;
1140 split->gains_split = other;
1148 get_currency_denom(
const Split * s)
1150 if (!(s && s->parent && s->parent->common_currency))
1161 get_commodity_denom(
const Split * s)
1188 SET_GAINS_A_VDIRTY(s);
1190 qof_instance_set_dirty(QOF_INSTANCE(s));
1196 qofSplitSetSharePrice (Split *split, gnc_numeric price)
1198 g_return_if_fail(split);
1200 price, get_currency_denom(split),
1216 price, get_currency_denom(s),
1219 SET_GAINS_VDIRTY(s);
1221 qof_instance_set_dirty(QOF_INSTANCE(s));
1227 qofSplitSetAmount (Split *split, gnc_numeric amt)
1229 g_return_if_fail(split);
1237 split->amount = amt;
1247 ENTER (
"(split=%p) old amt=%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT
1248 " new amt=%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT, s,
1249 s->amount.num, s->amount.denom, amt.num, amt.denom);
1260 s->adjusted_amount = s->amount;
1262 SET_GAINS_ADIRTY(s);
1264 qof_instance_set_dirty(QOF_INSTANCE(s));
1270 qofSplitSetValue (Split *split, gnc_numeric amt)
1272 g_return_if_fail(split);
1282 gnc_numeric new_val;
1286 ENTER (
"(split=%p) old val=%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT
1287 " new val=%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT, s,
1288 s->value.num, s->value.denom, amt.num, amt.denom);
1300 PERR(
"numeric error %s in converting the split value's denominator with amount %s and denom %d",
1305 SET_GAINS_VDIRTY(s);
1307 qof_instance_set_dirty(QOF_INSTANCE(s));
1318 return s ? s->balance : gnc_numeric_zero();
1324 return s ? s->noclosing_balance : gnc_numeric_zero();
1330 return s ? s->cleared_balance : gnc_numeric_zero();
1336 return s ? s->reconciled_balance : gnc_numeric_zero();
1342 return s ? s->adjusted_amount : gnc_numeric_zero();
1351 s->adjusted_amount = amt;
1356 const gnc_commodity * base_currency)
1358 const gnc_commodity *currency;
1359 const gnc_commodity *commodity;
1366 PERR (
"split must have a parent account");
1381 get_commodity_denom(s),
1385 get_currency_denom(s),
1395 PERR (
"inappropriate base currency %s " 1396 "given split currency=%s and commodity=%s\n",
1403 SET_GAINS_A_VDIRTY(s);
1405 qof_instance_set_dirty(QOF_INSTANCE(s));
1412 if (!s || !s->acc || !s->parent)
return gnc_numeric_zero();
1421 PERR (
"inappropriate base currency %s " 1422 "given split currency=%s and commodity=%s\n",
1426 return gnc_numeric_zero();
1433 xaccSplitConvertAmount (
const Split *split,
const Account * account)
1435 gnc_commodity *acc_com, *to_commodity;
1437 gnc_numeric amount, value, convrate;
1444 if (split_acc == account)
1467 gnc_commodity* split_comm =
1473 PERR(
"The split's (%s) amount can't be converted from %s into %s.",
1478 return gnc_numeric_zero();
1496 convrate = xaccTransGetAccountConvRate(txn, account);
1512 if (!split)
return TRUE;
1515 trans = split->parent;
1524 qof_instance_set_dirty(QOF_INSTANCE(split));
1525 qof_instance_set_destroying(split, TRUE);
1540 const char *da, *db;
1541 gboolean action_for_num;
1543 if (sa == sb)
return 0;
1554 sb->parent, sb->action);
1557 if (retval)
return retval;
1560 da = sa->memo ? sa->memo :
"";
1561 db = sb->memo ? sb->memo :
"";
1562 retval = g_utf8_collate (da, db);
1567 da = sa->action ? sa->action :
"";
1568 db = sb->action ? sb->action :
"";
1569 retval = g_utf8_collate (da, db);
1574 if (sa->reconciled < sb->reconciled)
return -1;
1575 if (sa->reconciled > sb->reconciled)
return +1;
1579 if (comp < 0)
return -1;
1580 if (comp > 0)
return +1;
1583 if (comp < 0)
return -1;
1584 if (comp > 0)
return +1;
1587 if (sa->date_reconciled < sb->date_reconciled)
1589 else if (sa->date_reconciled > sb->date_reconciled)
1594 if (retval)
return retval;
1600 xaccSplitOrderDateOnly (
const Split *sa,
const Split *sb)
1602 Transaction *ta, *tb;
1604 if (sa == sb)
return 0;
1611 if ( !ta && !tb )
return 0;
1612 if ( !tb )
return -1;
1613 if ( !ta )
return +1;
1615 if (ta->date_posted == tb->date_posted)
1617 return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
1621 get_corr_account_split(
const Split *sa,
const Split **retval)
1624 g_return_val_if_fail(sa, FALSE);
1640 static const char *split_const =
nullptr;
1641 const Split *other_split;
1643 if (!get_corr_account_split(sa, &other_split))
1646 split_const = _(
"-- Split Transaction --");
1657 static const char *split_const =
nullptr;
1658 const Split *other_split;
1660 if (!get_corr_account_split(sa, &other_split))
1663 split_const = _(
"-- Split Transaction --");
1665 return g_strdup(split_const);
1673 static const char *split_const =
nullptr;
1674 const Split *other_split;
1676 if (!get_corr_account_split(sa, &other_split))
1679 split_const = C_(
"Displayed account code of the other account in a multi-split transaction",
"Split");
1691 if (sa == sb)
return 0;
1697 if (aa == ab)
return 0;
1699 auto path_a = gnc_account_get_all_parents (aa);
1700 auto path_b = gnc_account_get_all_parents (ab);
1701 auto mismatch_pair = std::mismatch (path_a.rbegin(), path_a.rend(),
1702 path_b.rbegin(), path_b.rend());
1704 return mismatch_pair.first == path_a.rend() ? -1
1705 : mismatch_pair.second == path_b.rend() ? 1
1715 if (!sa && !sb)
return 0;
1730 if (!sa && !sb)
return 0;
1740 retval = g_strcmp0(ca, cb);
1749 const char *ca, *cb;
1750 if (!sa && !sb)
return 0;
1756 return g_strcmp0(ca, cb);
1760 qofSplitSetMemo (Split *split,
const char* memo)
1762 g_return_if_fail(split);
1763 CACHE_REPLACE(split->memo, memo);
1769 if (!split || !memo)
return;
1772 CACHE_REPLACE(split->memo, memo);
1773 qof_instance_set_dirty(QOF_INSTANCE(split));
1779 qofSplitSetAction (Split *split,
const char *actn)
1781 g_return_if_fail(split);
1782 CACHE_REPLACE(split->action, actn);
1788 if (!split || !actn)
return;
1791 CACHE_REPLACE(split->action, actn);
1792 qof_instance_set_dirty(QOF_INSTANCE(split));
1798 qofSplitSetReconcile (Split *split,
char recn)
1800 g_return_if_fail(split);
1808 split->reconciled = recn;
1813 PERR(
"Bad reconciled flag");
1821 if (!split || split->reconciled == recn)
return;
1831 split->reconciled = recn;
1833 qof_instance_set_dirty(QOF_INSTANCE(split));
1837 PERR(
"Bad reconciled flag");
1850 split->date_reconciled = secs;
1851 qof_instance_set_dirty(QOF_INSTANCE(split));
1861 return split ? split->date_reconciled : 0;
1872 return split ? split->parent :
nullptr;
1876 xaccSplitSetParent(Split *s, Transaction *t)
1878 Transaction *old_trans;
1881 g_return_if_fail(s);
1882 if (s->parent == t)
return;
1884 if (s->parent != s->orig_parent && s->orig_parent != t)
1885 PERR(
"You may not add the split to more than one transaction" 1886 " during the BeginEdit/CommitEdit block.");
1888 old_trans = s->parent;
1896 qof_event_gen(&old_trans->inst, GNC_EVENT_ITEM_REMOVED, &ed);
1899 qof_instance_set_dirty(QOF_INSTANCE(s));
1909 if (
nullptr == g_list_find(t->splits, s))
1910 t->splits = g_list_append(t->splits, s);
1922 return split ? split->lot :
nullptr;
1930 qof_instance_set_dirty(QOF_INSTANCE(split));
1937 return split ? split->memo :
nullptr;
1947 std::optional<const char*> val;
1949 val = g_strdup (
id);
1950 qof_instance_set_path_kvp<const char*> (QOF_INSTANCE(split), val, {split_online_id});
1951 qof_instance_set_dirty (QOF_INSTANCE(split));
1957 if (!split)
return nullptr;
1958 auto rv{qof_instance_get_path_kvp<const char*> (QOF_INSTANCE(split), {split_online_id})};
1959 return rv ? *rv :
nullptr;
1972 return split ? split->action :
nullptr;
1978 return split ? split->reconciled :
' ';
1985 return split ? split->amount : gnc_numeric_zero();
1991 return split ? split->value : gnc_numeric_zero();
1997 gnc_numeric amt, val, price;
1998 if (!split)
return gnc_numeric_create(0, 1);
2008 return gnc_numeric_create(0, 1);
2020 PERR(
"Computing share price failed (%d): [ %" G_GINT64_FORMAT
" / %" 2021 G_GINT64_FORMAT
" ] / [ %" G_GINT64_FORMAT
" / %" G_GINT64_FORMAT
" ]",
2023 return gnc_numeric_create(0, 1);
2041 if (!s)
return nullptr;
2045 auto type{qof_instance_get_path_kvp<const char*> (QOF_INSTANCE(s), {
"split-type"})};
2047 if (!type || !g_strcmp0 (*type, split_type_normal))
2048 s->split_type = split_type_normal;
2049 else if (!g_strcmp0 (*type, split_type_stock_split))
2050 s->split_type = split_type_stock_split;
2053 PERR (
"unexpected split-type %s, reset to normal.", *type);
2054 s->split_type = split_type_normal;
2057 return s->split_type;
2067 s->value = gnc_numeric_zero();
2068 s->split_type = split_type_stock_split;
2069 qof_instance_set_path_kvp<const char*> (QOF_INSTANCE(s), g_strdup(split_type_stock_split),
2071 SET_GAINS_VDIRTY(s);
2073 qof_instance_set_dirty(QOF_INSTANCE(s));
2089 g_return_if_fail (split !=
nullptr);
2090 g_return_if_fail (other_split !=
nullptr);
2094 qof_instance_kvp_add_guid (QOF_INSTANCE (split),
"lot-split",
2097 qof_instance_set_dirty (QOF_INSTANCE (split));
2104 return qof_instance_has_slot (QOF_INSTANCE (split),
"lot-split");
2112 g_return_val_if_fail (split !=
nullptr, FALSE);
2113 g_return_val_if_fail (other_split !=
nullptr, FALSE);
2116 return qof_instance_kvp_has_guid (QOF_INSTANCE (split),
"lot-split",
2125 g_return_if_fail (split !=
nullptr);
2126 g_return_if_fail (other_split !=
nullptr);
2130 qof_instance_kvp_remove_guid (QOF_INSTANCE (split),
"lot-split",
2133 qof_instance_set_dirty (QOF_INSTANCE (split));
2141 qof_instance_kvp_merge_guids (QOF_INSTANCE (split),
2142 QOF_INSTANCE (other_split),
"lot-split");
2144 qof_instance_set_dirty (QOF_INSTANCE (split));
2164 Split *other =
nullptr;
2166 if (!split)
return nullptr;
2167 trans = split->parent;
2168 if (!trans)
return nullptr;
2172 Split *s = GNC_SPLIT(n->data);
2174 (!xaccTransStillHasSplit(trans, s)) ||
2176 (qof_instance_has_slot (QOF_INSTANCE (s),
"lot-split")))
2193 g_return_val_if_fail(split, gnc_numeric_zero());
2194 auto num{qof_instance_get_path_kvp<gnc_numeric> (QOF_INSTANCE(split), {void_former_amt_str})};
2195 return num ? *num : gnc_numeric_zero();
2201 g_return_val_if_fail(split, gnc_numeric_zero());
2202 auto num{qof_instance_get_path_kvp<gnc_numeric> (QOF_INSTANCE(split), {void_former_val_str})};
2203 return num ? *num : gnc_numeric_zero();
2207 xaccSplitVoid(Split *split)
2209 g_return_if_fail (GNC_IS_SPLIT(split));
2210 qof_instance_set_path_kvp<gnc_numeric> (QOF_INSTANCE(split),
xaccSplitGetAmount(split), {void_former_amt_str});
2211 qof_instance_set_path_kvp<gnc_numeric> (QOF_INSTANCE(split),
xaccSplitGetValue(split), {void_former_val_str});
2212 qof_instance_set_dirty (QOF_INSTANCE(split));
2214 static gnc_numeric zero = gnc_numeric_zero();
2221 xaccSplitUnvoid(Split *split)
2223 g_return_if_fail (GNC_IS_SPLIT(split));
2227 qof_instance_set_path_kvp<gnc_numeric> (QOF_INSTANCE(split), {}, {void_former_amt_str});
2228 qof_instance_set_path_kvp<gnc_numeric> (QOF_INSTANCE(split), {}, {void_former_val_str});
2229 qof_instance_set_dirty (QOF_INSTANCE(split));
2245 static QofObject split_object_def =
2248 DI(.e_type = ) GNC_ID_SPLIT,
2249 DI(.type_label = ) "Split",
2251 DI(.book_begin = )
nullptr,
2252 DI(.book_end = )
nullptr,
2255 DI(.foreach = ) qof_collection_foreach,
2261 split_account_guid_getter (gpointer obj, const QofParam *p)
2263 Split *s = GNC_SPLIT(obj);
2266 if (!s)
return nullptr;
2268 if (!acc)
return nullptr;
2273 DxaccSplitGetShareAmount (
const Split * split)
2279 no_op (gpointer obj,
const QofParam *p)
2285 qofSplitSetParentTrans(Split *s,
QofInstance *ent)
2287 Transaction *trans = (Transaction*)ent;
2289 g_return_if_fail(trans);
2290 xaccSplitSetParent(s, trans);
2298 g_return_if_fail(acc);
2299 xaccSplitSetAccount(s, acc);
2302 gboolean xaccSplitRegister (
void)
2304 static const QofParam params[] =
2307 SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
2315 "d-share-amount", QOF_TYPE_DOUBLE,
2319 "d-share-int64", QOF_TYPE_INT64,
2323 SPLIT_BALANCE, QOF_TYPE_NUMERIC,
2327 SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC,
2331 SPLIT_RECONCILED_BALANCE, QOF_TYPE_NUMERIC,
2335 SPLIT_MEMO, QOF_TYPE_STRING,
2339 SPLIT_ACTION, QOF_TYPE_STRING,
2343 SPLIT_RECONCILE, QOF_TYPE_CHAR,
2348 SPLIT_AMOUNT, QOF_TYPE_NUMERIC,
2352 SPLIT_SHARE_PRICE, QOF_TYPE_NUMERIC,
2357 SPLIT_VALUE, QOF_TYPE_DEBCRED,
2362 SPLIT_VOIDED_AMOUNT, QOF_TYPE_NUMERIC,
2366 SPLIT_VOIDED_VALUE, QOF_TYPE_NUMERIC,
2371 SPLIT_TRANS, GNC_ID_TRANS,
2376 SPLIT_ACCOUNT, GNC_ID_ACCOUNT,
2382 { SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op,
nullptr },
2383 { SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op,
nullptr },
2384 { SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op,
nullptr },
2387 QOF_PARAM_GUID, QOF_TYPE_GUID,
2406 _utest_split_fill_functions (
void)
2410 func->xaccSplitEqualCheckBal = xaccSplitEqualCheckBal;
2411 func->get_currency_denom = get_currency_denom;
2412 func->get_commodity_denom = get_commodity_denom;
2413 func->get_corr_account_split = get_corr_account_split;
void xaccSplitSetValue(Split *s, gnc_numeric amt)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
int qof_instance_version_cmp(const QofInstance *left, const QofInstance *right)
Compare two instances, based on their last update times.
gnc_numeric xaccSplitGetClearedBalance(const Split *s)
The cleared-balance is the currency-denominated balance of all transactions that have been marked as ...
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
This is the private header for the account structure.
void xaccSplitSetAdjustedAmount(Split *s, gnc_numeric amt)
Sets the stock split adjusted amount of a split.
void xaccSplitAddPeerSplit(Split *split, const Split *other_split, time64 timestamp)
Add a peer split to this split's lot-split list.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
void xaccSplitSetBaseValue(Split *s, gnc_numeric value, const gnc_commodity *base_currency)
Depending on the base_currency, set either the value or the amount of this split or both: If the base...
void xaccSplitSetAction(Split *split, const char *actn)
The Action is an arbitrary user-assigned string.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
void xaccSplitMakeStockSplit(Split *s)
Mark a split to be of type stock split - after this, you shouldn't modify the value anymore...
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
void qof_instance_set_kvp(QofInstance *, GValue const *value, unsigned count,...)
Sets a KVP slot to a value from a GValue.
int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb)
Compare two splits by code of account.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
#define qof_instance_is_dirty
Return value of is_dirty flag.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
gboolean qof_collection_is_dirty(const QofCollection *col)
Return value of 'dirty' flag on collection.
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
#define PINFO(format, args...)
Print an informational note.
gnc_numeric xaccSplitGetReconciledBalance(const Split *s)
Returns the reconciled-balance of this split.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
gboolean xaccSplitDestroy(Split *split)
Destructor.
gboolean xaccSplitHasOnlineID(const Split *split)
Returns TRUE if the split has a non-empty online_id.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
const char * xaccAccountGetCode(const Account *acc)
Get the account's accounting code.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
GncGUID * guid_copy(const GncGUID *guid)
Returns a newly allocated GncGUID that matches the passed-in GUID.
const char * xaccTransGetReadOnly(Transaction *trans)
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text...
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
void xaccSplitCopyOnto(const Split *from_split, Split *to_split)
This is really a helper for xaccTransCopyOnto.
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.
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction nu...
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
void gnc_lot_add_split(GNCLot *lot, Split *split)
Adds a split to this lot.
gboolean gnc_account_remove_split(Account *acc, Split *s)
Remove the given split from an account.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
Object instance holds common fields that most gnucash objects use.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
void xaccAccountInsertLot(Account *acc, GNCLot *lot)
The xaccAccountInsertLot() method will register the indicated lot with this account.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
API for Transactions and Splits (journal entries)
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
void xaccSplitRemovePeerSplit(Split *split, const Split *other_split)
Remove a peer split from this split's lot-split list.
const char * xaccSplitGetType(Split *s)
Returns the split type, which is either the string "normal", or "stock-split" for a split from a stoc...
int(* QofSortFunc)(gconstpointer, gconstpointer)
This function is the default sort function for a particular object type.
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b.
gboolean xaccTransIsBalanced(const Transaction *trans)
Returns true if the transaction is balanced according to the rules currently in effect.
#define QOF_OBJECT_VERSION
Defines the version of the core object object registration interface.
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.
int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb)
Compare two splits by full name of the other account.
#define PERR(format, args...)
Log a serious error.
QofBook * xaccSplitGetBook(const Split *split)
Returns the book of this split, i.e.
int xaccTransOrder_num_action(const Transaction *ta, const char *actna, const Transaction *tb, const char *actnb)
The xaccTransOrder_num_action(ta,actna,tb,actnb) method is useful for sorting.
const char * xaccSplitGetOnlineID(const Split *split)
Returns the split's online_id.
#define ENTER(format, args...)
Print a function entry debugging message.
gnc_numeric xaccSplitGetBalance(const Split *s)
Returns the running balance up to and including the indicated split.
#define QOF_PARAM_BOOK
"Known" Object Parameters – all objects must support these
Split * xaccSplitGetCapGainsSplit(const Split *split)
The xaccSplitGetCapGainsSplit() routine returns the split that records the cap gains for this split...
void gnc_lot_set_closed_unknown(GNCLot *lot)
Reset closed flag so that it will be recalculated.
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
void qof_instance_get_kvp(QofInstance *, GValue *value, unsigned count,...)
Retrieves the contents of a KVP slot into a provided GValue.
int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb)
Compare two splits by full name of account.
#define VREC
split is void
Account used to record multiple commodity transactions.
gboolean xaccSplitEqual(const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits)
Equality.
gboolean xaccSplitHasPeers(const Split *split)
Does this split have peers?
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.
int xaccTransCountSplits(const Transaction *trans)
Returns the number of splits in this transaction.
#define xaccAccountGetGUID(X)
gdouble gnc_numeric_to_double(gnc_numeric n)
Convert numeric to floating-point value.
convert single-entry accounts to clean double-entry
void xaccSplitMergePeerSplits(Split *split, const Split *other_split)
Merge the other_split's peer splits into split's peers.
gnc_numeric xaccSplitVoidFormerAmount(const Split *split)
Returns the original pre-void amount of a split.
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split.
guint32 qof_instance_get_idata(gconstpointer inst)
get the instance tag number used for kvp management in sql backends.
void xaccSplitSetAmount(Split *s, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
gboolean xaccTransEqual(const Transaction *ta, const Transaction *tb, gboolean check_guids, gboolean check_splits, gboolean check_balances, gboolean assume_ordered)
Equality.
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
Change the denominator of a gnc_numeric value to the specified denominator under standard arguments '...
gnc_numeric xaccSplitVoidFormerValue(const Split *split)
Returns the original pre-void value of a split.
Account public routines (C++ api)
#define YREC
The Split has been reconciled.
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Multiply a times b, returning the product.
const char * gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
Returns a string representation of the given GNCNumericErrorCode.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
#define FREC
frozen into accounting period
int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb)
Compare two splits by code of the other account.
void xaccSplitSetSharePriceAndAmount(Split *s, gnc_numeric price, gnc_numeric amt)
The xaccSplitSetSharePriceAndAmount() method will simultaneously update the share price and the numbe...
void qof_instance_copy_book(gpointer ptr1, gconstpointer ptr2)
Copy the book from one QofInstances to another.
gnc_numeric xaccSplitGetNoclosingBalance(const Split *s)
The noclosing-balance is the currency-denominated balance of all transactions except 'closing' transa...
#define SPLIT_ACCOUNT_GUID
for guid_match_all
void xaccAccountRecomputeBalance(Account *acc)
The following recompute the partial balances (stored with the transaction) and the total balance...
gboolean xaccSplitIsPeerSplit(const Split *split, const Split *other_split)
Report if a split is a peer of this one.
char * xaccSplitGetCorrAccountFullName(const Split *sa)
These functions take a split, get the corresponding split on the "other side" of the transaction...
void gnc_lot_remove_split(GNCLot *lot, Split *split)
Adds a split from this lot.
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
gboolean xaccSplitIsStockSplit(Split *s)
Returns true if the split is of type stock split.
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
void qof_collection_mark_clean(QofCollection *)
reset value of dirty flag
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
Additional event handling code.
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
Division.
#define xaccSplitGetGUID(X)
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
gnc_numeric xaccSplitGetSharePrice(const Split *split)
Returns the price of the split, that is, the value divided by the amount.
int xaccTransGetSplitIndex(const Transaction *trans, const Split *split)
Inverse of xaccTransGetSplit()
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b are exactly the same (have the same numerator and ...
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer ent)
#define CREC
The Split has been cleared.
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
gnc_numeric xaccSplitGetBaseValue(const Split *s, const gnc_commodity *base_currency)
Depending on the base_currency, return either the value or the amount of this split: If the base_curr...
Split * xaccMallocSplit(QofBook *book)
Constructor.
const char * xaccSplitGetCorrAccountName(const Split *sa)
document me
Encapsulate all the information about a dataset.
gboolean gnc_account_insert_split(Account *acc, Split *s)
Insert the given split from an account.
void xaccSplitSetLot(Split *split, GNCLot *lot)
Assigns the split to a specific Lot.
API for the transaction logger.
const char * gnc_commodity_get_printname(const gnc_commodity *cm)
Retrieve the 'print' name for the specified commodity.
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64. ...
time64 xaccSplitGetDateReconciled(const Split *split)
Retrieve the date when the Split was reconciled.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *s)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
Returns the valuation commodity of this transaction.
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.
void xaccSplitSetOnlineID(Split *split, const char *id)
The online_id is the OFX/HBCI "FITID" recorded on a split when it is imported.
const char * xaccSplitGetCorrAccountCode(const Split *sa)
document me
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
#define LEAVE(format, args...)
Print a function exit debugging message.
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
void xaccSplitSetSharePrice(Split *s, gnc_numeric price)
time64 gnc_time(time64 *tbuf)
get the current time
int xaccTransOrder(const Transaction *ta, const Transaction *tb)
The xaccTransOrder(ta,tb) method is useful for sorting.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a)
Check for error signal in value.
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
const char * xaccSplitGetAction(const Split *split)
Returns the action string.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
gnc_numeric xaccSplitGetAdjustedAmount(const Split *s)
Returns the stock-split adjusted amount of the split in the account's commodity.
#define GNC_EVENT_ITEM_ADDED
These events are used when a split is added to an account.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
The type used to store guids in C.
Utilities to Automatically Compute Capital Gains/Losses.
size_t qof_print_date_buff(char *buff, size_t buflen, time64 secs)
Convenience: calls through to qof_print_date_dmy_buff().
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
Commodity handling public routines.
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
GNCLot * xaccSplitGetLot(const Split *split)
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't be...
#define NREC
not reconciled or cleared
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.