Skip to content

Commit

Permalink
Provide wrapper for qof numeric predicate
Browse files Browse the repository at this point in the history
Python bindings already have some wrapping objects for
qof predicates. This adds the one missing for GncNumeric
comparisons.

Additionally fixes a wrong number for QOF_NUMERIC_MATCH_ANY
in example file.
  • Loading branch information
c-holtermann committed Mar 8, 2022
1 parent f44d230 commit 06e17df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bindings/python/example_scripts/qof.py
Expand Up @@ -161,7 +161,7 @@ def query_splits(book, terms=[]):

# query split value
threshold = GncNumeric(5000, 100)
QOF_NUMERIC_MATCH_ANY = 1
terms = [(["amount"], gnucash_core_c.qof_query_numeric_predicate(QOF_COMPARE_GT, QOF_NUMERIC_MATCH_ANY, threshold.instance), QOF_QUERY_AND)]
QOF_NUMERIC_MATCH_ANY = 3
terms = [(["amount"], gnucash_core.QueryNumericPredicate(QOF_COMPARE_GT, QOF_NUMERIC_MATCH_ANY, threshold), QOF_QUERY_AND)]
splits_3 = query_splits(book, terms)
print("Query splits with amount > " + str(threshold) + ": " + str(len(splits_3)) + " (Should be about 50).")
6 changes: 6 additions & 0 deletions bindings/python/gnucash_core.py
Expand Up @@ -967,3 +967,9 @@ class QueryGuidPredicate(GnuCashCoreClass):

QueryGuidPredicate.add_constructor_and_methods_with_prefix(
'qof_query_', 'guid_predicate')

class QueryNumericPredicate(GnuCashCoreClass):
pass

QueryNumericPredicate.add_constructor_and_methods_with_prefix(
'qof_query_', 'numeric_predicate')

0 comments on commit 06e17df

Please sign in to comment.