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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan macroplan,
  Product_MP product,
  StockingPoint_MP stockingpoint,
  Real inventoryquantity,
  Date date,
  Date manufactureddate
) declarative remote as Boolean
{
  Description: 'Check for input obtained from UI and methods'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Populate variable
    gp := macroplan.GlobalParameters_MP();
    min_mfgdate := InventorySupply::GetMinimumManufacturedDate( product, macroplan, date );
    pispspec := select(  product, 
                         PISPSpecification, spec, 
                         spec.StockingPoint_MP() = stockingpoint );
    
    hasshelflife := product.HasShelfLife()
                    and guard( not pispspec.IsExcludeShelfLifeAndMaturation(), true );
                    
    hasshelflifeormaturation := product.HasShelfLifeOrMaturation()
                    and guard( not pispspec.IsExcludeShelfLifeAndMaturation(), true );     
                      
    // Check if product is null
    if( isnull( product ) )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsNullProduct();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if stocking point is null
    else if( isnull( stockingpoint ) )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsNullStockingPoint();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if date is valid
    else if( not ( date >= stockingpoint.Start()
                   and date <= stockingpoint.End() ) )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsInvalidDate( date,
                                                                                  stockingpoint.Start(),
                                                                                  stockingpoint.End() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the entered manufactured date will result in product expiry in pispip
    else if( hasshelflife
             and manufactureddate < min_mfgdate )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsExpiredManufacturedDate( min_mfgdate );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if product has shelf-life or maturation, and is manufactured in the future
    else if( hasshelflifeormaturation
             and manufactureddate > date )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsFutureManufacturedDate( manufactureddate, date );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if inventory quantity is entered
    else if( inventoryquantity = Real::MinReal() )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_IsEmpty();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if inventory quantity is valid
    else if( inventoryquantity <> 0
             and not GlobalParameters_MP::GetIsValueWithinRange( inventoryquantity,
                                                                 gp.AbsoluteUpperLimit(),
                                                                 gp.AbsoluteLowerLimit() ) )
    {
      feedback_o := Translations::MP_InventorySupply_ValidateInput_InvalidQuantity( inventoryquantity, gp.AbsoluteLowerLimit(), gp.AbsoluteUpperLimit() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    
    // Add feedback text if any of the precondition above is violated
    if( feedback_o <> '' )
    {
      instance := InventorySupply::GetInstanceText( product, stockingpoint, date );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}