From e522cc3dcdce255be159e09911626e39743788d0 Mon Sep 17 00:00:00 2001 From: ej2 Date: Sun, 11 Oct 2020 13:46:25 -0500 Subject: [PATCH] Updates to creditcardpayment and invoice --- CHANGELOG.rst | 5 ++++ quickbooks/mixins.py | 25 +++++++++++++++---- .../objects/creditcardpayment_entity.py | 1 + quickbooks/objects/invoice.py | 3 +++ setup.py | 2 +- tests/integration/test_base.py | 2 +- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ca2424..43ee924 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/quickbooks/mixins.py b/quickbooks/mixins.py index bf33875..791ec69 100644 --- a/quickbooks/mixins.py +++ b/quickbooks/mixins.py @@ -93,6 +93,7 @@ def to_dict(self): class ReadMixin(object): qbo_object_name = "" + qbo_json_object_name = "" @classmethod def get(cls, id, qb=None): @@ -100,7 +101,11 @@ def get(cls, id, qb=None): 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): @@ -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: @@ -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 @@ -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): @@ -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 diff --git a/quickbooks/objects/creditcardpayment_entity.py b/quickbooks/objects/creditcardpayment_entity.py index 11220b4..d7b83a9 100644 --- a/quickbooks/objects/creditcardpayment_entity.py +++ b/quickbooks/objects/creditcardpayment_entity.py @@ -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__() diff --git a/quickbooks/objects/invoice.py b/quickbooks/objects/invoice.py index ddcdb94..0aed1c6 100644 --- a/quickbooks/objects/invoice.py +++ b/quickbooks/objects/invoice.py @@ -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 = "" @@ -70,6 +72,7 @@ def __init__(self): self.EmailStatus = "NotSet" self.ExchangeRate = 1 self.GlobalTaxCalculation = "TaxExcluded" + self.InvoiceLink = "" self.EInvoiceStatus = None diff --git a/setup.py b/setup.py index 2e1c27a..92d0d9a 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def read(*parts): return fp.read() -VERSION = (0, 8, 3) +VERSION = (0, 8, 4) version = '.'.join(map(str, VERSION)) setup( diff --git a/tests/integration/test_base.py b/tests/integration/test_base.py index af39212..4eda02f 100644 --- a/tests/integration/test_base.py +++ b/tests/integration/test_base.py @@ -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'),