renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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
Quintiq file version 2.0
#parent: #root
StaticMethod UpdateNonFinancialKPIValueInPeriod (
  KPIValues kpivalues,
  Period_MP period,
  DateTime start,
  DateTime end,
  Scenario scenario
)
{
  Description: 'Update kpi value in period other than account kpis'
  TextBody:
  [*
    // Non financial kpis
    traverse( kpivalues, Elements, kpivalue )
    {
      kpiname := kpivalue.KPI().Name();
    
      // Only create for TargetInventoryLevel, Fulfillment, Volume and PostponedPenalty
      if( kpiname = Translations::MP_GlobalParameters_KPISafetyStock() )
      {
        value := guard( period.TargetInventoryLevelFulfillment() / period.TargetInventoryLevel() * 100, 0 );
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
    
      else if( kpiname = Translations::MP_GlobalParameters_KPIFulfillmentName() )
      {
        value := guard( period.SalesDemandFulfillmentWithExclusion() / period.SalesDemandQuantityWithExclusion() * 100, 0 );
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
    
      else if( kpiname = Translations::MP_GlobalParameters_KPIVolumeName() )
      {
        value := period.SalesDemandFulfillmentWithExclusion();
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
    
      else if( kpiname = Translations::MP_GlobalParameters_KPIPostponementPenaltyName() )
      {
        value := period.PostponedSalesDemandPenalty();
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
      
      // Total expired quantity KPI
      else if( kpiname = Translations::MP_GlobalParameters_KPITotalExpiredQuantity() )
      {
        value := period.TotalExpiredQuantity();
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
      // Number of shelf-life violation KPI
      else if( kpiname = Translations::MP_GlobalParameters_KPINumberOfShelfLifeViolation() )
      {
        value := [Real] period.NumberOfShelfLifeViolations();
        KPIValueInPeriod::Create( kpivalue, start, end, value, kpiname );
      }
    }
  *]
}