Quintiq file version 2.0
|
#parent: #root
|
Function CalcPreviousPeriodLastShiftDay
|
{
|
Description:
|
[*
|
This is to facilitate the assignment of capacity to unit period bucket with rolling shift functionality.
|
E.g. We have a shift pattern of 7 days where day 1 is 8 hour, day 2 is 7 hour, day 3 is 6 hour, so forth. We also have a daily bucket of 14 days. Instead of restarting shift patterns or
|
assigning each daily bucket with 8 hour, we would like to see bucket 1 ( assuming bucket 1 falls on the first week day with only 1 unit) had the capacity of 8 hour, and bucket 2 is 7 hours.
|
*]
|
TextBody:
|
[*
|
// desmondt May-11-2015 (created)
|
|
value := 0;
|
// Skip the calculation if its null
|
if( not isnull( this.Period_MP() ) )
|
{
|
value := maxvalue( this.StartDate() - this.Period_MP().Start().StartOfWeek().Date(), 0 );
|
periodduration := this.Period_MP().Duration().Days();
|
// Check if there is ShiftPattern
|
if( not isnull( this.ShiftPattern() ) )
|
{
|
nrofdays := this.ShiftPattern().NumberOfDays();
|
// Check if have pervious and its belong to same ShiftPattern
|
if( this.HasPreviousAndBelongToSameShiftPattern() )
|
{
|
lastshiftday := this.Previous().astype( UnitPeriodTimeBase ).PreviousPeriodLastShiftDay();
|
// Check if the last ShiftDay is equal to nr of days and the sum with period duration is lesser or equal to nr of day
|
if( not lastshiftday = nrofdays and
|
lastshiftday + periodduration <= nrofdays )
|
{
|
value := periodduration + lastshiftday;
|
}
|
// Check if the last shift day + the period duration is greater than the nr of days
|
if( lastshiftday + periodduration > nrofdays )
|
{
|
value := periodduration - ( nrofdays - lastshiftday )
|
}
|
}
|
else
|
{
|
value := periodduration + value;
|
}
|
// If the pre period last shift days greater than nr of days
|
if( value > nrofdays )
|
{
|
value := value mod nrofdays
|
if( value = 0 )
|
{
|
value := nrofdays;
|
}
|
}
|
value := minvalue( nrofdays, value );
|
}
|
}
|
this.PreviousPeriodLastShiftDay( value );
|
*]
|
}
|