陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan macroplan,
  CampaignType_MP campaigntype,
  DateTime start,
  DateTime end,
  Real minqty,
  Real maxqty,
  String comment,
  Campaign_MP_DELETED_Q320 campaign,
  Boolean checkunique
) declarative remote as Boolean
{
  Description: 'Checks the correctness of input data from Create/Edit dialog.'
  TextBody:
  [*
    // Precondition to validate the input for creating/editing Campaign_MP
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Check if campaign type is null
    if( isnull( campaigntype ) )
    {
      feedback_o := Translations::MP_Campaign_ValidateInput_IsNullCampaignType();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if start and end time window is valid
    else if( start >= end )
    {
      feedback_o := '' // Translation is removed as object not in-used anymore
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if minimum quantity is valid
    else if( minqty < 0 )
    {
      feedback_o := Translations::MP_Campaign_ValidateInput_IsNegativeMinQuantity( minqty );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if maximum quantity is valid
    else if( maxqty < 0 )
    {
      feedback_o := Translations::MP_Campaign_ValidateInput_IsNegativeMaxQuantity( maxqty );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if maximum quantity is larger than minimum quantity
    else if( maxqty < minqty )
    {
      feedback_o := Translations::MP_Campaign_ValidateInput_IsMaxQuantityLessThanMaxQuantity( minqty, maxqty );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if campaign details are unique
    else if( checkunique
             and exists( campaigntype, Unit.Campaign_MP_DELETED_Q320, cpg,
                         cpg <> campaign
                         and Period_MP::IsInPeriod( start, end, cpg.Start(), cpg.End() ) ) )
    {
      feedback_o := Translations::MP_Campaign_ViolatesIsPlannedWithNoOverlap();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    
    // Format feedback text if any of the precondition above is violated
    if( feedback_o <> '' )
    {
      instance := Campaign_MP_DELETED_Q320::GetInstanceText( campaigntype, start );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o.Length() = 0
  *]
}