loftx/gnucash-rest

Don't use magic numbers in getInvoices()

Closed this issue · 1 comments

--- gnucash_rest.py
+++ gnucash_rest.py
@@ -32,6 +32,10 @@ from gnucash import \

 from gnucash import \
     INVOICE_IS_PAID
+    
+from gnucash.gnucash_core_c import \
+       GNC_INVOICE_CUST_INVOICE, \
+       GNC_INVOICE_VEND_INVOICE

 app = Flask(__name__)
 app.debug = True
@@ -164,8 +168,8 @@ def getInvoices(book, is_paid, is_active):
        elif is_active == 1:
                query.add_boolean_match(['active'], True, QOF_QUERY_AND)

-       # return only invoices (1 = invoices)
-       pred_data = gnucash.gnucash_core.QueryInt32Predicate(QOF_COMPARE_EQUAL, 1)
+       # return only invoices 
+       pred_data = gnucash.gnucash_core.QueryInt32Predicate(QOF_COMPARE_EQUAL, GNC_INVOICE_CUST_INVOICE)
        query.add_term([INVOICE_TYPE], pred_data, QOF_QUERY_AND)

        invoices = []
loftx commented

This issue has now been resolved as of the lastest commit - thanks for your help!