chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Quintiq file version 2.0
#parent: #root
Method ExtendCombiWithNextSubPeriod
{
  Description: 'Determine if the combi needs to be extended with an additional sub period. This is the case if there is only one element type in the combi and the (min/max)end time of the element extend beyond the subperiod.'
  TextBody:
  [*
    lastelement := this.LastCombiElement();
    if( isnull( lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() ) )
    {
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
      //There are no periods to extend to so close the combi to make it does not end in an endless loop. 
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
      this.IsCompleteCombi( true );
    }
    else
    {
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
      //Extend the combi with the same element in the next subperiod
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
      if( lastelement.istype( OptCampaignCombiElementCampaign ) )
      {
        OptCampaignCombiElementCampaign::Create( this, lastelement.astype( OptCampaignCombiElementCampaign ).CampaignType_MP(), lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() );
      }
      else
      {
        OptCampaignCombiElementTransition::Create( this, lastelement.astype( OptCampaignCombiElementTransition ).TransitionType_MP(), lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() );
      }
    }
  *]
}