From 2f21e574aecb89b3216abe8d539e3e90ad7bef2d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 24 Sep 2023 09:23:31 -0500 Subject: [PATCH] Fix start/end date defaults for importers, per upstream changes --- rattail_harvest/importing/model.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rattail_harvest/importing/model.py b/rattail_harvest/importing/model.py index 086965c..715f5a8 100644 --- a/rattail_harvest/importing/model.py +++ b/rattail_harvest/importing/model.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -67,9 +67,14 @@ class HarvestTimeEntryImporter(ToRattail): self.session, model.HarvestProject, key='id') def cache_query(self): - query = super(HarvestTimeEntryImporter, self).cache_query() - return query.filter(self.model_class.spent_date >= self.start_date)\ - .filter(self.model_class.spent_date <= self.end_date) + query = super().cache_query() + + if self.start_date: + query = query.filter(self.model_class.spent_date >= self.start_date) + if self.end_date: + query = query.filter(self.model_class.spent_date <= self.end_date) + + return query def get_harvest_project(self, project_id): if hasattr(self, 'harvest_projects_by_id'):