chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Boolean checkunique,
  PostponementSpecification postponementspecification,
  SalesSegment_MP targetsalessegment,
  String horizontimeunit,
  Number horizonnroftimeunit,
  String maxtimeunit,
  Number maxnroftimeunit
) declarative remote as Boolean
{
  Description: 'Check for input obtained from UI'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Is unique
    if( checkunique
        and ( not isnull( targetsalessegment )                             
              and not isnull( targetsalessegment.PostponementSpecification() )          
              // For when Editing the PS. New and Copy have postponementspecification = null
              and targetsalessegment.PostponementSpecification() <> postponementspecification ) ) 
    {
      feedback_o := Translations::MP_PostponementSpecification_ValidateInput_SalesSegment( targetsalessegment.Name() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if horizon time unit is valid
    else if( not PeriodSpecification_MP::GetHasValidTimeUnit( horizontimeunit )  )
    {
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_InvalidTimeUnit();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the number of horizon time unit is valid
    else if( horizonnroftimeunit <= 0 )
    {
      feedback_o := Translations::MP_PostponementSpecification_ValidateInput_PostponementHorizon( horizonnroftimeunit, horizontimeunit );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if max time unit is valid
    else if( not PeriodSpecification_MP::GetHasValidTimeUnit( maxtimeunit )  )
    {
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_InvalidTimeUnit();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the number of max time unit is valid
    else if( maxnroftimeunit <= 0 )
    {
      feedback_o := Translations::MP_PostponemenSpecification_ValidateInput_MaximumPostponement( maxnroftimeunit, maxtimeunit );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    
    return feedback_o = '';
  *]
}