From 7fb9f67df7a5f20e7cd34991b7b395be75768c5e Mon Sep 17 00:00:00 2001 From: Hassan Syyid Date: Mon, 3 May 2021 13:19:55 -0400 Subject: [PATCH] ensure P&L report stream works even if current period has no data --- setup.py | 2 +- tap_quickbooks/quickbooks/__init__.py | 4 ++-- .../reportstreams/ProfitAndLossDetailReport.py | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index f8f0de3..1cc4c2a 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def get_version(): readme = f.read() setup(name='tap-quickbooks', - version='1.4.31', + version='1.4.32', description='Singer.io tap for extracting data from the Quickbooks API', author='hotglue', url='http://hotglue.xyz/', diff --git a/tap_quickbooks/quickbooks/__init__.py b/tap_quickbooks/quickbooks/__init__.py index fb6e464..ab7232a 100644 --- a/tap_quickbooks/quickbooks/__init__.py +++ b/tap_quickbooks/quickbooks/__init__.py @@ -412,6 +412,6 @@ def query(self, catalog_entry, state): self.api_type)) def query_report(self, catalog_entry, state): - - reader = ProfitAndLossDetailReport(self) + start_date = self.get_start_date(state, catalog_entry) + reader = ProfitAndLossDetailReport(self, start_date) return reader.sync(catalog_entry) diff --git a/tap_quickbooks/quickbooks/reportstreams/ProfitAndLossDetailReport.py b/tap_quickbooks/quickbooks/reportstreams/ProfitAndLossDetailReport.py index d2d791c..6ce9238 100644 --- a/tap_quickbooks/quickbooks/reportstreams/ProfitAndLossDetailReport.py +++ b/tap_quickbooks/quickbooks/reportstreams/ProfitAndLossDetailReport.py @@ -15,8 +15,9 @@ class ProfitAndLossDetailReport(QuickbooksStream): key_properties: ClassVar[List[str]] = [] replication_method: ClassVar[str] = 'FULL_TABLE' - def __init__(self, qb): + def __init__(self, qb, start_date): self.qb = qb + self.start_date = start_date def _get_column_metadata(self, resp): columns = [] @@ -51,7 +52,7 @@ def _recursive_row_search(self, row, output, categories): categories.pop() def sync(self, catalog_entry): - + LOGGER.info(f"ignoring config start date {self.start_date}") end_date = datetime.date.today() for i in range(NUMBER_OF_PERIODS): @@ -73,7 +74,9 @@ def sync(self, catalog_entry): row_array = row_group.get("Row") if row_array is None: - return + # Update end date + end_date = start_date - datetime.timedelta(days=1) + continue output = [] categories = []