Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method FindCreateUnitCalendar ( 
 | 
  IOUnitCalendar iounitcalendar 
 | 
) as UnitCalendar 
 | 
{ 
 | 
  Description: 'Create a new UnitCalendar if this unit dont have it' 
 | 
  TextBody: 
 | 
  [* 
 | 
    objectinstance := null( UnitCalendar ); 
 | 
     
 | 
    if( not isnull( this ) ) 
 | 
    { 
 | 
      // Find existing UnitCalendar 
 | 
      objectinstance := this.UnitCalendar(); 
 | 
     
 | 
      // If no existing UnitCalendar is found, create one 
 | 
      if( isnull( objectinstance ) ) 
 | 
      { 
 | 
        objectinstance := this.UnitCalendar( relnew, 
 | 
                                             CalendarID := iounitcalendar.CalendarID(), 
 | 
                                             CalendarType := iounitcalendar.CalendarType() ); 
 | 
                                              
 | 
      } 
 | 
    } 
 | 
     
 | 
    return objectinstance; 
 | 
  *] 
 | 
} 
 |