From 8163243dadbc0c552a0c5688284226e9ef4a82ff Mon Sep 17 00:00:00 2001 From: Ashutosh singh <55102089+Ashutosh619-sudo@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:33:53 +0530 Subject: [PATCH] Allocation Entry API support (#81) * Allocation Entry API support * Version bump up * Implemented Allocation entry API * Add delete api for all dimensions * remove line * adding compulsory fields * added allocations api * allocations api * allocations api * change in allocation_entry * comment resolved * comment resolved * Added fields to allocation --- sageintacctsdk/apis/__init__.py | 6 +++++- sageintacctsdk/apis/allocation_entry.py | 25 +++++++++++++++++++++++++ sageintacctsdk/apis/allocations.py | 6 ++++++ sageintacctsdk/apis/api_base.py | 14 ++++++++++++++ sageintacctsdk/apis/constants.py | 11 +++++++++++ sageintacctsdk/sageintacctsdk.py | 12 +++++++++++- setup.py | 2 +- 7 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 sageintacctsdk/apis/allocation_entry.py create mode 100644 sageintacctsdk/apis/allocations.py diff --git a/sageintacctsdk/apis/__init__.py b/sageintacctsdk/apis/__init__.py index a0df6a4..5abd571 100644 --- a/sageintacctsdk/apis/__init__.py +++ b/sageintacctsdk/apis/__init__.py @@ -37,6 +37,8 @@ from .revenue_recognition_schedule_entries import RevRecScheduleEntries from .cost_types import CostTypes from .order_entry_transactions import OrderEntryTransactions +from .allocation_entry import AllocationEntry +from .allocations import Allocations __all__ = [ 'ApiBase', @@ -57,8 +59,9 @@ 'Customers', 'Items', 'APPayments', + 'AllocationEntry', 'ARInvoices', - 'ARPayments' + 'ARPayments', 'Reimbursements', 'CheckingAccounts', 'SavingsAccounts', @@ -75,4 +78,5 @@ 'RevRecScheduleEntries', 'CostTypes', 'OrderEntryTransactions', + 'Allocations' ] diff --git a/sageintacctsdk/apis/allocation_entry.py b/sageintacctsdk/apis/allocation_entry.py new file mode 100644 index 0000000..3b23405 --- /dev/null +++ b/sageintacctsdk/apis/allocation_entry.py @@ -0,0 +1,25 @@ +from .api_base import ApiBase + +class AllocationEntry(ApiBase): + """Class for Allocation Entry APIs.""" + def __init__(self): + ApiBase.__init__(self, dimension='allocationentry') + + + def get_all_generator(self, field: str = None, value: str = None, fields: list = None, updated_at: str = None, order_by_field: str = None, order: str = None): + + """ + Get all the allocation entries. + """ + + allocation_entries_fields = ['ALLOCATIONID', 'ALLOCATIONKEY', 'LOCATIONID', 'DEPARTMENTID', 'PROJECTID', + 'CUSTOMERID', 'ITEMID', 'TASKID', 'COSTTYPEID', 'CLASSID'] + + fields = self.get_lookup() + if fields: + fields = fields['Type']['Relationships']['Relationship'] + + for allocation_field in fields: + allocation_entries_fields.append(allocation_field['RELATEDBY']) + + yield from super().get_all_generator(fields=allocation_entries_fields, field=field, value=value) diff --git a/sageintacctsdk/apis/allocations.py b/sageintacctsdk/apis/allocations.py new file mode 100644 index 0000000..8a58c18 --- /dev/null +++ b/sageintacctsdk/apis/allocations.py @@ -0,0 +1,6 @@ +from .api_base import ApiBase + +class Allocations(ApiBase): + """Class for Allocation Entry APIs.""" + def __init__(self): + ApiBase.__init__(self, dimension='ALLOCATION') diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index d809cce..9e92ef8 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -598,3 +598,17 @@ def get_lookup(self): data = {'lookup': {'object': self.__dimension}} return self.format_and_send_request(data)['data'] + + def delete(self, key): + """ + Delete the dimension with the given key + """ + + data = { + 'delete': { + 'object': self.__dimension, + 'keys': str(key) + } + } + + return self.format_and_send_request(data=data) diff --git a/sageintacctsdk/apis/constants.py b/sageintacctsdk/apis/constants.py index 166e4f6..bc5bec0 100644 --- a/sageintacctsdk/apis/constants.py +++ b/sageintacctsdk/apis/constants.py @@ -696,5 +696,16 @@ 'TASKDIMKEY', 'TASKID', 'TASKNAME' + ], + 'ALLOCATION': [ + 'RECORDNO', + 'ALLOCATIONID', + 'STATUS', + 'DESCRIPTION', + 'TYPE', + 'WHENCREATED', + 'WHENMODIFIED', + 'CREATEDBY', + 'MODIFIEDBY' ] } diff --git a/sageintacctsdk/sageintacctsdk.py b/sageintacctsdk/sageintacctsdk.py index 1d4273c..8f07471 100644 --- a/sageintacctsdk/sageintacctsdk.py +++ b/sageintacctsdk/sageintacctsdk.py @@ -5,7 +5,7 @@ Vendors, Bills, Projects, Departments, ChargeCardAccounts, ChargeCardTransactions, Customers, Items,\ APPayments, Reimbursements, CheckingAccounts, SavingsAccounts, Tasks, ExpensePaymentTypes, Dimensions,\ DimensionValues, LocationEntities, ARInvoices, ARPayments, TaxDetails, GLDetail, Classes, JournalEntries,\ - RevRecSchedules, RevRecScheduleEntries, CostTypes, OrderEntryTransactions + RevRecSchedules, RevRecScheduleEntries, CostTypes, OrderEntryTransactions, Allocations, AllocationEntry class SageIntacctSDK: @@ -52,6 +52,7 @@ def __init__(self, sender_id: str, sender_password: str, user_id: str, self.customers = Customers() self.items = Items() self.ap_payments = APPayments() + self.allocation_entry = AllocationEntry() self.ar_invoices = ARInvoices() self.ar_payments = ARPayments() self.reimbursements = Reimbursements() @@ -70,6 +71,7 @@ def __init__(self, sender_id: str, sender_password: str, user_id: str, self.rev_rec_schedule_entries = RevRecScheduleEntries() self.cost_types = CostTypes() self.order_entry_transactions = OrderEntryTransactions() + self.allocations = Allocations() self.update_sender_id() self.update_sender_password() self.update_session_id() @@ -115,6 +117,8 @@ def update_sender_id(self): self.rev_rec_schedule_entries.set_sender_id(self.__sender_id) self.cost_types.set_sender_id(self.__sender_id) self.order_entry_transactions.set_sender_id(self.__sender_id) + self.allocation_entry.set_sender_id(self.__sender_id) + self.allocations.set_sender_id(self.__sender_id) def update_sender_password(self): """ @@ -156,6 +160,8 @@ def update_sender_password(self): self.rev_rec_schedule_entries.set_sender_password(self.__sender_password) self.cost_types.set_sender_password(self.__sender_password) self.order_entry_transactions.set_sender_password(self.__sender_password) + self.allocation_entry.set_sender_password(self.__sender_password) + self.allocations.set_sender_password(self.__sender_password) def update_session_id(self): """ @@ -199,6 +205,8 @@ def update_session_id(self): self.rev_rec_schedule_entries.set_session_id(self.__session_id) self.cost_types.set_session_id(self.__session_id) self.order_entry_transactions.set_session_id(self.__session_id) + self.allocation_entry.set_session_id(self.__session_id) + self.allocations.set_session_id(self.__session_id) def update_show_private(self): """ @@ -240,3 +248,5 @@ def update_show_private(self): self.rev_rec_schedule_entries.set_show_private(self.__show_private) self.cost_types.set_show_private(self.__show_private) self.order_entry_transactions.set_show_private(self.__show_private) + self.allocation_entry.set_show_private(self.__show_private) + self.allocations.set_show_private(self.__show_private) diff --git a/setup.py b/setup.py index 1272f5b..22c1e0e 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='sageintacctsdk', - version='1.21.1', + version='1.22.0', author='Ashwin T', author_email='ashwin.t@fyle.in', description='Python SDK for accessing Sage Intacct APIs',