| Quintiq file version 2.0 | 
| #parent: #root | 
| DeclarativeReferenceRelation CalcArrivalPISPIP | 
| { | 
|   #keys: '1[134266.1.22297719]' | 
|   Expression: | 
|   [* | 
|     pispip := null( ProductInStockingPointInPeriodPlanningLeaf ); | 
|      | 
|     if( this.Trip().HasValidArrival() ) | 
|     { | 
|       destpisp := select( this, Trip.LaneLeg.LaneLegOutput.ProductInStockingPoint_MP, pisp, | 
|                           pisp.StockingPoint_MP() = this.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() | 
|                           and pisp.Product_MP() = this.Product_MP() ); | 
|      | 
|       pispip := select( destpisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), p, | 
|                         p.Period_MP() = this.Trip().ArrivalUnitPeriod().Period_MP() ); | 
|     } | 
|      | 
|     return pispip; | 
|   *] | 
|   Relation: ArrivalPISPIP | 
| } |