GnuCash c935c2f+
Loading...
Searching...
No Matches
Functions | Variables
change_tax_code.py File Reference

Recurse over all accounts in a book and marks the first one having target_account_code as tax related. More...

Go to the source code of this file.

Functions

 change_tax_code.mark_account_with_code_as_tax_related (account, target_code)
 

Variables

str change_tax_code.TARGET_ACCOUNT_CODE = '1234'
 
 change_tax_code.gnucash_session = Session("/home/mark/python-bindings-help/test.xac")
 

Detailed Description

Recurse over all accounts in a book and marks the first one having target_account_code as tax related.

Definition in file change_tax_code.py.

Function Documentation

◆ mark_account_with_code_as_tax_related()

change_tax_code.mark_account_with_code_as_tax_related (   account,
  target_code 
)
Looks at account to see if it has the target_account_code, if so
set the account tax related flag to True and return True.
If not, recursively tries to do the same to all children accounts
of account.
Returns False when recursion fails to find it.

Definition at line 12 of file change_tax_code.py.

12def 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
16 of account.
17 Returns False when recursion fails to find it.
18 """
19 if account.GetCode() == target_code:
20 account.SetTaxRelated(True)
21 return True
22 else:
23 for child in account.get_children():
24 if mark_account_with_code_as_tax_related(child, target_code):
25 return True
26 return False
27
28# Change this path to your own

Variable Documentation

◆ gnucash_session

change_tax_code.gnucash_session = Session("/home/mark/python-bindings-help/test.xac")

Definition at line 29 of file change_tax_code.py.

◆ TARGET_ACCOUNT_CODE

str change_tax_code.TARGET_ACCOUNT_CODE = '1234'

Definition at line 10 of file change_tax_code.py.