diff --git a/accounting/templates/accounting/balance-sheet.html b/accounting/templates/accounting/balance-sheet.html index 1afe54a..b785424 100644 --- a/accounting/templates/accounting/balance-sheet.html +++ b/accounting/templates/accounting/balance-sheet.html @@ -27,7 +27,7 @@ First written: 2020/7/20 {% load accounting %} {% block settings %} - {% blocktrans asvar title with period=period.description context "Accounting|" %}Balance Sheet in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=period.prep_desc context "Accounting|" %}Balance Sheet {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html index b96af18..7fceedd 100644 --- a/accounting/templates/accounting/cash.html +++ b/accounting/templates/accounting/cash.html @@ -27,7 +27,7 @@ First written: 2020/7/1 {% load accounting %} {% block settings %} - {% blocktrans asvar title with account=account.title|title period=period.description context "Accounting|" %}Cash Account for {{ account }} in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with account=account.title|title prep_period=period.prep_desc context "Accounting|" %}Cash Account for {{ account }} {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/accounting/templates/accounting/income-statement.html b/accounting/templates/accounting/income-statement.html index d2deaca..c5e0767 100644 --- a/accounting/templates/accounting/income-statement.html +++ b/accounting/templates/accounting/income-statement.html @@ -27,7 +27,7 @@ First written: 2020/7/19 {% load accounting %} {% block settings %} - {% blocktrans asvar title with period=period.description context "Accounting|" %}Income Statement in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=period.prep_desc context "Accounting|" %}Income Statement {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/accounting/templates/accounting/journal.html b/accounting/templates/accounting/journal.html index 6f10523..f38b7a6 100644 --- a/accounting/templates/accounting/journal.html +++ b/accounting/templates/accounting/journal.html @@ -27,7 +27,7 @@ First written: 2020/7/17 {% load accounting %} {% block settings %} - {% blocktrans asvar title with period=period.description context "Accounting|" %}Journal in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=period.prep_desc context "Accounting|" %}Journal {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/accounting/templates/accounting/ledger.html b/accounting/templates/accounting/ledger.html index 202751b..7faa4c3 100644 --- a/accounting/templates/accounting/ledger.html +++ b/accounting/templates/accounting/ledger.html @@ -27,7 +27,7 @@ First written: 2020/7/16 {% load accounting %} {% block settings %} - {% blocktrans asvar title with account=account.title|title period=period.description context "Accounting|" %}Ledger for {{ account }} in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with account=account.title|title prep_period=period.prep_desc context "Accounting|" %}Ledger for {{ account }} {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/accounting/templates/accounting/trial-balance.html b/accounting/templates/accounting/trial-balance.html index 60cec4c..c47d008 100644 --- a/accounting/templates/accounting/trial-balance.html +++ b/accounting/templates/accounting/trial-balance.html @@ -27,7 +27,7 @@ First written: 2020/7/19 {% load accounting %} {% block settings %} - {% blocktrans asvar title with period=period.description context "Accounting|" %}Trial Balance in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=period.prep_desc context "Accounting|" %}Trial Balance {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} diff --git a/mia_core/period.py b/mia_core/period.py index 1785b94..0aa8639 100644 --- a/mia_core/period.py +++ b/mia_core/period.py @@ -82,6 +82,17 @@ class Period: """ return self._period.description + @property + def prep_desc(self): + """Returns the text description with preposition of the + currently-specified period. + + Returns: + str: The text description with preposition of the + currently-specified period + """ + return self._period.prep_desc + @staticmethod def _get_last_month_start(): """Returns the first day of the last month. @@ -409,6 +420,7 @@ class Period: start (datetime.date): The start of the period. end (datetime.date): The end of the period. description (str): The text description of the period. + prep_desc (str): The text description with preposition. """ VERY_START = datetime.date(1990, 1, 1) @@ -417,6 +429,7 @@ class Period: self.start = None self.end = None self.description = None + self.prep_desc = None if spec is None: self._set_this_month() @@ -431,6 +444,7 @@ class Period: self.start = datetime.date(year, month, 1) self.end = self._month_last_day(self.start) self.description = self._month_text(year, month) + self.prep_desc = gettext("In %s") % self.description return # From a specific month m = re.match("^([0-9]{4})-([0-9]{2})-$", spec) @@ -442,6 +456,7 @@ class Period: self.end = self._month_last_day(timezone.localdate()) self.description = gettext("Since %s")\ % self._month_text(year, month) + self.prep_desc = self.description return # Until a specific month m = re.match("^-([0-9]{4})-([0-9]{2})$", spec) @@ -454,6 +469,7 @@ class Period: self.end = self._month_last_day(until_month) self.description = gettext("Until %s")\ % self._month_text(year, month) + self.prep_desc = self.description return # A specific year m = re.match("^([0-9]{4})$", spec) @@ -463,6 +479,7 @@ class Period: self.start = datetime.date(year, 1, 1) self.end = datetime.date(year, 12, 31) self.description = self._year_text(year) + self.prep_desc = gettext("In %s") % self.description return # Until a specific year m = re.match("^-([0-9]{4})$", spec) @@ -473,12 +490,14 @@ class Period: self.start = Period.Parser.VERY_START self.description = gettext("Until %s")\ % self._year_text(year) + self.prep_desc = self.description return # All time if spec == "-": self.start = Period.Parser.VERY_START self.end = self._month_last_day(timezone.localdate()) - self.description = gettext("All") + self.description = gettext("All Time") + self.prep_desc = gettext("In %s") % self.description return # A specific date m = re.match("^([0-9]{4})-([0-9]{2})-([0-9]{2})$", @@ -491,6 +510,7 @@ class Period: int(m.group(3))) self.end = self.start self.description = self._date_text(self.start) + self.prep_desc = gettext("In %s") % self.description return # A specific date period m = re.match(("^([0-9]{4})-([0-9]{2})-([0-9]{2})" @@ -536,6 +556,7 @@ class Period: else: self.spec = dateformat.format(self.start, "Y-m-d") self.description = self._date_text(self.start) + self.prep_desc = gettext("In %s") % self.description return # Until a specific day m = re.match("^-([0-9]{4})-([0-9]{2})-([0-9]{2})$", spec) @@ -548,6 +569,7 @@ class Period: self.start = Period.Parser.VERY_START self.description = gettext("Until %s")\ % self._date_text(self.end) + self.prep_desc = self.description return # Wrong period format raise ValueError