Provide wrapper for qof numeric predicate

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.
This commit is contained in:
Christoph Holtermann 2022-03-08 09:45:48 +01:00
parent f44d23035e
commit 06e17dfd5c
2 changed files with 8 additions and 2 deletions

View File

@ -161,7 +161,7 @@ with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
# 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).")

View File

@ -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')