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
Quintiq file version 2.0
#parent: #root
Method GetHasValidPostponement (
  output Strings feedback_o,
  output Strings sanitycheckfeedback_o
) declarative remote as Boolean
{
  TextBody:
  [*
    // Indicate if the poseponement is valid
    value := true;
    
    message := '';
    psEnd := guard( this.PostponementSpecification().End().Date(), Date::MinDate() );
    
    // If this SalesDemandInPeriod has PostponedSalesDemand and the EndDate is out of the valid postponement period
    if( this.HasPostponedSalesDemand()
        and this.EndDate() > psEnd )
    {
      value := false;
      // Get the effective PostponementSpecification
      postponementspec := guard( this.MasterSalesDemand().SalesSegment_MP().EffectivePostponementSpecification(), null( PostponementSpecification ) );
      // Generate PostponementSpecification's horizon in string, e.g. 3 Months, 1 Day, etc.
      displayEnd := guard( [String] postponementspec.HorizonNrOfTimeUnit()
                           + " "
                           + postponementspec.HorizonTimeUnit()
                           + ifexpr( postponementspec.HorizonNrOfTimeUnit() > 1, 's', '' ), "" );
            
      message := Translations::MP_BaseSalesDemandInPeriod_GetHasValidDemandManagement_OverPostponementHorizon( displayEnd );
    }
    
    // If precondition is violated, insert the feedback message into feedback_o and sanitycheckfeedback_o
    if( not isnull( feedback_o )
        and not value )
    { 
      instance := Translations::MP_BaseSalesDemandInPeriod_Instance( this.SalesSegmentName(), this.StartDate() );
      feedback_o.Add( SanityCheckMessage::GetFormattedMessage( instance, message ) );
      sanitycheckfeedback_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryPlanningIssue() );
    }
    
    return value;
  *]
}