| Quintiq file version 2.0 | 
| #parent: #root | 
| DeclarativeReferenceRelation CalcAsPlanningBaseSalesDemandInPeriodForOptimization | 
| { | 
|   #keys: '1[141320.2.197612351]' | 
|   Expression: | 
|   [* | 
|     value := null(  ProductInStockingPointInPeriodPlanningLeaf );  | 
|     if ( this.NeedsToBePlanned()  | 
|          and this.IsWithinThresholdQuantity() | 
|          and ( not this.IsPostponed() or this.IsManuallyPostponed() ) ) // note that postponed sd is not unplanned prior to optimizer initialization. This only happens in the handle feasible for those in scope | 
|     {                                 // with this we make sure postponed sd is treated separate by the optimizer | 
|       value := this.AsPlanningBaseSalesDemandInPeriod();  | 
|     } | 
|     return value; | 
|   *] | 
|   Relation: AsPlanningBaseSalesDemandInPeriodForOptimization | 
| } |