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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  ScenarioManager owner,
  Boolean hasparent,
  Account parent,
  String name,
  Real budget,
  String costdriver,
  String timeunit,
  Number lengthoftime,
  Real cost,
  Account account
) remote as Boolean
{
  Description: 'Validate input, called from designer'
  TextBody:
  [*
    // Precondition used to validate the input for creating/editing an Account
    feedback_o := '';
    
    // If name is empty
    if( name = '' )
    {
      feedback_o := Translations::MP_Account_ValidateInput_IsNullName();
    }
    // If name is not unique
    else if( exists( owner, KPI, a,
                     account <> a,
                     a.Name() = name ) )
    {
      feedback_o := Translations::MP_Account_ValidateInput_IsNotUnique( name );
    }
    // If budget is infinite/not entered
    else if( budget.IsMinInfinity() or budget.IsMaxInfinity() or budget.IsInfinite() or budget.IsNaN() )
    {
      feedback_o := Translations::MP_Account_ValidateInput_InvalidBudget();
    }
    // To check if this account is assigning to its own child.
    else if( hasparent 
             and not isnull( parent )
             and exists( parent.GetAllParent(), Elements, parentaccount,
                         parentaccount = account ) )
    {
      feedback_o := Translations::MP_Account_ValidateInput_InvalidParent();
    }
    // If cost is infinite/not entered
    else if( cost.IsMinInfinity() or cost.IsMaxInfinity() or cost.IsInfinite() or cost.IsNaN() )
    {
      feedback_o := Translations::MP_Account_ValidateInput_InvalidCost();
    }
    // If the cost driver matches the logic in AccountAssignment::GetTimeUnitVisibility. Currently, it's Time, Fixed, or Number of units
    else if( AccountAssignment::GetTimeUnitVisibility( costdriver ) )
    {
      // If time unit is not entered
      if( timeunit.Length() = 0 )
      {
        feedback_o := Translations::MP_Account_ValidateInput_IsNullTimeUnit();
      }
      // If the entered time unit is less than or equals to zero
      else if( lengthoftime <= 0 )
      {
        feedback_o := Translations::MP_Account_ValidateInput_InvalidLengthOfTime();
      }
    }
    return feedback_o = '';
  *]
}