Skip to content

Commit

Permalink
add feature filter_transactions_by_date (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
arilton authored Sep 18, 2024
1 parent 8d60cd1 commit f434ac8
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions tap_restaurant365/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

from functools import cached_property
import typing as t
from datetime import datetime, timedelta
from typing import Any
Expand Down Expand Up @@ -152,7 +153,6 @@ class TransactionsParentStream(LimitedTimeframeStream):
name = "transaction_parent_stream"
path = "/Transaction"
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True
schema = th.PropertiesList(
th.Property("transactionId", th.StringType),
Expand All @@ -171,55 +171,46 @@ class TransactionsParentStream(LimitedTimeframeStream):
th.Property("modifiedBy", th.StringType),
).to_dict()

@cached_property
def replication_key(self):
if self._config.get("filter_transactions_by_date"):
return "date"
return "modifiedOn"


class BillsStream(TransactionsParentStream):
"""Define custom stream."""

name = "bills"
path = "/Transaction" # ?$filter=type eq 'AP Invoices'
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True


class JournalEntriesStream(TransactionsParentStream):
"""Define custom stream."""

name = "journal_entries"
path = "/Transaction" # ?$filter=type eq 'Journal Entry and modifiedOn ge '
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True


class CreditMemosStream(TransactionsParentStream):
"""Define custom stream."""

name = "credit_memos"
path = "/Transaction" # ?$filter=type eq 'AP Credit memo and modifiedOn ge '
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True


class StockCountStream(TransactionsParentStream):
"""Define custom stream."""

name = "stock_count"
path = "/Transaction" # ?$filter=type eq 'Stock Count and modifiedOn ge '
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True


class BankExpensesStream(TransactionsParentStream):
"""Define custom stream."""

name = "bank_expenses"
path = "/Transaction" # ?$filter=type eq 'Bank Expense and modifiedOn ge '
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True


class VendorsStream(Restaurant365Stream):
Expand Down

0 comments on commit f434ac8

Please sign in to comment.