| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod OptimizerPostProcessing ( | 
|   LibOpt_Scope scope, | 
|   RunContextForCapacityPlanning runcontext | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     //We need to propagate InventoryDemandFulfilledQuantity  | 
|     Transaction::Transaction().Propagate(); | 
|     pispipssmartplan := scope.GetSmartPlanPISPIPsInOptimizerRun();  | 
|      | 
|     traverse( pispipssmartplan, Elements, pispip ) | 
|     {                                          | 
|       // If this pispip has a user specified total available supply | 
|       // Then set the total supply user equal to this total available supply | 
|       // To make sure that any future optimizer runs will provide the user available supply | 
|       if( pispip.HasTotalAvailableSupplyUser() ) | 
|       { | 
|         pispip.UpdateTotalSupplyUser( true, pispip.TotalAvailableSupplyUser() ); | 
|       }  | 
|       else | 
|       { | 
|         qty := guard( pispip.InventoryLevelStartPISPIP().InventoryLevelEnd(), 0.0 ) + pispip.NewSupplyQuantity() + pispip.InventorySupplyQuantity();     | 
|         pispip.UpdateTotalSupplyUser( true, qty ); | 
|       } | 
|        | 
|        | 
|       //set the user flag for period tasks | 
|       //of the routing / laneleg units that are supplying to the pispip | 
|       //YY Question: Is it safe to assume | 
|       if( runcontext.IsSmartPlanForPeriodTask() and pispip.istype( ProductInStockingPointInPeriodPlanningLeaf ) ) | 
|       {       | 
|         traverse( pispip.astype( ProductInStockingPointInPeriodPlanningLeaf ),  | 
|                   NewSupply,  | 
|                   ns,  | 
|                   exists( scope.GetPeriodTaskOperationInOptimizerRun(), Elements.Operation, pto, ns.IsSuppliedByThisProcess( pto ), true ) | 
|                   or exists( scope.GetProductInTripInOptimizerRun(), Elements.Trip.LaneLeg, ll, ns.IsSuppliedByThisProcess( ll ), true ) ) | 
|         {    | 
|           if( ns.IsNewSupplyOfTrip() ) | 
|           { | 
|             pit := ns.ProductInTrip(); | 
|             pit.Update( pit.OptimizerQuantity(), true ); | 
|           } | 
|           else if( ns.PeriodTask_MP().istype( PeriodTaskOperation ) ) | 
|           { | 
|             pto := ns.PeriodTask_MP().astype( PeriodTaskOperation ); | 
|             pto.Update( pto.OptimizerQuantity(), true, scope ); | 
|           } | 
|         } | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |