static gboolean invoice_guid_handler (xmlNodePtr node, gpointer invoice_pdata) { struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata); GncGUID* guid; GncInvoice* invoice; guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); invoice = gncInvoiceLookup (pdata->book, guid); if (invoice) { gncInvoiceDestroy (pdata->invoice); pdata->invoice = invoice; gncInvoiceBeginEdit (invoice); } else { gncInvoiceSetGUID (pdata->invoice, guid); } g_free (guid); return TRUE; }
/* ================================================================= */ template<> void GncSqlColumnTableEntryImpl<CT_INVOICEREF>::load (const GncSqlBackend* be, GncSqlRow& row, QofIdTypeConst obj_name, gpointer pObject) const noexcept { load_from_guid_ref(row, obj_name, pObject, [be](GncGUID* g){ return gncInvoiceLookup (be->book(), g); }); }
static void compare_single_invoice( QofInstance* inst, gpointer user_data ) { CompareInfoStruct* info = (CompareInfoStruct*)user_data; GncInvoice* inv_1 = GNC_INVOICE(inst); GncInvoice* inv_2 = gncInvoiceLookup( info->book_2, qof_instance_get_guid(inst) ); if (!gncInvoiceEqual( inv_1, inv_2 )) { info->result = FALSE; } }
static GncInvoice* load_single_invoice (GncSqlBackend* be, GncSqlRow& row) { const GncGUID* guid; GncInvoice* pInvoice; g_return_val_if_fail (be != NULL, NULL); guid = gnc_sql_load_guid (be, row); pInvoice = gncInvoiceLookup (be->book(), guid); if (pInvoice == NULL) { pInvoice = gncInvoiceCreate (be->book()); } gnc_sql_load_object (be, row, GNC_ID_INVOICE, pInvoice, col_table); qof_instance_mark_clean (QOF_INSTANCE (pInvoice)); return pInvoice; }
/* ================================================================= */ static void load_invoice_guid( const GncSqlBackend* be, GncSqlRow* row, QofSetterFunc setter, gpointer pObject, const GncSqlColumnTableEntry* table_row ) { const GValue* val; GncGUID guid; GncInvoice* invoice = NULL; g_return_if_fail( be != NULL ); g_return_if_fail( row != NULL ); g_return_if_fail( pObject != NULL ); g_return_if_fail( table_row != NULL ); val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); if ( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) { string_to_guid( g_value_get_string( val ), &guid ); invoice = gncInvoiceLookup( be->book, &guid ); if ( invoice != NULL ) { if ( table_row->gobj_param_name != NULL ) { qof_instance_increase_editlevel (pObject); g_object_set( pObject, table_row->gobj_param_name, invoice, NULL ); qof_instance_decrease_editlevel (pObject); } else { (*setter)( pObject, (const gpointer)invoice ); } } else { PWARN( "Invoice ref '%s' not found", g_value_get_string( val ) ); } } }
static gboolean entry_bill_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata *pdata = entry_pdata; GncGUID *guid; GncInvoice *invoice; guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); invoice = gncInvoiceLookup (pdata->book, guid); if (!invoice) { invoice = gncInvoiceCreate (pdata->book); gncInvoiceBeginEdit (invoice); gncInvoiceSetGUID (invoice, guid); gncInvoiceCommitEdit (invoice); } gncInvoiceBeginEdit (invoice); gncBillAddEntry (invoice, pdata->entry); gncInvoiceCommitEdit (invoice); g_free(guid); return TRUE; }