Added the period_spec function to be used to compose the download file name, to replace the spec property of the Period utility.

This commit is contained in:
2023-03-08 11:55:52 +08:00
parent b0a4a735f3
commit 617dd29f23
7 changed files with 51 additions and 12 deletions

View File

@ -27,7 +27,7 @@ from accounting.locale import gettext
from accounting.models import Currency, Account, Transaction, JournalEntry
from accounting.report.period import Period
from .utils.base_report import BaseReport
from .utils.csv_export import BaseCSVRow, csv_download
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
from .utils.option_link import OptionLink
from .utils.page_params import PageParams
from .utils.period_choosers import TrialBalancePeriodChooser
@ -234,7 +234,8 @@ class TrialBalance(BaseReport):
:return: The response of the report for download.
"""
filename: str = "trial-balance-{currency}-{period}.csv"\
.format(currency=self.__currency.code, period=self.__period.spec)
.format(currency=self.__currency.code,
period=period_spec(self.__period))
return csv_download(filename, self.__get_csv_rows())
def __get_csv_rows(self) -> list[CSVRow]: