Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method VerifyDayInvSpecPISPIPInvLevelEnd ( 
 | 
  Product_MP product, 
 | 
  StockingPoint_MP stockingPoint, 
 | 
  DateTime start, 
 | 
  DateTime end, 
 | 
  Number numberOfPeriods 
 | 
) 
 | 
{ 
 | 
  Description: 'Verify PISPIP inventory level end (days ) in range of periods  is adhered to respective inventory specification configuration.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Verify Min Max inventory level calculation 
 | 
    /* 
 | 
    For the months when min/max inventory level are defined in days, the value is converted from days to quantity. ( days * Demand of the next month / Nr of days in the next month ) 
 | 
    */ 
 | 
    // Setup pispips 
 | 
    pisp := product.FindProductInStockingPoint( stockingPoint.ID() ); 
 | 
    pispips := selectset( pisp, ProductInStockingPointInPeriodPlanning, p, p.Start() >= start and p.Start() < end ); 
 | 
     
 | 
    // Check if all pispips have adhere to settings in UTF 
 | 
    this.Run().AssertEqual( numberOfPeriods, pispips.Size() ); 
 | 
    this.Run().AssertTrue( forallexists( pispips, Elements.InventorySpecification, invSpec, true, invSpec.HasMinLevelInDays() and invSpec.HasMaxLevelInDays() ) ); 
 | 
     
 | 
    // Traverse to check stock level in days 
 | 
    traverse( pispips, Elements, pispip ) 
 | 
    { 
 | 
      inventorySpec := pispip.InventorySpecification(); 
 | 
      minInv := inventorySpec.MinLevelInDays(); 
 | 
      maxInv := inventorySpec.MaxLevelInDays(); 
 | 
       
 | 
      expectedInventoryLevelEndInDaysIsWithin := pispip.StockLevelInDays() >= minInv and pispip.StockLevelInDays() <= maxInv 
 | 
      this.Run().AssertTrue( expectedInventoryLevelEndInDaysIsWithin, 
 | 
                             'Verify ' + pisp.Name() + ' by ' + [String] pispip.Start().Date() 
 | 
                                       + ' has inventory level end of [' + [String]pispip.StockLevelInDays() 
 | 
                                       + ' days] within min [' + [String]minInv + ' days] and max [' + [String]maxInv + ' days]' ); 
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |