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.

This commit is contained in:
依瑪貓 2023-04-26 13:26:38 +08:00
parent 3eb3aef2f2
commit 169b3c292a

View File

@ -124,40 +124,33 @@ class LineItemCollector:
""" """
conditions: list[sa.BinaryExpression] \ conditions: list[sa.BinaryExpression] \
= [JournalEntry.note.icontains(k)] = [JournalEntry.note.icontains(k)]
journal_entry_date: dt.datetime date: dt.datetime
try: try:
journal_entry_date = dt.datetime.strptime(k, "%Y") date = dt.datetime.strptime(k, "%Y")
conditions.append(sa.extract("year", JournalEntry.date) conditions.append(
== journal_entry_date.year) sa.extract("year", JournalEntry.date) == date.year)
except ValueError: except ValueError:
pass pass
try: try:
journal_entry_date = dt.datetime.strptime(k, "%Y/%m") date = dt.datetime.strptime(k, "%Y/%m")
conditions.append(sa.and_( conditions.append(sa.and_(
sa.extract("year", JournalEntry.date) sa.extract("year", JournalEntry.date) == date.year,
== journal_entry_date.year, sa.extract("month", JournalEntry.date) == date.month))
sa.extract("month", JournalEntry.date)
== journal_entry_date.month))
except ValueError: except ValueError:
pass pass
try: 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_( conditions.append(sa.and_(
sa.extract("month", JournalEntry.date) sa.extract("month", JournalEntry.date) == date.month,
== journal_entry_date.month, sa.extract("day", JournalEntry.date) == date.day))
sa.extract("day", JournalEntry.date)
== journal_entry_date.day))
except ValueError: except ValueError:
pass pass
try: try:
journal_entry_date = dt.datetime.strptime(k, "%Y/%m/%d") date = dt.datetime.strptime(k, "%Y/%m/%d")
conditions.append(sa.and_( conditions.append(sa.and_(
sa.extract("year", JournalEntry.date) sa.extract("year", JournalEntry.date) == date.year,
== journal_entry_date.year, sa.extract("month", JournalEntry.date) == date.month,
sa.extract("month", JournalEntry.date) sa.extract("day", JournalEntry.date) == date.day))
== journal_entry_date.month,
sa.extract("day", JournalEntry.date)
== journal_entry_date.day))
except ValueError: except ValueError:
pass pass
return sa.select(JournalEntry.id).filter(sa.or_(*conditions)) return sa.select(JournalEntry.id).filter(sa.or_(*conditions))