mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Update to provide the book when creating a new commodity.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9703 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -203,6 +203,7 @@ gnc_commodity_end_handler(gpointer data_for_children,
|
||||
xmlNodePtr achild;
|
||||
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
||||
gxpf_data *gdata = (gxpf_data*)global_data;
|
||||
QofBook *book = gdata->bookdata;
|
||||
|
||||
if(parent_data)
|
||||
{
|
||||
@@ -218,7 +219,7 @@ gnc_commodity_end_handler(gpointer data_for_children,
|
||||
|
||||
g_return_val_if_fail(tree, FALSE);
|
||||
|
||||
com = gnc_commodity_new(NULL, NULL, NULL, NULL, 0);
|
||||
com = gnc_commodity_new(book, NULL, NULL, NULL, NULL, 0);
|
||||
|
||||
for(achild = tree->xmlChildrenNode; achild; achild = achild->next)
|
||||
{
|
||||
|
||||
@@ -712,7 +712,8 @@ tt_act_handler( xmlNodePtr node, gpointer data )
|
||||
away at some point, but the same concern still
|
||||
applies for
|
||||
SchedXaction.c:xaccSchedXactionInit... */
|
||||
com = gnc_commodity_new( "template", "template",
|
||||
com = gnc_commodity_new( txd->book,
|
||||
"template", "template",
|
||||
"template", "template",
|
||||
1 );
|
||||
xaccAccountSetCommodity( acc, com );
|
||||
|
||||
@@ -392,7 +392,7 @@ gnc_commodity_import_legacy(QofBook *book, const char * currency_name)
|
||||
currency_name);
|
||||
|
||||
if(!old) {
|
||||
old = gnc_commodity_new(currency_name,
|
||||
old = gnc_commodity_new(book, currency_name,
|
||||
GNC_COMMODITY_NS_LEGACY, currency_name,
|
||||
0, 100000);
|
||||
old = gnc_commodity_table_insert(table, old);
|
||||
|
||||
@@ -1938,7 +1938,8 @@ commodity_restore_end_handler(gpointer data_for_children,
|
||||
if(!cpi->name) cpi->name = g_strdup("");
|
||||
if(!cpi->xcode) cpi->xcode = g_strdup("");
|
||||
|
||||
comm = gnc_commodity_new(cpi->name,
|
||||
comm = gnc_commodity_new(pstatus->book,
|
||||
cpi->name,
|
||||
cpi->space,
|
||||
cpi->id,
|
||||
cpi->xcode,
|
||||
|
||||
@@ -710,7 +710,7 @@ dom_tree_to_commodity_ref_no_engine(xmlNodePtr node, QofBook *book)
|
||||
} else {
|
||||
g_strstrip(space_str);
|
||||
g_strstrip(id_str);
|
||||
c = gnc_commodity_new(NULL, space_str, id_str, NULL, 0);
|
||||
c = gnc_commodity_new(book, NULL, space_str, id_str, NULL, 0);
|
||||
}
|
||||
|
||||
g_free(space_str);
|
||||
|
||||
@@ -31,11 +31,14 @@ test_dom_tree_to_commodity_ref(void)
|
||||
gchar *test_str2;
|
||||
gnc_commodity *test_com2;
|
||||
xmlNodePtr test_node;
|
||||
QofBook *book;
|
||||
|
||||
book = qof_book_new ();
|
||||
|
||||
test_str1 = get_random_string();
|
||||
test_str2 = get_random_string();
|
||||
|
||||
test_com1 = gnc_commodity_new(NULL, test_str1, test_str2, NULL, 0);
|
||||
test_com1 = gnc_commodity_new(book, NULL, test_str1, test_str2, NULL, 0);
|
||||
test_node = commodity_ref_to_dom_tree("test-com", test_com1);
|
||||
|
||||
test_com2 = dom_tree_to_commodity_ref_no_engine(test_node, NULL);
|
||||
@@ -48,6 +51,8 @@ test_dom_tree_to_commodity_ref(void)
|
||||
gnc_commodity_destroy(test_com2);
|
||||
g_free(test_str1);
|
||||
g_free(test_str2);
|
||||
|
||||
qof_book_destroy (book);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ get_commodities_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
if (com) continue;
|
||||
|
||||
/* no we don't ... restore it */
|
||||
com = gnc_commodity_new (DB_GET_VAL("fullname",j),
|
||||
com = gnc_commodity_new (book,
|
||||
DB_GET_VAL("fullname",j),
|
||||
DB_GET_VAL("namespace",j),
|
||||
DB_GET_VAL("mnemonic",j),
|
||||
DB_GET_VAL("code",j),
|
||||
|
||||
@@ -778,13 +778,15 @@ void rpcend_free_verslist (gnc_vers_list *vlist, gboolean freeguid)
|
||||
void rpcend_load_gnccommodity (gnc_commodity_table *ct, gncCommodity *com)
|
||||
{
|
||||
gnc_commodity *gc;
|
||||
QofBook * book = gnc_get_current_book ();
|
||||
|
||||
if (!ct || !com)
|
||||
return;
|
||||
|
||||
if ((gc = gnc_commodity_table_lookup (ct, com->namespace, com->mnemonic))
|
||||
== NULL) {
|
||||
gc = gnc_commodity_new (com->fullname, com->namespace,
|
||||
gc = gnc_commodity_new (book,
|
||||
com->fullname, com->namespace,
|
||||
com->mnemonic, com->exchange_code, com->fraction);
|
||||
gnc_commodity_table_insert (ct, gc);
|
||||
}
|
||||
|
||||
@@ -1051,6 +1051,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w)
|
||||
const char * namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
|
||||
const char * mnemonic = gtk_entry_get_text(GTK_ENTRY(w->mnemonic_entry));
|
||||
const char * code = gtk_entry_get_text(GTK_ENTRY(w->code_entry));
|
||||
QofBook * book = gnc_get_current_book ();
|
||||
int fraction = gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON(w->fraction_spinbutton));
|
||||
const char *string;
|
||||
@@ -1087,7 +1088,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w)
|
||||
}
|
||||
|
||||
if (!w->edit_commodity) {
|
||||
c = gnc_commodity_new(fullname, namespace, mnemonic, code, fraction);
|
||||
c = gnc_commodity_new(book, fullname, namespace, mnemonic, code, fraction);
|
||||
w->edit_commodity = c;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -140,6 +140,7 @@ gnc_ui_commodity_druid_create(const char * filename)
|
||||
CommodityDruidPage * new_page;
|
||||
GnomeDruidPage * back_page;
|
||||
GladeXML * xml;
|
||||
QofBook * book = gnc_get_current_book ();
|
||||
|
||||
xml = gnc_glade_xml_new ("binary-import.glade",
|
||||
"New Commodity Format Druid");
|
||||
@@ -184,7 +185,7 @@ gnc_ui_commodity_druid_create(const char * filename)
|
||||
|
||||
/* otherwise, guess that it's a NASDAQ security. */
|
||||
if(!found) {
|
||||
found = gnc_commodity_new(gnc_commodity_get_mnemonic(lost),
|
||||
found = gnc_commodity_new(book, gnc_commodity_get_mnemonic(lost),
|
||||
GNC_COMMODITY_NS_NASDAQ,
|
||||
gnc_commodity_get_mnemonic(lost),
|
||||
NULL, 100000);
|
||||
|
||||
@@ -607,6 +607,7 @@
|
||||
(gnc:get-current-group)
|
||||
(qif-map-entry:gnc-name map-entry)
|
||||
separator))
|
||||
(book (gnc:group-get-book (gnc:get-current-group)))
|
||||
(existing-type
|
||||
(gnc:account-get-type existing-gnc-acct)))
|
||||
(if (and existing-gnc-acct
|
||||
@@ -626,7 +627,8 @@
|
||||
(set! names (cons stock-name names))
|
||||
(hash-set!
|
||||
stock-hash stock-name
|
||||
(gnc:commodity-create stock-name
|
||||
(gnc:commodity-create book
|
||||
stock-name
|
||||
GNC_COMMODITY_NS_NYSE
|
||||
ticker-symbol
|
||||
""
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
|
||||
(let ((qiffile (qif-io:make-empty-file))
|
||||
(acct-table (qif-io:make-empty-acct-table))
|
||||
(com-table (gnc:commodity-table-new)))
|
||||
(session (gnc:get-current-session))
|
||||
(book (gnc:session-get-book session))
|
||||
(com-table (gnc:commodity-table-new)))
|
||||
|
||||
(gnc:commodity-table-add-default-data com-table)
|
||||
(gnc:commodity-table-add-default-data com-table book)
|
||||
|
||||
;; read the file and look at data formats. we need to do this
|
||||
;; immediately when loading a file.
|
||||
@@ -59,9 +61,7 @@
|
||||
(let ((group (qif-io:acct-table-make-gnc-group
|
||||
acct-table qiffile commodity)))
|
||||
;; write the file
|
||||
(let* ((session (gnc:get-current-session))
|
||||
(book (gnc:session-get-book session))
|
||||
(name (simple-format #f "file:~A.gnc" filename)))
|
||||
(let* ((name (simple-format #f "file:~A.gnc" filename)))
|
||||
(simple-format #t "using book name='~A'\n" name)
|
||||
(gnc:group-concat-group (gnc:book-get-group book) group)
|
||||
(gnc:account-group-destroy group)
|
||||
|
||||
Reference in New Issue
Block a user