Show yesterday by default for Trainwreck if so configured

This commit is contained in:
Lance Edgar 2023-09-20 18:13:52 -05:00
parent 836fc0bf5b
commit 3d6cc8a490

View file

@ -165,16 +165,22 @@ class TransactionView(MasterView):
return TrainwreckSession()
def configure_grid(self, g):
super(TransactionView, self).configure_grid(g)
super().configure_grid(g)
app = self.get_rattail_app()
g.filters['receipt_number'].default_active = True
g.filters['receipt_number'].default_verb = 'equal'
# end_time
g.set_sort_defaults('end_time', 'desc')
g.filters['end_time'].default_active = True
g.filters['end_time'].default_verb = 'equal'
g.filters['end_time'].default_value = str(app.today())
g.set_sort_defaults('end_time', 'desc')
# TODO: should expose this setting somewhere
if self.rattail_config.getbool('trainwreck', 'show_yesterday_first'):
date = app.yesterday()
else:
date = app.today()
g.filters['end_time'].default_value = str(date)
g.set_enum('system', self.enum.TRAINWRECK_SYSTEM)
g.set_type('total', 'currency')