| Quintiq file version 2.0 | 
| #parent: #root | 
| DeclarativeReferenceRelation CalcDeparturePISPIP | 
| { | 
|   #keys: '1[134266.1.22297753]' | 
|   Expression: | 
|   [* | 
|     pispip := null( ProductInStockingPointInPeriodPlanningLeaf ); | 
|      | 
|     if( this.Trip().HasValidDeparture() ) | 
|     { | 
|       destpisp := select( this, Trip.LaneLeg.LaneLegInput.ProductInStockingPoint_MP, pisp, | 
|                           pisp.StockingPoint_MP() = this.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() | 
|                           and pisp.Product_MP() = this.Product_MP() ); | 
|      | 
|       pispip := select( destpisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), p, | 
|                         p.Period_MP() = this.Trip().DepartureUnitPeriod().Period_MP() ); | 
|     } | 
|      | 
|     return pispip; | 
|   *] | 
|   Relation: DeparturePISPIP | 
| } |