FORMAT==100
SKIPCHECK;

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

#******************************************************
#
#******************************************************
['Local', 'Asset Name']=S:
  IF(ATTRS('AssetType', !AssetType, 'Description') @= DB('AssetNewInput',!Version,!Region,!Department,!Item,'Asset Type')
  & DIMIX('SL_Time', ATTRS('SL_Time', !SL_Time, 'Description'))
  >= DIMIX('SL_Time', DB('AssetNewInput',!Version,!Region,!Department,!Item,'Purchase Month')),
    DB('AssetNewInput',!Version,!Region,!Department,!Item,'Asset Name'),
    STET
  );


#******************************************************
#
#******************************************************
['Local','Acquisition $']=N:
  IF(ATTRS('AssetType', !AssetType, 'Description') @= DB('AssetNewInput',!Version,!Region,!Department,!Item,'Asset Type')
  & ATTRS('SL_Time', !SL_Time, 'Description') @= DB('AssetNewInput',!Version,!Region,!Department,!Item,'Purchase Month'),
    DB('AssetNewInput',!Version,!Region,!Department,!Item,'Acquisition $'),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Life in Years']=N:
  IF(['Acquisition $'] <> 0,
    IF(DB('AssetNewInput',!Version,!Region,!Department,!Item,'Life In Years Override') <> 0,
      DB('AssetNewInput',!Version,!Region,!Department,!Item,'Life In Years Override'),
      DB('AssetNewInput',!Version,!Region,!Department,!Item,'Life In Years')
    ),
    CONTINUE
  );

#******************************************************
#
#******************************************************
['Local','Life in Years']=N:
  IF(DIMIX('SL_Time', ATTRS('SL_Time', !SL_Time, 'Description'))
  >= DIMIX('SL_Time', DB('AssetNewInput',!Version,!Region,!Department,!Item,'Purchase Month')),
    DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Life In Years'),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Months Remaining']=N:
  IF(['Acquisition $'] <> 0,
    ['Life in Years'] * 12,
    IF(DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Months Remaining') >= 1,
      DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Months Remaining') - 1,
      STET
    )
  );

#******************************************************
#
#******************************************************
['Local','<Cum Amount>']=N:
  IF(['Acquisition $'] <> 0,
    ['Acquisition $'],
    CONTINUE
  );

#******************************************************
#
#******************************************************
['Local','<Cum Amount>']=N:
  IF(['Months Remaining'] <> 0,
    IF(DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures) <> 0,
      DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures),
      STET
    ),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Cash Paid']=N:
  IF(['Months Remaining'] <> 0,
    ['<Cum Amount>']*['Cash Impact'],
    STET
  );

#******************************************************
#
#******************************************************
['Local','Jul 2005','Opening Liab']=N: 0;

#******************************************************
#
#******************************************************
['Local','Opening Liab']=N:
  IF(DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Acquisition $') <> 0,
    DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'<Cum Amount>')
    - DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Cash Paid'),
    CONTINUE
  );

#******************************************************
#
#******************************************************
['Local','Opening Liab']=N:
  IF(['Months Remaining'] <> 0,
    DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Opening Liab')
    - DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Cash Paid'),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Closing Liab']=N:
  IF(['Acquisition $'] <> 0,
    ['<Cum Amount>']-['Cash Paid'],
    CONTINUE
  );

#******************************************************
#
#******************************************************
['Local','Closing Liab']=N:
  IF(['Months Remaining'] <> 0,
    ['Opening Liab'] - ['Cash Paid'],
     STET
  );

#******************************************************
#
#******************************************************
['Local','Jul 2005', 'Mvmnt Liab']=N:
  ['Closing WDV'];

#******************************************************
#
#******************************************************
['Local','Mvmnt Liab']=N:
  IF(['Months Remaining'] <> 0,
    ['Closing Liab'] -
    DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Closing Liab'),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Opening WDV']=N:
  IF(['Months Remaining'] <> 0,
    DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Closing WDV'),
    STET
  );

#******************************************************
#
#******************************************************
['Local','Depreciation']=N:
  IF(['Months Remaining'] <> 0,
   (['<Cum Amount>']\['Life In Years'])\12,
    STET
  );

#******************************************************
#
#******************************************************
['Local','Closing WDV']=N:
  IF(['Acquisition $'] <> 0,
    ['<Cum Amount>']-['Depreciation'],
    IF(['Months Remaining'] <> 0,
      DB('AssetNewSummary',!Currency,!Version,DIMNM('SL_Time', DIMIX('SL_Time', !SL_Time) - 1),!Region,!Department,!Item,!AssetType,'Closing WDV')
      -['Depreciation'],
      STET
    )
  );

FEEDERS;


['Local', 'Asset Name']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Life in Years']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Months Remaining']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Acquisition $']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', '<Cum Amount>']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Cash Paid']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Opening Liab']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Closing Liab']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Mvmnt Liab']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Opening WDV']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Depreciation']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);
['Local', 'Closing WDV']=>
  DB('AssetNewSummary',!Currency,!Version,DNEXT('SL_Time', !SL_Time),!Region,!Department,!Item,!AssetType,!AssetNewSummaryMeasures);

