diff --git a/sageintacctsdk/apis/allocation_entry.py b/sageintacctsdk/apis/allocation_entry.py index fd2db88..8338b22 100644 --- a/sageintacctsdk/apis/allocation_entry.py +++ b/sageintacctsdk/apis/allocation_entry.py @@ -1,3 +1,6 @@ +import re + +from sageintacctsdk.exceptions import WrongParamsError from .api_base import ApiBase class AllocationEntry(ApiBase): @@ -19,8 +22,28 @@ def get_all_generator(self, field: str = None, value: str = None, fields: list = fields = self.get_lookup() if fields and 'Type' in fields and fields['Type'] and 'Relationships' in fields['Type'] and fields['Type']['Relationships'] and 'Relationship' in fields['Type']['Relationships']: user_defined_dimensions = fields['Type']['Relationships']['Relationship'] - + for allocation_field in user_defined_dimensions: allocation_entries_fields.append(allocation_field['RELATEDBY']) - yield from super().get_all_generator(fields=allocation_entries_fields, field=field, value=value) + try: + yield from super().get_all_generator(fields=allocation_entries_fields, field=field, value=value) + except WrongParamsError as e: + error_response = e.response + if error_response is None: + raise + description2 = '' + if 'error' in error_response and isinstance(error_response['error'], list) and error_response['error']: + error = error_response['error'][0] + if 'description2' in error: + description2 = error['description2'] + + if description2: + match = re.search(r'\n\tallocationentry: \[(.*?)\]', description2) + if match: + removable_fields = match.group(1).split(', ') + for remove_field in removable_fields: + allocation_entries_fields.remove(remove_field) + yield from super().get_all_generator(fields=allocation_entries_fields, field=field, value=value) + else: + raise diff --git a/setup.py b/setup.py index 47a7677..3cd47c4 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='sageintacctsdk', - version='1.22.3', + version='1.22.4', author='Ashwin T', author_email='ashwin.t@fyle.in', description='Python SDK for accessing Sage Intacct APIs',