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 = '';
|
*]
|
}
|