42#include <glib/gi18n.h>
47#include <unordered_set>
54#include "TransactionP.hpp"
56#include "qofinstance-p.h"
57#include "gnc-session.h"
60#define G_LOG_DOMAIN "gnc.engine.scrub"
62static QofLogModule log_module = G_LOG_DOMAIN;
63static gboolean abort_now = FALSE;
64static gint scrub_depth = 0;
68 gnc_commodity* currency,
81gnc_get_abort_scrub (
void)
89 return scrub_depth > 0;
94using TransSet = std::unordered_set<Transaction*>;
97get_all_transactions (
Account *account,
bool descendants)
100 auto add_transactions = [&set](
auto a)
101 { gnc_account_foreach_split (a, [&set](
auto s){ set.insert (
xaccSplitGetParent (s)); }); };
102 add_transactions (account);
104 gnc_account_foreach_descendant (account, add_transactions);
111TransScrubOrphansFast (Transaction *trans,
Account *root)
113 g_return_if_fail (trans && trans->common_currency && root);
115 for (GList *node = trans->splits; node; node = node->next)
117 Split *split = GNC_SPLIT(node->data);
118 if (abort_now)
break;
120 if (split->acc)
continue;
122 DEBUG (
"Found an orphan\n");
124 gchar *accname = g_strconcat
128 Account *orph = xaccScrubUtilityGetOrMakeAccount
129 (root, trans->common_currency, accname, ACCT_TYPE_BANK,
false,
true);
134 xaccSplitSetAccount(split, orph);
144 auto transactions = get_all_transactions (acc, descendants);
145 auto total_trans = transactions.size();
146 const char *message =
_(
"Looking for orphans in transaction: %u of %zu");
147 guint current_trans = 0;
149 for (
auto trans : transactions)
151 if (current_trans % 10 == 0)
153 char *progress_msg = g_strdup_printf (message, current_trans, total_trans);
154 (percentagefunc)(progress_msg, (100 * current_trans) / total_trans);
155 g_free (progress_msg);
156 if (abort_now)
break;
162 (percentagefunc)(
nullptr, -1.0);
169 AccountScrubOrphans (acc,
false, percentagefunc);
175 AccountScrubOrphans (acc,
true, percentagefunc);
187 for (node = trans->splits; node; node = node->next)
189 Split *split = GNC_SPLIT(node->data);
190 if (abort_now)
break;
204 PINFO (
"Free Floating Transaction!");
206 root = gnc_book_get_root_account (book);
207 TransScrubOrphansFast (trans, root);
213xaccAccountTreeScrubSplits (
Account *account)
215 if (!account)
return;
217 xaccAccountScrubSplits (account);
218 gnc_account_foreach_descendant(account,
219 (AccountCb)xaccAccountScrubSplits,
nullptr);
223xaccAccountScrubSplits (
Account *account)
226 for (
auto s : xaccAccountGetSplits (account))
228 if (abort_now)
break;
237split_scrub_or_dry_run (Split *split,
bool dry_run)
241 gnc_numeric value, amount;
242 gnc_commodity *currency, *acc_commodity;
245 if (!split)
return false;
246 ENTER (
"(split=%p)", split);
275 PINFO (
"Free Floating Transaction!");
276 LEAVE (
"no account");
282 if (gnc_numeric_check (value))
284 value = gnc_numeric_zero();
292 if (gnc_numeric_check (amount))
294 amount = gnc_numeric_zero();
316 LEAVE (
"(split=%p) inequiv currency", split);
325 LEAVE(
"(split=%p) different values", split);
336 PINFO (
"Adjusted split with mismatched values, desc=\"%s\" memo=\"%s\""
337 " old amount %s %s, new amount %s",
338 trans->description, split->memo,
346 LEAVE (
"(split=%p)", split);
354AccountScrubImbalance (
Account *acc,
bool descendants,
357 const char *message =
_(
"Looking for imbalances in transaction date %s: %u of %zu");
362 Account *root = gnc_book_get_root_account (book);
363 auto transactions = get_all_transactions (acc, descendants);
364 auto count = transactions.size();
368 for (
auto trans : transactions)
370 if (abort_now)
break;
372 PINFO(
"Start processing transaction %d of %zu", curr_trans + 1, count);
374 if (curr_trans % 10 == 0)
377 char *progress_msg = g_strdup_printf (message, date, curr_trans, count);
378 (percentagefunc)(progress_msg, (100 * curr_trans) / count);
379 g_free (progress_msg);
383 TransScrubOrphansFast (trans, root);
387 PINFO(
"Finished processing transaction %d of %zu", curr_trans + 1, count);
390 (percentagefunc)(
nullptr, -1.0);
401 PERR (
"Transaction doesn't have a currency!");
403 bool must_scrub =
false;
406 if (split_scrub_or_dry_run (GNC_SPLIT(n->data),
true))
426 split_scrub_or_dry_run (split,
false);
435 AccountScrubImbalance (acc,
true, percentagefunc);
441 AccountScrubImbalance (acc,
false, percentagefunc);
445get_balance_split (Transaction *trans,
Account *root,
Account *account,
446 gnc_commodity *commodity)
448 Split *balance_split;
460 PERR (
"Bad data corruption, no root account in book");
464 accname = g_strconcat (
_(
"Imbalance"),
"-",
466 account = xaccScrubUtilityGetOrMakeAccount (root, commodity,
467 accname, ACCT_TYPE_BANK,
472 PERR (
"Can't get balancing account");
477 balance_split = xaccTransFindSplitByAccount(trans, account);
485 xaccSplitSetParent(balance_split, trans);
486 xaccSplitSetAccount(balance_split, account);
490 return balance_split;
494find_root_currency(
void)
496 QofSession *sess = gnc_get_current_session ();
506 for (GList *node = children; node && !root_currency;
507 node = g_list_next (node))
509 Account *child = GNC_ACCOUNT (node->data);
513 g_list_free (children);
515 return root_currency;
521get_trading_split (Transaction *trans,
Account *base,
522 gnc_commodity *commodity)
524 Split *balance_split;
530 trading_account = xaccScrubUtilityGetOrMakeAccount (root,
535 if (!trading_account)
537 PERR (
"Can't get trading account");
541 ns_account = xaccScrubUtilityGetOrMakeAccount (trading_account,
548 PERR (
"Can't get namespace account");
552 account = xaccScrubUtilityGetOrMakeAccount (ns_account, commodity,
558 PERR (
"Can't get commodity account");
563 balance_split = xaccTransFindSplitByAccount(trans, account);
569 xaccDisableDataScrubbing();
572 xaccSplitSetParent(balance_split, trans);
573 xaccSplitSetAccount(balance_split, account);
575 xaccEnableDataScrubbing();
578 return balance_split;
582add_balance_split (Transaction *trans, gnc_numeric imbalance,
585 const gnc_commodity *commodity;
586 gnc_numeric old_value, new_value;
587 Split *balance_split;
590 balance_split = get_balance_split(trans, root, account, currency);
605 GNC_HOW_RND_ROUND_HALF_UP);
638gnc_transaction_balance_no_trading (Transaction *trans,
Account *root,
646 PINFO (
"Value unbalanced transaction");
648 add_balance_split (trans, imbalance, root, account);
654gnc_transaction_get_commodity_imbalance (Transaction *trans,
655 gnc_commodity *commodity)
658 gnc_numeric val_imbalance = gnc_numeric_zero();
659 GList *splits =
nullptr;
660 for (splits = trans->splits; splits; splits = splits->next)
662 Split *split = GNC_SPLIT(splits->data);
663 gnc_commodity *split_commodity =
665 if (xaccTransStillHasSplit (trans, split) &&
670 GNC_HOW_DENOM_EXACT);
672 return val_imbalance;
677destroy_split (
void* ptr)
679 Split *split = GNC_SPLIT (ptr);
688xaccTransClearTradingSplits (Transaction *trans)
690 GList *trading_splits =
nullptr;
692 for (GList* node = trans->splits; node; node = node->next)
694 Split* split = GNC_SPLIT(node->data);
700 trading_splits = g_list_prepend (trading_splits, node->data);
710 g_list_free_full (trading_splits, destroy_split);
715gnc_transaction_balance_trading (Transaction *trans,
Account *root)
717 MonetaryList *imbal_list;
718 MonetaryList *imbalance_commod;
719 Split *balance_split =
nullptr;
725 LEAVE(
"transaction is balanced");
729 PINFO (
"Currency unbalanced transaction");
731 for (imbalance_commod = imbal_list; imbalance_commod;
732 imbalance_commod = imbalance_commod->next)
734 auto imbal_mon =
static_cast<gnc_monetary*
>(imbalance_commod->data);
735 gnc_commodity *commodity;
736 gnc_numeric old_amount, new_amount;
739 commodity = gnc_monetary_commodity (*imbal_mon);
741 balance_split = get_trading_split(trans, root, commodity);
753 new_amount =
gnc_numeric_sub (old_amount, gnc_monetary_value(*imbal_mon),
755 GNC_HOW_RND_ROUND_HALF_UP);
767 gnc_numeric val_imbalance = gnc_transaction_get_commodity_imbalance (trans, commodity);
772 GNC_HOW_RND_ROUND_HALF_UP);
790gnc_transaction_balance_trading_more_splits (Transaction *trans,
Account *root)
793 GList *splits_dup = g_list_copy(trans->splits), *splits =
nullptr;
795 for (splits = splits_dup; splits; splits = splits->next)
797 Split *split = GNC_SPLIT(splits->data);
798 if (! xaccTransStillHasSplit(trans, split))
continue;
802 gnc_commodity *commodity;
803 gnc_numeric old_value, new_value;
804 Split *balance_split;
809 PERR(
"Split has no commodity");
812 balance_split = get_trading_split(trans, root, commodity);
824 GNC_HOW_RND_ROUND_HALF_UP);
835 g_list_free(splits_dup);
848 gnc_numeric imbalance;
860 LEAVE (
"transaction is balanced");
866 gnc_transaction_balance_no_trading (trans, root, account);
867 LEAVE (
"transaction balanced, no managed trading accounts");
871 xaccTransClearTradingSplits (trans);
875 PINFO (
"Value unbalanced transaction");
877 add_balance_split (trans, imbalance, root, account);
880 gnc_transaction_balance_trading (trans, root);
891 gnc_transaction_balance_trading_more_splits (trans, root);
893 PERR(
"Balancing currencies unbalanced value");
904static gnc_commodity *
905FindCommonExclSCurrency (
SplitList *splits,
906 gnc_commodity * ra, gnc_commodity * rb,
911 if (!splits)
return nullptr;
913 for (node = splits; node; node = node->next)
915 Split *s = GNC_SPLIT(node->data);
916 gnc_commodity * sa, * sb;
918 if (s == excl_split)
continue;
920 g_return_val_if_fail (s->acc,
nullptr);
932 if ( (!aa) && bb) rb =
nullptr;
933 else if ( (!ab) && ba) rb =
nullptr;
934 else if ( (!ba) && ab) ra =
nullptr;
935 else if ( (!bb) && aa) ra =
nullptr;
936 else if ( aa && bb && ab && ba )
952 if ( aa && ab ) ra =
nullptr;
958 ra = ( aa && ab ) ?
nullptr : rb;
961 if ((!ra) && (!rb))
return nullptr;
971static gnc_commodity *
972FindCommonCurrency (GList *splits, gnc_commodity * ra, gnc_commodity * rb)
974 return FindCommonExclSCurrency(splits, ra, rb,
nullptr);
977static gnc_commodity *
978xaccTransFindOldCommonCurrency (Transaction *trans,
QofBook *book)
980 gnc_commodity *ra, *rb, *retval;
983 if (!trans)
return nullptr;
985 if (trans->splits ==
nullptr)
return nullptr;
987 g_return_val_if_fail (book,
nullptr);
989 split = GNC_SPLIT(trans->splits->data);
991 if (!split ||
nullptr == split->acc)
return nullptr;
996 retval = FindCommonCurrency (trans->splits, ra, rb);
1010 gnc_commodity *commodity;
1015commodity_equal (gconstpointer a, gconstpointer b)
1018 gnc_commodity *com = (gnc_commodity*)b;
1019 if ( cc ==
nullptr || cc->commodity ==
nullptr ||
1020 !GNC_IS_COMMODITY( cc->commodity ) )
return -1;
1021 if ( com ==
nullptr || !GNC_IS_COMMODITY( com ) )
return 1;
1028commodity_compare( gconstpointer a, gconstpointer b)
1031 if (ca ==
nullptr || ca->commodity ==
nullptr ||
1032 !GNC_IS_COMMODITY( ca->commodity ) )
1034 if (cb ==
nullptr || cb->commodity ==
nullptr ||
1035 !GNC_IS_COMMODITY( cb->commodity ) )
1039 if (cb ==
nullptr || cb->commodity ==
nullptr ||
1040 !GNC_IS_COMMODITY( cb->commodity ) )
1042 if (ca->count == cb->count)
1044 return ca->count > cb->count ? 1 : -1;
1055static gnc_commodity *
1056xaccTransFindCommonCurrency (Transaction *trans,
QofBook *book)
1058 gnc_commodity *com_scratch;
1059 GList *node =
nullptr;
1060 GSList *comlist =
nullptr, *found =
nullptr;
1062 if (!trans)
return nullptr;
1064 if (trans->splits ==
nullptr)
return nullptr;
1066 g_return_val_if_fail (book,
nullptr);
1072 for (node = trans->splits; node; node = node->next)
1074 Split *s = GNC_SPLIT(node->data);
1075 unsigned int curr_weight;
1077 if (s ==
nullptr || s->acc ==
nullptr)
continue;
1087 if (com_scratch ==
nullptr)
continue;
1092 found = g_slist_find_custom(comlist, com_scratch, commodity_equal);
1094 if (comlist ==
nullptr || found ==
nullptr)
1097 count->commodity = com_scratch;
1098 count->count = curr_weight;
1099 comlist = g_slist_append(comlist, count);
1104 count->count += curr_weight;
1107 found = g_slist_sort( comlist, commodity_compare);
1109 if ( found && found->data && (((
CommodityCount*)(found->data))->commodity !=
nullptr))
1115 return xaccTransFindOldCommonCurrency( trans, book );
1124 gnc_commodity *currency;
1146 if (
nullptr == trans->splits)
1148 PWARN (
"Transaction \"%s\" has no splits in it!", trans->description);
1155 PWARN (
"no common transaction currency found for trans=\"%s\" (%s);",
1156 trans->description, guid_str);
1158 for (node = trans->splits; node; node = node->next)
1160 Split *split = GNC_SPLIT(node->data);
1161 if (
nullptr == split->acc)
1163 PWARN (
" split=\"%s\" is not in any account!", split->memo);
1168 PWARN (
"setting to split=\"%s\" account=\"%s\" commodity=\"%s\"",
1182 for (node = trans->splits; node; node = node->next)
1184 Split *sp = GNC_SPLIT(node->data);
1189 gnc_commodity *acc_currency;
1192 if (acc_currency == currency)
1211 PWARN (
"Adjusted split with mismatched values, desc=\"%s\" memo=\"%s\""
1212 " old amount %s %s, new amount %s",
1213 trans->description, sp->memo,
1240 gnc_commodity *commodity;
1242 if (!account)
return;
1246 if (commodity)
return;
1264 PERR (
"Account \"%s\" does not have a commodity!",
1274xaccAccountDeleteOldData (
Account *account)
1276 if (!account)
return;
1282 qof_instance_set_dirty (QOF_INSTANCE (account));
1287scrub_trans_currency_helper (Transaction *t, gpointer data)
1294scrub_account_commodity_helper (
Account *account, gpointer data)
1298 xaccAccountDeleteOldData (account);
1307 xaccAccountTreeForEachTransaction (acc, scrub_trans_currency_helper,
nullptr);
1309 scrub_account_commodity_helper (acc,
nullptr);
1310 gnc_account_foreach_descendant (acc, scrub_account_commodity_helper,
nullptr);
1317check_quote_source (gnc_commodity *com, gpointer data)
1319 gboolean *commodity_has_quote_src = (gboolean *)data;
1326move_quote_source (
Account *account, gpointer data)
1329 gnc_quote_source *quote_source;
1330 gboolean new_style = GPOINTER_TO_INT(data);
1331 const char *source, *tz;
1340 if (!source || !*source)
1363 gboolean new_style = FALSE;
1366 if (!root || !
table)
1372 gnc_commodity_table_foreach_commodity (
table, check_quote_source, &new_style);
1374 move_quote_source(root, GINT_TO_POINTER(new_style));
1375 gnc_account_foreach_descendant (root, move_quote_source,
1376 GINT_TO_POINTER(new_style));
1377 LEAVE(
"Migration done");
1386 GValue v = G_VALUE_INIT;
1389 if (!account)
return;
1393 if (G_VALUE_HOLDS_STRING (&v))
1395 str2 = g_strstrip(g_value_dup_string(&v));
1396 if (strlen(str2) == 0)
1397 qof_instance_slot_delete (QOF_INSTANCE (account),
"notes");
1402 if ((G_VALUE_HOLDS_STRING (&v) &&
1403 strcmp(g_value_get_string (&v),
"false") == 0) ||
1404 (G_VALUE_HOLDS_BOOLEAN (&v) && ! g_value_get_boolean (&v)))
1405 qof_instance_slot_delete (QOF_INSTANCE (account),
"placeholder");
1408 qof_instance_slot_delete_if_empty (QOF_INSTANCE (account),
"hbci");
1417 GValue value_s = G_VALUE_INIT;
1418 gboolean already_scrubbed;
1423 already_scrubbed = (G_VALUE_HOLDS_STRING (&value_s) &&
1424 !g_strcmp0 (g_value_get_string (&value_s),
"true"));
1425 g_value_unset (&value_s);
1427 if (already_scrubbed)
1431 GValue value_b = G_VALUE_INIT;
1432 Account *root = gnc_book_get_root_account (book);
1436 for (ptr = accts; ptr; ptr = g_list_next (ptr))
1438 auto acct = GNC_ACCOUNT(ptr->data);
1441 if (g_strcmp0 (color,
"Not Set") == 0)
1444 g_list_free (accts);
1446 g_value_init (&value_b, G_TYPE_BOOLEAN);
1447 g_value_set_boolean (&value_b, TRUE);
1451 g_value_unset (&value_b);
1458construct_account (
Account *root, gnc_commodity *currency,
const char *accname,
1461 gnc_commodity* root_currency = find_root_currency ();
1464 if (accname && *accname)
1466 if (currency || root_currency)
1478find_root_currency_account_in_list (GList *acc_list)
1480 gnc_commodity* root_currency = find_root_currency();
1481 for (GList *node = acc_list; node; node = g_list_next (node))
1483 Account *acc = GNC_ACCOUNT (node->data);
1484 gnc_commodity *acc_commodity =
nullptr;
1485 if (G_UNLIKELY (!acc))
continue;
1495find_account_matching_name_in_list (GList *acc_list,
const char* accname)
1497 for (GList* node = acc_list; node; node = g_list_next(node))
1499 Account *acc = GNC_ACCOUNT (node->data);
1500 if (G_UNLIKELY (!acc))
continue;
1508xaccScrubUtilityGetOrMakeAccount (
Account *root, gnc_commodity * currency,
1510 gboolean placeholder, gboolean checkname)
1515 g_return_val_if_fail (root,
nullptr);
1519 checkname ? accname : nullptr,
1523 return construct_account (root, currency, accname,
1524 acctype, placeholder);
1526 if (g_list_next(acc_list))
1529 acc = find_root_currency_account_in_list (acc_list);
1532 acc = find_account_matching_name_in_list (acc_list, accname);
1536 acc = GNC_ACCOUNT (acc_list->data);
1538 g_list_free (acc_list);
1546 if(orig == INT64_MAX)
1550 if(time != INT64_MAX)
This is the private header for the account structure.
Account handling public routines.
Account public routines (C++ api)
convert single-entry accounts to clean double-entry
API for Transactions and Splits (journal entries)
Commodity handling public routines.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
void xaccAccountSetColor(Account *acc, const char *str)
Set the account's Color.
const char * xaccAccountGetColor(const Account *acc)
Get the account's color.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to.
GList * gnc_account_get_descendants_sorted(const Account *account)
This function returns a GList containing all the descendants of the specified account,...
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed.
gnc_commodity * gnc_account_get_currency_or_parent(const Account *account)
Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship,...
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
void dxaccAccountSetPriceSrc(Account *acc, const char *src)
Set a string that identifies the Finance::Quote backend that should be used to retrieve online prices...
GList * gnc_account_get_children(const Account *account)
This routine returns a GList of all children accounts of the specified account.
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Set the account's type.
const char * dxaccAccountGetPriceSrc(const Account *acc)
Get a string that identifies the Finance::Quote backend that should be used to retrieve online prices...
Account * xaccMallocAccount(QofBook *book)
Constructor.
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
Set the account's commodity.
@ ACCT_TYPE_ROOT
The hidden root account of an account tree.
void(* QofPercentageFunc)(const char *message, double percent)
The qof_session_load() method causes the QofBook to be made ready to to use with this URL/datastore.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
gnc_quote_source * gnc_quote_source_add_new(const char *source_name, gboolean supported)
Create a new quote source.
const char * gnc_commodity_get_namespace(const gnc_commodity *cm)
Retrieve the namespace for the specified commodity.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
void gnc_commodity_set_quote_flag(gnc_commodity *cm, const gboolean flag)
Set the automatic price quote flag for the specified commodity.
void gnc_commodity_set_quote_source(gnc_commodity *cm, gnc_quote_source *src)
Set the automatic price quote source for the specified commodity.
gnc_quote_source * gnc_quote_source_lookup_by_internal(const char *name)
Given the internal (gnucash or F::Q) name of a quote source, find the data structure identified by th...
void gnc_monetary_list_free(MonetaryList *list)
Free a MonetaryList and all the monetaries it points to.
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
gboolean gnc_commodity_get_quote_flag(const gnc_commodity *cm)
Retrieve the automatic price quote flag for the specified commodity.
void gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz)
Set the automatic price quote timezone for the specified commodity.
gboolean gnc_commodity_is_currency(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
char * qof_print_date(time64 t)
Convenience; calls through to qof_print_date_dmy_buff().
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
Returns the valuation commodity of this transaction.
GDate xaccTransGetDatePostedGDate(const Transaction *trans)
Retrieve the posted date of the transaction.
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
MonetaryList * xaccTransGetImbalance(const Transaction *trans)
The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency ...
GList * gnc_account_lookup_by_type_and_commodity(Account *root, const char *name, GNCAccountType acctype, gnc_commodity *commodity)
Find a direct child account matching name, GNCAccountType, and/or commodity.
gboolean xaccTransIsBalanced(const Transaction *trans)
Returns true if the transaction is balanced according to the rules currently in effect.
#define xaccTransGetGUID(X)
void dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
Set the timezone to be used when interpreting the results from a given Finance::Quote backend.
void xaccTransSetDatePostedSecs(Transaction *trans, time64 secs)
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction,...
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.
gboolean xaccTransUseTradingAccounts(const Transaction *trans)
Determine whether this transaction should use commodity trading accounts.
void xaccAccountSetPlaceholder(Account *acc, gboolean val)
Set the "placeholder" flag for an account.
GList SplitList
GList of Split.
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
gnc_commodity * DxaccAccountGetCurrency(const Account *acc)
const char * dxaccAccountGetQuoteTZ(const Account *acc)
Get the timezone to be used when interpreting the results from a given Finance::Quote backend.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
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...
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
void qof_instance_get_kvp(QofInstance *, GValue *value, unsigned count,...)
Retrieves the contents of a KVP slot into a provided GValue.
void qof_instance_set_kvp(QofInstance *, GValue const *value, unsigned count,...)
Sets a KVP slot to a value from a GValue.
#define PINFO(format, args...)
Print an informational note.
#define DEBUG(format, args...)
Print a debugging message.
#define LEAVE(format, args...)
Print a function exit debugging message.
#define PERR(format, args...)
Log a serious error.
#define PWARN(format, args...)
Log a warning.
#define ENTER(format, args...)
Print a function entry debugging message.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
int gnc_numeric_same(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Equivalence predicate: Convert both a and b to denom using the specified DENOM and method HOW,...
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
void xaccAccountTreeScrubCommodities(Account *acc)
The xaccAccountTreeScrubCommodities will scrub the currency/commodity of all accounts & transactions ...
void xaccTransScrubOrphans(Transaction *trans)
The xaccTransScrubOrphans() method scrubs only the splits in the given transaction.
gboolean gnc_get_ongoing_scrub(void)
The gnc_get_ongoing_scrub () method returns TRUE if a scrub operation is ongoing.
void gnc_set_abort_scrub(gboolean abort)
The gnc_set_abort_scrub () method causes a currently running scrub operation to stop,...
void xaccSplitScrub(Split *split)
The xaccSplitScrub method ensures that if this split has the same commodity and currency,...
void xaccAccountScrubOrphans(Account *acc, QofPercentageFunc percentagefunc)
The xaccAccountScrubOrphans() method performs this scrub only for the indicated account,...
void xaccAccountScrubKvp(Account *account)
Removes empty "notes", "placeholder", and "hbci" KVP slots from Accounts.
void xaccTransScrubCurrency(Transaction *trans)
The xaccTransScrubCurrency method fixes transactions without a common_currency by looking for the mos...
void xaccAccountScrubColorNotSet(QofBook *book)
Remove color slots that have a "Not Set" value, since 2.4.0, fixed in 3.4 This should only be run onc...
void xaccTransScrubSplits(Transaction *trans)
The xacc*ScrubSplits() calls xaccSplitScrub() on each split in the respective structure: transaction,...
void xaccAccountTreeScrubQuoteSources(Account *root, gnc_commodity_table *table)
This routine will migrate the information about price quote sources from the account data structures ...
void xaccAccountScrubCommodity(Account *account)
The xaccAccountScrubCommodity method fixed accounts without a commodity by using the old account curr...
void xaccTransScrubPostedDate(Transaction *trans)
Changes Transaction date_posted timestamps from 00:00 local to 11:00 UTC.
void xaccAccountTreeScrubOrphans(Account *acc, QofPercentageFunc percentagefunc)
The xaccAccountTreeScrubOrphans() method performs this scrub for the indicated account and its childr...
void xaccTransScrubImbalance(Transaction *trans, Account *root, Account *account)
Correct transaction imbalances.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
gboolean xaccSplitDestroy(Split *split)
Destructor.
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.
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.
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.