Skip to content

Commit

Permalink
Created use_decimal flag on client creation
Browse files Browse the repository at this point in the history
  • Loading branch information
laf-rge committed Jun 1, 2024
1 parent 4158e8b commit 031831e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion quickbooks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 031831e

Please sign in to comment.