> Creating Gnucash Accounts and Transactions.
>
> The sample code I sent out Wednesday is what I've tried so far; it may
> need some gnc.gwp code that sits only on my PC at home, but that's merely
> wrapping standard GnuCash engine calls, so there's nothing there that
> wouldn't be simple to drop into gnc.gwp...
>
> c) is what I've had *no* success with; I have tried adding both
> accounts and transactions, and while the return codes seem OK on
> the Guile side of things, they don't appear to get linked with the
> data structures that the engine is working with.
I've got this working! Here is my scheme code. I renamed
some of your functions to be idiomatic with the rest of
gnc.gwp. Are you on the patch list? I submitted this file
along with the necessary gnc.gwp changes.
Your solution was close, but it failed when you got
the group from the current session. As written, the
current session will not always contain a valid group.
It appears to me that the correct way to get the top group
is using gncGetCurrentGroup, which works even if the
current Session doesn't have a group.
dave
(define (gnc:create-account AccPtr name description notes type)
(display "start creation")(newline)
(gnc:account-begin-edit AccPtr 0)
(display "edit")(newline)
(display (string-append "Name:" name)) (newline)
(gnc:account-set-name AccPtr name)
(display (string-append "Descr:" description)) (newline)
(gnc:account-set-description AccPtr description)
(display (string-append "notes:" notes)) (newline)
(gnc:account-set-notes AccPtr notes)
(display (string-append "Type:" (number->string type))) (newline)
(gnc:account-set-type AccPtr type)
(gnc:account-commit-edit AccPtr)
(display "committed")(newline)
)
(define (gnc:test-creation)
(let ((group (gnc:get-current-group))
(cash
(list (gnc:malloc-account)
"Sample Cash"
"Sample Cash Description"
"No notes - this is just a sample"
1))
(inc1
(list (gnc:malloc-account)
"Misc Income"
"Miscellaneous Income"
"Just a dumb income account"
8))
(exp1
(list (gnc:malloc-account)
"Misc Exp"
"Miscellaneous Expenses"
"Just a dumb expense account"
9)))
(display "Samples: ") (newline)
(display (list cash inc1 exp1)) (newline)
(apply gnc:create-account cash)
(apply gnc:create-account inc1)
(apply gnc:create-account exp1)
(display "group:") (display group) (newline)
(gnc:group-insert-account group (car cash))
(gnc:group-insert-account group (car inc1))
(gnc:group-insert-account group (car exp1))
(gnc:refresh-main-window))
(display "Tried creation")(newline))
(display "loaded test.scm")(newline)
--
Gnucash Developer's List
To unsubscribe send empty email to: [EMAIL PROTECTED]