From 395c7a705248615a70cb8b2ea334d309daee875f Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Tue, 8 Mar 2022 10:40:12 +0100 Subject: [PATCH] Modify examples to respect previous patch --- bindings/python/example_scripts/qof.py | 11 +++++------ .../python/example_scripts/rest-api/gnucash_rest.py | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bindings/python/example_scripts/qof.py b/bindings/python/example_scripts/qof.py index 5f138137bb..4ec7001045 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 5334471396..c1bb7ba05c 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: