Skip to content

Commit

Permalink
Updates to creditcardpayment and invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
ej2 committed Oct 11, 2020
1 parent 885fcfa commit e522cc3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

* 0.8.4 (October 11, 2020)
* Added support for the CreditCardPayment entity
* Updated readme
* Added missing property InvoiceLink and AllowOnlineACHPayment to Invoice object

* 0.8.3 (August 24, 2020)
* Fixed issue with CompanyCurrency object
* Added to_ref method to the Term object
Expand Down
25 changes: 20 additions & 5 deletions quickbooks/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ def to_dict(self):

class ReadMixin(object):
qbo_object_name = ""
qbo_json_object_name = ""

@classmethod
def get(cls, id, qb=None):
if not qb:
qb = QuickBooks()

json_data = qb.get_single_object(cls.qbo_object_name, pk=id)
return cls.from_json(json_data[cls.qbo_object_name])

if cls.qbo_json_object_name != '':
return cls.from_json(json_data[cls.qbo_json_object_name])
else:
return cls.from_json(json_data[cls.qbo_object_name])


class SendMixin(object):
Expand Down Expand Up @@ -141,6 +146,7 @@ def void(self, qb=None):

class UpdateMixin(object):
qbo_object_name = ""
qbo_json_object_name = ""

def save(self, qb=None):
if not qb:
Expand All @@ -151,9 +157,12 @@ def save(self, qb=None):
else:
json_data = qb.create_object(self.qbo_object_name, self.to_json())

obj = type(self).from_json(json_data[self.qbo_object_name])
self.Id = obj.Id
if self.qbo_json_object_name != '':
obj = type(self).from_json(json_data[self.qbo_json_object_name])
else:
obj = type(self).from_json(json_data[self.qbo_object_name])

self.Id = obj.Id
return obj


Expand All @@ -176,6 +185,7 @@ def delete(self, qb=None):

class ListMixin(object):
qbo_object_name = ""
qbo_json_object_name = ""

@classmethod
def all(cls, order_by="", start_position="", max_results=100, qb=None):
Expand Down Expand Up @@ -253,8 +263,13 @@ def query(cls, select, qb=None):

obj_list = []

if cls.qbo_object_name in json_data["QueryResponse"]:
for item_json in json_data["QueryResponse"][cls.qbo_object_name]:
if cls.qbo_json_object_name != '':
object_name = cls.qbo_json_object_name
else:
object_name = cls.qbo_object_name

if object_name in json_data["QueryResponse"]:
for item_json in json_data["QueryResponse"][object_name]:
obj_list.append(cls.from_json(item_json))

return obj_list
Expand Down
1 change: 1 addition & 0 deletions quickbooks/objects/creditcardpayment_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CreditCardPayment(DeleteMixin, QuickbooksManagedObject, QuickbooksTransact
}

qbo_object_name = "CreditCardPayment"
qbo_json_object_name = "CreditCardPaymentTxn" # JSON object name doesn't match the endpoint name - Thanks Intuit!

def __init__(self):
super(CreditCardPayment, self).__init__()
Expand Down
3 changes: 3 additions & 0 deletions quickbooks/objects/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def __init__(self):
self.Balance = 0
self.AllowIPNPayment = True
self.AllowOnlineCreditCardPayment = False
self.AllowOnlineACHPayment = False
self.DocNumber = None

self.PrivateNote = ""
self.DueDate = ""
self.ShipDate = ""
Expand All @@ -70,6 +72,7 @@ def __init__(self):
self.EmailStatus = "NotSet"
self.ExchangeRate = 1
self.GlobalTaxCalculation = "TaxExcluded"
self.InvoiceLink = ""

self.EInvoiceStatus = None

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(*parts):
return fp.read()


VERSION = (0, 8, 3)
VERSION = (0, 8, 4)
version = '.'.join(map(str, VERSION))

setup(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
)

self.qb_client = QuickBooks(
minorversion=53,
minorversion=54,
auth_client=self.auth_client,
refresh_token=os.environ.get('REFRESH_TOKEN'),
company_id=os.environ.get('COMPANY_ID'),
Expand Down

0 comments on commit e522cc3

Please sign in to comment.