admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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,
  LaneLeg laneleg,
  Period_MP arrivalperiod
) declarative remote as Boolean
{
  Description: 'Validate user input for trip. Sets feedback and returns a boolean.'
  TextBody:
  [*
    // Validate input for trip
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    start := laneleg.MacroPlan().Start();
    // Get arrival & departure time depending on lead time logic
    arrival := guard( Trip::GetTripArrivalDate( arrivalperiod, laneleg ), DateTime::MaxDateTime() );
    departure := arrival - laneleg.LeadTime();
    
    // Check if arrival period is provided
    if( isnull( arrivalperiod ) )
    {
      feedback_o := Translations::MP_Trip_ValidateInput_IsInvalidArrival( arrival.Date() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if arrival period is a planning period
    else if( not arrivalperiod.IsPlanning() )
    {
      feedback_o := Translations::MP_Trip_ValidateInput_NonPlanningPeriod();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the arrival & departure date is within the valid period
    else if( not Trip::GetIsValidTrip( laneleg, departure.Date(), arrival.Date() ) )
    {
      feedback_o := Translations::MP_Trip_ValidateInput_IsValidTrip( laneleg );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // need to include historical date
    // Check if the departure time is within the planning horizon
    else if( departure < start )
    {
      feedback_o := Translations::MP_Trip_ValidateInput_IsInvalidDeparture( laneleg.LeadTime(),
                                                                            departure.Date() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryPlanningIssue();
    }
    
    // Add instance text if any of the preconditions above are violated
    if( feedback_o <> '' )
    {
      instance := Trip::GetInstanceText( laneleg, arrival.Date() );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}