| Quintiq file version 2.0 | 
| #parent: #root | 
| Function CalcLotSizeViolationContinuous | 
| { | 
|   TextBody: | 
|   [* | 
|     process := this.PeriodTask_MP().Process_MP(); | 
|     pisp := guard( this.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP(), null( ProductInStockingPoint_MP ) ); | 
|     period := guard( this.PeriodTask_MP().UnitPeriod().Period_MP(), null( Period_MP ) ); | 
|      | 
|     value := 0.0;  | 
|     if( guard( process.HasInputLotSize() | 
|                and pisp.HasInputLotSize()                     // To prevent division by zero | 
|                and period.IsWithinLotSizeHorizon(),       // Only check within the lotsize horizon | 
|                false ) | 
|        )   | 
|     { | 
|       quantitytotal := sum( this, ProductInStockingPointInPeriodPlanningLeaf.DependentDemand, dd, dd.ProcessInput() = this.ProcessInput(), dd.Quantity() );  | 
|        | 
|       // calculate distance to the nearest lot.  | 
|       lotsize := pisp.PISPSpecification().InputLotSize();  | 
|       requiredlot := Util::Ceil( quantitytotal /  lotsize );  | 
|       load := lotsize * requiredlot;  | 
|       diff1 := load - quantitytotal;  | 
|       diff2 := abs(  ( load - lotsize ) - quantitytotal );  | 
|       value := minvalue(  diff1, diff2 );  | 
|        | 
|       value := value * this.PeriodTask_MP().UnitPeriod().Unit().DefaultUOMConversionFactor() | 
|     } | 
|     this.LotSizeViolationContinuous( value ); | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |