7 from gnucash
import Session, Account
10 TARGET_ACCOUNT_CODE =
'1234' 12 def mark_account_with_code_as_tax_related(account, target_code):
13 """Looks at account to see if it has the target_account_code, if so 14 set the account tax related flag to True and return True. 15 If not, recursively tries to do the same to all children accounts 17 Returns False when recursion fails to find it. 19 if account.GetCode() == target_code:
20 account.SetTaxRelated(
True)
23 for child
in account.get_children():
24 if mark_account_with_code_as_tax_related(child, target_code):
29 gnucash_session = Session(
"/home/mark/python-bindings-help/test.xac")
31 mark_account_with_code_as_tax_related(
32 gnucash_session.book.get_root_account(),
35 gnucash_session.save()