Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Count call without filters #94

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sageintacctsdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,19 +352,21 @@ def __construct_post_legacy_payload(self, data: Dict):

return self.format_and_send_request(payload)

def count(self):
def count(self, field: str = 'STATUS', value: str = 'active'):
get_count = {
'query': {
'object': self.__dimension,
'select': {
'field': 'RECORDNO'
},
'filter': {
'equalto': {'field': 'STATUS', 'value': 'active'}
'equalto': {'field': field, 'value': value}
},
'pagesize': '1'
}
}
if not field or not value:
del get_count['query']['filter']

response = self.format_and_send_request(get_count)
return int(response['data']['@totalcount'])
Expand Down Expand Up @@ -417,7 +419,7 @@ def get_all(self, field: str = None, value: str = None, fields: list = None):
List of Dict.
"""
complete_data = []
count = self.count()
count = self.count(None)
pagesize = self.__pagesize
for offset in range(0, count, pagesize):
data = {
Expand Down Expand Up @@ -448,7 +450,7 @@ def get_all_generator(self, field: str = None, value: str = None, fields: list =
"""
Get all data from Sage Intacct
"""
count = self.count()
count = self.count(None)
pagesize = self.__pagesize
for offset in range(0, count, pagesize):
data = {
Expand Down Expand Up @@ -534,7 +536,7 @@ def get_by_query(self, fields: List[str] = None,

complete_data = []
filtered_total = None
count = self.count()
count = self.count(None)
pagesize = self.__pagesize
offset = 0
formatted_filter = filter_payload
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='sageintacctsdk',
version='1.23.0',
version='1.23.1',
author='Ashwin T',
author_email='[email protected]',
description='Python SDK for accessing Sage Intacct APIs',
Expand Down