| 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
 | | Quintiq file version 2.0 |  | #parent: #root |  | Method UpdateKPIValue ( |  |   MacroPlan macroplan, |  |   Boolean issmartplan |  | ) as Boolean |  | { |  |   Description: |  |   [* |  |     Update value of kpi |  |     Called by job JobUpdateDefaultStrategyValue |  |   *] |  |   TextBody: |  |   [* |  |     isupdated := false; |  |     scenario := select( this, ScenarioMP, s, |  |                         not s.IsDeleted(), |  |                         s.DatasetMDSID() = macroplan.MDSID() ); |  |      |  |     if( not isnull( scenario ) ) |  |     { |  |       this.UpdateUnitOfMeasurement( macroplan, scenario ); |  |        |  |       //smartplanstart := guard ( lastalgorithmrun.FirstPeriodInOptimizerRun().Start(), macroplan.Start() ); |  |        |  |       traverse( scenario, KPIValue, kpivalue ) |  |       {  |  |         if( not issmartplan ) |  |         { |  |           kpivalue.DeleteKPIValueInPeriod();      // Delete all kpi value in periods |  |         } |  |         else |  |         { |  |           kpivalueinperiod := selectset ( kpivalue, KPIValueInPeriod, p, p.End() >= macroplan.SmartPlanStartForUpdateKPI() ); |  |           MacroPlan::DeleteObjects( kpivalueinperiod ); |  |         } |  |          |  |         ScenarioManager::UpdateKPITotalValue( kpivalue, macroplan );                  // Get kpi total value |  |       } |  |      |  |       // Sort account kpis decendingly such that the higher level account with children can get the value from its children |  |       accountkpis := selectsortedset( scenario, KPIValue, kpivalue, kpivalue.KPI().IsAccount(), -kpivalue.KPI().astype( Account ).Level() ); |  |       otherkpis := selectset( scenario, KPIValue, kpivalue, not kpivalue.KPI().IsAccount() ); |  |      |  |       // Update kpi value per period         |  |       |  |        |  |       traverse( macroplan,  |  |                 PeriodKPI,  |  |                 period,  |  |                 not issmartplan  |  |                 or period.End() >= macroplan.SmartPlanStartForUpdateKPI() ) |  |       { |  |         start := period.Start(); |  |         end := period.End(); |  |         ScenarioManager::UpdateAccountKPIValueInPeriod( accountkpis, period, start, end, scenario ); |  |         ScenarioManager::UpdateNonFinancialKPIValueInPeriod( otherkpis, period, start, end, scenario ); |  |       } |  |     } |  |     isupdated := true; |  |     //to be used for chain in reactive quill code |  |     return isupdated; |  |   *] |  | } | 
 |