30 from sys
import argv, exit
32 from gnucash
import Session, Transaction, Split, Account, GncNumeric, \
45 print(
'not enough parameters')
46 print(
'usage: test_imbalance_transaction.py {book_url}')
48 print(
"python3 test_imbalance_transaction.py '/home/username/test.gnucash'")
53 session = Session(argv[1])
57 root = book.get_root_account()
59 commod_tab = session.book.get_table()
60 CAD = commod_tab.lookup(
"ISO4217",
"CAD")
61 USD = commod_tab.lookup(
"ISO4217",
"USD")
64 root.append_child(account)
65 root.append_child(account2)
66 account.SetCommodity(CAD)
67 account.SetName(
"blahblah")
69 account2.SetCommodity(USD)
70 account2.SetName(
"blahblahsdfs ")
86 s2.SetAccount(account2)
89 print(
'overall imbalance', a.GetImbalanceValue().to_string())
91 print(
'per-currency imbalances')
92 imbalance_list = a.GetImbalance()
93 for (commod, value)
in imbalance_list:
94 print(value.to_string(), commod.get_mnemonic())
102 if "session" in locals():
The primary numeric class for representing amounts and values.