mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
rename string_to_gnc_numeric to gnc_numeric_from_string
This commit is contained in:
parent
75f6ee1817
commit
7ce4198c20
@ -49,8 +49,8 @@ from gnucash.gnucash_core_c import gncInvoiceLookup, gncInvoiceGetInvoiceFromTxn
|
||||
gnc_search_customer_on_id, gnc_search_bill_on_id , \
|
||||
gnc_search_vendor_on_id, gncInvoiceNextID, gncCustomerNextID, \
|
||||
gncVendorNextID, gncTaxTableGetTables, gnc_numeric_zero, \
|
||||
gnc_numeric_create, double_to_gnc_numeric, string_to_gnc_numeric, \
|
||||
gnc_numeric_to_string
|
||||
gnc_numeric_create, double_to_gnc_numeric, gnc_numeric_from_string, \
|
||||
gnc_numeric_to_string, gnc_numeric_check
|
||||
|
||||
from gnucash.deprecation import (
|
||||
deprecated_args_session,
|
||||
@ -432,8 +432,8 @@ class GncNumeric(GnuCashCoreClass):
|
||||
elif isinstance(arg, float):
|
||||
return double_to_gnc_numeric(arg, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER)
|
||||
elif isinstance(arg, str):
|
||||
instance = gnc_numeric_zero()
|
||||
if not string_to_gnc_numeric(arg, instance):
|
||||
instance = gnc_numeric_from_string(arg)
|
||||
if gnc_numeric_check(instance):
|
||||
raise TypeError('Failed to convert to GncNumeric: ' + str(args))
|
||||
return instance
|
||||
elif isinstance(arg, GncNumeric):
|
||||
|
@ -194,9 +194,8 @@ gui_to_fi (FinCalcDialog *fcd)
|
||||
text = gtk_entry_get_text (GTK_ENTRY(entry));
|
||||
if (text && *text)
|
||||
{
|
||||
gnc_numeric out;
|
||||
gboolean result = string_to_gnc_numeric (text, &out);
|
||||
if (result)
|
||||
gnc_numeric out = gnc_numeric_from_string (text);
|
||||
if (!gnc_numeric_check (out))
|
||||
npp = gnc_numeric_convert (out, 1, GNC_HOW_RND_TRUNC);
|
||||
else
|
||||
npp = gnc_numeric_zero ();
|
||||
|
@ -233,12 +233,12 @@ static split_record interpret_split_record( char *record_line)
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
string_to_gnc_numeric(tok_ptr, &(record.amount));
|
||||
record.amount = gnc_numeric_from_string (tok_ptr);
|
||||
record.amount_present = TRUE;
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
string_to_gnc_numeric(tok_ptr, &(record.value));
|
||||
record.value = gnc_numeric_from_string (tok_ptr);
|
||||
record.value_present = TRUE;
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
|
@ -98,10 +98,9 @@ gnc_exp_parser_real_init ( gboolean addPredefined )
|
||||
for (key = keys; key && *key; key++)
|
||||
{
|
||||
str_value = g_key_file_get_string(key_file, GEP_GROUP_NAME, *key, NULL);
|
||||
if (str_value && string_to_gnc_numeric(str_value, &value))
|
||||
{
|
||||
value = gnc_numeric_from_string (str_value);
|
||||
if (!gnc_numeric_check (value))
|
||||
gnc_exp_parser_set_value (*key, gnc_numeric_reduce (value));
|
||||
}
|
||||
}
|
||||
g_strfreev(keys);
|
||||
g_key_file_free(key_file);
|
||||
|
@ -472,6 +472,13 @@ simple_kvp_value_parser_new (sixtp_end_handler end_handler)
|
||||
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
string_to_gnc_numeric(const gchar* str, gnc_numeric *n)
|
||||
{
|
||||
*n = gnc_numeric_from_string (str);
|
||||
return (!gnc_numeric_check (*n));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* generic type copnversion for kvp types */
|
||||
#define KVP_CVT_VALUE(TYPE) \
|
||||
|
@ -509,8 +509,8 @@ dom_tree_to_gnc_numeric (xmlNodePtr node)
|
||||
if (!content)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
gnc_numeric num;
|
||||
if (!string_to_gnc_numeric (content, &num))
|
||||
gnc_numeric num = gnc_numeric_from_string (content);
|
||||
if (gnc_numeric_check (num))
|
||||
num = gnc_numeric_zero ();
|
||||
|
||||
g_free (content);
|
||||
|
@ -611,7 +611,8 @@ generic_gnc_numeric_end_handler (gpointer data_for_children,
|
||||
num = g_new (gnc_numeric, 1);
|
||||
if (num)
|
||||
{
|
||||
if (string_to_gnc_numeric (txt, num))
|
||||
*num = gnc_numeric_from_string (txt);
|
||||
if (!gnc_numeric_check (*num))
|
||||
{
|
||||
ok = TRUE;
|
||||
*result = num;
|
||||
|
Loading…
Reference in New Issue
Block a user