chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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 VerifyInventoryLevelEndAndAge (
  ProductInStockingPoint_MP pisp,
  Date startdate,
  Real inventorylevel,
  String age,
  Boolean isproductshelflifeok,
  Boolean isequal
)
{
  Description: 'Verify the inventory level and age of the inventory'
  TextBody:
  [*
    pispip := select(  pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pisipip, pisipip.Start().Date() = startdate );
    
    if( this.Run().AssertNotIsNull( pispip, 'PISPIP for ' + pisp.Name() + " on " + startdate.Format( "D-M-Y" ) + " not found." ) )
    {
      shelflife := pispip.ShelfLife();
      if( this.Run().AssertNotIsNull( shelflife, " Shelf life is null." ) )
      {    
        agestr := this.GetShelflifeInventoryAge( shelflife );
        if ( isequal )
        {
         this.Run().AssertEqual( inventorylevel, pispip.InventoryLevelEnd(), "Inventory level end not match for PISPIP start on " + startdate.Format( "D-M-Y" ) );
        }
        else
        {
         this.Run().AssertLessOrEqual( inventorylevel, pispip.InventoryLevelEnd(), "Inventory level end not match for PISPIP start on " + startdate.Format( "D-M-Y" ) );
        } 
        
        this.Run().AssertEqual( age, agestr, " Age not match for PISPIP start on " +  startdate.Format( "D-M-Y") ); 
        this.Run().AssertEqual( isproductshelflifeok, pispip.IsProductShelfLifeOK(), "PISPIP.IsProductShelfLifeOK not as expected for PISPIP start on " +  startdate.Format( "D-M-Y" ) ); 
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}