Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod UpdateAccountKPIValueInPeriod ( 
 | 
  KPIValues accountkpis, 
 | 
  Period_MP period, 
 | 
  DateTime start, 
 | 
  DateTime end, 
 | 
  Scenario scenario 
 | 
) 
 | 
{ 
 | 
  Description: 'Update the kpi value in period for account kpis' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // soh yee Jul-14-2014 (created) 
 | 
     
 | 
    periods := construct( KPIValueInPeriods ); 
 | 
     
 | 
    // Account KPIs is sorted from non-children to the highest level, such that the arithmetic operation can take places for accounts with children 
 | 
    traverse( accountkpis, Elements, kpivalue ) 
 | 
    { 
 | 
      kpiname := kpivalue.KPI().Name(); 
 | 
      account := select( period, MacroPlan.Account_MP, a, a.Name() = kpiname ); 
 | 
     
 | 
      sales := 0.0; 
 | 
      inventoryholding := 0.0; 
 | 
      fixed := 0.0; 
 | 
      nrofunits := 0.0; 
 | 
      time := 0.0; 
 | 
      volume := 0.0; 
 | 
      staffing := 0.0; 
 | 
     
 | 
      createsales := false; 
 | 
      createinventoryholding := false; 
 | 
      createfixed := false; 
 | 
      createnrofunits := false; 
 | 
      createtime := false; 
 | 
      createvolume := false; 
 | 
      createstaffing := false; 
 | 
     
 | 
     
 | 
      // Accounts without any children. 
 | 
      traverse( account, AccountAssignment, aa, aa.Account_MP().Child( relsize ) = 0 ) 
 | 
      { 
 | 
        costdriver := aa.CostDriver(); 
 | 
     
 | 
        // Sales 
 | 
        if( costdriver = Translations::MP_AccountAssignmentCostDriverSales() ) 
 | 
        { 
 | 
          sales := sales + aa.GetSalesAccountValueInPeriod( period ); 
 | 
           
 | 
          createsales := true; 
 | 
        } 
 | 
     
 | 
        // Inventory holding 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverInventoryHolding() ) 
 | 
        { 
 | 
          inventoryholding := inventoryholding + aa.GetInventoryHoldingAccountValueInPeriod( period ); 
 | 
           
 | 
          createinventoryholding := true; 
 | 
        } 
 | 
     
 | 
        // Fixed 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverFixed() ) 
 | 
        { 
 | 
          fixed := fixed + aa.GetFixedAccountValueInPeriod( period ); 
 | 
     
 | 
          createfixed := true; 
 | 
        } 
 | 
     
 | 
        //Staffing 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverStaffing() ) 
 | 
        { 
 | 
          staffing := staffing + aa.GetStaffingAccountValueInPeriod( period ); 
 | 
                                                 
 | 
          createstaffing := true; 
 | 
        } 
 | 
     
 | 
        // Nr of units 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverNrOfUnits() ) 
 | 
        { 
 | 
          nrofunits := nrofunits + aa.GetNrOfUnitsAccountValueInPeriod( period ); 
 | 
           
 | 
          createnrofunits := true; 
 | 
        } 
 | 
     
 | 
        // Time 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverTime() ) 
 | 
        { 
 | 
          time := time + aa.GetTimeAccountValueInPeriod( period ); 
 | 
           
 | 
          createtime := true; 
 | 
        } 
 | 
     
 | 
        // Volume 
 | 
        else if( costdriver = Translations::MP_AccountAssignmentCostDriverVolume() ) 
 | 
        { 
 | 
          volume := volume + aa.GetVolumeAccountValueInPeriod( period ); 
 | 
                                             
 | 
          createvolume := true; 
 | 
        } 
 | 
      } 
 | 
     // create kpivalue in period for each of account assignment and acount kpis 
 | 
      ScenarioManager::CreateKPIValueInPeriod( createsales, createinventoryholding, createfixed,  
 | 
                                               createstaffing,createnrofunits, createtime,  
 | 
                                               createvolume, kpivalue, start, end,  
 | 
                                               sales, inventoryholding, fixed, staffing,  
 | 
                                               nrofunits, time, volume, account, kpiname, periods );  
 | 
     
 | 
    } 
 | 
     
 | 
    ScenarioManager::UpdateMarginAcount( period, periods, scenario, start, end ); 
 | 
  *] 
 | 
} 
 |