mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Nice example python scripts, patch by Mark Jenkins.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19314 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from gnucash import Session, Account
|
||||
from os.path import abspath
|
||||
from gnucash.gnucash_core_c import ACCT_TYPE_ASSET
|
||||
|
||||
s = Session('sqlite3://%s' % abspath('test.blob'), True)
|
||||
# this seems to make a difference in more complex cases
|
||||
s.save()
|
||||
|
||||
book = s.book
|
||||
root = book.get_root_account()
|
||||
a = Account(book)
|
||||
root.append_child(a)
|
||||
a.SetName('wow')
|
||||
a.SetType(ACCT_TYPE_ASSET)
|
||||
|
||||
commod_table = book.get_table()
|
||||
a.SetCommodity( commod_table.lookup('CURRENCY', 'CAD') )
|
||||
s.save()
|
||||
|
||||
s.end()
|
||||
Reference in New Issue
Block a user