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 CanEditValuesFromMatrix (
  Strings attributenames,
  output String feedback_o,
  output Boolean isSupply_o,
  output Boolean isActInvent_o
) as Boolean
{
  Description: 'Returns true if these attributes can be edited via the matrix'
  TextBody:
  [*
    feedback_o := '';                     
    
    // These are the editable attributes
    supplyQty := attribute( ProductInStockingPointInPeriod, SupplyQuantity ).Name();
    actualInvEnd := attribute( ProductInStockingPointInPeriod, ActualInventoryLevelEnd ).Name();
    
    uniqueattributes := attributenames.Unique();
    
    // Check if the selected attribute(s) in the matrix is one of the editable attributes
    isvalid := forall( uniqueattributes, 
                       Elements, 
                       e, 
                       e = supplyQty 
                       or e = actualInvEnd );
    if( not isvalid )
    {
      feedback_o := Translations::MP_ProductInStockingPointInPeriod_CanEditValuesFromMatrix();
    }
    // Check if the user is trying to edit more than one attribute in the matrix
    else if( uniqueattributes.Size() > 1 )
    {
      feedback_o := Translations::MP_ProductInStockingPointInPeriod_CanOnlyEditOneAttribute();
    }
    else
    {
      // Check if the selected attribute in the matrix is of SupplyQuantity or ActualInventoryLevelEnd
      isSupply_o := uniqueattributes.Element( 0 ) = supplyQty;
      isActInvent_o := uniqueattributes.Element( 0 ) = actualInvEnd;
    }
    
    return feedback_o = '';
  *]
}