/** Return displayable name */ static gchar* impl_get_display_name(const QofInstance* inst) { GncEntry* entry; gchar* display_name; gchar* s; g_return_val_if_fail(inst != NULL, FALSE); g_return_val_if_fail(GNC_IS_ENTRY(inst), FALSE); entry = GNC_ENTRY(inst); if (entry->order != NULL) { display_name = qof_instance_get_display_name(QOF_INSTANCE(entry->order)); s = g_strdup_printf("Entry in %s", display_name); g_free(display_name); return s; } if (entry->invoice != NULL) { display_name = qof_instance_get_display_name(QOF_INSTANCE(entry->invoice)); s = g_strdup_printf("Entry in %s", display_name); g_free(display_name); return s; } if (entry->bill != NULL) { display_name = qof_instance_get_display_name(QOF_INSTANCE(entry->bill)); s = g_strdup_printf("Entry in %s", display_name); g_free(display_name); return s; } return g_strdup_printf("Entry %p", inst); }
static void destroy_entry_on_book_close(QofInstance *ent, gpointer data) { GncEntry* entry = GNC_ENTRY(ent); gncEntryBeginEdit(entry); gncEntryDestroy(entry); }
/* for each entry, check the tax tables. If the tax tables are * grandchildren, then fix them to point to the most senior child */ static void taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p) { GHashTable *ht = static_cast<decltype(ht)>(ht_p); GncEntry *entry = GNC_ENTRY(entry_p); GncTaxTable *table, *new_tt; gint32 count; table = gncEntryGetInvTaxTable(entry); if (table) { if (taxtable_is_grandchild(table)) { gchar guidstr[GUID_ENCODING_LENGTH+1]; guid_to_string_buff(qof_instance_get_guid(QOF_INSTANCE(entry)),guidstr); PINFO("Fixing i-taxtable on entry %s\n",guidstr); new_tt = taxtable_find_senior(table); gncEntryBeginEdit(entry); gncEntrySetInvTaxTable(entry, new_tt); gncEntryCommitEdit(entry); table = new_tt; } if (table) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table)); count++; g_hash_table_insert(ht, table, GINT_TO_POINTER(count)); } } table = gncEntryGetBillTaxTable(entry); if (table) { if (taxtable_is_grandchild(table)) { gchar guidstr[GUID_ENCODING_LENGTH+1]; guid_to_string_buff(qof_instance_get_guid(QOF_INSTANCE(entry)),guidstr); PINFO("Fixing b-taxtable on entry %s\n",guidstr); new_tt = taxtable_find_senior(table); gncEntryBeginEdit(entry); gncEntrySetBillTaxTable(entry, new_tt); gncEntryCommitEdit(entry); table = new_tt; } if (table) { count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table)); count++; g_hash_table_insert(ht, table, GINT_TO_POINTER(count)); } } }
static void gnc_entry_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GncEntry *entry; g_return_if_fail(GNC_IS_ENTRY(object)); entry = GNC_ENTRY(object); switch (prop_id) { case PROP_DESCRIPTION: gncEntrySetDescription(entry, g_value_get_string(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
/** Does this object refer to a specific object */ static gboolean impl_refers_to_object(const QofInstance* inst, const QofInstance* ref) { GncEntry* entry; g_return_val_if_fail(inst != NULL, FALSE); g_return_val_if_fail(GNC_IS_ENTRY(inst), FALSE); entry = GNC_ENTRY(inst); if (GNC_IS_ACCOUNT(ref)) { Account* acc = GNC_ACCOUNT(ref); return (entry->i_account == acc || entry->b_account == acc); } else if (GNC_IS_TAXTABLE(ref)) { GncTaxTable* tt = GNC_TAXTABLE(ref); return (entry->i_tax_table == tt || entry->b_tax_table == tt); } return FALSE; }