gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Tue Mar 8 16:57:48 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/cbfacdcd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/64920e7c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/07cfe9e4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/395c7a70 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/62f8acf6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/06e17dfd (commit)
	from  https://github.com/Gnucash/gnucash/commit/d841b322 (commit)



commit cbfacdcd55fd7df760264d9d9c3f52b9e6cdee1f
Merge: d841b322d 64920e7c7
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Mar 8 13:46:07 2022 -0800

    Merge Christoff Holtermann's 'python-qof-example' into maint.


commit 64920e7c70f789c24dad977100b33b416bbda220
Author: Christoph Holtermann <mail at c-holtermann.net>
Date:   Tue Mar 8 10:49:44 2022 +0100

    Small fix in expected result

diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py
index 166ca72df..65e714e40 100644
--- a/bindings/python/example_scripts/qof.py
+++ b/bindings/python/example_scripts/qof.py
@@ -162,4 +162,4 @@ with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
     threshold = GncNumeric(5000, 100)
     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).")
+    print("Query splits with amount > " + str(threshold) + ": " + str(len(splits_3)) + " (Should be about 100).")

commit 07cfe9e45c15a4fa3ae8cfe40a6550ab710640d8
Author: Christoph Holtermann <mail at c-holtermann.net>
Date:   Tue Mar 8 10:45:17 2022 +0100

    Missed one redundancy

diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py
index 4ec700104..166ca72df 100644
--- a/bindings/python/example_scripts/qof.py
+++ b/bindings/python/example_scripts/qof.py
@@ -160,7 +160,6 @@ with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
 
     # query split value
     threshold = GncNumeric(5000, 100)
-    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).")

commit 395c7a705248615a70cb8b2ea334d309daee875f
Author: Christoph Holtermann <mail at c-holtermann.net>
Date:   Tue Mar 8 10:40:12 2022 +0100

    Modify examples to respect previous patch

diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py
index 5f138137b..4ec700104 100644
--- a/bindings/python/example_scripts/qof.py
+++ b/bindings/python/example_scripts/qof.py
@@ -9,8 +9,11 @@
 
 import datetime
 from random import randint
-from gnucash import Session, SessionOpenMode, Account, Transaction, Split, GncNumeric, Query
-from gnucash import QOF_COMPARE_GTE, QOF_COMPARE_GT, QOF_QUERY_AND, QOF_QUERY_OR, QOF_STRING_MATCH_NORMAL
+from gnucash import Session, SessionOpenMode, Account, Transaction, Split, \
+                    GncNumeric, Query
+from gnucash import QOF_COMPARE_GTE, QOF_COMPARE_GT, QOF_QUERY_AND, \
+                    QOF_QUERY_OR, QOF_STRING_MATCH_NORMAL, QOF_COMPARE_CONTAINS, \
+                    QOF_NUMERIC_MATCH_ANY
 from gnucash import gnucash_core_c
 from gnucash import gnucash_core
 
@@ -129,7 +132,6 @@ with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
     print("Query transactions with date > 1950: " + str(len(transactions_2)) + " (Should be about 50).")
 
     # query description
-    QOF_COMPARE_CONTAINS = 7
     isRegex = False
     terms = [(['desc'], gnucash_core.QueryStringPredicate(QOF_COMPARE_CONTAINS, "Transaction 5", QOF_STRING_MATCH_NORMAL, isRegex), QOF_QUERY_AND)]
     transactions_3 = query_transactions(book, terms)
@@ -138,21 +140,18 @@ with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
     # SPLITS
     #
     # query memo
-    QOF_COMPARE_CONTAINS = 7
     isRegex = False
     terms = [(['memo'], gnucash_core.QueryStringPredicate(QOF_COMPARE_CONTAINS, "A22", QOF_STRING_MATCH_NORMAL, isRegex), QOF_QUERY_AND)]
     splits_1 = query_splits(book, terms)
     print("Query splits with memo containing 'A22': " + str(len(splits_1)) + " (Should be 1).")
 
     # query description
-    QOF_COMPARE_CONTAINS = 7
     isRegex = False
     terms = [(['trans', 'desc'], gnucash_core.QueryStringPredicate(QOF_COMPARE_CONTAINS, "Transaction 5", QOF_STRING_MATCH_NORMAL, isRegex), QOF_QUERY_AND)]
     splits_2 = query_splits(book, terms)
     print("Query splits with transaction description containing 'Transaction 5': " + str(len(splits_2)) + " (Should be 22).")
 
     # query memo and desc
-    QOF_COMPARE_CONTAINS = 7
     isRegex = False
     terms = [(['memo'], gnucash_core.QueryStringPredicate(QOF_COMPARE_CONTAINS, "A22", QOF_STRING_MATCH_NORMAL, isRegex), QOF_QUERY_AND)]
     terms += [(['trans', 'desc'], gnucash_core.QueryStringPredicate(QOF_COMPARE_CONTAINS, "Transaction 55", QOF_STRING_MATCH_NORMAL, isRegex), QOF_QUERY_OR)]
diff --git a/bindings/python/example_scripts/rest-api/gnucash_rest.py b/bindings/python/example_scripts/rest-api/gnucash_rest.py
index 533447139..c1bb7ba05 100644
--- a/bindings/python/example_scripts/rest-api/gnucash_rest.py
+++ b/bindings/python/example_scripts/rest-api/gnucash_rest.py
@@ -62,6 +62,9 @@ from gnucash import \
     QOF_COMPARE_GTE, \
     QOF_COMPARE_NEQ
 
+from gnucash import \
+    QOF_DATE_MATCH_NORMAL
+
 from gnucash import \
     INVOICE_TYPE
 
@@ -915,8 +918,6 @@ def getAccountSplits(book, guid, date_posted_from, date_posted_to):
 
     SPLIT_TRANS= 'trans'
 
-    QOF_DATE_MATCH_NORMAL = 1
-
     TRANS_DATE_POSTED = 'date-posted'
 
     if date_posted_from != None:

commit 62f8acf6ae265ceac29a01b290b450b9a4cf8cfd
Author: Christoph Holtermann <mail at c-holtermann.net>
Date:   Tue Mar 8 10:33:25 2022 +0100

    Provide the complete set of QOF enums in gnucash

diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index 5ac3b6562..5147f7ae3 100644
--- a/bindings/python/gnucash_core.py
+++ b/bindings/python/gnucash_core.py
@@ -908,7 +908,29 @@ from gnucash.gnucash_core_c import \
     QOF_COMPARE_EQUAL, \
     QOF_COMPARE_GT, \
     QOF_COMPARE_GTE, \
-    QOF_COMPARE_NEQ
+    QOF_COMPARE_NEQ, \
+    QOF_COMPARE_CONTAINS, \
+    QOF_COMPARE_NCONTAINS
+
+from gnucash.gnucash_core_c import \
+    QOF_DATE_MATCH_NORMAL, \
+    QOF_DATE_MATCH_DAY
+
+from gnucash.gnucash_core_c import \
+    QOF_NUMERIC_MATCH_DEBIT, \
+    QOF_NUMERIC_MATCH_CREDIT, \
+    QOF_NUMERIC_MATCH_ANY
+
+from gnucash.gnucash_core_c import \
+    QOF_GUID_MATCH_ANY, \
+    QOF_GUID_MATCH_NONE, \
+    QOF_GUID_MATCH_NULL, \
+    QOF_GUID_MATCH_ALL, \
+    QOF_GUID_MATCH_LIST_ANY
+
+from gnucash.gnucash_core_c import \
+    QOF_CHAR_MATCH_ANY, \
+    QOF_CHAR_MATCH_NONE
 
 from gnucash.gnucash_core_c import \
     INVOICE_TYPE

commit 06e17dfd5c052f92f2afac419b12d9997ae96aac
Author: Christoph Holtermann <mail at c-holtermann.net>
Date:   Tue Mar 8 09:45:48 2022 +0100

    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.

diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py
index 8d009548b..5f138137b 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 b4d7126b7..5ac3b6562 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')



Summary of changes:
 bindings/python/example_scripts/qof.py             | 16 +++++-------
 .../example_scripts/rest-api/gnucash_rest.py       |  5 ++--
 bindings/python/gnucash_core.py                    | 30 +++++++++++++++++++++-
 3 files changed, 39 insertions(+), 12 deletions(-)



More information about the gnucash-changes mailing list