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
Quintiq file version 2.0
#parent: #root
StaticMethod CanEditCapacities (
  UnitPeriods unitperiods,
  output String feedback_o
) declarative remote as Boolean
{
  Description: 'True if batch editing capacity is allowed for all given UnitPeriods'
  TextBody:
  [*
    // Check if the selected set of UnitPeriods can be batch edited
    feedback_o := ''
    
    // Check if there's any Unit of the selected set of UnitPeriods has infinite capacity type
    if( exists( unitperiods, Elements.Unit, u, u.HasCapacityTypeInfinite() ) )
    {
      feedback_o := Translations::MP_UnitPeriod_CanEditCapacities_IsInfinite();
    }
    else
    {
      // Check if the selected set of UnitPeriods all belong to the same subclass
      issamesubclass := forall( unitperiods, Elements, up, up.istype( UnitPeriodTime ) )
                        or forall( unitperiods, Elements, up, up.istype( UnitPeriodQuantity ) )
                        or forall( unitperiods, Elements, up, up.istype( UnitPeriodTransportQuantity ) )
                        or forall( unitperiods, Elements, up, up.istype( UnitPeriodTransportTime ) );
      
      // If the selected set of UnitPeriods do not belong to the same subclass
      if( not issamesubclass )
      {
        // Check if the selected set of UnitPeriods is either type of UnitPeriodTimeAggregation or UnitPeriodQuantityAggregation
        if( exists( unitperiods, Elements, up, up.istype( UnitPeriodTimeAggregation )
                                                  or up.istype( UnitPeriodQuantityAggregation ) ) )
        {
          feedback_o := Translations::MP_UnitPeriod_CanEditCapacities_IsAggregatedCapacitity();
        }
        else
        {
          feedback_o := Translations::MP_UnitPeriod_CanEditCapacities_IsDifferentSubclass();
        }
      }
    }
    
    return feedback_o = '';
  *]
}