From 830b198ea7f3c200c1951fdec18e77206710316d Mon Sep 17 00:00:00 2001 From: David Hampton Date: Mon, 12 Feb 2007 05:04:13 +0000 Subject: [PATCH] Get QIF import working again. One bad function conversion when removing the Group structure. Mostly scheme function calls with wrong names, and some swigification issues. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/remove-group2@15571 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 16 ++++++++++++---- src/engine/Account.h | 2 +- src/engine/engine.i | 4 ++++ .../qif-import/qif-dialog-utils.scm | 2 +- .../qif-import/qif-merge-groups.scm | 10 +++++----- src/import-export/qif-import/qif-to-gnc.scm | 10 +++++----- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index d7c14303e7..153b2e7398 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -149,6 +149,12 @@ xaccInitAccount (Account * acc, QofBook *book) LEAVE ("account=%p\n", acc); } +QofBook * +gnc_account_get_book(const Account *account) +{ + return qof_instance_get_book(QOF_INSTANCE(account)); +} + /********************************************************************\ \********************************************************************/ @@ -3169,8 +3175,7 @@ gnc_account_copy_children (Account *to, Account *from) void gnc_account_merge_children (Account *parent) { - GList *node_a; - GList *node_b; + GList *node_a, *node_b, *work, *worker; if (!parent) return; @@ -3198,8 +3203,11 @@ gnc_account_merge_children (Account *parent) /* consolidate children */ if (acc_b->children) { - acc_a->children = g_list_concat(acc_a->children, acc_b->children); - acc_b->children = NULL; + work = g_list_copy(acc_b->children); + for (worker = work; worker; worker = g_list_next(worker)) + gnc_account_append_child (acc_a, (Account *)worker->data); + g_list_free(work); + qof_event_gen (&acc_a->inst.entity, QOF_EVENT_MODIFY, NULL); qof_event_gen (&acc_b->inst.entity, QOF_EVENT_MODIFY, NULL); } diff --git a/src/engine/Account.h b/src/engine/Account.h index 0c1411f3ef..2918e887d5 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -216,7 +216,6 @@ Account *gnc_book_get_root_account(QofBook *book); void gnc_book_set_root_account(QofBook *book, Account *root); /** @deprecated */ -#define gnc_account_get_book(X) qof_instance_get_book(QOF_INSTANCE(X)) #define xaccAccountGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X)) #define xaccAccountReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null())) @@ -233,6 +232,7 @@ Account * xaccAccountLookup (const GUID *guid, QofBook *book); /** @name Account general setters/getters @{ */ +QofBook *gnc_account_get_book(const Account *account); /** Set the account's type */ void xaccAccountSetType (Account *account, GNCAccountType); /** Set the account's name */ diff --git a/src/engine/engine.i b/src/engine/engine.i index 06b77e4d60..a616ed1261 100644 --- a/src/engine/engine.i +++ b/src/engine/engine.i @@ -85,6 +85,10 @@ functions. */ %include %include +AccountList * gnc_account_get_children (const Account *account); +AccountList * gnc_account_get_descendants (const Account *account); +%ignore gnc_account_get_children; +%ignore gnc_account_get_descendants; %include %include %include diff --git a/src/import-export/qif-import/qif-dialog-utils.scm b/src/import-export/qif-import/qif-dialog-utils.scm index f7d5e58742..5d3e2c5053 100644 --- a/src/import-export/qif-import/qif-dialog-utils.scm +++ b/src/import-export/qif-import/qif-dialog-utils.scm @@ -606,7 +606,7 @@ (not (hash-ref stock-hash stock-name))) (let* ((separator (string-ref (gnc-get-account-separator-string) 0)) (existing-gnc-acct - (gnc-get-account-from-full-name + (gnc-account-lookup-by-full-name (gnc-get-current-root-account) (qif-map-entry:gnc-name map-entry))) (book (gnc-account-get-book (gnc:get-current-root-account))) diff --git a/src/import-export/qif-import/qif-merge-groups.scm b/src/import-export/qif-import/qif-merge-groups.scm index 8eb066b295..d6cda59fff 100644 --- a/src/import-export/qif-import/qif-merge-groups.scm +++ b/src/import-export/qif-import/qif-merge-groups.scm @@ -87,7 +87,7 @@ ;; query won't find anything. optimize this later. (xaccQueryAddSingleAccountMatch sq - (gnc-get-account-from-full-name + (gnc-account-lookup-by-full-name old-root (gnc-account-get-full-name (xaccSplitGetAccount split))) QOF-QUERY-AND) @@ -158,7 +158,7 @@ (define (gnc:account-tree-catenate-and-merge old-root new-root) ;; stuff the new accounts into the old account tree and merge the accounts - (gnc:account-join-children old-root new-root) - (gnc:account-begin-edit new-root) - (gnc:account-destroy new-root) - (gnc:account-merge-children old-root)) + (gnc-account-join-children old-root new-root) + (xaccAccountBeginEdit new-root) + (xaccAccountDestroy new-root) + (gnc-account-merge-children old-root)) diff --git a/src/import-export/qif-import/qif-to-gnc.scm b/src/import-export/qif-import/qif-to-gnc.scm index 952ed3e7e4..56b2ce17b3 100644 --- a/src/import-export/qif-import/qif-to-gnc.scm +++ b/src/import-export/qif-import/qif-to-gnc.scm @@ -19,7 +19,7 @@ (gnc-name (qif-map-entry:gnc-name acct-info)) (existing-account (hash-ref gnc-acct-hash gnc-name)) (same-gnc-account - (gnc-get-account-from-full-name old-root gnc-name)) + (gnc-account-lookup-by-full-name old-root gnc-name)) (allowed-types (qif-map-entry:allowed-types acct-info)) (make-new-acct #f) @@ -38,12 +38,12 @@ #t)))) (define (make-unique-name-variant long-name short-name) - (if (not (null? (gnc-get-account-from-full-name old-root long-name))) + (if (not (null? (gnc-account-lookup-by-full-name old-root long-name))) (let loop ((count 2)) (let* ((test-name (string-append long-name (sprintf #f " %a" count))) (test-acct - (gnc-get-account-from-full-name old-root test-name))) + (gnc-account-lookup-by-full-name old-root test-name))) (if (and (not (null? test-acct)) (not (compatible? test-acct))) (loop (+ 1 count)) (string-append short-name (sprintf #f " %a" count))))) @@ -158,8 +158,8 @@ pinfo #t default-currency #f default-currency gnc-acct-hash old-root new-root)))) (if (and parent-acct (not (null? parent-acct))) - (gnc:account-append-child parent-acct new-acct) - (gnc:account-append-child new-root new-acct)) + (gnc-account-append-child parent-acct new-acct) + (gnc-account-append-child new-root new-acct)) (hash-set! gnc-acct-hash gnc-name new-acct) new-acct))))