Attached is a patch that imports GncNumeric rounding constants and all the Account codes into gnucash.gnucash_core. They also thus become available in the most simple way: from gnucash import ACCT_TYPE_LIABILITY
Apply with -p0. Mark Jenkins p.s. I've noticed some of the posts from folks who have had trouble with the python bindings in recent months. Sorry for not responding yet, I only saw them recently because I filter gnucash-devel into a folder I haven't been able to look at much. I've updated my filters to isolate posts with python in the subject so I can stay on top of these.
Index: src/optional/python-bindings/gnucash_core.py =================================================================== --- src/optional/python-bindings/gnucash_core.py (revision 528) +++ src/optional/python-bindings/gnucash_core.py (revision 529) @@ -140,6 +140,16 @@ class GncNumeric(GnuCashCoreClass): """Object used by GnuCash to store all numbers. Always consists of a numerator and denominator. + + The constants GNC_DENOM_AUTO, + GNC_HOW_RND_FLOOR, GNC_HOW_RND_CEIL, GNC_HOW_RND_TRUNC, + GNC_HOW_RND_PROMOTE, GNC_HOW_RND_ROUND_HALF_DOWN, + GNC_HOW_RND_ROUND_HALF_UP, GNC_HOW_RND_ROUND, GNC_HOW_RND_NEVER, + GNC_HOW_DENOM_EXACT, GNC_HOW_DENOM_REDUCE, GNC_HOW_DENOM_LCD, + and GNC_HOW_DENOM_FIXED are available for arithmetic + functions like GncNumeric.add + + Look at gnc-numeric.h to see how ot use these """ def __init__(self, num=0, denom=1, **kargs): @@ -194,15 +204,17 @@ """A GnuCash Account. A fundamental entity in accounting, an Account provides representation - for a financial object, such as a BANK account, an ASSET (like a building), - a LIABILITY (such as a bank loan), a summary of some type of EXPENSE, or - a summary of some source of INCOME. + for a financial object, such as a ACCT_TYPE_BANK account, an + ACCT_TYPE_ASSET (like a building), + a ACCT_TYPE_LIABILITY (such as a bank loan), a summary of some type of + ACCT_TYPE_EXPENSE, or a summary of some source of ACCT_TYPE_INCOME . The words in upper case are the constants that GnuCash and this library uses to describe account type. Here is the full list: - BANK, CASH, CREDIT, ASSET, LIABILITY, STOCK, MUTUAL - CURRENCY, INCOME, EXPENSE, EQUITY, RECEIVABLE, PAYABLE, - CHECKING, SAVINGS, MONEYMRKT, CREDITLINE + ACCT_TYPE_ASSET, ACCT_TYPE_BANK, ACCT_TYPE_CASH, ACCT_TYPE_CHECKING, \ + ACCT_TYPE_CREDIT, ACCT_TYPE_EQUITY, ACCT_TYPE_EXPENSE, ACCT_TYPE_INCOME, \ + ACCT_TYPE_LIABILITY, ACCT_TYPE_MUTUAL, ACCT_TYPE_PAYABLE, \ + ACCT_TYPE_RECEIVABLE, ACCT_TYPE_STOCK, ACCT_TYPE_ROOT, ACCT_TYPE_TRADING These are not strings, they are attributes you can import from this module @@ -232,6 +244,30 @@ extract_attributes_with_prefix(gnucash_core_c, 'ERR_'): this_module_dict[ error_name ] = error_value +# GncNumeric demoniminator computation schemes +# Used for the denom argument in arithmetic functions like GncNumeric.add +from gnucash.gnucash_core_c import GNC_DENOM_AUTO + +# GncNumeric rounding instructions +# used for the how argument in arithmetic functions like GncNumeric.add +from gnucash.gnucash_core_c import \ + GNC_HOW_RND_FLOOR, GNC_HOW_RND_CEIL, GNC_HOW_RND_TRUNC, \ + GNC_HOW_RND_PROMOTE, GNC_HOW_RND_ROUND_HALF_DOWN, \ + GNC_HOW_RND_ROUND_HALF_UP, GNC_HOW_RND_ROUND, GNC_HOW_RND_NEVER + +# GncNumeric denominator types +# used for the how argument in arithmetic functions like GncNumeric.add +from gnucash.gnucash_core_c import \ + GNC_HOW_DENOM_EXACT, GNC_HOW_DENOM_REDUCE, GNC_HOW_DENOM_LCD, \ + GNC_HOW_DENOM_FIXED + +# import account types +from gnucash.gnucash_core_c import \ + ACCT_TYPE_ASSET, ACCT_TYPE_BANK, ACCT_TYPE_CASH, ACCT_TYPE_CHECKING, \ + ACCT_TYPE_CREDIT, ACCT_TYPE_EQUITY, ACCT_TYPE_EXPENSE, ACCT_TYPE_INCOME, \ + ACCT_TYPE_LIABILITY, ACCT_TYPE_MUTUAL, ACCT_TYPE_PAYABLE, \ + ACCT_TYPE_RECEIVABLE, ACCT_TYPE_STOCK, ACCT_TYPE_ROOT, ACCT_TYPE_TRADING + #Book Book.add_constructor_and_methods_with_prefix('qof_book_', 'new') Book.add_method('gnc_book_get_root_account', 'get_root_account')
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel