Kevin Kok Khah Whey
2023-09-25 34d29be6a3eb0c025da50b77f2107c4ad259c6c0
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
Quintiq file version 2.0
#parent: #root
Method OnCostDriverChanged (
  String costdriver
) id:Method_DialogCreateEditAccountStructure_OnCostDriverChanged
{
  #keys: '[139394.0.458440668]'
  Body:
  [*
    // On cost driver changed
    feedback := '';
    iscostvisible := Account::CanCreateCost( feedback, costdriver );    // Label cost is only visible for certain cost drivers
    
    if( not iscostvisible )
    {
      EditFieldCost.Text( '0' ); // Reset cost edit field
    }
    EditFieldCost.Visible( iscostvisible );
    istimeunitvisible := iscostvisible and AccountAssignment::GetTimeUnitVisibility( costdriver );  // Time unit is only visible for certain cost drivers
    DropDownStringListTimeUnit.Visible( istimeunitvisible );
    EditFieldLengthOfTime.Visible( istimeunitvisible );
    
    // Reset dropdownlist if not related to time, preselect first element when related to time
    if( not istimeunitvisible )
    {
      DropDownStringListTimeUnit.Text( '*' );
      EditFieldLengthOfTime.Text( '1' );
    }
    else
    {
      defaultTimeUnit := DataHolderDialogData.Data().DefaultTimeUnit();
      // Set to first available time unit when no time-unit is found
      if( defaultTimeUnit = '*' )
      {
        DropDownStringListTimeUnit.SetSelectedElement( 0 );
      }
      else if( defaultTimeUnit <> '' )
      {
        DropDownStringListTimeUnit.SetSelectedElementFromString( defaultTimeUnit );
      }
    }
  *]
}