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
Quintiq file version 2.0
#parent: #root
Method UpdateRecurrencePeriod (
  Boolean isRecurring_i,
  String periodType_i,
  Date startOfPeriod_i,
  Number nrOfOccurrences_i,
  Date endOfPeriod_i
)
{
  TextBody:
  [*
    if( not isRecurring_i )
    {
      // Remove the RecurrencePeriod
      this.RemoveRecurrencePeriod();
    }
    else
    {
      // First validate the recurrence period.
      // If something is wrong the validation results in an error so that the actual update below will not be executed.
      hasSpecificPeriod := guard( not this.astype( LibCal_Subscription ).UseLeadingPeriod(), true );
      feedback := LibCal_Validate::Participation_RecurrencePeriod( this.ParticipationID(), isRecurring_i, this.IsLeading(), hasSpecificPeriod,
                                                                   this.StartDate(), periodType_i, startOfPeriod_i, nrOfOccurrences_i, endOfPeriod_i,
                                                                   this.Event().GetEventInfo().Erase( 0, 8 ) );
      // Process the feedback that has been registered by the validation (if any).
      LibCal_Util::ProcessFeedbackObject( feedback );
      
      // The below is only executed when no validation errors were encountered.
      // Set a RecurrencePeriod of the applicable type.
      if( periodType_i = LibCal_RecurrencePeriod::TYPE_WITHOUTEND() )
      {
        this.SetPeriodWithoutEnd( startOfPeriod_i );
      }
      
      else if( periodType_i = LibCal_RecurrencePeriod::TYPE_NROFOCCURRENCES() )
      {
        this.SetPeriodWithNrOfOccurrences( startOfPeriod_i, nrOfOccurrences_i );
      }
    
      else if( periodType_i = LibCal_RecurrencePeriod::TYPE_WITHENDDATE() )
      {
        this.SetPeriodWithEndDate( startOfPeriod_i, endOfPeriod_i );
      }
    }
    
    // Directly calculate IsRecurring.
    // This is important when the current Participation is a LeadingParticipation
    // to which a Subscription might be created in the same transaction.
    // this.CalcIsRecurring(); is not good enough here, explicit propagation is required.
    Transaction::Transaction().Propagate( attribute( LibCal_Participation, IsRecurring ) );
  *]
  InterfaceProperties { Accessibility: 'Extensible' }
}