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
51
52
53
54
55
56
57
Quintiq file version 2.0
#parent: #root
StaticMethod GetUoMText (
  Number lengthOfTime,
  String timeUnit,
  String currencyId,
  String uom,
  String costDriver
) declarative remote as String
{
  Description: 'Set account UoM according to different cost driver'
  TextBody:
  [*
    // Omit length of time if equal 1, as we will use later for displaying e.g. uom / month, uom / 2 month
    length := ifexpr( lengthOfTime >= 2, lengthOfTime.AsQUILL() + ' ', '' );
    period := length + timeUnit;
    currency := currencyId;
    costDriver := costDriver.TrimBoth();
    
    // Default text
    text := currency;
    
    // Cost drivers where the '(Currency per UoM)' does not need to be added to the label
    displayCostOnly := costDriver = Translations::MP_AccountAssignmentCostDriverOneTime()
                       or costDriver = Translations::MP_AccountAssignmentCostDriverInvestment();
    
    if( not displayCostOnly )
    {
      if(costDriver = Translations::MP_AccountAssignmentCostDriverStaffing() )
      {
        uom := Translations::MP_GlobalParameters_Hour();
      }
      else if( costDriver = Translations::MP_AccountAssignmentCostDriverLot() )
      {
        uom := Translations::MP_AccountAssignmentCostDriverLot();
      }
      else if ( costDriver = Translations::MP_AccountAssignmentCostDriverChangeover() ) 
      {
        uom := Translations::MP_AccountAssignmentCostDriverChangeover();
      }
    
      if( AccountAssignment::GetTimeUnitVisibility( costDriver ) )
      {
        text := currency + '/' + period
      }
      else if( costDriver = Translations::MP_AccountAssignmentCostDriverInventoryHolding() )
      {
        text := currency + '/' + '(' + uom + '*' + Translations::MP_GlobalParameters_Year() + ')';
      }
      else 
      {
        text := currency + '/' + uom;
      }
    }
    return text;
  *]
}