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
Quintiq file version 2.0
#parent: #root
StaticMethod Update (
  Accounts accounts,
  Boolean isbatcheditparent,
  Account parent,
  Boolean isbatcheditaccounttype,
  String accounttype,
  Boolean isbatcheditreporttype,
  String reporttype,
  Boolean isbatcheditbudget,
  Real budget,
  Boolean isbatcheditdefaultcost,
  Real defaultcost,
  String defaultcostdriver,
  Number defaultlengthoftime,
  String defaulttimeunit
)
{
  Description: 'Batch update accounts'
  TextBody:
  [*
    // Batch update the selected set of accounts
    traverse( accounts, Elements, account )
    {
      // Set the corresponding parent, account type, report type, and budget according to the batch edit settings
      parent := ifexpr( isbatcheditparent, parent, account.Parent() );
      accounttype := ifexpr( isbatcheditaccounttype, accounttype, account.AccountTypeName() );
      reporttype := ifexpr( isbatcheditreporttype, reporttype, account.ReportType() );
      budget := ifexpr( isbatcheditbudget, budget, account.Budget() );
      
      // If default cost attributes are not selected to be batch edited, 
      if( not isbatcheditdefaultcost )
      {
        defaultcost := account.DefaultCost();
        defaultcostdriver := account.DefaultCostDriver();
        defaultlengthoftime := account.DefaultLengthOfTime();
        defaulttimeunit := account.DefaultTimeUnit();
      }
    
      // Update account's attributes
      account.Update( guard( parent.Name(), '' ), accounttype, reporttype, budget,
                      defaultcost, defaultcostdriver, defaultlengthoftime, defaulttimeunit, account.IsPercentage() );
    }
    
    // This will update all the accounts
    scenariomanager := accounts.Element( 0 ).ScenarioManager();
    if( not isnull( scenariomanager ) )
    {
      scenariomanager.UpdateAccountChanges();
    }
  *]
}