Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Function CalcShelfLifeAgeAndQuantityVectorAsBinaryValue 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Get the destination PISPIPPL and Product 
 | 
    destination_pispippl := this.ProductInStockingPointInPeriodPlanningLeaf(); 
 | 
    destination_product_mp := destination_pispippl.ProductInStockingPoint_MP().Product_MP(); 
 | 
     
 | 
    // Check if destination product has shelf life or maturation 
 | 
    if( guard( destination_product_mp.HasShelfLifeOrMaturation(), 
 | 
               false ) ) 
 | 
    { 
 | 
      quantityvector := RealVector::Construct(); 
 | 
      agevector := RealVector::Construct(); 
 | 
     
 | 
     
 | 
      // Check if this supply is created due to laneleg or routing operation 
 | 
      if( this.PeriodTask_MP().istype( PeriodTaskLaneLeg ) ) 
 | 
      {  
 | 
        // If this new supply is being transported with trip, 
 | 
        // We will not track the age of product at the origin stocking point. E.g out of 100 NS, 20 is 1 day old, 80 is 2 days old. 
 | 
        // So it's sufficient to just set all of their age to the leadtime. E.g. all 100 NS are 3 days old when leadtime is 3 days. 
 | 
        age := this.PeriodTask_MP().astype( PeriodTaskLaneLeg ).Trip().GetShelfLifeAgeToAdd(); 
 | 
        quantityvector.Append( this.Quantity() ); 
 | 
        agevector.Append( age ); 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        // If this new supply is created using routing operation 
 | 
        // We assume that the output is a different product altogether 
 | 
        // therefore, the age of the product is 0 
 | 
        quantityvector.Append( this.Quantity() ); 
 | 
        agevector.Append( 0.0 ); 
 | 
      } 
 | 
       
 | 
      // Merge the vectors 
 | 
      ShelfLife::MergeVectorAccordingToAgeAndExpiration( quantityvector, agevector, 
 | 
                                                         destination_pispippl, 
 | 
                                                         destination_pispippl.Start() ); 
 | 
     
 | 
      this.ShelfLifeQuantityVectorAsBinaryValue( quantityvector.AsBinaryValue() ); 
 | 
      this.ShelfLifeAgeVectorAsBinaryValue( agevector.AsBinaryValue() ); 
 | 
    } 
 | 
  *] 
 | 
} 
 |