admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Quintiq file version 2.0
#parent: #root
Method SetIsActiveStatus (
  Date earlieststart, 
  Date lateststart
) as Boolean
{
  TextBody:
  [*
    startdatecombi := this.OptCampaignUnitSubPeriod().UnitPeriod().StartDate()
    isactive := true;  // active by default
    if ( not this.IsSelectedByOptimizer() ) // selected combis are active for the new iteration. For non selected combis we do some checks to see whether we want to throw them into active set
    {
      isactive := startdatecombi >= earlieststart and startdatecombi <= lateststart; // if outside of window and not selected, then disactivate combi  
      if ( isactive )                                                                // otherwise do some additional checking to see whether it should be active
      {
        // clear help relation. Use to go over combi elements for current combi only from unit sub period 
        unitsubperiods := construct( OptCampaignUnitSubPeriods ); 
        traverse( this, OptCampaignCombiElement.astype( OptCampaignCombiElementCampaign ).OptCampaignUnitSubPeriod, period ) 
        {
          period.OptCampaignCombiElementHelper( relflush ); 
          unitsubperiods.Add( period ); 
        }
        
        // set help relation
        traverse( this, OptCampaignCombiElement.astype( OptCampaignCombiElementCampaign ), element ) 
        {
          element.OptCampaignUnitSubPeriod().OptCampaignCombiElementHelper( relinsert, element ); 
        }
        
        // for each unitsubperiod of the combi we must check the usage, exit if at any point we set it to not 'isactive'
        traverse( unitsubperiods, Elements, period, isactive ) 
        {
          traverse( period, OptCampaignCTypeCPeriod, typeperiod, isactive ) // go over all campaign types
          {
            usage := typeperiod.IsUsingCampaignTypeForSubPeriod(); // usage based on currently selected combis
            // if the campaign type is not active we are only interested in combis that have the same usage for the period 
            // if the campaign type is active there is no restriction
            if ( not typeperiod.OptCampaignCampaignType().IsActive() ) 
            {
              usageforcombi := exists( period, 
                                       OptCampaignCombiElementHelper.astype( OptCampaignCombiElementCampaign ), 
                                       elementofcombi, 
                                       elementofcombi.OptCampaignElementType() = typeperiod.OptCampaignCampaignType() ); 
              isactive := usageforcombi = usage;
            }
          }
        }
      }
    }
    this.IsActive( isactive ); 
    return isactive;
  *]
}