chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Quintiq file version 2.0
#parent: #root
StaticMethod CreateKPIValueInPeriod (
  Boolean createsales,
  Boolean createinventoryholding,
  Boolean createfixed,
  Boolean createstaffing,
  Boolean createnrofunits,
  Boolean createtime,
  Boolean createvolume,
  KPIValue kpivalue,
  DateTime start,
  DateTime end,
  Real sales,
  Real inventoryholding,
  Real fixed,
  Real staffing,
  Real nrofunits,
  Real time,
  Real volume,
  Account_MP account,
  String kpiname,
  output KPIValueInPeriods periods
)
{
  Description: 'Create kpi value in period'
  TextBody:
  [*
    // Check if KPIValueInPeriod for cost driver sales should be created
    if( createsales )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, sales, Translations::MP_AccountAssignmentCostDriverSales() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver inventory holding should be created
    if( createinventoryholding )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, inventoryholding, Translations::MP_AccountAssignmentCostDriverInventoryHolding() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver fixed should be created
    if( createfixed )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, fixed, Translations::MP_AccountAssignmentCostDriverFixed() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver staffing should be created
    if( createstaffing )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, staffing, Translations::MP_AccountAssignmentCostDriverStaffing() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver number of units should be created
    if( createnrofunits )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, nrofunits, Translations::MP_AccountAssignmentCostDriverNrOfUnits() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver time should be created
    if( createtime )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, time, Translations::MP_AccountAssignmentCostDriverTime() );
      periods.Add( kvip );
    }
    // Check if KPIValueInPeriod for cost driver volume should be created
    if( createvolume )
    {
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, volume, Translations::MP_AccountAssignmentCostDriverVolume() );
      periods.Add( kvip );
    }
    // KPIs with children
    if( account.Child( relsize ) > 0 )
    {
      value := sum( periods, Elements, p,
                    p.KPIValue().KPI().astype( Account ).Parent() = kpivalue.KPI().astype( Account ),
                    p.Value() );
    
      kvip := KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      periods.Add( kvip );
    }
  *]
}