diff --git a/src/app-utils/app-utils.i b/src/app-utils/app-utils.i index 14fad9c076..3689ec649d 100644 --- a/src/app-utils/app-utils.i +++ b/src/app-utils/app-utils.i @@ -13,6 +13,7 @@ #include #include #include +#include #include "engine-helpers.h" @@ -111,3 +112,23 @@ gint gnc_process_get_fd(const Process *proc, const guint std_fd); void gnc_detach_process(Process *proc, const gboolean kill_it); time_t gnc_parse_time_to_timet(const gchar *s, const gchar *format); + +%typemap(out) GHashTable * { + SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17); + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, $1); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const GncGUID* c_guid = (const GncGUID*) key; + const gnc_numeric* c_numeric = (const gnc_numeric*) value; + SCM scm_guid = gnc_guid2scm(*c_guid); + SCM scm_numeric = gnc_numeric_to_scm(*c_numeric); + + scm_hash_set_x(table, scm_guid, scm_numeric); + } + g_hash_table_destroy($1); + $result = table; +} +GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end); +%clear GHashTable *; diff --git a/src/app-utils/gnc-sx-instance-model.c b/src/app-utils/gnc-sx-instance-model.c index 5892668197..fc5c8af92f 100644 --- a/src/app-utils/gnc-sx-instance-model.c +++ b/src/app-utils/gnc-sx-instance-model.c @@ -1673,6 +1673,17 @@ void gnc_sx_all_instantiate_cashflow(GList *all_sxes, g_list_foreach(all_sxes, instantiate_cashflow_cb, &userdata); } +GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end) +{ + GHashTable *result_map = gnc_g_hash_new_guid_numeric(); + GList *all_sxes = gnc_book_get_schedxactions(gnc_get_current_book())->sx_list; + gnc_sx_all_instantiate_cashflow(all_sxes, + &range_start, &range_end, + result_map, NULL); + return result_map; +} + + // Local Variables: // mode: c // indent-tabs-mode: nil diff --git a/src/app-utils/gnc-sx-instance-model.h b/src/app-utils/gnc-sx-instance-model.h index 501b8eb3b4..dc1d9ebd53 100644 --- a/src/app-utils/gnc-sx-instance-model.h +++ b/src/app-utils/gnc-sx-instance-model.h @@ -254,6 +254,15 @@ void gnc_sx_all_instantiate_cashflow(GList *all_sxes, const GDate *range_start, const GDate *range_end, GHashTable* map, GList **creation_errors); +/** Simplified wrapper around gnc_sx_all_instantiate_cashflow(): Run + * that function on all SX of the current book for the given date + * range. Ignore any potential error messages. Returns a newly + * allocated GHashTable with the result, which is a GHashTable, identical to what gnc_g_hash_new_guid_numeric() + * would return. The returned value must be free'd with + * g_hash_table_destroy. */ +GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end); + G_END_DECLS #endif // _GNC_SX_INSTANCE_MODEL_H