Added the get_journal_url utility to replace the common codes to retrieve the URL of an income statement.
This commit is contained in:
parent
740e1cfac1
commit
a65dccac92
@ -24,6 +24,18 @@ from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import Period
|
||||
|
||||
|
||||
def get_journal_url(period: Period) \
|
||||
-> str:
|
||||
"""Returns the URL of a journal.
|
||||
|
||||
:param period: The period.
|
||||
:return: The URL of the journal.
|
||||
"""
|
||||
if period.is_default:
|
||||
return url_for("accounting.report.journal-default")
|
||||
return url_for("accounting.report.journal", period=period)
|
||||
|
||||
|
||||
def get_ledger_url(currency: Currency, account: Account, period: Period) \
|
||||
-> str:
|
||||
"""Returns the URL of a ledger.
|
||||
|
@ -30,8 +30,8 @@ from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import YearPeriod, Period, ThisMonth, \
|
||||
LastMonth, SinceLastMonth, ThisYear, LastYear, Today, Yesterday, \
|
||||
TemplatePeriod
|
||||
from .get_url import get_ledger_url, get_income_expenses_url, \
|
||||
get_trial_balance_url, get_income_statement_url
|
||||
from .get_url import get_journal_url, get_ledger_url, \
|
||||
get_income_expenses_url, get_trial_balance_url, get_income_statement_url
|
||||
|
||||
|
||||
class PeriodChooser(ABC):
|
||||
@ -114,9 +114,7 @@ class JournalPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
if period.is_default:
|
||||
return url_for("accounting.report.journal-default")
|
||||
return url_for("accounting.report.journal", period=period)
|
||||
return get_journal_url(period)
|
||||
|
||||
|
||||
class LedgerPeriodChooser(PeriodChooser):
|
||||
|
@ -32,8 +32,8 @@ from accounting.models import Currency, Account
|
||||
from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import Period
|
||||
from accounting.template_globals import default_currency_code
|
||||
from .get_url import get_ledger_url, get_income_expenses_url, \
|
||||
get_trial_balance_url, get_income_statement_url
|
||||
from .get_url import get_journal_url, get_ledger_url, \
|
||||
get_income_expenses_url, get_trial_balance_url, get_income_statement_url
|
||||
from .option_link import OptionLink
|
||||
from .report_type import ReportType
|
||||
|
||||
@ -88,10 +88,7 @@ class ReportChooser:
|
||||
|
||||
:return: The journal.
|
||||
"""
|
||||
url: str = url_for("accounting.report.journal-default") \
|
||||
if self.__period.is_default \
|
||||
else url_for("accounting.report.journal", period=self.__period)
|
||||
return OptionLink(gettext("Journal"), url,
|
||||
return OptionLink(gettext("Journal"), get_journal_url(self.__period),
|
||||
self.__active_report == ReportType.JOURNAL,
|
||||
fa_icon="fa-solid fa-book")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user