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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Currency_MP owner,
  Date start,
  Real rate,
  CurrencyRate_MP currencyrate
) declarative remote as Boolean
{
  Description: 'Validate input, called from designer'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Currency name
    name := MacroPlan::GetSubstituteName( guard( owner.Name(), '' ) );
    // Get Currency instance
    instance := Translations::MP_CurrencyRate_Instance( name, start );
    
    // Check if rate is valid
    if( rate <= 0 )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_CurrencyRate_ValidateInput_IsInvalidRate( rate ) );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if currency rate with the same start time exists
    else if( exists( owner, CurrencyRate_MP, cr,
                     cr <> currencyrate,
                     cr.Start() = start ) )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_CurrencyRate_ValidateInput_IsRateExists() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if Currency is found
    else if( isnull( owner ) )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_CurrencyRate_ValidateInput_IsNullCurrency() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if Currency is base currency
    else if( owner.IsBase() )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_CurrencyRate_ValidateInput_IsBaseCurrency() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    
    return feedback_o = '';
  *]
}