yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
55
56
Quintiq file version 2.0
#parent: #root
Method CreateUnitPeriod (
  Period_MP period
) as UnitPeriod
{
  Description: 'Create a unit period based on capacity type'
  TextBody:
  [*
    // soh yee Sep-3-2015 (moved)
    
    // Null period
    unitperiod := UnitPeriod::FindUnitPeriodTypeIndex( this.ID(), period.Start(), period.End() );
    
    if( isnull( unitperiod ) )
    {
      // Capacity time
      if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeTime() )
      {
        unitperiod := UnitPeriodTime::Create( this, period );
      }
      // Capacity quantity
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeQuantity() )
      {
        unitperiod := UnitPeriodQuantity::Create( this, period );
      }
      // Capacity infinite
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeInfinite() )
      {
        unitperiod := UnitPeriodInfinite::Create( this, period );
      }
      // Capacity time aggregation
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeTimeAggregation() )
      {
        unitperiod := UnitPeriodTimeAggregation::Create( this, period );
      }
      // Capacity quantity aggregation
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeQuantityAggregation() )
      {
        unitperiod := UnitPeriodQuantityAggregation::Create( this, period );
      }
      // Capacity Transport time
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeTransportTime() )
      {
        unitperiod := UnitPeriodTransportTime::Create( this, period );
      }
      // Capacity Transport quantity
      else if( this.CapacityType() = GlobalParameters_MP::GetCapacityTypeTransportQuantity() )
      {
        unitperiod := UnitPeriodTransportQuantity::Create( this, period );
      }
    }
    
    return unitperiod;
  *]
}