Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method MPSyncFeedbackProductInTrip ( 
 | 
  Boolean isoverwritemanualconfig, 
 | 
  IOFeedbackProductInTrips iofeedbackproductintrips 
 | 
) 
 | 
{ 
 | 
  Description: 'Synchronization of FeedbackProductInTrip for MPSync' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Select a set of existing FeedbackProductInTrip 
 | 
    existing := selectset( this, Feedback.astype( FeedbackProductInTrip ), item, true ); 
 | 
    updates := construct( FeedbackProductInTrips );  
 | 
     
 | 
    // Traverse the new set of valid FeedbackProductInTrip 
 | 
    traverse( iofeedbackproductintrips , Elements, io, io.IsValid() ) 
 | 
    { 
 | 
      id := io.ID(); 
 | 
      // Find existing FeedbackProductInTrip 
 | 
      objectinstance := FeedbackProductInTrip::FindFeedbackProductInTripTypeIndex( id ); 
 | 
       
 | 
      // If no existing FeedbackProductInTrip is found, create one 
 | 
      if( isnull( objectinstance ) ) 
 | 
      { 
 | 
        objectinstance := FeedbackProductInTrip::Create( this, 
 | 
                                                          id, 
 | 
                                                          io.Arrival(), 
 | 
                                                          io.Description(), 
 | 
                                                          io.OriginStockingPointID(), 
 | 
                                                          io.DestinationStockingPointID(), 
 | 
                                                          io.FeedbackQuantity(), 
 | 
                                                          io.LaneID(), 
 | 
                                                          io.ProductID(), 
 | 
                                                          true ); 
 | 
      } 
 | 
      // Else if the FeedbackProductInTrip is not manually configured or the imported instance should overwrite manual configuration, 
 | 
      // update the existing FeedbackProductInTrip 
 | 
      else if( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig ) 
 | 
      { 
 | 
        // Update FeedbackProductInTrip 
 | 
        objectinstance.Update( io.Arrival(), 
 | 
                               io.Description(), 
 | 
                               io.OriginStockingPointID(), 
 | 
                               io.DestinationStockingPointID(), 
 | 
                               io.FeedbackQuantity(), 
 | 
                               io.LaneID(), 
 | 
                               io.ProductID(), 
 | 
                               true ); 
 | 
        updates.Add( objectinstance ); 
 | 
      } 
 | 
       
 | 
      if( not isnull( objectinstance ) ) 
 | 
      { 
 | 
        objectinstance.CustomUpdate( io, isoverwritemanualconfig );    
 | 
      } 
 | 
    } 
 | 
     
 | 
    // Get the set of old FeedbackProductInTrip to be deleted 
 | 
    tobedeleteset := existing.Difference( updates ); 
 | 
     
 | 
    // Traverse the set of FeedbackProductInTrip to be deleted 
 | 
    // Only delete FeedbackProductInTrip that is not manually configured or the imported instance should overwrite manual configuration 
 | 
    traverse( tobedeleteset, Elements, ele, 
 | 
              not ele.IsManuallyConfigured() or isoverwritemanualconfig ) 
 | 
    { 
 | 
      ele.Delete(); 
 | 
    } 
 | 
  *] 
 | 
} 
 |