26 #define __USE_MINGW_ANSI_STDIO 1 30 #include <glib/gi18n.h> 37 #if defined(G_OS_WIN32) && !defined(_MSC_VER) 45 #include <unicode/listformatter.h> 53 #include "gnc-hooks.h" 54 #include "gnc-session.h" 55 #include "engine-helpers.h" 56 #include "gnc-locale-utils.h" 58 #define GNC_PREF_CURRENCY_CHOICE_LOCALE "currency-choice-locale" 59 #define GNC_PREF_CURRENCY_CHOICE_OTHER "currency-choice-other" 60 #define GNC_PREF_CURRENCY_OTHER "currency-other" 61 #define GNC_PREF_REVERSED_ACCTS_NONE "reversed-accounts-none" 62 #define GNC_PREF_REVERSED_ACCTS_CREDIT "reversed-accounts-credit" 63 #define GNC_PREF_REVERSED_ACCTS_INC_EXP "reversed-accounts-incomeexpense" 64 #define GNC_PREF_PRICES_FORCE_DECIMAL "force-price-decimal" 66 using UniStr = icu::UnicodeString;
68 static QofLogModule log_module = GNC_MOD_GUI;
70 static bool auto_decimal_enabled =
false;
71 static int auto_decimal_places = 2;
73 static bool reverse_balance_inited =
false;
79 static char* user_default_currency =
nullptr;
80 static char* user_report_currency =
nullptr;
81 constexpr
int maximum_decimals = 15;
82 constexpr int64_t pow_10[] = {1, 10, 100, 1000, 10000, 100000, 1000000,
83 10000000, 100000000, 1000000000, 10000000000,
84 100000000000, 1000000000000, 10000000000000,
85 100000000000000, 1000000000000000};
88 gnc_normalize_account_separator (
const gchar* separator)
90 char* new_sep=
nullptr;
92 if (!separator || !*separator || g_strcmp0(separator,
"colon") == 0)
93 new_sep = g_strdup (
":");
94 else if (g_strcmp0(separator,
"slash") == 0)
95 new_sep = g_strdup (
"/");
96 else if (g_strcmp0(separator,
"backslash") == 0)
97 new_sep = g_strdup (
"\\");
98 else if (g_strcmp0(separator,
"dash") == 0)
99 new_sep = g_strdup (
"-");
100 else if (g_strcmp0(separator,
"period") == 0)
101 new_sep = g_strdup (
".");
103 new_sep = g_strdup (separator);
114 gnc_configure_account_separator (
void)
117 auto separator = gnc_normalize_account_separator (
string);
119 gnc_set_account_separator(separator);
127 gnc_configure_reverse_balance (
void)
130 reverse_type[i] =
false;
137 else if (
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_CREDIT))
146 PWARN(
"no reversed account preference set, using none");
151 gnc_reverse_balance_init (
void)
153 gnc_configure_reverse_balance ();
154 reverse_balance_inited = TRUE;
158 gnc_reverse_balance (
const Account *account)
160 if (account ==
nullptr)
167 if (!reverse_balance_inited)
168 gnc_reverse_balance_init ();
170 return reverse_type[type];
173 gboolean gnc_using_equity_type_opening_balance_account (QofBook* book)
175 return gnc_features_check_used (book, GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE);
178 void gnc_set_use_equity_type_opening_balance_account (QofBook* book)
184 gnc_get_default_directory (
const char* section)
191 dir = g_strdup (g_get_user_data_dir ());
193 dir = g_strdup (g_get_home_dir ());
200 gnc_set_default_directory (
const char* section,
const char* directory)
206 gnc_get_current_book (
void)
220 gnc_is_new_book (
void)
222 return (!gnc_current_session_exist() ||
226 #define OPTION_TAXUS_NAME "tax_US/name" 227 #define OPTION_TAXUS_TYPE "tax_US/type" 228 #define OLD_OPTION_TAXUS_NAME "book/tax_US/name" 229 #define OLD_OPTION_TAXUS_TYPE "book/tax_US/type" 232 gnc_set_current_book_tax_name_type (gboolean name_changed,
const char* tax_name,
233 gboolean type_changed,
const char* tax_type)
239 auto book = gnc_get_current_book();
240 if ((g_strcmp0 (tax_name,
"") == 0) ||
241 (tax_name ==
nullptr))
243 if ((g_strcmp0 (tax_type,
"Other") == 0) ||
244 (g_strcmp0 (tax_type,
"") == 0) ||
245 (tax_type ==
nullptr))
247 qof_book_set_string_option(book, OPTION_TAXUS_NAME,
nullptr);
248 qof_book_set_string_option(book, OPTION_TAXUS_TYPE,
nullptr);
249 qof_book_option_frame_delete(book,
"tax_US");
253 qof_book_set_string_option(book, OPTION_TAXUS_NAME,
nullptr);
254 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
259 if ((g_strcmp0 (tax_type,
"Other") == 0) ||
260 (g_strcmp0 (tax_type,
"") == 0) ||
261 (tax_type ==
nullptr))
263 qof_book_set_string_option(book, OPTION_TAXUS_TYPE,
nullptr);
264 qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
268 qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
269 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
275 auto book = gnc_get_current_book();
276 if ((g_strcmp0 (tax_name,
"") == 0) ||
277 (tax_name ==
nullptr))
279 if ((g_strcmp0 (tax_type,
"Other") == 0) ||
280 (g_strcmp0 (tax_type,
"") == 0) ||
281 (tax_type ==
nullptr))
283 qof_book_set_string_option(book, OPTION_TAXUS_NAME,
nullptr);
284 qof_book_option_frame_delete(book,
"tax_US");
288 qof_book_set_string_option(book, OPTION_TAXUS_NAME,
nullptr);
293 qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
301 auto book = gnc_get_current_book();
302 if ((g_strcmp0 (tax_type,
"Other") == 0) ||
303 (g_strcmp0 (tax_type,
"") == 0) ||
304 (tax_type ==
nullptr))
306 if ((g_strcmp0 (tax_name,
"") == 0) ||
307 (tax_name ==
nullptr))
309 qof_book_set_string_option(book, OPTION_TAXUS_TYPE,
nullptr);
310 qof_book_option_frame_delete(book,
"tax_US");
314 qof_book_set_string_option(book, OPTION_TAXUS_TYPE,
nullptr);
319 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
326 gnc_get_current_book_tax_name (
void)
328 auto book = gnc_get_current_book();
329 auto tax_name = qof_book_get_string_option(book, OPTION_TAXUS_NAME);
336 const char* old_option_taxus_name =
337 qof_book_get_string_option(book, OLD_OPTION_TAXUS_NAME);
338 if (old_option_taxus_name)
340 char* taxus_name = g_strdup(old_option_taxus_name);
341 const char* old_option_taxus_type =
342 qof_book_get_string_option(book, OLD_OPTION_TAXUS_TYPE);
343 if (old_option_taxus_type)
345 char* taxus_type = g_strdup(old_option_taxus_type);
346 qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
347 qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME,
nullptr);
348 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
349 qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE,
nullptr);
350 qof_book_option_frame_delete(book,
"book/tax_US");
351 qof_book_option_frame_delete(book,
"book");
356 qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
357 qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME,
nullptr);
358 qof_book_option_frame_delete(book,
"book/tax_US");
359 qof_book_option_frame_delete(book,
"book");
362 return qof_book_get_string_option(book, OPTION_TAXUS_NAME);
369 gnc_get_current_book_tax_type (
void)
371 auto book = gnc_get_current_book();
373 qof_book_get_string_option(book, OPTION_TAXUS_TYPE);
380 auto old_option_taxus_type =
381 qof_book_get_string_option(book, OLD_OPTION_TAXUS_TYPE);
382 if (old_option_taxus_type)
384 auto taxus_type = g_strdup(old_option_taxus_type);
385 auto old_option_taxus_name =
386 qof_book_get_string_option(book, OLD_OPTION_TAXUS_NAME);
387 if (old_option_taxus_name)
389 auto taxus_name = g_strdup(old_option_taxus_name);
390 qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
391 qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME,
nullptr);
392 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
393 qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE,
nullptr);
394 qof_book_option_frame_delete(book,
"book/tax_US");
395 qof_book_option_frame_delete(book,
"book");
400 qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
401 qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE,
nullptr);
402 qof_book_option_frame_delete(book,
"book/tax_US");
403 qof_book_option_frame_delete(book,
"book");
406 return qof_book_get_string_option(book, OPTION_TAXUS_TYPE);
413 gnc_get_current_root_account (
void)
415 return gnc_book_get_root_account (gnc_get_current_book ());
418 gnc_commodity_table *
419 gnc_get_current_commodities (
void)
421 if (gnc_current_session_exist())
428 gboolean show_leaf_accounts)
430 if (show_leaf_accounts)
439 auto show_leaf_accounts =
441 GNC_PREF_SHOW_LEAF_ACCT_NAMES);
449 auto show_leaf_accounts =
451 GNC_PREF_SHOW_LEAF_ACCT_NAMES);
453 if (show_leaf_accounts)
467 gnc_get_reconcile_str (
char reconciled_flag)
469 switch (reconciled_flag)
472 return C_(
"Reconciled flag 'not cleared'",
"n");
474 return C_(
"Reconciled flag 'cleared'",
"c");
476 return C_(
"Reconciled flag 'reconciled'",
"y");
478 return C_(
"Reconciled flag 'frozen'",
"f");
480 return C_(
"Reconciled flag 'void'",
"v");
482 PERR(
"Bad reconciled flag\n");
494 gnc_get_reconcile_valid_flags (
void)
508 gnc_get_reconcile_flag_order (
void)
510 static const char flags[] = {
NREC,
CREC, 0 };
520 return C_(
"Document Link flag for 'web'",
"w");
522 return C_(
"Document Link flag for 'file'",
"f");
526 PERR(
"Bad link flag");
534 static const char flags[] = { FLINK, WLINK,
' ', 0 };
541 static const char flags[] = { FLINK, WLINK,
' ', 0 };
546 equity_base_name (GNCEquityType equity_type)
550 case EQUITY_OPENING_BALANCE:
551 return N_(
"Opening Balances");
553 case EQUITY_RETAINED_EARNINGS:
554 return N_(
"Retained Earnings");
562 gnc_find_or_create_equity_account (
Account *root,
563 GNCEquityType equity_type,
564 gnc_commodity *currency)
566 g_return_val_if_fail (equity_type >= 0,
nullptr);
567 g_return_val_if_fail (equity_type < NUM_EQUITY_TYPES,
nullptr);
568 g_return_val_if_fail (currency !=
nullptr,
nullptr);
569 g_return_val_if_fail (root !=
nullptr,
nullptr);
572 auto use_eq_op_feature = equity_type == EQUITY_OPENING_BALANCE && gnc_using_equity_type_opening_balance_account (gnc_get_current_book ());
574 if (use_eq_op_feature)
581 auto base_name = equity_base_name (equity_type);
589 base_name = base_name && *base_name ? _(base_name) :
"";
596 auto base_name_exists = (account !=
nullptr);
601 if (use_eq_op_feature)
606 auto name = g_strconcat (base_name,
" - ",
612 auto name_exists = (account !=
nullptr);
617 if (use_eq_op_feature)
623 if (name_exists && base_name_exists)
625 PWARN (
"equity account with unexpected currency");
630 if (!base_name_exists &&
634 name = g_strdup (base_name);
650 if (use_eq_op_feature)
665 gnc_account_create_opening_balance (
Account *account,
673 g_return_val_if_fail (account !=
nullptr, FALSE);
677 auto equity_account =
679 EQUITY_OPENING_BALANCE,
724 auto table = gnc_get_current_commodities ();
725 auto code = gnc_locale_default_iso_currency_code ();
727 auto currency = gnc_commodity_table_lookup (
table,
728 GNC_COMMODITY_NS_CURRENCY,
731 return (currency ? currency :
nullptr);
739 return (currency ? currency :
740 gnc_commodity_table_lookup (gnc_get_current_commodities (),
741 GNC_COMMODITY_NS_CURRENCY,
"USD"));
745 static gnc_commodity*
746 gnc_default_currency_common (
char* requested_currency,
749 gnc_commodity *currency =
nullptr;
751 if (requested_currency)
752 return gnc_commodity_table_lookup(gnc_get_current_commodities(),
753 GNC_COMMODITY_NS_CURRENCY,
756 if (gnc_current_session_exist() &&
760 currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
761 GNC_COMMODITY_NS_CURRENCY,
763 DEBUG(
"mnemonic %s, result %p",
764 mnemonic && *mnemonic ? mnemonic :
"(null)", currency);
773 g_free (requested_currency);
782 return gnc_default_currency_common (user_default_currency,
783 GNC_PREFS_GROUP_GENERAL);
788 gboolean * currency_from_account_found)
790 gnc_commodity *currency;
793 if (currency_from_account_found)
794 *currency_from_account_found = FALSE;
801 if (currency_from_account_found)
802 *currency_from_account_found = TRUE;
806 if (currency_from_account_found)
807 *currency_from_account_found = FALSE;
818 return gnc_default_currency_common (user_report_currency,
819 GNC_PREFS_GROUP_GENERAL_REPORT);
823 gnc_currency_changed_cb (GSettings *settings,
char* key, gpointer user_data)
825 user_default_currency =
nullptr;
826 user_report_currency =
nullptr;
827 gnc_hook_run(HOOK_CURRENCY_CHANGED,
nullptr);
832 gnc_default_print_info (gboolean use_symbol)
835 static bool got_it =
false;
838 info.use_symbol = use_symbol ? 1 : 0;
844 auto lc = gnc_localeconv ();
846 info.max_decimal_places = lc->frac_digits;
847 info.min_decimal_places = lc->frac_digits;
849 info.use_separators = 1;
861 is_decimal_fraction (
int fraction, uint8_t *max_decimal_places_p)
863 uint8_t max_decimal_places = 0;
868 while (fraction != 1)
870 if (fraction % 10 != 0)
873 fraction = fraction / 10;
874 max_decimal_places += 1;
877 if (max_decimal_places_p)
878 *max_decimal_places_p = max_decimal_places;
884 gnc_commodity_print_info (
const gnc_commodity *commodity,
889 if (commodity ==
nullptr)
890 return gnc_default_print_info (use_symbol);
892 info.commodity = commodity;
897 &info.max_decimal_places))
900 info.min_decimal_places = info.max_decimal_places;
902 info.min_decimal_places = 0;
905 info.max_decimal_places = info.min_decimal_places = 0;
907 info.use_separators = 1;
908 info.use_symbol = use_symbol ? 1 : 0;
909 info.use_locale = is_iso ? 1 : 0;
918 gnc_account_print_info_helper(
const Account *account, gboolean use_symbol,
919 gnc_commodity * (*efffunc)(
const Account *),
920 int (*scufunc)(
const Account*))
924 if (account ==
nullptr)
925 return gnc_default_print_info (use_symbol);
927 info.commodity = efffunc (account);
931 auto scu = scufunc (account);
933 if (is_decimal_fraction (scu, &info.max_decimal_places))
936 info.min_decimal_places = info.max_decimal_places;
938 info.min_decimal_places = 0;
941 info.max_decimal_places = info.min_decimal_places = 0;
943 info.use_separators = 1;
944 info.use_symbol = use_symbol ? 1 : 0;
945 info.use_locale = is_iso ? 1 : 0;
954 gnc_account_print_info (
const Account *account, gboolean use_symbol)
956 return gnc_account_print_info_helper(account, use_symbol,
962 gnc_split_amount_print_info (Split *split, gboolean use_symbol)
967 info.use_symbol = use_symbol;
975 gnc_default_print_info_helper (
int decplaces)
979 info.commodity =
nullptr;
981 info.max_decimal_places = decplaces;
982 info.min_decimal_places = 0;
984 info.use_separators = 1;
995 gnc_default_share_print_info (
void)
998 static bool got_it =
false;
1002 info = gnc_default_print_info_helper (5);
1011 gnc_share_print_info_places (
int decplaces)
1015 info = gnc_default_share_print_info ();
1016 info.max_decimal_places = decplaces;
1017 info.min_decimal_places = decplaces;
1024 gnc_price_print_info (
const gnc_commodity *curr, gboolean use_symbol)
1028 GNC_PREF_PRICES_FORCE_DECIMAL);
1029 info.commodity = curr;
1034 guint8 decplaces = 2;
1035 while (frac != 1 && (frac % 10) == 0 && (frac /= 10)) ++decplaces;
1036 info.max_decimal_places = decplaces;
1037 info.min_decimal_places = decplaces;
1041 info.max_decimal_places = 6;
1042 info.min_decimal_places = 0;
1045 info.use_separators = 1;
1046 info.use_symbol = use_symbol ? 1 : 0;
1047 info.use_locale = 1;
1050 info.force_fit = force;
1056 gnc_default_price_print_info (
const gnc_commodity *curr)
1058 return gnc_price_print_info (curr, FALSE);
1063 gnc_integral_print_info (
void)
1066 static bool got_it =
false;
1070 info = gnc_default_print_info_helper (0);
1081 auto *lc = gnc_localeconv();
1082 constexpr
size_t buf_size = 128;
1083 char temp_buf[buf_size];
1085 g_return_val_if_fail (info !=
nullptr, 0);
1089 PWARN (
"Bad numeric: %s.",
1101 if (!value_is_decimal && info->force_fit && info->round)
1108 const int64_t denom = info->commodity ?
1110 (info->max_decimal_places &&
1111 info->max_decimal_places <= maximum_decimals) ?
1112 pow_10[info->max_decimal_places] : pow_10[maximum_decimals];
1116 auto min_dp = info->min_decimal_places;
1117 auto max_dp = info->max_decimal_places;
1121 if (!info->force_fit)
1125 if (value_is_decimal && info->round && info->force_fit)
1128 gnc_numeric rounding{5, pow_10[max_dp + 1]};
1135 PWARN (
"Bad numeric from rounding: %s.",
1147 PWARN (
"Problem with remainder: %s.",
1156 snprintf(temp_buf, buf_size,
"%" G_GINT64_FORMAT, whole.num);
1157 auto num_whole_digits = strlen (temp_buf);
1159 if (!info->use_separators)
1160 strcpy (buf, temp_buf);
1168 separator = lc->mon_thousands_sep;
1169 group = lc->mon_grouping;
1173 separator = lc->thousands_sep;
1174 group = lc->grouping;
1178 auto temp_ptr = &temp_buf[num_whole_digits - 1];
1179 auto group_count = 0;
1181 while (temp_ptr != temp_buf)
1183 *buf_ptr++ = *temp_ptr--;
1185 if (*group != CHAR_MAX)
1189 if (group_count == *group)
1191 g_utf8_strncpy(buf_ptr, separator, 1);
1192 buf_ptr = g_utf8_find_next_char(buf_ptr,
nullptr);
1214 *buf_ptr++ = *temp_ptr;
1216 auto rev_buf = g_utf8_strreverse(buf, -1);
1217 strcpy (buf, rev_buf);
1224 if (!value_is_decimal)
1229 snprintf (temp_buf, buf_size,
"%" G_GINT64_FORMAT
"/%" G_GINT64_FORMAT,
1230 val.num, val.denom);
1232 snprintf (temp_buf, buf_size,
"%" G_GINT64_FORMAT
" * %" G_GINT64_FORMAT,
1233 val.num, -val.denom);
1237 else if (value_is_negative)
1242 strcat (buf, temp_buf);
1246 guint8 num_decimal_places = 0;
1247 char* temp_ptr = temp_buf;
1249 auto decimal_point = info->monetary
1250 ? lc->mon_decimal_point
1251 : lc->decimal_point;
1252 g_utf8_strncpy(temp_ptr, decimal_point, 1);
1253 temp_ptr = g_utf8_find_next_char(temp_ptr,
nullptr);
1257 && (num_decimal_places < max_dp))
1261 val.denom = val.denom / 10;
1263 digit = val.num / val.denom;
1265 *temp_ptr++ = digit +
'0';
1266 num_decimal_places++;
1268 val.num = val.num - (digit * val.denom);
1271 while (num_decimal_places < min_dp)
1274 num_decimal_places++;
1281 while (*temp_ptr ==
'0' && num_decimal_places > min_dp)
1284 num_decimal_places--;
1287 if (num_decimal_places > max_dp)
1289 PWARN (
"max_decimal_places too small; limit %d, value %s%s",
1290 info->max_decimal_places, buf, temp_buf);
1293 if (num_decimal_places > 0)
1294 strcat (buf, temp_buf);
1306 auto orig_bufp = bufp;
1307 auto currency_symbol =
"";
1314 bool print_sign =
true;
1315 bool print_absolute =
false;
1320 auto lc = gnc_localeconv();
1321 if (info.use_locale)
1324 cs_precedes = lc->n_cs_precedes;
1325 sep_by_space = lc->n_sep_by_space;
1329 cs_precedes = lc->p_cs_precedes;
1330 sep_by_space = lc->p_sep_by_space;
1335 sep_by_space = TRUE;
1338 if (info.commodity && info.use_symbol)
1343 cs_precedes = FALSE;
1344 sep_by_space = TRUE;
1350 sign = lc->negative_sign;
1351 sign_posn = lc->n_sign_posn;
1355 sign = lc->positive_sign;
1356 sign_posn = lc->p_sign_posn;
1363 if (print_sign && (sign_posn == 1))
1364 bufp = g_stpcpy(bufp, sign);
1370 if (print_sign && (sign_posn == 3))
1371 bufp = g_stpcpy(bufp, sign);
1373 if (info.use_symbol)
1375 bufp = g_stpcpy(bufp, currency_symbol);
1377 bufp = g_stpcpy(bufp,
" ");
1381 if (print_sign && (sign_posn == 4))
1382 bufp = g_stpcpy(bufp, sign);
1386 if (print_sign && (sign_posn == 0))
1388 bufp = g_stpcpy(bufp,
"(");
1389 print_absolute = TRUE;
1393 bufp += PrintAmountInternal(bufp,
1398 if (print_sign && (sign_posn == 0))
1399 bufp = g_stpcpy(bufp,
")");
1405 if (print_sign && (sign_posn == 3))
1406 bufp = g_stpcpy(bufp, sign);
1408 if (info.use_symbol)
1411 bufp = g_stpcpy(bufp,
" ");
1412 bufp = g_stpcpy(bufp, currency_symbol);
1416 if (print_sign && (sign_posn == 4))
1417 bufp = g_stpcpy(bufp, sign);
1421 if (print_sign && (sign_posn == 2))
1422 bufp = g_stpcpy(bufp, sign);
1425 return (bufp - orig_bufp);
1434 static char buf[BUFLEN];
1447 static char buf[BUFLEN];
1448 static const char ltr_isolate[] = {
'\xe2',
'\x81',
'\xa6' };
1449 static const char ltr_pop_isolate[] = {
'\xe2',
'\x81',
'\xa9' };
1450 auto offset = info.use_symbol ? 3 : 0;
1455 memset (buf, 0, BUFLEN);
1465 memcpy (buf, ltr_isolate, 3);
1467 if (buf[BUFLEN - 4] ==
'\0')
1469 auto length = strlen (buf);
1470 memcpy (buf + length, ltr_pop_isolate, 3);
1474 buf[BUFLEN - 1] =
'\0';
1475 memcpy (buf + BUFLEN - 4, ltr_pop_isolate, 3);
1477 PWARN(
"buffer length %d exceeded, string truncated was %s", BUFLEN, buf);
1487 static const char* ltr =
"\u2066";
1488 static const char* pop =
"\u2069";
1493 return g_strconcat (ltr, text, pop,
nullptr);
1499 #define FUDGE .00001 1509 static const char* small_numbers[] =
1517 "Zero",
"One",
"Two",
"Three",
"Four",
1518 "Five",
"Six",
"Seven",
"Eight",
"Nine",
1519 "Ten",
"Eleven",
"Twelve",
"Thirteen",
"Fourteen",
1520 "Fifteen",
"Sixteen",
"Seventeen",
"Eighteen",
"Nineteen",
1523 static const char* medium_numbers[] =
1525 "Zero",
"Ten",
"Twenty",
"Thirty",
"Forty",
1526 "Fifty",
"Sixty",
"Seventy",
"Eighty",
"Ninety" 1528 static const char* big_numbers[] =
1553 integer_to_words(gint64 val)
1556 return g_strdup(
"zero");
1560 auto result = g_string_sized_new(100);
1564 int log_val = log10(val) / 3 + FUDGE;
1565 int pow_val = exp(log_val * 3 * G_LN10) + FUDGE;
1566 int this_part = val / pow_val;
1567 val -= this_part * pow_val;
1568 auto tmp = integer_to_words(this_part);
1569 g_string_append_printf(result,
"%s %s ", tmp, gettext(big_numbers[log_val]));
1575 int this_part = val / 100;
1576 val -= this_part * 100;
1577 g_string_append_printf(result,
"%s %s ",
1578 gettext(small_numbers[this_part]),
1579 gettext(big_numbers[0]));
1584 int this_part = val / 10;
1585 val -= this_part * 10;
1586 g_string_append(result, gettext(medium_numbers[this_part]));
1587 g_string_append_c(result,
' ');
1592 int this_part = val;
1593 g_string_append(result, gettext(small_numbers[this_part]));
1594 g_string_append_c(result,
' ');
1597 result = g_string_truncate(result, result->len - 1);
1598 return g_string_free(result, FALSE);
1602 static double round(
double x)
1605 return floor(x + 0.5);
1610 number_to_words(
double val, int64_t denom)
1612 if (val < 0) val = -val;
1613 if (denom < 0) denom = -denom;
1615 auto int_part = floor(val);
1616 auto frac_part =
static_cast<int64_t
>(round((val - int_part) * denom));
1618 auto int_string = integer_to_words(int_part);
1622 auto nomin_string = g_strdup_printf(
"%02" PRId64, frac_part);
1623 auto denom_string = g_strdup_printf(
"%" PRId64, denom);
1629 g_strdup_printf(
"%s and %s/%s",
1630 int_string, nomin_string, denom_string);
1632 g_free(nomin_string);
1633 g_free(denom_string);
1638 numeric_to_words(gnc_numeric val)
1641 gnc_numeric_denom(val));
1645 printable_value (
double val,
int denom)
1647 auto num = gnc_numeric_create(round(val * denom), denom);
1648 auto info = gnc_share_print_info_places(log10(denom));
1675 #define done_state(state) (((state) == DONE_ST) || ((state) == NO_NUM_ST)) 1677 static inline int64_t
1678 multiplier (
int num_decimals)
1680 switch (num_decimals)
1683 return 1000000000000;
1685 return 100000000000;
1709 PERR(
"bad fraction length");
1710 g_assert_not_reached();
1718 xaccParseAmountInternal (
const char* in_str, gboolean monetary,
1719 gunichar negative_sign, gunichar decimal_point,
1720 gunichar group_separator,
const char* ignore_list,
1721 gboolean use_auto_decimal,
1722 gnc_numeric *result,
char** endstr)
1726 *endstr = (
char* ) in_str;
1732 if (!g_utf8_validate(in_str, -1, &in))
1734 printf(
"Invalid utf8 string '%s'. Bad character at position %ld.\n",
1735 in_str, g_utf8_pointer_to_offset (in_str, in));
1741 auto out_str = g_new(gchar, strlen(in_str) + 128);
1747 auto is_negative =
false;
1748 auto got_decimal =
false;
1749 auto need_paren =
false;
1754 auto state = START_ST;
1759 auto next_state = state;
1760 auto uc = g_utf8_get_char(in);
1763 if (ignore_list && uc && g_utf8_strchr(ignore_list, -1, uc))
1765 in = g_utf8_next_char(in);
1775 if (g_unichar_isdigit(uc))
1777 int count = g_unichar_to_utf8(uc, out);
1780 next_state = NUMER_ST;
1782 else if (uc == decimal_point)
1783 next_state = FRAC_ST;
1784 else if (g_unichar_isspace(uc))
1786 else if (uc == negative_sign)
1789 next_state = NEG_ST;
1795 next_state = NEG_ST;
1798 next_state = NO_NUM_ST;
1805 if (g_unichar_isdigit(uc))
1807 int count = g_unichar_to_utf8(uc, out);
1809 next_state = NUMER_ST;
1811 else if (uc == decimal_point)
1812 next_state = FRAC_ST;
1813 else if (g_unichar_isspace(uc))
1816 next_state = NO_NUM_ST;
1823 if (g_unichar_isdigit(uc))
1825 int count = g_unichar_to_utf8(uc, out);
1828 else if (uc == decimal_point)
1829 next_state = FRAC_ST;
1830 else if (uc == group_separator)
1832 else if (uc ==
')' && need_paren)
1834 next_state = DONE_ST;
1838 next_state = DONE_ST;
1844 if (g_unichar_isdigit(uc))
1846 int count = g_unichar_to_utf8(uc, out);
1849 else if (uc == decimal_point)
1854 if (g_unichar_isspace(decimal_point))
1855 next_state = DONE_ST;
1857 next_state = NO_NUM_ST;
1859 else if (uc == group_separator)
1864 if (g_unichar_isspace(group_separator))
1865 next_state = DONE_ST;
1867 else if (uc ==
')' && need_paren)
1869 next_state = DONE_ST;
1873 next_state = DONE_ST;
1879 g_assert_not_reached();
1885 if (((next_state == FRAC_ST) && (state != FRAC_ST)) ||
1886 ((next_state == DONE_ST) && !got_decimal))
1890 if (*out_str && sscanf(out_str,
"%" SCNd64, &numer) < 1)
1891 next_state = NO_NUM_ST;
1892 else if (next_state == FRAC_ST)
1903 if (done_state (state))
1906 in = g_utf8_next_char(in);
1910 if (need_paren || (state == NO_NUM_ST))
1920 if (got_decimal && *out_str)
1923 auto len = strlen(out_str);
1932 if (sscanf (out_str,
"%" SCNd64 , &fraction) < 1)
1938 denom = multiplier(len);
1942 else if (monetary && use_auto_decimal && !got_decimal)
1944 if ((auto_decimal_places > 0) && (auto_decimal_places <= 12))
1946 denom = multiplier(auto_decimal_places);
1958 *result = gnc_numeric_create (numer, denom);
1964 *endstr = (
char* ) in;
1973 xaccParseAmountBasicInternal (
const char* in_str, gboolean monetary,
1974 gboolean use_auto_decimal, gnc_numeric *result,
1975 char** endstr, gboolean skip)
1977 struct lconv *lc = gnc_localeconv();
1978 gunichar negative_sign = g_utf8_get_char(lc->negative_sign);
1980 gunichar decimal_point;
1981 gunichar group_separator;
1984 group_separator = g_utf8_get_char(lc->mon_thousands_sep);
1985 decimal_point = g_utf8_get_char(lc->mon_decimal_point);
1989 group_separator = g_utf8_get_char(lc->thousands_sep);
1990 decimal_point = g_utf8_get_char(lc->decimal_point);
1993 const char* ignore =
nullptr;
1999 ignore = lc->positive_sign;
2000 if (!ignore || !*ignore)
2004 return xaccParseAmountInternal(in_str, monetary, negative_sign,
2005 decimal_point, group_separator,
2006 ignore, use_auto_decimal,
2015 return xaccParseAmountBasicInternal (in_str, monetary, auto_decimal_enabled,
2016 result, endstr, FALSE);
2021 gnc_numeric *result,
2022 char** endstr, gboolean skip)
2024 return xaccParseAmountBasicInternal (in_str, monetary, FALSE,
2025 result, endstr, skip);
2031 gunichar negative_sign, gunichar decimal_point,
2032 gunichar group_separator,
const char* ignore_list,
2033 gnc_numeric *result,
char** endstr)
2035 return xaccParseAmountInternal (in_str, monetary, negative_sign,
2036 decimal_point, group_separator,
2037 ignore_list, auto_decimal_enabled,
2043 gunichar negative_sign, gunichar decimal_point,
2044 gunichar group_separator,
const char* ignore_list,
2045 gnc_numeric *result,
char** endstr)
2047 return xaccParseAmountInternal (in_str, monetary, negative_sign,
2048 decimal_point, group_separator,
2056 gnc_set_auto_decimal_enabled (gpointer settings,
char* key, gpointer user_data)
2058 auto_decimal_enabled =
2064 gnc_set_auto_decimal_places (gpointer settings,
char* key, gpointer user_data)
2066 auto_decimal_places =
2071 gnc_auto_decimal_init (
void)
2073 auto_decimal_enabled =
2075 auto_decimal_places =
2080 gnc_ui_util_init (
void)
2082 gnc_configure_account_separator ();
2083 gnc_auto_decimal_init();
2086 (
void*)gnc_configure_account_separator,
nullptr);
2088 (
void*)gnc_configure_reverse_balance,
nullptr);
2090 (
void*)gnc_configure_reverse_balance,
nullptr);
2092 (
void*)gnc_configure_reverse_balance,
nullptr);
2094 (
void*)gnc_currency_changed_cb,
nullptr);
2096 (
void*)gnc_currency_changed_cb,
nullptr);
2098 (
void*)gnc_currency_changed_cb,
nullptr);
2100 (
void*)gnc_currency_changed_cb,
nullptr);
2102 (
void*)gnc_currency_changed_cb,
nullptr);
2104 (
void*)gnc_currency_changed_cb,
nullptr);
2106 (
void*)gnc_set_auto_decimal_enabled,
nullptr);
2108 (
void*)gnc_set_auto_decimal_places,
nullptr);
2113 gnc_ui_util_remove_registered_prefs (
void)
2117 GNC_PREF_ACCOUNT_SEPARATOR,
2118 (
void*)gnc_configure_account_separator,
nullptr);
2120 GNC_PREF_REVERSED_ACCTS_NONE,
2121 (
void*)gnc_configure_reverse_balance,
nullptr);
2123 GNC_PREF_REVERSED_ACCTS_CREDIT,
2124 (
void*)gnc_configure_reverse_balance,
nullptr);
2126 GNC_PREF_REVERSED_ACCTS_INC_EXP,
2127 (
void*)gnc_configure_reverse_balance,
nullptr);
2129 GNC_PREF_CURRENCY_CHOICE_LOCALE,
2130 (
void*)gnc_currency_changed_cb,
nullptr);
2132 GNC_PREF_CURRENCY_CHOICE_OTHER,
2133 (
void*)gnc_currency_changed_cb,
nullptr);
2135 GNC_PREF_CURRENCY_OTHER,
2136 (
void*)gnc_currency_changed_cb,
nullptr);
2138 GNC_PREF_CURRENCY_CHOICE_LOCALE,
2139 (
void*)gnc_currency_changed_cb,
nullptr);
2141 GNC_PREF_CURRENCY_CHOICE_OTHER,
2142 (
void*)gnc_currency_changed_cb,
nullptr);
2144 GNC_PREF_CURRENCY_OTHER,
2145 (
void*)gnc_currency_changed_cb,
nullptr);
2147 GNC_PREF_AUTO_DECIMAL_POINT,
2148 (
void*)gnc_set_auto_decimal_enabled,
nullptr);
2150 GNC_PREF_AUTO_DECIMAL_PLACES,
2151 (
void*)gnc_set_auto_decimal_places,
nullptr);
2155 unichar_is_cntrl (gunichar uc)
2157 return (uc < 0x20 || (uc > 0x7e && uc < 0xa0));
2164 bool text_found =
false;
2169 if (!g_utf8_validate (text, -1,
nullptr))
2172 auto filtered = g_string_sized_new (strlen (text) + 1);
2178 auto uc = g_utf8_get_char (ch);
2181 if (unichar_is_cntrl (uc) && !text_found)
2183 ch = g_utf8_next_char (ch);
2187 if (!unichar_is_cntrl (uc))
2189 filtered = g_string_append_unichar (filtered, uc);
2193 if (unichar_is_cntrl (uc))
2196 ch = g_utf8_next_char (ch);
2200 auto uc2 = g_utf8_get_char (ch);
2202 if (!unichar_is_cntrl (uc2))
2203 filtered = g_string_append_unichar (filtered,
' ');
2207 return g_string_free (filtered, FALSE);
2213 gint *cursor_position)
2217 if (*cursor_position == 0)
2220 if (!incoming_text || !symbol)
2223 if (g_strrstr (incoming_text, symbol) ==
nullptr)
2226 auto text_len = g_utf8_strlen (incoming_text, -1);
2228 for (
int x = 0; x < text_len; x++)
2230 auto temp = g_utf8_offset_to_pointer (incoming_text, x);
2232 if (g_str_has_prefix (temp, symbol))
2235 if (g_strrstr (temp, symbol) ==
nullptr)
2238 *cursor_position = *cursor_position - (num * g_utf8_strlen (symbol, -1));
2249 return g_strdup (incoming_text);
2251 if (g_strrstr (incoming_text, symbol) ==
nullptr)
2252 return g_strdup (incoming_text);
2254 auto split = g_strsplit (incoming_text, symbol, -1);
2256 auto ret_text = g_strjoinv (
nullptr, split);
2264 const char* incoming_text,
2265 const char** symbol)
2276 return g_strdup (incoming_text);
2290 g_return_val_if_fail (strings,
nullptr);
2292 UErrorCode status = U_ZERO_ERROR;
2293 auto formatter = icu::ListFormatter::createInstance(status);
2294 std::vector<UniStr> strvec;
2298 for (
auto n = strings; n; n = g_list_next (n))
2300 auto utf8_str{
static_cast<const char*
>(n->data)};
2301 strvec.push_back (UniStr::fromUTF8(utf8_str));
2304 formatter->format (strvec.data(), strvec.size(), result, status);
2306 if (U_FAILURE(status))
2307 PERR (
"Unicode error");
2309 result.toUTF8String(retval);
2312 return g_strdup (retval.c_str());
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Set the account's type.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
Never round at all, and signal an error if there is a fractional result in a computation.
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
gboolean xaccParseAmount(const char *in_str, gboolean monetary, gnc_numeric *result, char **endstr)
Parses in_str to obtain a numeric result.
gboolean xaccParseAmountImport(const char *in_str, gboolean monetary, gnc_numeric *result, char **endstr, gboolean skip)
Similar to xaccParseAmount, but with two differences.
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
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...
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
gnc_commodity * gnc_locale_default_currency_nodefault(void)
Returns the default currency of the current locale, or NULL if no sensible currency could be identifi...
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
const char * gnc_print_amount_with_bidi_ltr_isolate(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
utility functions for the GnuCash UI
Expense accounts are used to denote expenses.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
#define DEBUG(format, args...)
Print a debugging message.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
char * gnc_wrap_text_with_bidi_ltr_isolate(const char *text)
This function helps with GTK's use of 'Unicode Bidirectional Text Algorithm'.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
gboolean gnc_numeric_to_decimal(gnc_numeric *a, guint8 *max_decimal_places)
Attempt to convert the denominator to an exact power of ten without rounding.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
stop here; the following types just aren't ready for prime time
char * gnc_filter_text_for_currency_commodity(const gnc_commodity *comm, const char *incoming_text, const char **symbol)
Returns the incoming text removed of currency symbol.
Use any denominator which gives an exactly correct ratio of numerator to denominator.
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
Store a string into the preferences backend.
#define PERR(format, args...)
Log a serious error.
gnc_commodity * gnc_default_report_currency(void)
Return the default currency for use in reports, as set by the user.
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
#define VREC
split is void
gnc_numeric gnc_numeric_reduce(gnc_numeric in)
Return input after reducing it by Greater Common Factor (GCF) elimination.
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the s...
#define PWARN(format, args...)
Log a warning.
gboolean xaccParseAmountExtImport(const char *in_str, gboolean monetary, gunichar negative_sign, gunichar decimal_point, gunichar group_separator, const char *ignore_list, gnc_numeric *result, char **endstr)
Similar to xaccParseAmountExtended, but will not automatically set a decimal point, regardless of what the user has set for this option.
char * gnc_get_account_name_for_register(const Account *account)
Get either the full name of the account or the simple name, depending on the configuration parameter ...
double gnc_numeric_to_double(gnc_numeric in)
Convert numeric to floating-point value.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
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...
Account handling public routines.
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 '...
Income accounts are used to denote income.
#define YREC
The Split has been reconciled.
char * gnc_get_account_name_for_split_register(const Account *account, gboolean show_leaf_accounts)
Get either the full name of the account or the simple name, depending on the show_leaf_accounts.
const char * gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
Returns a string representation of the given GNCNumericErrorCode.
const char * gnc_get_doclink_flag_order(void)
Get a string containing document link flag order.
#define FREC
frozen into accounting period
gboolean xaccParseAmountExtended(const char *in_str, gboolean monetary, gunichar negative_sign, gunichar decimal_point, gunichar group_separator, const char *ignore_list, gnc_numeric *result, char **endstr)
Converts a string to a gnc_numeric.
void gnc_filter_text_set_cursor_position(const char *incoming_text, const char *symbol, int *zcursor_position)
Updates cursor_position after removal of currency symbols.
gchar * gnc_list_formatter(GList *strings)
This function takes a GList of char*, and uses locale-sensitive list formatter.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
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...
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
void xaccAccountSetIsOpeningBalance(Account *acc, gboolean val)
Set the "opening-balance" flag for an account.
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
gint gnc_account_n_children(const Account *account)
Return the number of children of the specified account.
All type declarations for the whole Gnucash engine.
#define CREC
The Split has been cleared.
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
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.
Split * xaccMallocSplit(QofBook *book)
Constructor.
char * gnc_filter_text_for_control_chars(const char *text)
Returns the incoming text removed of control characters.
Account * gnc_account_lookup_for_register(const Account *base_account, const char *name)
Retrieve the account matching the given name starting from the descendants of base_account.
Generic api to store and retrieve preferences.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
gnc_commodity * gnc_account_or_default_currency(const Account *account, gboolean *currency_from_account_found)
Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.
char * gnc_filter_text_for_currency_symbol(const char *incoming_text, const char *symbol)
Returns the incoming text removed of a currency symbol.
Truncate fractions (round toward zero)
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
Account * xaccMallocAccount(QofBook *book)
Constructor.
const char * gnc_get_doclink_str(char link_flag)
Get a string representing the document link type.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
const char * gnc_get_doclink_valid_flags(void)
Get a string containing documentation link valid flags.
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to...
Account * gnc_account_lookup_by_opening_balance(Account *account, gnc_commodity *commodity)
Find the opening balance account for the currency.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Equity account is used to balance the balance sheet.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
API for Transactions and Splits (journal entries)
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
gnc_commodity * gnc_locale_default_currency(void)
Returns the default currency of the current locale.
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
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_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.
The Credit card account is used to denote credit (e.g.
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
Set the account's commodity.
#define NREC
not reconciled or cleared
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.
Utility functions for file access.