Quintiq file version 2.0
#parent: #root
Method CreateShadowAcountAssignmentInPeriodForScenarioAnalysis () id:Method_FormScenarioAnalysisCosts_CreateShadowAcountAssignmentInPeriodForScenarioAnalysis
{
  #keys: '[138546.0.808325227]'
  Body:
  [*
    // Generate account cost in period shadow instances
    account := DataHolderScenarioAnalysisAccount.Data();
    
    owner := shadow( MacroPlan.GlobalParameters_MP() );
    
    // Clean up data
    owner.AccountAssignmentInPeriod( relflush );
    
    if( not isnull( account ) )
    { 
      // Assign data to DataHolderGlobalParameter
      activePeriods := DataHolderPeriods.Data();
      
      //create AAiP of different types
      // TODO QY, need to use DataHolders as sources instead of MacroPlan
      // once R&D has fixed dataholders
      uas := selectset( DataHolderUnit.Data(), Elements.UnitAccount, ua, ua.Account_MP() = account  );
      ApplicationMacroPlanner.CreateShadowAcountAssignmentInPeriodForUnitAccount( owner, uas, activePeriods );
      
      spas := selectset( DataHolderStockingPoint.Data(), Elements.StockingPointAccount, spa, spa.Account_MP() = account );
      ApplicationMacroPlanner.CreateShadowAcountAssignmentInPeriodForStockingPointAccount ( owner, spas, activePeriods );            
      
      pispas := selectset( DataHolderPISP.Data(), Elements.PISPAccount, pispa, pispa.Account_MP() = account ); 
      ApplicationMacroPlanner.CreateShadowAcountAssignmentInPeriodForPISPAccount( owner, pispas, activePeriods );
    }
    
    DataHolderScenarioAnalysisGlobalParameters.Data( &owner );
  *]
}
