joniles / mpxj

Primary repository for MPXJ library
http://www.mpxj.org/
GNU Lesser General Public License v2.1
249 stars 104 forks source link

Add support for reading time phased planned work from MPP for manual scheduled tasks v2 #740

Closed Fabian-Schmidt closed 3 months ago

Fabian-Schmidt commented 3 months ago

Add support for reading time phased planned work from MPP for manual scheduled tasks. Manual scheduled tasks in Project permit starting an assignment outside of regular work calendar.

This PR is a simplified implementation of #737. This PR addresses the issue reported in #733.

For manual scheduled tasks I identified the following rules:

On the first or last day of an assignment it can have work outside of the work calendar. If assignment start is on a non working day then the generic work calendar, without any exceptions, is applied. Project starts looking for working hours used by searching work calendar on Tuesday. If assignment starts before work hours then work full until regular work range start and then use range. If assignment starts after work hours range then work full until end of day. If assignment starts on range end then work start on next regular work day. If assignment starts within work range then work normal.

The logic is encapsulated in the class ManuallyScheduledTaskCalendar.

I added a number of test cases to ensure the support is working correctly. image

Fabian-Schmidt commented 3 months ago

Is using this.setParent(calendar); inside of the ManuallyScheduledTaskCalendar a good idea?

Fabian-Schmidt commented 3 months ago

What is your opinion of this approach? I managed to implement all necessary changes in the ManuallyScheduledTaskCalendar by only overriding the getRanges(LocalDate date) method.

All Unit test are green.

joniles commented 3 months ago

Merged! I ended up collapsing down the big if-statement by using a data-driven approach with a stream. All tests are passing and my local regression tests are working as expected.

Many thanks for the contribution!