|
|

楼主 |
发表于 2011/12/12 17:15:26
|
显示全部楼层
select QQ.ASSET_NUMBER 资产编号
,QQ.TAG_NUMBER 标签号
,QQ.DESCRIPTION 资产名称
,QQ.MODEL_NUMBER 资产规格
,QQ.ATTRIBUTE_CATEGORY_CODE 资产类别
,QQ.Department_Number 部门编号
,QQ.Department_Name 部门名称
,QQ.BG_NUM 保管人编号
,QQ.BG_Name 保管人名称
,QQ.supplier_num 供应商编号
,QQ.supplier_name 供应商名称
,QQ.CURRENT_UNITS 数量
,QQ.life_in_months 耐用月数
,QQ.SUR_MONTHS 未摊月数
,QQ.USE_MONTHS 已使用月数
,QQ.date_placed_in_service 启用日期
,QQ.xz_date 销帐日期
,'CNY' 币种
,QQ.original_cost 原始成本
,QQ.cost 当前成本
,QQ.cost-QQ.deprn_reserve 资产净值
,QQ.salvage_value 资产残值
,QQ.deprn_method_code 折旧方法
,QQ.prorate_date 摊销日期
,QQ.deprn_reserve 累计折旧
,QQ.DEPRN_AMOUNT 当月折旧
,QQ.ytd_deprn 本年折旧
,QQ.DEPRN_RESERVE_ACCT_FLEX 累计折旧科目
,QQ.COST_ACCT_FLEX 资产科目
,QQ.DEPRN_EXPENSE_ACCT_FLEX 折旧科目
,QQ.receipt_num 接收单号
,QQ.invoice_number 发票编号
,QQ.batch_name 发票批名
,qq.value_num "凭证编号(应付)"
from(select fbv.book_type_code --资产账簿
,fav.ASSET_NUMBER --资产编号
,fav.TAG_NUMBER
,fav.DESCRIPTION
,fav.MODEL_NUMBER
,fav.ATTRIBUTE_CATEGORY_CODE
,fbv.date_placed_in_service
,fbv.deprn_method_code
,fav.CURRENT_UNITS
,fbv.prorate_date
,fbv.life_in_months --耐用月数
,fbv.life_in_months-decode(round(fbv.life_in_months- Months_between(sysdate,to_date(fbv.prorate_date) ),0)+
abs(round(fbv.life_in_months- Months_between(sysdate,to_date(fbv.prorate_date) ),0)),0,0,
round(fbv.life_in_months- Months_between(sysdate,to_date(fbv.prorate_date) ),0))USE_MONTHS --已使用月数
,(case when (fbv.life_in_months -
months_between(trunc(SYSDATE, 'month'),
(fbv.prorate_date)) ) < 0
then
0
else
(fbv.life_in_months -
months_between(trunc(SYSDATE, 'month'),
(fbv.prorate_date)))
end)SUR_MONTHS --剩余寿命(月)
,(fbv.life_in_months/12*365) + (fbv.prorate_date)xz_date --销帐日期
,(select ffv.FLEX_VALUE_MEANING
from fa_distribution_history fdh,
gl_code_combinations gcc,
fnd_flex_values_vl ffv
where fdh.asset_id(+) = fbv.asset_id
and fdh.code_combination_id = gcc.code_combination_id
and gcc.segment2 = ffv.FLEX_VALUE
and ffv.FLEX_VALUE_SET_ID = '1014569'
and fdh.date_ineffective is null)Department_Number
,(select ffv.DESCRIPTION
from fa_distribution_history fdh,
gl_code_combinations gcc,
fnd_flex_values_vl ffv
where fdh.asset_id(+) = fbv.asset_id
and fdh.code_combination_id = gcc.code_combination_id
and gcc.segment2 = ffv.FLEX_VALUE
and ffv.FLEX_VALUE_SET_ID = '1014569'
and fdh.date_ineffective is null)Department_name
,fbv.original_cost
,fbv.cost
,fbv.salvage_value
,(select fds.deprn_reserve
from fa_deprn_summary fds
where fds.asset_id(+) = fbv.asset_id
and fds.book_type_code = fbv.book_type_code
and fds.period_counter = (select max(fff.period_counter)
from fa_deprn_summary fff
where fff.asset_id(+) = fbv.asset_id
and fff.book_type_code = fbv.book_type_code))deprn_reserve --累计折旧
,nvl((select sum(fds.deprn_amount) From fa_deprn_summary fds,fa_deprn_periods fdp
where fds.period_counter=fdp.period_counter
and fds.book_type_code=fdp.book_type_code
and fbv.asset_id=fds.asset_id
and fbv.book_type_code=fds.book_type_code
and fdp.PERIOD_COUNTER=(select fp.period_counter from fa_deprn_periods fp
where 1=1
and fp.FISCAL_YEAR||'-'||DECODE(LENGTH(fp.PERIOD_NUM), 1, 0 || fp.PERIOD_NUM, 2, fp.PERIOD_NUM)='2011-08')),0)DEPRN_AMOUNT --当月折旧
,(select fds.ytd_deprn
from fa_deprn_summary fds
where fds.asset_id(+) = fbv.asset_id
and fds.book_type_code = fbv.book_type_code
and fds.period_counter = (select max(fff.period_counter)
from fa_deprn_summary fff
where fff.asset_id(+) = fbv.asset_id
and fff.book_type_code = fbv.book_type_code))ytd_deprn --本年折旧
,(select pap.employee_number
from per_all_people_f pap,
fa_distribution_history fdh
where (pap.effective_end_date > sysdate or pap.effective_end_date is null)
and fdh.asset_id(+) = fbv.asset_id
and fdh.date_ineffective is null
and fdh.assigned_to = pap.person_id)BG_NUM --保管人编号
,(select pap.last_name
from per_all_people_f pap,
fa_distribution_history fdh
where (pap.effective_end_date > sysdate or pap.effective_end_date is null)
and fdh.asset_id(+) = fbv.asset_id
and fdh.date_ineffective is null
and fdh.assigned_to = pap.person_id) BG_Name --保管人名称
,(select distinct pv.SEGMENT1
from fa_asset_invoices fai
,po_vendors pv
where fai.po_vendor_id=pv.VENDOR_ID
and fai.date_ineffective is null
and fav.ASSET_ID=fai.asset_id
and fai.deleted_flag = 'NO') supplier_num --供应商编号
,(select distinct pv.VENDOR_NAME
from fa_asset_invoices fai
,po_vendors pv
where fai.po_vendor_id=pv.VENDOR_ID
and fai.date_ineffective is null
and fav.ASSET_ID=fai.asset_id
and fai.deleted_flag = 'NO') supplier_name --供应商名称
,(SELECT fcb.deprn_reserve_acct FROM fa_category_books fcb
WHERE fcb.category_id = fav.asset_category_id
AND fcb.book_type_code = fbv.book_type_code)DEPRN_RESERVE_ACCT_FLEX --累计折旧段
,(select gcc.segment3 COST_ACCT_FLEX
from gl_code_combinations gcc
where gcc.code_combination_id = fcb.asset_cost_account_ccid)COST_ACCT_FLEX --资产科目
,(SELECT fcb.deprn_expense_acct FROM fa_category_books fcb
WHERE fcb.category_id = fav.asset_category_id
AND fcb.book_type_code = fbv.book_type_code)DEPRN_EXPENSE_ACCT_FLEX --折旧科目
,(select distinct rsh.receipt_num
from fa_asset_invoices fai
,ap_invoice_distributions_all aida
,rcv_transactions rt
,rcv_shipment_headers rsh
where fai.ap_distribution_line_number=aida.distribution_line_number
and fai.invoice_distribution_id=aida.invoice_distribution_id
and fai.invoice_id=aida.invoice_id
and aida.rcv_transaction_id=rt.transaction_id
and fav.ASSET_ID=fai.asset_id
and rt.shipment_header_id=rsh.shipment_header_id )receipt_num --接收单号
,(select distinct fai.invoice_number
from fa_asset_invoices fai
,po_vendors pv
where fai.po_vendor_id=pv.VENDOR_ID
and fai.date_ineffective is null
and fav.ASSET_ID=fai.asset_id
and fai.deleted_flag = 'NO') invoice_number --发票编号
,(select distinct fai.payables_batch_name
from fa_asset_invoices fai
,po_vendors pv
where fai.po_vendor_id=pv.VENDOR_ID
and fai.date_ineffective is null
and fav.ASSET_ID=fai.asset_id
and fai.deleted_flag = 'NO')batch_name --发票批名
,(select distinct aia.doc_sequence_value From fa_asset_invoices ai,ap_invoices_all aia
where ai.invoice_id=aia.invoice_id
and ai.asset_id=fav.ASSET_ID) value_num --发票凭证编号
from fa_additions_v fav,
fa_books_v fbv,
fa_category_books fcb,
gl_code_combinations gcc
where fav.ASSET_ID = fbv.asset_id
and fbv.book_type_code = NVL('FA_BOOK_CW',FBV.book_type_code)
and fbv.date_ineffective is null
and fcb.category_id = fav.ASSET_CATEGORY_ID
and fcb.book_type_code = fbv.book_type_code
and fcb.asset_cost_account_ccid = gcc.code_combination_id
and fbv.date_placed_in_service <= to_date('2011-08-31','yyyy-mm-DD'))qq
where qq.ASSET_NUMBER='13883'
ORDER BY QQ.ASSET_NUMBER
|
|