Wednesday 5 June 2013

FA DEPRECIATION QUERY

FA DEPRECIATION QUERY



Data can come into Oracle Assets via the FA_MASS_ADDITIONS table from the following sources: external sources (i.e. legacy systems), Project Accounting (PA), Accounts Payable (AP) and indirectly from Purchasing (PO).

Once the data is posted in Oracle Assets, it is then considered to be a true asset. If an asset is setup as a capitalized asset, it can be depreciated. When Depreciation has ran successfully and the period has closed, you can then submit the Create Journal Entries program (FAPOST).

The Create Journal Entries program creates the journals for General Ledger (GL) and inserts that data directly into the GL tables, GL_JE_HEADERS, GL_JE_BATCHES, and GL_JE_LINES. Therefore, no journal import from within GL is necessary. If the Create Journals program was successful, the unposted journals can be viewed immediately in GL

SELECT
fp.period_name,
dhcc.segment2 business_unit,
dhcc.segment3 account,
dhcc.segment4 dept,
adt.asset_number,
adt.tag_number,
ltrim(rtrim(cat.segment1)) ||'-'|| ltrim(rtrim(cat.segment2)) ||'-'|| ltrim(rtrim(cat.segment3)) category,
bks.date_placed_in_service acquistion_date,
bks.original_cost,
adt.description,
dh.location_id,
adt.context subject_to_property_tax,
adt.attribute1 property_tax_code,
round(sum(decode(bks.period_counter_fully_retired, '',bks.cost, 0) * dh.units_assigned / ah.units), 2) COST, round(sum(nvl(dn.deprn_amount,0) * dh.units_assigned/ ah.units), 2) deprn,
round(sum(nvl(dn.deprn_reserve,0) * dh.units_assigned/ ah.units), 2) deprn_reserve,
round(sum(nvl(dn.ytd_deprn,0) * dh.units_assigned/ ah.units), 2) YTD_DEP,
round(sum(decode(bks.period_counter_fully_retired, '', (bks.cost - dn.deprn_reserve), 0) * dh.units_assigned/ ah.units), 2) c_nbv
FROM
fa_distribution_history dh,
fa_asset_history ah,
fa_additions adt,
fa_categories_b cat,
fa_books bks,
gl_code_combinations dhcc,
fa_deprn_summary dn,
fa_deprn_periods fp
WHERE
fp.book_type_code = 'XXX'
and dn.book_type_code = 'XXXX'
and dn.period_counter =
( select dp.period_counter from fa_deprn_periods dp where dp.book_type_code = 'XXXX'
and dp.period_counter =
( select max(dpz.period_counter) from fa_deprn_summary dsz, fa_deprn_periods dpz
where dpz.book_type_code = 'XXXX'
and dpz.period_counter <= fp.period_counter
and dsz.book_type_code = 'XXXX'
and dsz.period_counter = dpz.period_counter
and dsz.asset_id = dn.asset_id ))
and bks.book_type_code = 'XXXX'
and bks.asset_id = dn.asset_id
and nvl(bks.date_ineffective,sysdate) > to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
and bks.date_effective < to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
and nvl(bks.period_counter_fully_retired, fp.period_counter) in
( select dpy.period_counter
from fa_deprn_periods dpy
where dpy.book_type_code = 'XXXX'
and dpy.fiscal_year = fp.fiscal_year)
and adt.asset_id = dn.asset_id
and adt.ASSET_CATEGORY_ID = cat.category_id
and adt.asset_id = dh.asset_id
and dh.book_type_code = 'XXXX'
and nvl(dh.date_ineffective,sysdate) > to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
and dh.date_effective < to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY
HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
and dhcc.code_combination_id(+) = dh.code_combination_id
and ah.asset_id = adt.asset_id
and nvl(ah.date_ineffective,sysdate) > to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY
HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
and ah.date_effective < to_date(to_char(nvl(fp.period_close_date, sysdate),'DD-MM-YYYY
HH24:MI:SS'),'DD-MM-YYYY HH24:MI:SS')
GROUP BY
fp.period_name,
dhcc.segment2,
dhcc.segment4,
dhcc.segment3,
adt.asset_number,
adt.tag_number,
ltrim(rtrim(cat.segment1))||'-'||ltrim(rtrim(cat.segment2))||'-'||ltrim(rtrim(cat.segment3)),
adt.description,
bks.date_placed_in_service,
bks.original_cost,
dh.location_id,
adt.context,
adt.attribute1

No comments:

Post a Comment