Quintiq file version 2.0
|
#parent: #root
|
Method ShelfLifeExtendHistoricalPeriods (
|
Boolean restore,
|
owning ProductInStockingPoint_MPs pisps
|
)
|
{
|
TextBody:
|
[*
|
this.MacroPlan().IsPeriodUpdateForShelfLife( true ); // limit how much PlanningSpecification.Update will do
|
if ( isnull( pisps ) )
|
{
|
pisps := selectset( this, MacroPlan.Product_MP.ProductInStockingPoint_MP, pisp, true, pisp.IsOptMaturation() or pisp.IsOptShelfLife() );
|
}
|
|
if ( pisps.Size() > 0 )
|
{
|
maxshelflifematuration := maxvalue( max( this, MacroPlan.Product_MP, p, p.HasShelfLife(), p.ShelfLife() ),
|
max( this, MacroPlan.Product_MP, p, p.HasMaturation(), p.MaturationDays() ) );
|
periodspecs := selectset( this, MacroPlan.PeriodSpecification_MP, pspec, true, pspec.IsUsedForPlanning() );
|
|
planningspec := minselect( periodspecs,
|
Elements,
|
p,
|
true,
|
guard(p.FirstInPeriodSpecification().DurationInDays(), Real::MaxReal() ) ) ;
|
|
|
|
if ( not isnull( planningspec ) )
|
{
|
firstperiodinrun := min( planningspec, Period_MP, p, true, p.Start() );
|
offsetdays := [Number] ( firstperiodinrun - this.MacroPlan().StartOfPlanning() ).DaysAsReal();
|
perioddurationdays := min( planningspec, Period_MP, p, not p.IsGapPlanning(), p.DurationInDays() ); // ignore gap planning period to avoid an over-estimate
|
neededperiodhistory := ifexpr( restore, planningspec.OptimizerShelfLifePreviousHistoricalPeriods(), ceil( maxvalue( 0, maxshelflifematuration - offsetdays) / perioddurationdays ) );
|
|
if ( neededperiodhistory > planningspec.NrOfHistoricalPeriod() or restore )
|
{
|
debuginfo( 'Changing period', planningspec.ID(), planningspec.NrOfHistoricalPeriod(), '->', neededperiodhistory );
|
planningspec.Update( planningspec.ID(),
|
planningspec.TimeUnit(),
|
planningspec.NrOfTimeUnit(),
|
planningspec.PeriodAlignment(),
|
neededperiodhistory,
|
planningspec.NrOfFuturePeriod(),
|
true, // sync
|
planningspec.IsManuallyConfigured(),
|
planningspec.IsUsedForPlanning(),
|
false // is cleanup actuals
|
)
|
}
|
else
|
{
|
debuginfo( 'nr of historical periods for shelf life optimizer - not changing' );
|
}
|
}
|
}
|
|
this.MacroPlan().IsPeriodUpdateForShelfLife( false ); // limit how much PlanningSpecification.Update will do
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|