From 169b3c292ad020f46155c41fe7a5424609b5572a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 26 Apr 2023 13:26:38 +0800 Subject: [PATCH] Renamed the "journal_entry_date" variable to "date" in the "__get_journal_entry_condition" method of the LineItemCollector class in the "accounting.report.reports.search" module. --- src/accounting/report/reports/search.py | 35 ++++++++++--------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/accounting/report/reports/search.py b/src/accounting/report/reports/search.py index 1a34ee5..4446cf3 100644 --- a/src/accounting/report/reports/search.py +++ b/src/accounting/report/reports/search.py @@ -124,40 +124,33 @@ class LineItemCollector: """ conditions: list[sa.BinaryExpression] \ = [JournalEntry.note.icontains(k)] - journal_entry_date: dt.datetime + date: dt.datetime try: - journal_entry_date = dt.datetime.strptime(k, "%Y") - conditions.append(sa.extract("year", JournalEntry.date) - == journal_entry_date.year) + date = dt.datetime.strptime(k, "%Y") + conditions.append( + sa.extract("year", JournalEntry.date) == date.year) except ValueError: pass try: - journal_entry_date = dt.datetime.strptime(k, "%Y/%m") + date = dt.datetime.strptime(k, "%Y/%m") conditions.append(sa.and_( - sa.extract("year", JournalEntry.date) - == journal_entry_date.year, - sa.extract("month", JournalEntry.date) - == journal_entry_date.month)) + sa.extract("year", JournalEntry.date) == date.year, + sa.extract("month", JournalEntry.date) == date.month)) except ValueError: pass try: - journal_entry_date = dt.datetime.strptime(f"2000/{k}", "%Y/%m/%d") + date = dt.datetime.strptime(f"2000/{k}", "%Y/%m/%d") conditions.append(sa.and_( - sa.extract("month", JournalEntry.date) - == journal_entry_date.month, - sa.extract("day", JournalEntry.date) - == journal_entry_date.day)) + sa.extract("month", JournalEntry.date) == date.month, + sa.extract("day", JournalEntry.date) == date.day)) except ValueError: pass try: - journal_entry_date = dt.datetime.strptime(k, "%Y/%m/%d") + date = dt.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)) + sa.extract("year", JournalEntry.date) == date.year, + sa.extract("month", JournalEntry.date) == date.month, + sa.extract("day", JournalEntry.date) == date.day)) except ValueError: pass return sa.select(JournalEntry.id).filter(sa.or_(*conditions))