Skip to content

Commit

Permalink
support last_paid_at filter in fetching expenses (#27)
Browse files Browse the repository at this point in the history
support last_paid_at filter in fetching expenses (#27)
  • Loading branch information
Sravanksk authored Apr 29, 2022
1 parent 0e1e1d6 commit c4ac423
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions connector/fyle_integrations_platform_connector/apis/expenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Expenses(Base):
"""Class for Expenses APIs."""

def get(self, source_account_type: List[str], state: str, last_synced_at: datetime=None,
settled_at: datetime=None, filter_credit_expenses: bool=False) -> List[dict]:
settled_at: datetime=None, filter_credit_expenses: bool=False, last_paid_at=None) -> List[dict]:
"""
Get expenses.
Expand All @@ -25,7 +25,7 @@ def get(self, source_account_type: List[str], state: str, last_synced_at: dateti
"""
all_expenses = []

query_params = self.__construct_expenses_query_params(source_account_type, state, last_synced_at, settled_at)
query_params = self.__construct_expenses_query_params(source_account_type, state, last_synced_at, settled_at, last_paid_at)
generator = self.connection.list_all(query_params)

for expense_list in generator:
Expand All @@ -38,7 +38,7 @@ def get(self, source_account_type: List[str], state: str, last_synced_at: dateti


@staticmethod
def __construct_expenses_query_params(source_account_type: List[str], state: str, updated_at: datetime, settled_at: datetime) -> dict:
def __construct_expenses_query_params(source_account_type: List[str], state: str, updated_at: datetime, settled_at: datetime, last_paid_at: datetime) -> dict:
"""
Construct expenses query params.
:param source_account_type: Source account types.
Expand Down Expand Up @@ -75,6 +75,10 @@ def __construct_expenses_query_params(source_account_type: List[str], state: str
settled_at = 'gte.{}'.format(datetime.strftime(settled_at, '%Y-%m-%dT%H:%M:%S.000Z'))
query_params['last_settled_at'] = settled_at

if last_paid_at:
last_paid_at = 'gte.{}'.format(datetime.strftime(last_paid_at, '%Y-%m-%dT%H:%M:%S.000Z'))
query_params['report->last_paid_at'] = last_paid_at

return query_params


Expand Down
2 changes: 1 addition & 1 deletion connector/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='fyle-integrations-platform-connector',
version='1.11.0',
version='1.12.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='A common platform connector for all the Fyle Integrations to interact with Fyle Platform APIs',
Expand Down

0 comments on commit c4ac423

Please sign in to comment.