From 06e17dfd5c052f92f2afac419b12d9997ae96aac Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Tue, 8 Mar 2022 09:45:48 +0100 Subject: [PATCH] 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. --- bindings/python/example_scripts/qof.py | 4 ++-- bindings/python/gnucash_core.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py index 8d009548bc..5f138137bb 100644 --- a/bindings/python/example_scripts/qof.py +++ b/bindings/python/example_scripts/qof.py @@ -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).") diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index b4d7126b79..5ac3b6562f 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -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')