Split the report parameters from the report class so that it works better with both CSV export and HTML templates.

This commit is contained in:
2023-03-06 23:37:20 +08:00
parent e797cfeb8c
commit ef9e5cb5b3
7 changed files with 560 additions and 391 deletions

View File

@ -57,8 +57,8 @@ def __get_journal_list(period: Period) -> str | Response:
"""
report: Journal = Journal(period)
if "as" in request.args and request.args["as"] == "csv":
return report.as_csv_download()
return report.as_html_page()
return report.csv()
return report.html()
@bp.get("ledger/<currency:currency>/<account:account>",
@ -101,8 +101,8 @@ def __get_ledger_list(currency: Currency, account: Account, period: Period) \
"""
report: Ledger = Ledger(currency, account, period)
if "as" in request.args and request.args["as"] == "csv":
return report.as_csv_download()
return report.as_html_page()
return report.csv()
return report.html()
@bp.get("income-expenses/<currency:currency>/<account:account>",
@ -146,8 +146,8 @@ def __get_income_expenses_list(currency: Currency, account: Account,
"""
report: IncomeExpenses = IncomeExpenses(currency, account, period)
if "as" in request.args and request.args["as"] == "csv":
return report.as_csv_download()
return report.as_html_page()
return report.csv()
return report.html()
@bp.get("trial-balance/<currency:currency>",
@ -186,5 +186,5 @@ def __get_trial_balance_list(currency: Currency, period: Period) \
"""
report: TrialBalance = TrialBalance(currency, period)
if "as" in request.args and request.args["as"] == "csv":
return report.as_csv_download()
return report.as_html_page()
return report.csv()
return report.html()