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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Account_MP account,
  String costdriver,
  Date start,
  String timeunit,
  Number lengthoftime,
  Real cost,
  AccountCost accountcost
) declarative remote as Boolean
{
  Description: '(TC) Check for input obtained from UI'
  TextBody:
  [*
    // Precondition used to validate input when creating/editing account cost
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // If no account is selected
    if( isnull( account ) )
    {
      feedback_o := Translations::MP_AccountCost_ValidateInput_IsNullAccount();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the account cost can be created
    else if( AccountAssignment::GetTimeUnitVisibility( costdriver ) and lengthoftime <= 0 )
    {
      feedback_o := Translations::MP_AccountCost_ValidateInput_InvalidLengthOfTime( lengthoftime );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // If cost is less than zero
    else if( cost < 0 )
    {
      feedback_o := Translations::MP_AccountCost_ViolateHasValidCost( cost );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // If an account cost is being editted
    else if( not isnull( accountcost ) )
    {
      // Check if the account cost is unique in combination of account name, cost driver, and start date
      accountcost.GetIsUniqueCost( feedback_o, account.Name(), costdriver, start, null( AccountCosts ) )
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    
    return feedback_o = '';
  *]
}