Fix start/end date defaults for importers, per upstream changes

This commit is contained in:
Lance Edgar 2023-09-24 09:23:31 -05:00
parent 2fa7ef5e71
commit 2f21e574ae

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2023 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -67,9 +67,14 @@ class HarvestTimeEntryImporter(ToRattail):
self.session, model.HarvestProject, key='id') self.session, model.HarvestProject, key='id')
def cache_query(self): def cache_query(self):
query = super(HarvestTimeEntryImporter, self).cache_query() query = super().cache_query()
return query.filter(self.model_class.spent_date >= self.start_date)\
.filter(self.model_class.spent_date <= self.end_date) 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): def get_harvest_project(self, project_id):
if hasattr(self, 'harvest_projects_by_id'): if hasattr(self, 'harvest_projects_by_id'):