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] \
= [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))