Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method SynchronizeSalesDemandInPeriod ( 
 | 
  Boolean resetoptimizerfulfillment 
 | 
) 
 | 
{ 
 | 
  Description: 'Synchronize sales demand in period on base period modification.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // desmondt Nov-5-2015 (modified) 
 | 
    oldsdips := selectset( this, SalesDemandInPeriod, sdip, true ); 
 | 
    newsdips := construct( SalesDemandInPeriods ); 
 | 
     
 | 
    // If quantity had been updated, reset the optimizer fulfillment sales demand in the Pispip and the pispips onwards so that the calc system fulfilled quantity will kicks in 
 | 
    /* e.g 
 | 
    Period         Jan  Feb  March April 
 | 
    SalesDemandInPeriod HasOptimizerFulfillment 
 | 
    Sales demand 1 true true true  true 
 | 
    Sales demand 2 true true true  true 
 | 
    Sales demand 3 true true true  true  
 | 
     
 | 
    When a sales demand quantity in Feb had been updated, ALL sales demand from Feb ~ April will be reseted. 
 | 
     
 | 
    Period         Jan  Feb  March April 
 | 
    SalesDemandInPeriod HasOptimizerFulfillment 
 | 
    Sales demand 1 true false false  false 
 | 
    Sales demand 2 true false false  false 
 | 
    Sales demand 3 true false false  false 
 | 
    */ 
 | 
    if( resetoptimizerfulfillment ) 
 | 
    { 
 | 
      sdip := this.First(); 
 | 
      if( not isnull( sdip ) 
 | 
          and not isnull( sdip.AsSalesDemandInPeriodBase() ) ) 
 | 
      { 
 | 
        sdip.AsSalesDemandInPeriodBase().ResetSalesDemandFulfillmentForThisPeriodOnwards(); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    if( this.StartDate().IsFinite() and this.EndDate().IsFinite() ) 
 | 
    { 
 | 
      // SDiPs to get generated on planning period level 
 | 
      pispips := this.GetPlanningPISPIPs(); 
 | 
      traverse( pispips, Elements, pispip )  
 | 
      {  
 | 
        sdip := this.GetSalesDemandInPeriod( pispip ); 
 | 
        if( not isnull( sdip ) ) 
 | 
        { 
 | 
          newsdips.Add( sdip ); 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
     
 | 
    // Get the difference(obsolete) SDIP 
 | 
    deprecatedsdips := oldsdips.Difference( newsdips ); 
 | 
     
 | 
    // Remove the obsolete SDIP 
 | 
    SalesDemandInPeriod::Delete( deprecatedsdips ); 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Extensible' } 
 | 
} 
 |