Added the get_trial_balance_url utility to replace the common codes to retrieve the URL of an income statement.

This commit is contained in:
2023-03-09 11:31:23 +08:00
parent b62f31d385
commit 740e1cfac1
4 changed files with 24 additions and 23 deletions

View File

@ -20,7 +20,7 @@
from decimal import Decimal
import sqlalchemy as sa
from flask import url_for, Response, render_template
from flask import Response, render_template
from accounting import db
from accounting.locale import gettext
@ -29,7 +29,7 @@ from accounting.report.period import Period
from .utils.base_page_params import BasePageParams
from .utils.base_report import BaseReport
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
from .utils.get_url import get_ledger_url
from .utils.get_url import get_ledger_url, get_trial_balance_url
from .utils.option_link import OptionLink
from .utils.period_choosers import TrialBalancePeriodChooser
from .utils.report_chooser import ReportChooser
@ -149,14 +149,8 @@ class PageParams(BasePageParams):
:return: The currency options.
"""
def get_url(currency: Currency):
if self.period.is_default:
return url_for("accounting.report.trial-balance-default",
currency=currency)
return url_for("accounting.report.trial-balance",
currency=currency, period=self.period)
return self._get_currency_options(get_url, self.currency)
return self._get_currency_options(
lambda x: get_trial_balance_url(x, self.period), self.currency)
class TrialBalance(BaseReport):