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
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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Product_MP owner,
  StockingPoint_MP stockingpoint,
  Account_MP account,
  String costdriver,
  Date start,
  String timeunit,
  Number lengthoftime,
  Real cost,
  AccountCost accountcost,
  Boolean isWeb
) declarative remote as Boolean
{
  Description: 'Check for input obtained from UI'
  TextBody:
  [*
    // soh yee Nov-4-2012 (created)
    feedback_o := '';
    isvalid := true;
    
    // Skip for web app and use uniqueness check in this ValidateInput
    // Web allows changing product and SP from dialog hence declarative relation PISPAccount/PISP not calculated yet
    if( not isWeb )
    {
      isvalid := AccountCost::ValidateInput( feedback_o,
                                             sanitycheckfeedback_o,
                                             account,
                                             costdriver,
                                             start,
                                             timeunit,
                                             lengthoftime,
                                             cost,
                                             accountcost );
    }
    
    // Unlike other costs, since inventory value and costs are edited in real instances
    // The check is done in this validate input, and not in the method
    // DialogCreateEditInventoryValueandCost.GetIsUniqueCost()
    
    if( isvalid )
    {
      isvalid := not exists( owner, 
                             InventoryValueAndCost, 
                             ivc,
                             ivc <> accountcost,
                             ivc.AccountName() = guard( account.Name(), '' )
                             and ivc.CostDriver() = costdriver
                             and ivc.Start() = start 
                             and ivc.StockingPoint_MP() = stockingpoint );
      if( not isvalid )
      {
        if( isWeb ) // Check if used on WC, return specific feedback with newline logic
        {
          if( feedback_o <> '' )
          {
            feedback_o := feedback_o + String::NewLine(); // New line
          }
          
          feedback_o := feedback_o + Translations::MP_AccountCost_Web_IsNotUnique( Translations::MP_AccountCost_Web_InventoryCost() );
        }
        else
        {
          feedback_o := Translations::MP_AccountCost_ValidateInput_IsNotUnique();
        }
      }
    }
    
    if( not isvalid and not isnull( accountcost ) and not isWeb ) // isWeb used to differentiate feedback from WC & TC
    {
      instance := AccountCost::GetInstanceText( accountcost );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}