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
Quintiq file version 2.0
#parent: #root
StaticMethod CanEnterSupplyQuantity (
  output String feedback_o,
  ProductInStockingPointInPeriods pispips,
  Strings attributenames,
  output Boolean isSupply_o
) declarative remote as Boolean
{
  Description: 'Used to verify that user can specify supply quantity on a product planning matrix cell.'
  TextBody:
  [*
    // Check 3 conditions:
    // 1 - whether the pispips are of planning periods
    // 2 - whether the selected attribute can be edited
    // 3 - whether the params and profiles are there
    feedback_o := '';
    // These are the editable attributes
    supplyQty := attribute( ProductInStockingPointInPeriod, DisplaySupplyQuantity ).Name();
    
    uniqueattributes := attributenames.Unique();
    isEditSupply := uniqueattributes.Element( 0 ) = supplyQty;
    
    if( uniqueattributes.Size() > 1 )
    {
      feedback_o := Translations::MP_ProductInStockingPointInPeriod_CanOnlyEditOneAttribute();
    }
    // Not allowed to batch edit total supplies
    else if( isEditSupply
             and attributenames.Size() > 1 )
    {
      feedback_o := Translations::MP_ProductInStockingPointInPeriod_CanOnlyEditOneTotalSupply();
    }
    else if( not forall( uniqueattributes, Elements, e, 
                         e = supplyQty ) )
    {
      feedback_o := Translations::MP_ProductInStockingPointInPeriod_CanEditValuesFromMatrix();
    }
    else if( not forall( pispips, Elements.Period_MP, period, period.IsPlanning() ) ) 
    {
      feedback_o := Translations::MP_Period_CannotPlanSupply();
    }
    else
    {
      isSupply_o := isEditSupply;
    }
    
    return feedback_o = '';
  *]
}