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
Quintiq file version 2.0
#parent: #root
StaticMethod CanEditEntityInPeriod (
  structured_Object entityperiods,
  output String feedback_o
) declarative remote as Boolean
{
  Description: 'Check whether the stockingpointinperiod or unitperiod can be edited'
  TextBody:
  [*
    objectype := selectuniquevalues( entityperiods, Elements, element, true , element.DefinitionName() );
    aggregated := select( entityperiods, Elements.astype( UnitPeriod ).Unit, unit, true, unit.HasCapacityTypeAggregation() );
    isinfinite := select ( entityperiods, Elements.astype( UnitPeriod ).Unit, unit , true, unit.HasCapacityTypeInfinite() );
    
    result := true;
    
    if ( objectype.Size() >1 )
    {
      result := false;
      feedback_o:= Translations::MP_CapacityPlanning_CapacityDefinition_Incompatible();
    }
    else if( not isnull( aggregated ) )
    {
      result := false;
      capacitytype := ifexpr( aggregated.CapacityType() = GlobalParameters_MP::GetCapacityTypeTimeAggregation(), 
                              Translations::MP_CapacityPlanning_TimeAggregated(), Translations::MP_CapacityPlanning_QuantityAggregated() );
                                
      feedback_o:= Translations::MP_CapacityPlanning_CapacityDefinition_ChildLevel( capacitytype ); 
    }
    else if ( not isnull( isinfinite ) )
    {
      result := false;
      feedback_o := Translations::MP_UnitPeriodInfinite_NoCapacities();  
    }
    // Block edit if selected object is transition_mp
    else if ( exists( entityperiods, Elements.astype( Transition_MP ), e, true ) )
    {
     result := false; 
    }
    
    return result;
  *]
}