Quintiq file version 2.0
|
#parent: #root
|
Method ConvertInventorySpecificationToSafetyStocks
|
{
|
TextBody:
|
[*
|
updates := construct( InventorySpecifications );
|
|
// Always create safety stock regardless if target = 0
|
traverse( this, Product_MP.InventorySpecification, inv )
|
{
|
safetystock := SafetyStock::FindTypeIndexSafetyStock( inv.ProductID(), inv.StockingPointID(), inv.Start() );
|
if( isnull( safetystock) )
|
{
|
product := Product_MP::FindProductTypeIndex( inv.ProductID() );
|
stockingpoint := StockingPoint_MP::FindStockingPointTypeIndex( inv.StockingPointID() );
|
if ( not isnull( product ) and not isnull( stockingpoint ) )
|
{
|
SafetyStock::Create( product,
|
stockingpoint,
|
inv.Start(),
|
inv.HasTargetInDays_DELETED_Nov19(),
|
inv.TargetInDays_DELETED_Nov19(),
|
inv.TargetInQuantity_DELETED_Nov19(),
|
inv.IsCalculated(),
|
not inv.IsCalculated(),
|
not inv.IsManuallyConfigured() );
|
|
updates.Add( inv );
|
}
|
}
|
|
// Delete inventory spec thas has no min and no max levels defined
|
// If max level checked and value 0, respect user decision and don't remove
|
traverse( updates, Elements, in, not in.HasMinLevel() and not in.HasMaxLevel() )
|
{
|
in.Delete();
|
}
|
}
|
*]
|
}
|