| Quintiq file version 2.0 | 
| #parent: #root | 
| Function CalcAge | 
| { | 
|   TextBody: | 
|   [* | 
|     value := 0.0; | 
|     pispip := this.ProductInStockingPointInPeriodPlanningLeaf(); | 
|      | 
|     /* Start age of inventory supply is the duration between manufactured date to period start date | 
|        rounded up to the multiple of period's duration. | 
|       e.g. inv supply in W2, manufactured on 3-Jan, assuming W1: 1 Jan to 8 Jan, W2: 8 Jan to 15 Jan | 
|       age = 8-3 rounded up to multiple of 7 = 7 | 
|     */ | 
|      | 
|     if ( not isnull( pispip ) and this.Product_MP().HasShelfLifeOrMaturation() ) | 
|     { | 
|        | 
|       period := pispip.Period_MP(); | 
|       date := pispip.Start(); | 
|       manufacturedate := this.ManufacturedDate(); | 
|        | 
|       value := ifexpr( manufacturedate.IsFinite() and date.IsFinite(), | 
|                        ShelfLife::GetSupplyAge( manufacturedate, date.Date(), period ), 0.0 ); | 
|     }                 | 
|      | 
|     this.Age( value ); | 
|   *] | 
| } |