Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
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
83
84
85
86
87
Quintiq file version 2.0
#parent: #root
Method GetBaseCost (
  AccountCost accountcost,
  UnitPeriod unitperiod
) remote as Real
{
  Description: 'Returns base cost of a given period - used in designer'
  TextBody:
  [*
    // Returns base cost of a given period - used in designer
    basecost := 0.0;
    if( not isnull( unitperiod ) )
    {
      if( unitperiod.IsPlanning() )
      {
      
        // costs are of type fixed
        if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverFixed() )
        {
          basecost := unitperiod.GetFixedBaseCost( this, accountcost );
        }
        // costs are of type staffing
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverStaffing() )
        {
          basecost := unitperiod.GetStaffingBaseCost( this, accountcost );
        }
        // costs are of type NrOfUnits
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverNrOfUnits() )
        {
          basecost := unitperiod.GetNrOfUnitsBaseCost( this, accountcost );
        }
        // costs are of type volume, which require a bit more work
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverVolume() )
        {
          uaip := select( this, UnitAccountInPeriodForVolume, aip, true, aip.UnitPeriod() = unitperiod );
          if( not isnull( uaip ) )
          {
            basecost := uaip.TotalBaseCost();
          }
        }
        // costs are of type Time, which requires a bit more work
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverTime() )
        {
          uaip := select( this, UnitAccountInPeriodForTime, aip, true, aip.UnitPeriod() = unitperiod );
          if( not isnull( uaip ) )
          {
            basecost := uaip.TotalBaseCost();
          }
        }
        // costs are of type lot, with requires a bit more work
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverLot() )
        { 
          uaip := select( this, UnitAccountInPeriodForLot, aip, true, aip.UnitPeriod() = unitperiod );
          if( not isnull( uaip ) )
          {
            basecost := uaip.TotalBaseCost();
          }
        }
        // costs are of type One time cost, which requires a bit more work
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverOneTime() )
        { 
          uaip := select( this, UnitAccountInPeriodForOneTimeCost, aip, true, aip.UnitPeriod() = unitperiod );
          if( not isnull( uaip ) )
          {
            basecost := uaip.TotalBaseCost();
          }
        }
        else if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverChangeover() )
        {
          uaip := select( this, UnitAccountInPeriodForChangeover, aip, true, aip.UnitPeriod() = unitperiod );
          basecost := uaip.TotalBaseCost();
        }
      }
      else if( unitperiod.IsBase() )  // Base, fraction the value from planning period
      {
        basecost := this.GetBaseCost( accountcost, unitperiod.PlanningUP() ) * unitperiod.PlanningSystemRatio();
      }
      else                            // Non base non planning, retrieve the value of base periods
      {
        basecost := sum( unitperiod.GetChildrenOfPeriodDimension(), Elements, up, this.GetBaseCost( accountcost, up ) )
      }
    }
    
    return basecost;
  *]
}