From 650c26036ae90d72d496e7cbafbbb932e441fab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 9 Apr 2023 21:03:18 +0800 Subject: [PATCH] Fixed the search result to allow full year/month/day specification. --- src/accounting/report/reports/search.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/accounting/report/reports/search.py b/src/accounting/report/reports/search.py index 372fe27..61cc4c2 100644 --- a/src/accounting/report/reports/search.py +++ b/src/accounting/report/reports/search.py @@ -151,6 +151,17 @@ class LineItemCollector: == journal_entry_date.day)) except ValueError: pass + try: + journal_entry_date = datetime.strptime(k, "%Y/%m/%d") + conditions.append(sa.and_( + sa.extract("year", JournalEntry.date) + == journal_entry_date.year, + sa.extract("month", JournalEntry.date) + == journal_entry_date.month, + sa.extract("day", JournalEntry.date) + == journal_entry_date.day)) + except ValueError: + pass return sa.select(JournalEntry.id).filter(sa.or_(*conditions))