From a60ab030a1f4ebb18244a93032c696b0988a0db5 Mon Sep 17 00:00:00 2001 From: talas9 Date: Thu, 14 Nov 2024 13:59:42 +0400 Subject: [PATCH 1/3] Adding Credit Note to ZohoBooks Object Fixing typo "creditnode" -> "creditnote" --- pyzohoapi/books.py | 1 + pyzohoapi/inventory.py | 1 + pyzohoapi/objecttypes/__init__.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyzohoapi/books.py b/pyzohoapi/books.py index 7e53250..cf21b7d 100644 --- a/pyzohoapi/books.py +++ b/pyzohoapi/books.py @@ -14,6 +14,7 @@ def Account(self, *args, **kwargs): return objecttypes.Account(self, *args, **kw def CompositeItem(self, *args, **kwargs): return objecttypes.CompositeItem(self, *args, **kwargs) def Contact(self, *args, **kwargs): return objecttypes.Contact(self, *args, **kwargs) def CustomerPayment(self, *args, **kwargs): return objecttypes.CustomerPayment(self, *args, **kwargs) + def CreditNote(self, *args, **kwargs): return objecttypes.CreditNote(self, *args, **kwargs) def Document(self, *args, **kwargs): return objecttypes.Document(self, *args, **kwargs) def Invoice(self, *args, **kwargs): return objecttypes.Invoice(self, *args, **kwargs) def Item(self, *args, **kwargs): return objecttypes.Item(self, *args, **kwargs) diff --git a/pyzohoapi/inventory.py b/pyzohoapi/inventory.py index c6be24b..92a078b 100644 --- a/pyzohoapi/inventory.py +++ b/pyzohoapi/inventory.py @@ -14,6 +14,7 @@ def Account(self, *args, **kwargs): return objecttypes.Account(self, *args, **kw def Bill(self, *args, **kwargs): return objecttypes.Bill(self, *args, **kwargs) def Brand(self, *args, **kwargs): return objecttypes.Brand(self, *args, **kwargs) def Bundle(self, *args, **kwargs): return objecttypes.Bundle(self, *args, **kwargs) + def CreditNote(self, *args, **kwargs): return objecttypes.CreditNote(self, *args, **kwargs) def CompositeItem(self, *args, **kwargs): return objecttypes.CompositeItem(self, *args, **kwargs) def Contact(self, *args, **kwargs): return objecttypes.Contact(self, *args, **kwargs) def CustomerPayment(self, *args, **kwargs): return objecttypes.CustomerPayment(self, *args, **kwargs) diff --git a/pyzohoapi/objecttypes/__init__.py b/pyzohoapi/objecttypes/__init__.py index 4160eaa..3a68745 100644 --- a/pyzohoapi/objecttypes/__init__.py +++ b/pyzohoapi/objecttypes/__init__.py @@ -49,7 +49,7 @@ def ZohoObjectFactory(name, responseKey="composite_item", idKey="composite_item_id", mixins=[HasActivate, HasBundle, HasCustomFields]) Contact = ZohoObjectFactory("Contact", mixins=[HasActivate, HasAddresses, HasCustomFields]) -CreditNote = ZohoObjectFactory("CreditNode", mixins=[HasCustomFields]) +CreditNote = ZohoObjectFactory("CreditNote", mixins=[HasCustomFields]) Currency = ZohoObjectFactory("Currency", urlPath="settings/currencies", pluralResponseKey="currencies") CustomerPayment = ZohoObjectFactory("CustomerPayment", From 9bc85ee58f43d82e710e0d5fa64b56353e7657e2 Mon Sep 17 00:00:00 2001 From: talas9 Date: Thu, 14 Nov 2024 15:16:11 +0400 Subject: [PATCH 2/3] Added invoice status (void(),sent() and draft()) --- pyzohoapi/objecttypes/__init__.py | 4 ++-- pyzohoapi/objecttypes/mixins/__init__.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyzohoapi/objecttypes/__init__.py b/pyzohoapi/objecttypes/__init__.py index 3a68745..c190c85 100644 --- a/pyzohoapi/objecttypes/__init__.py +++ b/pyzohoapi/objecttypes/__init__.py @@ -3,7 +3,7 @@ from pyzohoapi.objecttypes.mixins.CompositeItemOps import HasBundle from ..core import ZohoObjectBase -from .mixins import HasActivate, HasAddresses, HasConfirm, HasCustomFields, HasDelivered, HasDraft, HasImage, HasVoid +from .mixins import HasActivate, HasAddresses, HasConfirm, HasCustomFields, HasDelivered, HasDraft, HasImage, HasVoid, HasSent def ZohoObjectFactory(name, @@ -55,7 +55,7 @@ def ZohoObjectFactory(name, CustomerPayment = ZohoObjectFactory("CustomerPayment", idKey="payment_id", numberKey="payment_number", mixins=[HasCustomFields]) Document = ZohoObjectFactory("Document", raw=True) -Invoice = ZohoObjectFactory("Invoice", mixins=[HasCustomFields]) +Invoice = ZohoObjectFactory("Invoice", mixins=[HasCustomFields, HasDraft, HasVoid, HasSent]) Item = ZohoObjectFactory("Item", mixins=[HasActivate, HasCustomFields, HasImage]) ItemAdjustment = ZohoObjectFactory("ItemAdjustment", urlPath="inventoryadjustments", responseKey="inventory_adjustment", diff --git a/pyzohoapi/objecttypes/mixins/__init__.py b/pyzohoapi/objecttypes/mixins/__init__.py index a2c1f37..33611cd 100644 --- a/pyzohoapi/objecttypes/mixins/__init__.py +++ b/pyzohoapi/objecttypes/mixins/__init__.py @@ -95,6 +95,13 @@ def Void(self): raise ZohoInvalidOpError("Void", self) return self._mark('void') +class HasSent(_HasStatus): + """Adds `Sent()`""" + def Sent(self): + if not self._id: + raise ZohoInvalidOpError("Sent", self) + return self._mark('sent') + class _HasAspect: def _updateAspect(self, aspect, aspect_id, data): From 1d5acee8fff781498db53387d55520efdef5cc64 Mon Sep 17 00:00:00 2001 From: talas9 Date: Thu, 14 Nov 2024 15:25:04 +0400 Subject: [PATCH 3/3] fix --- pyzohoapi/objecttypes/mixins/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyzohoapi/objecttypes/mixins/__init__.py b/pyzohoapi/objecttypes/mixins/__init__.py index 33611cd..5f04af1 100644 --- a/pyzohoapi/objecttypes/mixins/__init__.py +++ b/pyzohoapi/objecttypes/mixins/__init__.py @@ -10,7 +10,7 @@ 'HasActivate', 'HasAddresses', 'HasBundle', - 'HasConfirm', 'HasDraft', 'HasVoid', 'HasDelivered', + 'HasConfirm', 'HasDraft', 'HasVoid', 'HasSent', 'HasDelivered', 'HasCustomFields', 'HasImage', ]