Description
Background
At the moment, when we automatically create and update WorkPeriods for ResourceBookings as per this logic https://github.com/topcoder-platform/taas-apis/wiki/TaaS---Scope,-Status-and-permissions#work-period-wp-automation-and-constraints. We are going to update this logic as per new requirement https://github.com/topcoder-platform/taas-apis/wiki/Work-Periods-(WP)-Automation-and-Constraints below I would describe the reason for this update and solution.
Issue
Topcoder Manager could be interested in manually set the actual daysWorked
for WP.
If after this, we update RB start/end dates, the WPs would be re-calculated automatically, and the value which is set by Manager would be lost, as daysWorked
would be re-calculated.
Solution
During automatic creation of WPs we should NOT calculate daysWorked
they should be left as null
. When we show work periods in UI if we see null
UI should calculate the default value to show based on RB start/end dates.
- Manager would be able to manually set
daysWorked
. If it's set, then the value would be saved to API. - During automatic WP create/update don't set
daysWorked
Implement Constraints / Automatic updates
- If we reduce the duration of Resource Booking by making
startDate
later orendDate
earlier, then- if some WorkPeriod has
daysWorked
set (notnull
) then we have to make sure that suchdaysWorked
is a possible value. If currently setdaysWorked
is not possible - we have to update it to maximal possible as per new Resource BookingstartDate
/endDate
. see examples for constraints
- if some WorkPeriod has
- If we extend the duration of Resource Booking by making
startDate
earlier orendDate
later, then no problem.- If some WorkPeriod has
daysWorked
set, we don't update it.
- If some WorkPeriod has
- Update existent unit tests and create good unit tests to check all the essential cases in the logic of constraints and automatic updates - this is important
UI Logic
Not in scope of this issue, but to explain how UI would work:
- if UI sees
daysWorked=null
in some Work Period it should calculate the default value to show by itself - if UI see
daysWorked=N
then is just shows the value - when in UI we would process payments and
daysWorked=null
then again the payment would be process with the calculated value which is currently visible to the Manager