Skip to content

Commit

Permalink
fix: Count call without filters (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Oct 4, 2024
1 parent f4cdf4c commit c254d56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit c254d56

Please sign in to comment.