| Quintiq file version 2.0 | 
| #parent: #root | 
| Method Update ( | 
|   String id, | 
|   String name, | 
|   Unit parent, | 
|   String capacitytype, | 
|   Group group, | 
|   UnitOfMeasure_MP unitofmeasure, | 
|   Currency_MP currency, | 
|   Date startdate, | 
|   Date enddate, | 
|   Duration campaigntypeduration, | 
|   Boolean isplannedinfinite, | 
|   Real minimumquantity, | 
|   Boolean hasmaximumquantity, | 
|   Real maximumquantity, | 
|   Real lotsize, | 
|   String usericonname, | 
|   String quantitytoprocess, | 
|   String giscountrycode, | 
|   String giscity, | 
|   String gispostalcode, | 
|   String notes, | 
|   Boolean hascapacitysmoothing, | 
|   Boolean issmoothcapacityoverallperiods, | 
|   Number usercapacitysmoothinglength, | 
|   Real capacitysmoothingpercentagedelta, | 
|   Boolean isoverlapcapacitysmoothing, | 
|   Boolean isincludedinsupplyspec, | 
|   Boolean issupplier, | 
|   Boolean hasuserfrozenfutureduration, | 
|   Duration userfrozenfutureduration, | 
|   Boolean useshiftoptimization, | 
|   Boolean isfromdb | 
| ) | 
| { | 
|   Description: 'Update unit' | 
|   TextBody: | 
|   [* | 
|     // Update Unit | 
|     oldcapacitytype := this.CapacityType(); | 
|     hasnewparent := this.ParentUnitID() <> guard( parent.ID(), '' ); | 
|     isroot := isnull( parent ); | 
|      | 
|     this.UpdateTypeIndex( id ); | 
|      | 
|     this.UnitOfMeasureName( unitofmeasure.Name() ); | 
|     this.CurrencyID( currency.ID() ); | 
|     this.Name( name ); | 
|     this.CapacityType( capacitytype ); | 
|     this.StartDate( startdate ); | 
|     this.EndDate( enddate ); | 
|     this.CampaignTypeDuration( campaigntypeduration ); | 
|     this.AddToGroup( group ); | 
|      | 
|     this.IsPlannedInfinite( isplannedinfinite ); | 
|     this.MinimumQuantity( minimumquantity ); | 
|     this.HasMaximumQuantity( hasmaximumquantity ); | 
|     this.MaximumQuantity( maximumquantity ); | 
|     this.LotSize( lotsize ); | 
|     this.QuantityToProcess( quantitytoprocess ); | 
|     this.GISCountryCode( giscountrycode ); | 
|     this.GISCity( giscity ) | 
|     this.GISPostalCode( gispostalcode ); | 
|     this.Notes( notes ); | 
|     this.HasCapacitySmoothing( hascapacitysmoothing ); | 
|     this.IsSmoothCapacityOverAllPeriods( issmoothcapacityoverallperiods ); | 
|     this.UserCapacitySmoothingLength( usercapacitysmoothinglength ); | 
|     this.CapacitySmoothingPercentageDelta( capacitysmoothingpercentagedelta ); | 
|     this.IsOverlapCapacitySmoothing( isoverlapcapacitysmoothing ); | 
|     this.IsIncludedInSupplySpecification( isincludedinsupplyspec ); | 
|     this.IsSupplier( issupplier ); | 
|      | 
|     this.HasUserFrozenFutureDuration( hasuserfrozenfutureduration ); | 
|     this.UserFrozenFutureDuration( userfrozenfutureduration ); | 
|      | 
|     this.UseShiftOptimization( useshiftoptimization ); | 
|      | 
|     this.IsManuallyConfigured( not isfromdb ); | 
|      | 
|     this.UpdateIcon( usericonname ); | 
|      | 
|     //Update the parent relations | 
|     if( hasnewparent ) | 
|     { | 
|       this.AssignParent( parent ); | 
|     } | 
|     else if( isroot ) | 
|     { | 
|       this.SetRootUnit(); | 
|     } | 
|      | 
|     // create new unit period | 
|     if( oldcapacitytype <> capacitytype ) | 
|     { | 
|       this.DeleteOldPeriodCapacity(); | 
|       this.CreateUnitPeriods(); | 
|       this.UnitAvailability( relflush ); | 
|       this.UnitCapacity( relflush ); | 
|       this.TransportAvailability( relflush ); | 
|       this.TransportCapacity( relflush ); | 
|        | 
|       // Update unitshiftpatterns if the capacity changes | 
|       timecapacity := GlobalParameters_MP::GetCapacityTypeTime(); | 
|       if( oldcapacitytype = timecapacity ) | 
|       { | 
|         this.UnitShiftPattern( relflush ); | 
|       } | 
|       if( capacitytype = timecapacity ) | 
|       { | 
|         this.CreateUnitShiftPatterns(); | 
|       } | 
|     } | 
|   *] | 
| } |