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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Unit unit,
  CampaignType_MP fromcampaigntype,
  CampaignType_MP tocampaigntype,
  Real minquantity,
  Real maxquantity,
  Duration minduration,
  Duration maxduration,
  TransitionType_MP transitiontype,
  Boolean checkunique,
  String inputType,
  Boolean checkmaxqty,
  Boolean checkmaxdur
) declarative remote as Boolean
{
  Description: 'Checks the correctness of input data from Create/Edit dialog.'
  TextBody:
  [*
    // Validate input for TransitionType_MP
    feedback_o := '';
    sanitycheckfeedback_o := '';
    isDurationInput := inputType = GlobalParameters_MP::GetCampaignTransitionsTypeDuration();
    
    // Check if unit is null
    if( isnull( unit ) )
    {
      feedback_o := Translations::MP_TransitionType_ValidateInput_IsNullUnit() ;
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if from/to campaign type is null
    else if( isnull( fromcampaigntype ) or isnull( tocampaigntype ) )
    {
      feedback_o := Translations::MP_TransitionType_ValidateInput_IsNullFromToCampaignType() ;
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if from & to campaign type has different UnitID
    else if( fromcampaigntype.UnitID() <> tocampaigntype.UnitID() )
    {
      feedback_o := Translations::MP_TransitionType_ValidateInput_IsDifferentUnit();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if from & to campaign type is the same campaign type
    else if( TransitionType_MP::ValidateDistinctOriginDestination( feedback_o, sanitycheckfeedback_o, fromcampaigntype.Name(), tocampaigntype.Name() ) )
    {
      // Check if the name is unique
      if( checkunique )
      {
        units := construct( Units )
        units.Add( unit )
        TransitionType_MP::CheckIsUnique( feedback_o, sanitycheckfeedback_o, units, transitiontype, fromcampaigntype.Name(), tocampaigntype.Name() )
      }
    }
    if( feedback_o.Length() = 0 )
    {
      if( not isDurationInput ) 
      {
        // Check if minimum quantity is valid
        if( minquantity <= 0 )
        {
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMinQuantity( minquantity );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
        }
        // Check if the maximum quantity is valid
        else if( checkmaxqty and maxquantity <= 0 )
        {
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMaxQuantity( maxquantity );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
        }
        // Check if min vs max quantity is valid
        else if( checkmaxqty and maxquantity < minquantity ) 
        { 
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsMinQuantityGreaterThanMaxQuantity( minquantity, maxquantity ); 
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
        }
      }
      else if ( isDurationInput )
      {
        // Check if min duration is greater than zero
        if( minduration <= Duration::Zero() ) 
        {
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMinDuration( minduration );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
        }
        // Check if max duration is greater than zero
        else if( checkmaxdur and maxduration < Duration::Zero() )
        {
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMaxDuration( maxduration );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
        }
        // Check if min vs max duration is valid
        else if( checkmaxdur and maxduration < minduration )
        {
          feedback_o := Translations::MP_TransitionType_ValidateInput_IsMinDurationGreaterThanMaxDuration( minduration, maxduration );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
        }
      }
    }
    
    return feedback_o.Length() = 0;
  *]
}