Skip to content

Commit

Permalink
Add more EdifactFormatVersions (FV2310, FV2404) (#294)
Browse files Browse the repository at this point in the history
* Add more EdifactFormatVersions (`FV2310`, `FV2404`)

* fix date

* fix stupid test
  • Loading branch information
hf-kklein committed Aug 10, 2023
1 parent 666430b commit 4b9aaeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/maus/edifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class EdifactFormatVersion(str, Enum):
FV2110 = "FV2110" #: valid from 2021-10-01 until 2022-04-01
FV2210 = "FV2210" #: valid from 2022-10-01 onwards ("MaKo 2022", was 2204 previously)
FV2304 = "FV2304" #: valid from 2023-04-01 onwards
FV2310 = "FV2304" #: valid from 2023-10-01 onwards
FV2404 = "FV2404" #: valid from 2024-04-01 onwards
# whenever you add another value here, please also make sure to add its key date to get_edifact_format_version below

def __str__(self):
Expand All @@ -89,7 +91,11 @@ def get_edifact_format_version(key_date: datetime.datetime) -> EdifactFormatVers
return EdifactFormatVersion.FV2110
if key_date < datetime.datetime(2023, 3, 31, 22, 0, 0, 0, tzinfo=datetime.timezone.utc):
return EdifactFormatVersion.FV2210
return EdifactFormatVersion.FV2304
if key_date < datetime.datetime(2023, 9, 30, 22, 0, 0, 0, tzinfo=datetime.timezone.utc):
return EdifactFormatVersion.FV2304
if key_date < datetime.datetime(2024, 3, 31, 22, 0, 0, 0, tzinfo=datetime.timezone.utc):
return EdifactFormatVersion.FV2310
return EdifactFormatVersion.FV2404


def get_current_edifact_format_version() -> EdifactFormatVersion:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_edifact_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_pruefi_to_format(self, expectation_tuple: Tuple[str, EdifactFormat]):
pytest.param(datetime(2022, 7, 1, 0, 0, 0, tzinfo=timezone.utc), EdifactFormatVersion.FV2110),
pytest.param(datetime(2022, 10, 1, 0, 0, 0, tzinfo=timezone.utc), EdifactFormatVersion.FV2210),
pytest.param(
datetime(2050, 10, 1, 0, 0, 0, tzinfo=timezone.utc), EdifactFormatVersion.FV2304
datetime(2050, 10, 1, 0, 0, 0, tzinfo=timezone.utc), EdifactFormatVersion.FV2404
), # or what ever is the latest version
],
)
Expand Down

0 comments on commit 4b9aaeb

Please sign in to comment.