Added the _get_currency_options method to the BasePageParams class, and applied it to the currency_options pseudo property of the PageParams classes of the ledger, income and expenses log, trial balance, income statement, and balance sheet reports.

This commit is contained in:
2023-03-08 18:23:49 +08:00
parent d74c62dbb7
commit 5687852dfb
6 changed files with 25 additions and 30 deletions

View File

@ -155,12 +155,7 @@ class PageParams(BasePageParams):
return url_for("accounting.report.trial-balance",
currency=currency, period=self.period)
in_use: set[str] = set(db.session.scalars(
sa.select(JournalEntry.currency_code)
.group_by(JournalEntry.currency_code)).all())
return [OptionLink(str(x), get_url(x), x.code == self.currency.code)
for x in Currency.query.filter(Currency.code.in_(in_use))
.order_by(Currency.code).all()]
return self._get_currency_options(get_url, self.currency)
class TrialBalance(BaseReport):