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
31
32
33
34
35
36
37
38
39
40
41
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' }
}