yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Quintiq file version 2.0
#parent: #root
Method GetHasConformInputLotSizingRequirement () declarative remote as Boolean
{
  Description: 'Returns true if the (Operation only) DependentDemand quantity is an integer multiple of input lot size'
  TextBody:
  [*
    isvalid := true;
    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 ) );
    
    if( guard( process.HasInputLotSize()
               and pisp.HasInputLotSize()                     // To prevent division by zero
               and period.IsWithinLotSizeHorizon(),       // Only check within the lotsize horizon
               false )
       )  
    {
      gp := this.PeriodTask_MP().MacroPlan().GlobalParameters_MP();
      inputlotsize := pisp.PISPSpecification().InputLotSize();
      remainder := GlobalParameters_MP::GetRemainder( this.Quantity(), inputlotsize );
    
      isvalid := gp.GetIsLotSizeWithinTolerance( inputlotsize, remainder + inputlotsize )
                 or gp.GetIsLotSizeWithinTolerance( inputlotsize, remainder )
                 or gp.GetIsBalanceWithinTolerance( remainder, 0.0 );
    }
    
    return isvalid
  *]
}