Skip to content

Commit a01bb1d

Browse files
author
Jesse
committed
edge case that last recalc date not set correctly
1 parent 08a3472 commit a01bb1d

6 files changed

Lines changed: 101 additions & 148 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11

22
# Changelog - xerparser
33

4-
## 0.13.6 - 205-06-27
4+
## 0.13.7 - 2025-08-20
5+
6+
* Handle edge case where incorrect data date is recorded in the XER file; revert to planned start date in these cases. May need to re-create the the xer_data.json file when running the tests.
7+
8+
---
9+
10+
## 0.13.6 - 2025-06-27
511

612
* Added `duration_percent_complete` and `units_percent_complete` properties to the `TASK` class.
713
* Updated the `phys_complete_pct` attribute to be a decimal from 0 to 1.

poetry.lock

Lines changed: 83 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "xerparser"
3-
version = "0.13.6"
3+
version = "0.13.7"
44
description = "Parse a P6 .xer file to a Python object."
55
authors = ["Jesse <code@seqmanagement.com>"]
66
license = "GPL-3.0-only"

tests/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_create_xer(self):
284284
self.assertEqual(
285285
project.duration_percent,
286286
file[project.short_name]["duration_percent"],
287-
f"{project.short_name} Project Duration Percent",
287+
f"{project.short_name} Project Duration Percent | Remaining Duration is {project.remaining_duration} days | Original Duration is {project.original_duration} days",
288288
)
289289
self.assertEqual(
290290
project.original_duration,

xerparser/schemas/pcattype.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# xerparser
22
# pcattype.py
33

4+
from xerparser.src.validators import optional_int
5+
46

57
class PCATTYPE:
68
"""
@@ -14,7 +16,7 @@ def __init__(self, **data: str) -> None:
1416
"""Max Character Length"""
1517
self.name: str = data["proj_catg_type"]
1618
"""Project Code Name"""
17-
self.seq_num: int | None = None if (seq := data["seq_num"]) == "" else int(seq)
19+
self.seq_num: int | None = optional_int(data["seq_num"])
1820
"""Sort Order"""
1921

2022
def __eq__(self, __o: "PCATTYPE") -> bool:

xerparser/schemas/project.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def __init__(
4343
"""Date Project was Created"""
4444
self.default_calendar: CALENDAR | None = default_calendar
4545
"""Default Calendar Assigned to Project"""
46-
self.data_date: datetime = datetime.strptime(
47-
data["last_recalc_date"], date_format
46+
self.data_date: datetime = max(
47+
datetime.strptime(data["last_recalc_date"], date_format),
48+
datetime.strptime(data["plan_start_date"], date_format),
4849
)
4950
"""Date Project is Updated To"""
5051
self.export_flag: bool = data["export_flag"] == "Y"
@@ -185,7 +186,9 @@ def remaining_cost(self) -> float:
185186
@property
186187
def remaining_duration(self) -> int:
187188
"""Project remaining duration in calendar days from data date to finish date"""
188-
return max((0, (self.finish_date - self.data_date).days))
189+
return max(
190+
(0, (self.finish_date - max(self.data_date, self.actual_start)).days)
191+
)
189192

190193
@cached_property
191194
@rounded(ndigits=4)

0 commit comments

Comments
 (0)