Quintiq file version 2.0
|
#parent: #root
|
Method MPSyncTransportCapacity (
|
Boolean isoverwritemanualconfig,
|
IOTransportCapacitys iotransportcapacitys
|
)
|
{
|
Description: 'Synchronization of TransportCapacity for MPSync'
|
TextBody:
|
[*
|
// Select a set of existing TransportCapacity
|
existing := selectset( this, Unit.TransportCapacity, item, true );
|
updates := construct( TransportCapacitys );
|
|
// Traverse the new set of valid TransportCapacity
|
traverse( iotransportcapacitys , Elements, io, io.IsValid() )
|
{
|
// Find existing TransportCapacity
|
objectinstance := TransportCapacity::FindTransportCapacityTypeIndex( io.UnitID(), io.Start().DateTime() );
|
// Find existing Unit
|
unit := Unit::FindUnitTypeIndex( io.UnitID() );
|
|
// Check if there's valid Unit
|
if( not isnull( unit ) )
|
{
|
// If no existing TransportCapacity is found, create one
|
if( isnull( objectinstance ) )
|
{
|
objectinstance := TransportCapacity::Create( unit,
|
io.Start().DateTime(),
|
io.TimeUnit(),
|
io.MinimumCapacity(),
|
io.MaximumCapacity(),
|
io.LotSize(),
|
io.HasSecondaryCapacity(),
|
io.SecondaryLotSize(),
|
io.SecondaryMaximumCapacity(),
|
io.SecondaryMinimumCapacity(),
|
io.SecondaryUnitOfMeasureName(),
|
true );
|
}
|
// Else if the TransportCapacity is not manually configured or the imported instance should overwrite manual configuration,
|
// update the existing TransportCapacity
|
else if( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig )
|
{
|
// Update TransportCapacity
|
objectinstance.Update( unit,
|
io.Start().DateTime(),
|
io.TimeUnit(),
|
io.MinimumCapacity(),
|
io.MaximumCapacity(),
|
io.LotSize(),
|
io.HasSecondaryCapacity(),
|
io.SecondaryLotSize(),
|
io.SecondaryMaximumCapacity(),
|
io.SecondaryMinimumCapacity(),
|
io.SecondaryUnitOfMeasureName(),
|
true );
|
updates.Add( objectinstance );
|
}
|
|
if( not isnull( objectinstance ) )
|
{
|
objectinstance.CustomUpdate( io, isoverwritemanualconfig );
|
}
|
}
|
}
|
|
// Get the set of old TransportCapacity to be deleted
|
tobedeleteset := existing.Difference( updates );
|
|
// Traverse the set of TransportCapacity to be deleted
|
// Only delete TransportCapacity that is not manually configured or the imported instance should overwrite manual configuration
|
traverse( tobedeleteset, Elements, ele,
|
not ele.IsManuallyConfigured() or isoverwritemanualconfig )
|
{
|
ele.Delete();
|
}
|
*]
|
}
|