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

HGI-6501 / Add feature filter_transactions_by_date #26

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
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
Loading