| Quintiq file version 2.0 | 
| #parent: #root | 
| Method MPSyncStockingPointCapacity ( | 
|   Boolean isoverwritemanualconfig, | 
|   IOStockingPointCapacitys iostockingpointcapacitys | 
| ) | 
| { | 
|   Description: 'Synchronization of StockingPointCapacity for MPSync' | 
|   TextBody: | 
|   [* | 
|     // Select a set of existing StockingPointCapacity | 
|     existing := selectset( this, StockingPoint_MP.StockingPointCapacity, item, true ); | 
|     updates := construct( StockingPointCapacitys ); | 
|      | 
|     // Traverse the new set of valid StockingPointCapacity | 
|     traverse( iostockingpointcapacitys , Elements, io, io.IsValid() ) | 
|     { | 
|       spid := io.StockingPointID(); | 
|       start := io.Start(); | 
|       // Find existing StockingPointCapacity | 
|       objectinstance := StockingPointCapacity::FindStockingPointCapacityTypeIndex( spid, start ); | 
|       // Find existing StockingPoint_MP | 
|       sp := StockingPoint_MP::FindStockingPointTypeIndex( spid ); | 
|        | 
|       // If no existing StockingPointCapacity is found, create one | 
|       if( isnull( objectinstance ) ) | 
|       { | 
|         // Check if StockingPoint_MP is valid | 
|         if( not isnull( sp ) ) | 
|         { | 
|           objectinstance := StockingPointCapacity::Create( sp, start, io.MaxCapacity() ,true ); | 
|         } | 
|       } | 
|       // Else if the StockingPointCapacity is not manually configured or the imported instance should overwrite manual configuration, | 
|       // update the existing StockingPointCapacity | 
|       else if( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig ) | 
|       { | 
|         // Update StockingPointCapacity | 
|         if( not isnull( sp ) ) | 
|         { | 
|           objectinstance.Update( sp, io.Start(), io.MaxCapacity() ,true ); | 
|           updates.Add( objectinstance ); | 
|         } | 
|       } | 
|        | 
|       if( not isnull( objectinstance ) ) | 
|       { | 
|         objectinstance.CustomUpdate( io, isoverwritemanualconfig );   | 
|       } | 
|     } | 
|      | 
|     // Get the set of old StockingPointCapacity to be deleted | 
|     tobedeleteset := existing.Difference( updates ); | 
|      | 
|     // Traverse the set of StockingPointCapacity to be deleted | 
|     // Only delete StockingPointCapacity that is not manually configured or the imported instance should overwrite manual configuration | 
|     traverse( tobedeleteset, Elements, ele, | 
|               not ele.IsManuallyConfigured() or isoverwritemanualconfig ) | 
|     { | 
|       ele.Delete(); | 
|     } | 
|   *] | 
| } |