Skip to content

Commit

Permalink
Avoid NPE when splitting timephased costs over days
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Oct 7, 2024
1 parent 81533c2 commit 5d68346
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/net/sf/mpxj/mspdi/MSPDIWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,9 @@ private List<TimephasedCost> splitDays(ProjectCalendar calendar, List<Timephased
LocalDateTime finishDay = LocalDateTimeHelper.getDayStartDate(finishDate);
if (startDay.equals(finishDay))
{
LocalDateTime currentStart = LocalDateTime.of(startDay.toLocalDate(), calendar.getStartTime(LocalDateHelper.getLocalDate(startDay)));
if (startDate.isAfter(currentStart))
LocalTime startTime = calendar.getStartTime(LocalDateHelper.getLocalDate(startDay));
LocalDateTime currentStart = startTime == null ? null : LocalDateTime.of(startDay.toLocalDate(), startTime);
if (currentStart != null && startDate.isAfter(currentStart))
{
TimephasedCost padding = new TimephasedCost();
padding.setStart(currentStart);
Expand All @@ -2429,8 +2430,9 @@ private List<TimephasedCost> splitDays(ProjectCalendar calendar, List<Timephased

result.add(assignment);

LocalDateTime currentFinish = LocalDateTime.of(startDay.toLocalDate(), calendar.getFinishTime(LocalDateHelper.getLocalDate(startDay)));
if (finishDate.isBefore(currentFinish))
LocalTime finishTime = calendar.getFinishTime(LocalDateHelper.getLocalDate(startDay));
LocalDateTime currentFinish = finishTime == null ? null : LocalDateTime.of(startDay.toLocalDate(), finishTime);
if (currentFinish != null && finishDate.isBefore(currentFinish))
{
TimephasedCost padding = new TimephasedCost();
padding.setStart(finishDate);
Expand Down

0 comments on commit 5d68346

Please sign in to comment.