Skip to content

Commit

Permalink
Makes date intervals be 15 days only, not 30.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmesel committed Jan 25, 2024
1 parent cd7e0d8 commit 0f42218
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tap_restaurant365/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tap_restaurant365.client import Restaurant365Stream


class ThirtyDaysStream(Restaurant365Stream):
class LimitedTimeframeStream(Restaurant365Stream):
"""parent class stream for override/pagination"""

name = "vendors"
Expand All @@ -29,9 +29,9 @@ def get_next_page_token(
start_date = (parser.parse(self.tap_state["bookmarks"][self.name]['starting_replication_value']) + timedelta(seconds=1)) or parser.parse(self.config.get("start_date"))
today = datetime.today()
previous_token = previous_token or start_date
next_token = (previous_token + timedelta(days=30)).replace(tzinfo=None)
next_token = (previous_token + timedelta(days=15)).replace(tzinfo=None)

if (today - next_token).days < 30:
if (today - next_token).days < 15:
self.paginate = False
return next_token
else:
Expand Down Expand Up @@ -60,7 +60,7 @@ def get_url_params(
params["$filter"] += f" and type eq 'Stock Count'"
if self.name == "bank_expenses":
params["$filter"] += f" and type eq 'Bank Expense'"
#
#

return params

Expand Down Expand Up @@ -101,7 +101,7 @@ class AccountsStream(Restaurant365Stream):
).to_dict()


class TransactionsStream(ThirtyDaysStream):
class TransactionsStream(LimitedTimeframeStream):
"""Define custom stream."""

name = "transaction"
Expand Down Expand Up @@ -131,7 +131,7 @@ class BillsStream(TransactionsStream):
"""Define custom stream."""

name = "bills"
path = "/Transaction" #?$filter=type eq 'AP Invoices'
path = "/Transaction" #?$filter=type eq 'AP Invoices'
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True
Expand All @@ -145,7 +145,7 @@ class JournalEntriesStream(TransactionsStream):
primary_keys = ["transactionId"]
replication_key = "modifiedOn"
paginate = True

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

Expand Down Expand Up @@ -354,7 +354,7 @@ class POSEmployeeStream(Restaurant365Stream):

).to_dict()

class SalesEmployeeStream(ThirtyDaysStream):
class SalesEmployeeStream(LimitedTimeframeStream):
"""Define custom stream."""

name = "sales_employee"
Expand Down Expand Up @@ -393,7 +393,7 @@ class SalesEmployeeStream(ThirtyDaysStream):



class SalesDetailStream(ThirtyDaysStream):
class SalesDetailStream(LimitedTimeframeStream):
"""Define custom stream."""

name = "sales_detail"
Expand Down Expand Up @@ -426,7 +426,7 @@ class SalesDetailStream(ThirtyDaysStream):
).to_dict()


class SalesPaymentStream(ThirtyDaysStream):
class SalesPaymentStream(LimitedTimeframeStream):
"""Define custom stream."""

name = "sales_payment"
Expand Down Expand Up @@ -477,7 +477,7 @@ class EntityDeletedStream(Restaurant365Stream):

).to_dict()

class TransactionDetailsStream(ThirtyDaysStream):
class TransactionDetailsStream(LimitedTimeframeStream):
"""Define custom stream."""

name = "transaction_detail"
Expand Down

0 comments on commit 0f42218

Please sign in to comment.