From 031831ea5700f9c90ac359c138c03d0f4aca5b3e Mon Sep 17 00:00:00 2001 From: "William N. Green" Date: Sat, 1 Jun 2024 12:25:11 -0700 Subject: [PATCH] Created use_decimal flag on client creation https://github.com/ej2/python-quickbooks/pull/358#issuecomment-2143554544 --- quickbooks/client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/quickbooks/client.py b/quickbooks/client.py index 23b057a..0566ddb 100644 --- a/quickbooks/client.py +++ b/quickbooks/client.py @@ -26,6 +26,7 @@ class QuickBooks(object): minorversion = None verifier_token = None invoice_link = False + use_decimal = False sandbox_api_url_v3 = "https://sandbox-quickbooks.api.intuit.com/v3" api_url_v3 = "https://quickbooks.api.intuit.com/v3" @@ -81,6 +82,9 @@ def __new__(cls, **kwargs): if 'verifier_token' in kwargs: instance.verifier_token = kwargs.get('verifier_token') + if 'use_decimal' in kwargs: + instance.use_decimal = kwargs.get('use_decimal') + return instance def _start_session(self): @@ -208,7 +212,10 @@ def make_request(self, request_type, url, request_body=None, content_type='appli "Application authentication failed", error_code=req.status_code, detail=req.text) try: - result = json.loads(req.text, parse_float=decimal.Decimal) + if (self.use_decimal): + result = json.loads(req.text, parse_float=decimal.Decimal) + else: + result = json.loads(req.text) except: raise exceptions.QuickbooksException("Error reading json response: {0}".format(req.text), 10000)