yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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
Quintiq file version 2.0
#parent: #root
Method CopyOccurrences (
  Date start_i,
  Date end_i
)
{
  Description: 'Add occurrences during a period of time by coping them from the LeadingParticipation.'
  TextBody:
  [*
    if( start_i <= end_i )
    {
      timezone := this.Calendar().GetTimeZone();
      
      traverse( this.LeadingParticipation(), ExplicitTimeInterval, leadingETI,
                leadingETI.End().Date( timezone )   >= start_i                      and
                leadingETI.End()                    <> start_i.DateTime( timezone ) and            // Exclude when the end is exactly at start_i 
                leadingETI.Start().Date( timezone ) <= end_i                        and
                not exists( leadingETI, SubscribingETI, eti, true, eti.Participation() = this ) )  // Check if the subscribing occurrence does not already exists.
      {
        occurrence := this.CreateTimeInterval( leadingETI.Start(), leadingETI.End(), leadingETI.Capacity() );
      
        if( not isnull( occurrence ) )
        {
          // Register the occurrence (i.e. the ExplicitTimeInterval) as SubscribingETI of the LeadingETI.
          occurrence.LeadingETI( relset, leadingETI );
        }
      }            
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}