diff --git a/accounting/utils.py b/accounting/utils.py index e3ef052..2c881df 100644 --- a/accounting/utils.py +++ b/accounting/utils.py @@ -34,7 +34,7 @@ class ReportUrl: if "period" in kwargs: self._period = kwargs["period"] else: - self._period = Period(None, None, None, None) + self._period = Period() if "cash" in kwargs: self._cash_subject = kwargs["cash"] else: diff --git a/accounting/views/__init__.py b/accounting/views/__init__.py index 35c42de..13059ec 100644 --- a/accounting/views/__init__.py +++ b/accounting/views/__init__.py @@ -74,8 +74,7 @@ def cash(request, subject_code, period_spec): last_txn = Transaction.objects.order_by("-date").first() data_end = last_txn.date if last_txn is not None else None period = Period( - get_language(), data_start, data_end, - period_spec) + period_spec, data_start, data_end, get_language()) # The SQL query if subject_code == "0": subject = Subject(code="0") diff --git a/mia_core/period.py b/mia_core/period.py index 86ed767..b7e6f00 100644 --- a/mia_core/period.py +++ b/mia_core/period.py @@ -33,10 +33,10 @@ class Period: """The template helper for the period chooser. Args: - language (str|None): The current language. - data_start (date|None): The available first day of the data. - data_end (date|None): The available last day of the data. - spec (str|None): The current period specification + spec (str): The current period specification + data_start (date): The available first day of the data. + data_end (date): The available last day of the data. + language (str): The current language. Attributes: spec (date): The currently-working period specification. @@ -82,11 +82,13 @@ class Period: _data_end = None _period = None - def __init__(self, language, data_start, data_end, spec): - self._language = language + def __init__( + self, spec = None, + data_start = None, data_end = None, language = None): + self._period = self.Parser(spec) self._data_start = data_start self._data_end = data_end - self._period = self.Parser(spec) + self._language = language @property def spec(self):