FORMAT==100
FEEDSTRINGS;
SKIPCHECK;

#******************************************************
# Check if rules apply to this scenario
#******************************************************
#[]=N:
#  IF(ATTRS('Version', !Version, 'Link to Drivers') @= 'Y',
#    CONTINUE,
#    STET
#  );

#******************************************************
# Get figure from GL cube
#******************************************************
['Source Amount']=N:
  DB('GL','Local',!Version,!FiscalYear,'Total Year',DB('AllocationSource',!Version,!FiscalYear,!Region,!AllocationList,'Source Entity'),
  !Region,
  DB('AllocationSource',!Version,!FiscalYear,!Region,!AllocationList,'Source Account'),
  'Total Amount');

#******************************************************
# Apply %
#******************************************************
['Allocation Amount']=N:
  ['Source Amount']*['Pct to Allocate'];

FEEDERS;

#*****************************************************
# Internal Feeders
#*****************************************************
['Source Account'] =>
  ['Source Amount'];

['Pct to Allocate'] =>
  ['Allocation Amount'];

#*****************************************************
# External Feeders - AllocationCalcs
#*****************************************************
['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Allocation Amount');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Exclude Entity');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Driver');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Total Driver');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Ratio');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Allocated Amount');

['Pct to Allocate'] =>
  DB('AllocationCalcs',!Version,!FiscalYear,'Total Year','All Departments',!Region,!AllocationList,'Credit Amount');

#*****************************************************
# External Feeders - GL
#*****************************************************
['Pct to Allocate'] =>
  DB('GL','Local',!Version,!FiscalYear,'Total Year','All Departments',!Region,'9901','Amount');

['Pct to Allocate'] =>
  DB('GL','Local',!Version,!FiscalYear,'Total Year','All Departments',!Region,'9909','Amount');
