diff --git a/src/app-utils/gnc-helpers.c b/src/app-utils/gnc-helpers.c index 0fafd984b0..aa8f8beb0b 100644 --- a/src/app-utils/gnc-helpers.c +++ b/src/app-utils/gnc-helpers.c @@ -117,3 +117,17 @@ gnc_get_account_separator_string (void) return sep; } +SCM +gnc_parse_amount_helper (const char * string, gboolean monetary) +{ + gnc_numeric result; + gboolean ok; + + g_return_val_if_fail (string, SCM_BOOL_F); + + ok = xaccParseAmount (string, monetary, &result, NULL); + if (!ok) + return SCM_BOOL_F; + + return gnc_numeric_to_scm (result); +} diff --git a/src/app-utils/gnc-helpers.h b/src/app-utils/gnc-helpers.h index 4dfee75088..37f608601c 100644 --- a/src/app-utils/gnc-helpers.h +++ b/src/app-utils/gnc-helpers.h @@ -34,4 +34,6 @@ int gnc_printinfo_p(SCM info_scm); const char * gnc_get_account_separator_string (void); +SCM gnc_parse_amount_helper (const char * string, gboolean monetary); + #endif diff --git a/src/app-utils/gw-app-utils-spec.scm b/src/app-utils/gw-app-utils-spec.scm index 5910d09107..bdee907c7e 100644 --- a/src/app-utils/gw-app-utils-spec.scm +++ b/src/app-utils/gw-app-utils-spec.scm @@ -126,6 +126,15 @@ '() "Shutdown the expression parser and free any associated memory.") + (gw:wrap-function + mod + 'gnc:parse-amount + ' + "gnc_parse_amount_helper" + '((( gw:const) string) + ( monetary)) + "Parse the expression and return either a gnc numeric or #f.") + (gw:wrap-function mod 'gnc:setup-gettext