diff --git a/conservancy_beancount/config.py b/conservancy_beancount/config.py index 9acab353331cf3e227b4921ca4c73e4cd3dba855..4064981645732999173cbd4a31568384693c9208 100644 --- a/conservancy_beancount/config.py +++ b/conservancy_beancount/config.py @@ -33,6 +33,7 @@ from typing import ( Type, ) +from . import books from . import rtutil class RTCredentials(NamedTuple): @@ -130,7 +131,7 @@ class Config: config_root = self._path_from_environ('XDG_CONFIG_HOME') return Path(config_root, name, 'config.ini') - def fiscal_year_begin(self) -> Tuple[int, int]: + def fiscal_year_begin(self) -> books.FiscalYear: s = self.file_config.get('Beancount', 'fiscal year begin', fallback='3 1') match = re.match(r'([01]?[0-9])(?:\s*[-./ ]\s*([0-3]?[0-9]))?$', s.strip()) if match is None: @@ -146,7 +147,7 @@ class Config: except ValueError as e: raise ValueError(f"fiscal year begin {s!r} is invalid date: {e.args[0]}") else: - return (month, day) + return books.FiscalYear(month, day) def payment_threshold(self) -> decimal.Decimal: return decimal.Decimal(0) diff --git a/tests/test_config.py b/tests/test_config.py index 3faea8721b264fa0fc655e4f6048ec2711612c3f..284bb984855ad53ac493916adfc0bd2b538e988e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -378,4 +378,6 @@ def test_bad_fiscal_year_begin(value): def test_default_fiscal_year_begin(): config = config_mod.Config() - assert config.fiscal_year_begin() == (3, 1) + actual = config.fiscal_year_begin() + assert actual.month == 3 + assert actual.day == 1