| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SynchronizeLaneLeg ( | 
|   Lane originallane | 
| ) | 
| { | 
|   Description: 'Ensures the newly copied lanelegs have the same attributes as the original.' | 
|   TextBody: | 
|   [* | 
|     // MKO2 Aug-9-2016 (created) | 
|     idholder := this.Unit().MacroPlan().IDHolder(); | 
|      | 
|     traverse( originallane, LaneLeg, originallaneleg ) | 
|     { | 
|       // select the lane legs on the newly copied lane | 
|       newlaneleg := select( this, LaneLeg, ll,  | 
|                             ll.DestinationStockingPointID() = originallaneleg.DestinationStockingPointID()  | 
|                             and ll.OriginStockingPointID() = originallaneleg.OriginStockingPointID() ); | 
|      | 
|       // update lane leg with original attributes | 
|       if( not isnull( newlaneleg ) ) | 
|       { | 
|         newlaneleg.Update( newlaneleg.Lane(), | 
|                            originallaneleg.AsOriginStockingPointLeg(), | 
|                            originallaneleg.AsDestinationStockingPointLeg(), | 
|                            originallaneleg.IsEnabled(), | 
|                            originallaneleg.Start(), | 
|                            originallaneleg.End(), | 
|                            originallaneleg.HasUserLeadTime(), | 
|                            originallaneleg.LeadTime(), | 
|                            originallaneleg.HasStandardDeviationLeadTimeLaneLeg(), | 
|                            originallaneleg.StandardDeviationLeadTimeLaneLeg(), | 
|                            originallaneleg.CO2Emission() ); | 
|                             | 
|         // duplicate costs on new lane leg | 
|         traverse( originallaneleg, LaneLegCost, cost ) | 
|         { | 
|           accountassignment := select( this.Unit(), UnitAccount, ua, | 
|                                        ua.Account_MP() = cost.AccountAssignment().Account_MP() | 
|                                        and ua.CostDriver() = cost.AccountAssignment().CostDriver() ); | 
|          | 
|           if( not isnull( accountassignment ) ) | 
|           { | 
|             LaneLegCost::Create( idholder.GetLaneLegCostID(), | 
|                                  newlaneleg, | 
|                                  accountassignment.Account_MP(), | 
|                                  accountassignment.CostDriver(), | 
|                                  cost.Start(), | 
|                                  cost.TimeUnit(), | 
|                                  cost.LengthOfTime(), | 
|                                  cost.Cost(), | 
|                                  false ); | 
|           } | 
|         } | 
|       } | 
|     } | 
|   *] | 
| } |