renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateAccountMessage (
  MacroPlan macroplan
)
{
  Description: 'Create sanity check message for account.'
  TextBody:
  [*
    // Get the limit for the number of sanity check messages
    messagelimit := macroplan.GlobalParameters_MP().SanityCheckLimit();
    
    // Get the set of invalid objects
    invalidobjects := selectset( macroplan, 
                                 SanityCheckGroup.astype( SanityCheckGroupData ).InvalidAccount_MP, 
                                 invalidobject,
                                 true );
    
    objcount := 0;
    // Traverse the set of invalid objects as long as the number of created message is within the limit
    traverse( invalidobjects,
              Elements,
              invalidobject,
              objcount <= messagelimit )
    {
      // Update the number of created messages
      objcount := objcount + 1;
    
      feedbacks := construct( Strings );
      sanitycheckfeedbacks := construct( Strings );
      // Retrieve sanity check messages
      invalidobject.DoSanityCheckData( feedbacks, sanitycheckfeedbacks );
    
      i := 0;
      // Traverse the set of returned feedbacks
      traverse( feedbacks, Elements, fb )
      {
        // Check if there are any existing sanity check message with the same feedback message
        if( not exists( invalidobject, SanityCheckMessageData, msg, msg.Description() = fb ) )
        {
          //tokenize msg to retrieve category level and seperate the actual feedback
          sanitycheckmessage := SanityCheckMessageData::Create( invalidobject.SanityCheckGroupData(), 
                                                                fb, 
                                                                true,
                                                                sanitycheckfeedbacks.Element( i ) );
          sanitycheckmessage.Account_MP( relset, invalidobject );
        }
        i := i + 1;
      }
    }
  *]
}