admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method VerifyQuantityInvSpecPISPIPInvLevelEnd (
  Product_MP product,
  StockingPoint_MP stockingPoint,
  DateTime start,
  DateTime end,
  Number numberOfPeriods
)
{
  Description: 'Verify PISPIP in range of periods inventory level end amount is adhered to respective inventory specification configuration.'
  TextBody:
  [*
    // Verify Min Max inventory level calculation
    /*
    For the months when min inventory level is defined in quantity, the value is the same as what's defined in inventory specifications.
    */
    pisp := product.FindProductInStockingPoint( stockingPoint.ID() );
    pispips := selectset( pisp, ProductInStockingPointInPeriodPlanning, p, p.Start() >= start and p.Start() < end );
    uom := pisp.UnitOfMeasureName();
    
    // Verify number of periods is correct
    this.Run().AssertEqual( numberOfPeriods, pispips.Size() )
    traverse( pispips, Elements, pispip )
    {
      
      minInv := pispip.InventorySpecification().MinLevelInQuantity();
      maxInv := pispip.InventorySpecification().MaxLevelInQuantity();
      expectedInvLevelEndIsWithin := minInv <= pispip.InventoryLevelEnd() and pispip.InventoryLevelEnd() <= maxInv
      
      this.Run().AssertTrue( expectedInvLevelEndIsWithin,
                             'Verify ' + pisp.Name() + ' by ' + [String] pispip.Start() 
                                       + ' has inventory level end of [' + [String]pispip.InventoryLevelEnd().Round( 2 ) + ' ' + uom
                                       + ' ] within min [' + [String]minInv + ' ' + uom + '] and max [' + [String]maxInv + ' ' + uom + ' ]' );
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}