Quintiq file version 2.0
|
#parent: #root
|
Method SynchronizePeriods
|
{
|
Description: 'This will create periods based on this period definition'
|
TextBody:
|
[*
|
// DWE2 Apr-25-2016 (modified)
|
traverse( this, Period_MP, period )
|
{
|
period.IsDeleted( true );
|
}
|
|
// To create from historical period
|
start := PeriodSpecification_MP::GetStartOfPreviousPeriod( this.PeriodAlignment().Date(),
|
this.TimeUnit(),
|
this.NrOfTimeUnit() * this.NrOfHistoricalPeriod() ); // Multiply to get the earlist start
|
|
totalofperiods := this.NrOfFuturePeriod() + this.NrOfHistoricalPeriod(); // Sum for total period needs to be created
|
|
for( i:= 0; i < totalofperiods ; i++ )
|
{
|
end := PeriodSpecification_MP::GetStartOfNextPeriod( start, this.TimeUnit(), this.NrOfTimeUnit() );
|
period := Period_MP::FindPeriodTypeIndex( this.ID(), start , end );
|
if( isnull( period ) )
|
{
|
//Check if there's already a gap planning period with the same start and end
|
period := select( this, MacroPlan.Period_MP, p,
|
p.IsSystemCreated(),
|
p.Start() = start
|
and p.End() = end );
|
if( isnull( period ) )
|
{
|
Period_MP::Create( this.MacroPlan(), this, start, end, false, false );
|
}
|
else
|
{
|
//Change redundant gap planning period to planning period
|
period.LinkGapPlanningToPeriodSpecification( this );
|
}
|
}
|
else
|
{
|
period.Update( this ); // It may created by system as a base period previously
|
period.IsDeleted( false );
|
}
|
start := end;
|
}
|
|
if( not this.MacroPlan().IsRollingPeriod() )
|
{
|
periods := selectset( this, Period_MP, period, period.IsDeleted() )
|
Period_MP::Delete( periods );
|
}
|
*]
|
}
|