Quintiq file version 2.0
#parent: #root
Method ValuesPeriodOK () as Boolean id:Method_LibCal_dlgSubscription_ValuesPeriodOK
{
  #keys: '[131094.0.2065391858]'
  Body:
  [*
    feedback   := FeedbackObject::LocalFeedback();
    periodKind := "subscription";
    
    // StartOfPeriod must have a value.
    if( dsStartOfPeriod.Date().IsInfinite() )
    {
      feedback.AddHard( Translations::Period_InvalidStartOfPeriod( periodKind ) );
    }
    
    // EndOfPeriod must have a value.
    if( ckbEndOfPeriod.Checked() and
        dsEndOfPeriod.Date().IsInfinite() )
    {
      feedback.AddHard( Translations::Period_InvalidEndOfPeriod( periodKind ) );
    }
    
    if( feedback.IsAllowed() )
    {
      // EndOfPeriod must be greater than StartOfPeriod.
      startOfPeriod := dsStartOfPeriod.Date();
      endOfPeriod   := dsEndOfPeriod  .Date();
      
      if( ckbEndOfPeriod.Checked() and
          dsEndOfPeriod.Date() < dsStartOfPeriod.Date() )
      {
        feedback.AddHard( Translations::Period_EndMustBeGreaterThanStartOfPeriod( periodKind,
                                                                                  startOfPeriod.Format( Translations::DateFormat() ),
                                                                                  endOfPeriod  .Format( Translations::DateFormat() ) ) );
      }
    }
    
    return feedback.IsAllowed();
  *]
}
