static const char * get_date_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; GncEntry *entry; Timespec ts; entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); ts = gncEntryGetDate (entry); return gnc_print_date (ts); }
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 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; }
GDate gncEntryGetDateGDate(const GncEntry *entry) { return timespec_to_gdate(gncEntryGetDate(entry)); }