Added the "accounting.utils.cast" module to cast the things to the expected type in order to supress the warnings from PyCharm.
This commit is contained in:
@ -37,6 +37,7 @@ from accounting.report.utils.option_link import OptionLink
|
||||
from accounting.report.utils.report_chooser import ReportChooser
|
||||
from accounting.report.utils.report_type import ReportType
|
||||
from accounting.report.utils.urls import income_expenses_url
|
||||
from accounting.utils.cast import be
|
||||
from accounting.utils.pagination import Pagination
|
||||
|
||||
|
||||
@ -120,7 +121,7 @@ class EntryCollector:
|
||||
else_=-JournalEntry.amount))
|
||||
select: sa.Select = sa.Select(balance_func)\
|
||||
.join(Transaction).join(Account)\
|
||||
.filter(JournalEntry.currency_code == self.__currency.code,
|
||||
.filter(be(JournalEntry.currency_code == self.__currency.code),
|
||||
self.__account_condition,
|
||||
Transaction.date < self.__period.start)
|
||||
balance: int | None = db.session.scalar(select)
|
||||
@ -342,7 +343,7 @@ class PageParams(BasePageParams):
|
||||
self.account.id == 0)]
|
||||
in_use: sa.Select = sa.Select(JournalEntry.account_id)\
|
||||
.join(Account)\
|
||||
.filter(JournalEntry.currency_code == self.currency.code,
|
||||
.filter(be(JournalEntry.currency_code == self.currency.code),
|
||||
sa.or_(Account.base_code.startswith("11"),
|
||||
Account.base_code.startswith("12"),
|
||||
Account.base_code.startswith("21"),
|
||||
|
@ -36,6 +36,7 @@ from accounting.report.utils.option_link import OptionLink
|
||||
from accounting.report.utils.report_chooser import ReportChooser
|
||||
from accounting.report.utils.report_type import ReportType
|
||||
from accounting.report.utils.urls import ledger_url
|
||||
from accounting.utils.cast import be
|
||||
from accounting.utils.pagination import Pagination
|
||||
|
||||
|
||||
@ -116,8 +117,8 @@ class EntryCollector:
|
||||
(JournalEntry.is_debit, JournalEntry.amount),
|
||||
else_=-JournalEntry.amount))
|
||||
select: sa.Select = sa.Select(balance_func).join(Transaction)\
|
||||
.filter(JournalEntry.currency_code == self.__currency.code,
|
||||
JournalEntry.account_id == self.__account.id,
|
||||
.filter(be(JournalEntry.currency_code == self.__currency.code),
|
||||
be(JournalEntry.account_id == self.__account.id),
|
||||
Transaction.date < self.__period.start)
|
||||
balance: int | None = db.session.scalar(select)
|
||||
if balance is None:
|
||||
@ -303,7 +304,7 @@ class PageParams(BasePageParams):
|
||||
:return: The account options.
|
||||
"""
|
||||
in_use: sa.Select = sa.Select(JournalEntry.account_id)\
|
||||
.filter(JournalEntry.currency_code == self.currency.code)\
|
||||
.filter(be(JournalEntry.currency_code == self.currency.code))\
|
||||
.group_by(JournalEntry.account_id)
|
||||
return [OptionLink(str(x), ledger_url(self.currency, x, self.period),
|
||||
x.id == self.account.id)
|
||||
|
@ -32,6 +32,7 @@ from accounting.report.utils.base_report import BaseReport
|
||||
from accounting.report.utils.csv_export import csv_download
|
||||
from accounting.report.utils.report_chooser import ReportChooser
|
||||
from accounting.report.utils.report_type import ReportType
|
||||
from accounting.utils.cast import be
|
||||
from accounting.utils.pagination import Pagination
|
||||
from accounting.utils.query import parse_query_keywords
|
||||
from .journal import get_csv_rows
|
||||
@ -124,7 +125,7 @@ class EntryCollector:
|
||||
try:
|
||||
txn_date = datetime.strptime(k, "%Y")
|
||||
conditions.append(
|
||||
sa.extract("year", Transaction.date) == txn_date.year)
|
||||
be(sa.extract("year", Transaction.date) == txn_date.year))
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
|
Reference in New Issue
Block a user