static void entry_cb(gpointer data, gpointer user_data) { const GncEntry* entry = data; EntryQF *s = (EntryQF *) user_data; if (s->using_invoices == (gncEntryGetInvAccount(entry) != NULL)) { gnc_quickfill_insert (s->qf, gncEntryGetDescription(entry), s->qf_sort); } }
static const char * get_desc_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; GncEntry *entry; entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); return gncEntryGetDescription (entry); }
static void test_entry_basics ( Fixture *fixture, gconstpointer pData ) { time64 ts1 = gnc_time(NULL), ts2; const char *desc = "Test description with éà unicode chars"; const char *action = "Test action with éà unicode chars"; const char *note = "Test note with éà unicode chars"; gnc_numeric quantity = {500000, 100}; gboolean is_cn = FALSE; GncEntry *entry = gncEntryCreate(fixture->book); g_assert(entry); g_test_message( "Test basic setters/getters" ); g_test_message( " Date" ); gncEntrySetDate (entry, ts1); ts2 = gncEntryGetDate (entry); g_assert(ts2 == ts1); g_test_message( " DateEntered" ); gncEntrySetDateEntered (entry, ts1); ts2 = gncEntryGetDateEntered (entry); g_assert(ts2 == ts1); g_test_message( " Description" ); gncEntrySetDescription (entry, desc); g_assert(g_strcmp0 (gncEntryGetDescription (entry), desc) == 0); g_test_message( " Action" ); gncEntrySetAction (entry, action); g_assert(g_strcmp0 (gncEntryGetAction (entry), action) == 0); g_test_message( " Notes" ); gncEntrySetNotes (entry, note); g_assert(g_strcmp0 (gncEntryGetNotes (entry), note) == 0); g_test_message( " Quantity" ); gncEntrySetQuantity (entry, quantity); g_assert(gnc_numeric_eq (gncEntryGetQuantity (entry), quantity)); g_test_message( " DocQuantity (with is_cn = FALSE)" ); gncEntrySetDocQuantity (entry, quantity, is_cn); g_assert(gnc_numeric_eq (gncEntryGetDocQuantity (entry, is_cn), quantity)); g_assert(gnc_numeric_eq (gncEntryGetQuantity (entry), quantity)); g_test_message( " DocQuantity (with is_cn = TRUE)"); is_cn = TRUE; gncEntrySetDocQuantity (entry, quantity, is_cn); g_assert(gnc_numeric_eq (gncEntryGetDocQuantity (entry, is_cn), quantity)); g_assert(gnc_numeric_eq (gncEntryGetQuantity (entry), gnc_numeric_neg (quantity))); g_test_message( " InvAccount" ); gncEntrySetInvAccount (entry, fixture->account); g_assert(gncEntryGetInvAccount (entry) == fixture->account); }
static void listen_for_gncentry_events(QofInstance *entity, QofEventId event_type, gpointer user_data, gpointer event_data) { EntryQF *qfb = user_data; QuickFill *qf = qfb->qf; const char *desc; /* We only listen for GncEntry events */ if(!entity) return; if(typeid(*entity) != typeid(GncEntry)) return; // if (!GNC_IS_ENTRY (entity)) // return; /* We listen for MODIFY (if the description was changed into * something non-empty, so we add the string to the quickfill) and * DESTROY (to remove the description from the quickfill). */ if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY))) return; /* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */ /* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */ GncEntry * entry = dynamic_cast<GncEntry*>(entity); desc = gncEntryGetDescription(entry); if (event_type & QOF_EVENT_MODIFY) { /* If the description was changed into something non-empty, so * we add the string to the quickfill */ if (!desc || strlen(desc) == 0) return; /* Add the new string to the quickfill */ gnc_quickfill_insert (qf, desc, QUICKFILL_LIFO); } else if (event_type & QOF_EVENT_DESTROY) { if (!desc || strlen(desc) == 0) return; /* Remove the description from the quickfill */ gnc_quickfill_insert (qf, desc, QUICKFILL_LIFO); } }
/** Finds the GncEntry with the matching description string as given * in "desc", but searches this only in the given entry ledger * (i.e. the currently opened ledger window). */ static GncEntry* gnc_find_entry_in_reg_by_desc(GncEntryLedger *reg, const char* desc) { int virt_row, virt_col; int num_rows, num_cols; GncEntry *last_entry; g_assert(reg); g_assert(reg->table); if (!reg || !reg->table) return NULL; num_rows = reg->table->num_virt_rows; num_cols = reg->table->num_virt_cols; last_entry = NULL; for (virt_row = num_rows - 1; virt_row >= 0; virt_row--) for (virt_col = num_cols - 1; virt_col >= 0; virt_col--) { GncEntry *entry; VirtualCellLocation vcell_loc = { virt_row, virt_col }; entry = gnc_entry_ledger_get_entry(reg, vcell_loc); if (entry == last_entry) continue; if (safe_strcmp (desc, gncEntryGetDescription (entry)) == 0) return entry; last_entry = entry; } return NULL; }
static xmlNodePtr entry_dom_tree_create (GncEntry *entry) { xmlNodePtr ret; Timespec ts; Account *acc; GncTaxTable *taxtable; GncOrder *order; GncInvoice *invoice; kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_entry_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST entry_version_string); xmlAddChild(ret, guid_to_dom_tree(entry_guid_string, qof_instance_get_guid(QOF_INSTANCE(entry)))); ts = gncEntryGetDate (entry); xmlAddChild(ret, timespec_to_dom_tree (entry_date_string, &ts)); ts = gncEntryGetDateEntered (entry); xmlAddChild(ret, timespec_to_dom_tree (entry_dateentered_string, &ts)); maybe_add_string (ret, entry_description_string, gncEntryGetDescription (entry)); maybe_add_string (ret, entry_action_string, gncEntryGetAction (entry)); maybe_add_string (ret, entry_notes_string, gncEntryGetNotes (entry)); maybe_add_numeric (ret, entry_qty_string, gncEntryGetQuantity (entry)); /* cust invoice */ acc = gncEntryGetInvAccount (entry); if (acc) xmlAddChild (ret, guid_to_dom_tree (entry_invacct_string, qof_instance_get_guid(QOF_INSTANCE(acc)))); maybe_add_numeric (ret, entry_iprice_string, gncEntryGetInvPrice (entry)); maybe_add_numeric (ret, entry_idiscount_string, gncEntryGetInvDiscount (entry)); invoice = gncEntryGetInvoice (entry); if (invoice) { xmlAddChild (ret, guid_to_dom_tree (entry_invoice_string, qof_instance_get_guid(QOF_INSTANCE(invoice)))); xmlAddChild(ret, text_to_dom_tree(entry_idisctype_string, gncAmountTypeToString ( gncEntryGetInvDiscountType (entry)))); xmlAddChild(ret, text_to_dom_tree(entry_idischow_string, gncEntryDiscountHowToString ( gncEntryGetInvDiscountHow (entry)))); xmlAddChild(ret, int_to_dom_tree(entry_itaxable_string, gncEntryGetInvTaxable (entry))); xmlAddChild(ret, int_to_dom_tree(entry_itaxincluded_string, gncEntryGetInvTaxIncluded (entry))); } taxtable = gncEntryGetInvTaxTable (entry); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (entry_itaxtable_string, qof_instance_get_guid (QOF_INSTANCE(taxtable)))); /* vendor bills */ acc = gncEntryGetBillAccount (entry); if (acc) xmlAddChild (ret, guid_to_dom_tree (entry_billacct_string, qof_instance_get_guid (QOF_INSTANCE(acc)))); maybe_add_numeric (ret, entry_bprice_string, gncEntryGetBillPrice (entry)); invoice = gncEntryGetBill (entry); if (invoice) { GncOwner *owner; xmlAddChild (ret, guid_to_dom_tree (entry_bill_string, qof_instance_get_guid(QOF_INSTANCE(invoice)))); xmlAddChild(ret, int_to_dom_tree(entry_billable_string, gncEntryGetBillable (entry))); owner = gncEntryGetBillTo (entry); if (owner && owner->owner.undefined != NULL) xmlAddChild (ret, gnc_owner_to_dom_tree (entry_billto_string, owner)); xmlAddChild(ret, int_to_dom_tree(entry_btaxable_string, gncEntryGetBillTaxable (entry))); xmlAddChild(ret, int_to_dom_tree(entry_btaxincluded_string, gncEntryGetBillTaxIncluded (entry))); maybe_add_string (ret, entry_billpayment_string, gncEntryPaymentTypeToString (gncEntryGetBillPayment (entry))); } taxtable = gncEntryGetBillTaxTable (entry); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (entry_btaxtable_string, qof_instance_get_guid (QOF_INSTANCE(taxtable)))); /* Other stuff */ order = gncEntryGetOrder (entry); if (order) xmlAddChild (ret, guid_to_dom_tree (entry_order_string, qof_instance_get_guid(QOF_INSTANCE (order)))); kf = qof_instance_get_slots (QOF_INSTANCE(entry)); if (kf) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(entry_slots_string, kf); if (kvpnode) { xmlAddChild(ret, kvpnode); } } return ret; }