/* Formatted on 5/13/2013 12:53:14 PM (QP5 v5.114.809.3010) */
--EIS_AP_INV_TO_GL_V
SELECT
gsob.NAME ledger_name,
hou.NAME operating_unit,
gsob.currency_code ledger_currency_code,
gcc.concatenated_segments AP_DISTRIBUTION_ACCOUNT,
'Payables' ae_source,
gcc1.concatenated_segments gl_account,
xah.je_category_name ae_category_name,
xah.period_name period_name,
xah.accounting_date ap_accounting_date,
xal.ae_line_num ae_line_number,
xal.accounting_class_code ap_line_type_lookup_code,
xe.event_number accounting_even_number,
xah.gl_transfer_status_code ap_gl_transfer_flag,
pv.vendor_name supplier,
ai.invoice_num ap_invoice_num,
ph.segment1 po_number,
prh.segment1 REQUISITION_num,
xxeis.eis_rs_ap_fin_com_util_pkg.eis_get_po_requestor (
prl.to_person_id
)
requestor_name,
ai.invoice_amount ap_invoice_amt,
ai.freight_amount ap_invoice_freight_amt,
ai.amount_paid ap_invoice_amt_paid,
ai.pay_group_lookup_code invoice_pay_group,
ai.posting_status invoice_posting_status,
ai.description ap_invoice_description,
ai.invoice_date ap_invoice_date,
ai.creation_date ap_invoice_creation_date,
ai.invoice_currency_code ap_invoice_currency_code,
NVL (ai.discount_amount_taken, 0) ap_invoice_disc_taken_amount,
TRUNC (xah.accounting_date) ap_gl_date,
xal.currency_conversion_date exchange_date,
xal.currency_conversion_rate exchange_rate,
xal.currency_conversion_type exchange_rate_type,
ai.goods_received_date goods_received_date,
NVL (ai.payment_amount_total, 0) invoice_pymt_total_amount,
pv.customer_num vendor_customer_number,
--pv.vendor_name vendor_name,
pv.segment1 vendor_number,
pvs.vendor_site_code supplier_site,
pvs.customer_num vendor_site_customer_num,
pvs.address_line1
|| CHR (10)
|| pvs.address_line2
|| CHR (10)
|| pvs.address_line3
|| CHR (10)
|| pvs.city
|| ','
|| pvs.state
|| ','
|| pvs.country
vendor_address
,
xdl.unrounded_entered_dr sla_entered_dr,
xdl.unrounded_entered_cr sla_entered_cr,
xdl.unrounded_accounted_dr sla_accounted_dr,
xdl.unrounded_accounted_cr sla_accounted_cr,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
sla_net_entered_amt,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
sla_net_accounted_amt
,
ai.invoice_id,
xah.ae_header_id,
--xal.ae_line_id, -- r12
gcc.code_combination_id ap_code_combination_id,
xal.gl_sl_link_id gl_sl_link_id,
jb.NAME batch_name,
jb.description batch_description,
jh.NAME je_name,
jh.description je_description,
jh.je_source je_source,
jh.posted_date je_posted_date,
jl.je_line_num je_line_num,
DECODE (
jh.status,
'P',
'Posted',
'U',
'Unposted',
'F',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'K',
'Error10 - Showing unbalanced intercompany journal entry',
'Z',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'Unknown'
)
je_status,
DECODE (jh.actual_flag,
'A',
'Actual',
'B',
'Budget',
'E',
'Encumbrance')
je_type
,
DECODE (
xah.gl_transfer_status_code,
'Y',
DECODE (gir.gl_sl_link_id,
NULL, 'Transferred',
DECODE (jh.status, 'P', 'Posted', 'Imported')),
'N',
'Not-Transferred',
'Not-Transferred'
)
reconcile_status
,
jh.je_header_id,
jb.je_batch_id,
gsob.ledger_id
,
jl.entered_dr gl_entered_dr,
jl.entered_cr gl_entered_cr,
jl.accounted_dr gl_accounted_dr,
jl.accounted_cr gl_accounted_cr,
NVL (jl.entered_dr, 0) - NVL (jl.entered_cr, 0) gl_net_entered_amt,
NVL (jl.accounted_dr, 0) - NVL (jl.accounted_cr, 0)
gl_net_accounted_amt
,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
)
ap_gl_net_entered_amt,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
)
ap_gl_net_accounted_amt,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_dr, 0))
ap_gl_entered_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_cr, 0))
ap_gl_entered_cr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_dr, 0))
ap_gl_accounted_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_cr, 0))
ap_gl_accounted_cr,
--Added U.Keys
aid.distribution_line_number,
aid.invoice_line_number,
hou.organization_id,
pv.vendor_id,
pvs.vendor_site_id,
xah.application_id,
xal.ae_line_num,
xdl.ref_ae_header_id,
xdl.temp_line_num,
xe.event_id,
gcc1.code_combination_id ae_code_combination_id,
GCC.SEGMENT2 GCC#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC#50353#ACCOUNT#DESCR,
GCC.SEGMENT1 GCC#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC#50353#COMPANY#DESCR,
GCC.SEGMENT6 GCC#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC#50353#DEPARTMENT#DESCR,
GCC.SEGMENT8 GCC#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC#50353#FUTURE#DESCR,
GCC.SEGMENT7 GCC#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC#50353#IC#DESCR,
GCC.SEGMENT4 GCC#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT4,
'MAS_GL_COA_LOB')
GCC#50353#LOB#DESCR,
GCC.SEGMENT5 GCC#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC#50353#LOCATIONS#DESCR,
GCC.SEGMENT3 GCC#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC#50353#QUALIFIER#DESCR,
GCC1.SEGMENT2 GCC1#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC1#50353#ACCOUNT#DESCR,
GCC1.SEGMENT1 GCC1#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC1#50353#COMPANY#DESCR,
GCC1.SEGMENT6 GCC1#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC1#50353#DEPARTMENT#DESCR,
GCC1.SEGMENT8 GCC1#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC1#50353#FUTURE#DESCR,
GCC1.SEGMENT7 GCC1#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC1#50353#IC#DESCR,
GCC1.SEGMENT4 GCC1#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT4,
'MAS_GL_COA_LOB')
GCC1#50353#LOB#DESCR,
GCC1.SEGMENT5 GCC1#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC1#50353#LOCATIONS#DESCR,
GCC1.SEGMENT3 GCC1#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC1#50353#QUALIFIER#DESCR
FROM ap_invoices_all ai,
ap_invoice_distributions_All aid,
po_distributions_All pd,
po_headers_all ph,
po_requisition_headers_all prh,
po_requisition_lines_all prl,
po_req_distributions_all prd,
po_vendors pv,
po_vendor_sites_all pvs,
xla_distribution_links xdl,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
gl_code_combinations_kfv gcc,
gl_code_combinations_kfv gcc1,
gl_ledgers gsob,
gl_import_references gir,
gl_je_lines jl,
gl_je_headers jh,
gl_je_batches jb,
gl_je_sources jes,
gl_je_categories jec,
hr_operating_units hou
WHERE 1 = 1
-- SL Joins
AND ai.invoice_id = aid.invoice_id
AND pv.vendor_id = ai.vendor_id
AND pvs.vendor_site_id = ai.vendor_site_id
AND aid.po_distribution_id = pd.po_distribution_id(+)
AND pd.po_header_id = ph.po_header_id(+)
AND pd.req_distribution_id = prd.distribution_id(+)
AND prd.requisition_line_id = prl.requisition_line_id(+)
AND prl.requisition_header_id = prh.requisition_header_id(+)
AND aid.dist_code_combination_id = gcc.code_combination_id(+)
-- SLA - SL joins
AND xdl.ae_header_id = xal.ae_header_id(+)
AND xdl.ae_line_num = xal.ae_line_num(+)
AND xal.application_id(+) = 200
AND xal.ae_header_id = xah.ae_header_id(+)
AND xah.event_id = xe.event_id(+)
AND aid.invoice_distribution_id =
xdl.source_distribution_id_num_1(+)
AND xdl.source_distribution_type(+) = 'AP_INV_DIST'
AND xal.code_combination_id = gcc1.code_combination_id(+)
AND xah.ledger_id = gsob.ledger_id(+)
-- SLA : GIR Joins
AND xal.gl_sl_link_id = gir.gl_sl_link_id(+)
AND xal.gl_sl_link_table = gir.gl_sl_link_table(+)
-- GIR : GL Joins
AND gir.je_header_id = jl.je_header_id(+)
AND gir.je_line_num = jl.je_line_num(+)
-- GL Joins
AND jl.je_header_id = jh.je_header_id(+)
AND jh.je_batch_id = jb.je_batch_id(+)
AND jh.je_source = jes.je_source_name(+)
AND jh.je_category = jec.je_category_name(+)
AND ai.org_id = hou.organization_id
and ai.invoice_num ='MWS11063'
UNION
-- self assessed tax lines.. these are not stored in ap distributions table
SELECT --<== Sub-Ledger fields
gsob.NAME ledger_name,
hou.NAME operating_unit,
gsob.currency_code ledger_currency_code,
gcc.concatenated_segments AP_DISTRIBUTION_ACCOUNT,
'Payables' ae_source,
gcc1.concatenated_segments gl_account,
--xah.je_category_name ae_category,
xah.je_category_name ae_category_name,
xah.period_name period_name,
xah.accounting_date ap_accounting_date,
xal.ae_line_num ae_line_number,
xal.accounting_class_code ap_line_type_lookup_code,
xe.event_number accounting_even_number,
xah.gl_transfer_status_code ap_gl_transfer_flag,
pv.vendor_name supplier,
ai.invoice_num ap_invoice_num,
NULL po_number,
NULL requisition_num,
NULL requestor_name,
ai.invoice_amount ap_invoice_amt,
ai.freight_amount ap_invoice_freight_amt,
ai.amount_paid ap_invoice_amt_paid,
ai.pay_group_lookup_code invoice_pay_group,
ai.posting_status invoice_posting_status,
ai.description ap_invoice_description,
ai.invoice_date ap_invoice_date,
ai.creation_date ap_invoice_creation_date,
ai.invoice_currency_code ap_invoice_currency_code,
NVL (ai.discount_amount_taken, 0) ap_invoice_disc_taken_amount,
TRUNC (xah.accounting_date) ap_gl_date,
xal.currency_conversion_date exchange_date,
xal.currency_conversion_rate exchange_rate,
xal.currency_conversion_type exchange_rate_type,
ai.goods_received_date goods_received_date,
NVL (ai.payment_amount_total, 0) invoice_pymt_total_amount,
pv.customer_num vendor_customer_number,
--pv.vendor_name vendor_name,
pv.segment1 vendor_number,
pvs.vendor_site_code supplier_site,
pvs.customer_num vendor_site_customer_num,
pvs.address_line1
|| CHR (10)
|| pvs.address_line2
|| CHR (10)
|| pvs.address_line3
|| CHR (10)
|| pvs.city
|| ','
|| pvs.state
|| ','
|| pvs.country
vendor_address
,
xdl.unrounded_entered_dr sla_entered_dr,
xdl.unrounded_entered_cr sla_entered_cr,
xdl.unrounded_accounted_dr sla_accounted_dr,
xdl.unrounded_accounted_cr sla_accounted_cr,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
sla_net_entered_amt,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
sla_net_accounted_amt
,
ai.invoice_id,
xah.ae_header_id,
gcc.code_combination_id ap_code_combination_id,
xal.gl_sl_link_id gl_sl_link_id,
jb.NAME batch_name,
jb.description batch_description,
jh.NAME je_name,
jh.description je_description,
jh.je_source je_source,
jh.posted_date je_posted_date,
jl.je_line_num je_line_num,
DECODE (
jh.status,
'P',
'Posted',
'U',
'Unposted',
'F',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'K',
'Error10 - Showing unbalanced intercompany journal entry',
'Z',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'Unknown'
)
je_status,
DECODE (jh.actual_flag,
'A',
'Actual',
'B',
'Budget',
'E',
'Encumbrance')
je_type
,
DECODE (
xah.gl_transfer_status_code,
'Y',
DECODE (gir.gl_sl_link_id,
NULL, 'Transferred',
DECODE (jh.status, 'P', 'Posted', 'Imported')),
'N',
'Not-Transferred',
'Not-Transferred'
)
reconcile_status
,
jh.je_header_id,
jb.je_batch_id,
gsob.ledger_id
,
jl.entered_dr gl_entered_dr,
jl.entered_cr gl_entered_cr,
jl.accounted_dr gl_accounted_dr,
jl.accounted_cr gl_accounted_cr,
NVL (jl.entered_dr, 0) - NVL (jl.entered_cr, 0) gl_net_entered_amt,
NVL (jl.accounted_dr, 0) - NVL (jl.accounted_cr, 0)
gl_net_accounted_amt
,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
)
ap_gl_net_entered_amt,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
)
ap_gl_net_accounted_amt,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_dr, 0))
ap_gl_entered_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_cr, 0))
ap_gl_entered_cr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_dr, 0))
ap_gl_accounted_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_cr, 0))
ap_gl_accounted_cr,
aid.distribution_line_number,
aid.invoice_line_number,
hou.organization_id,
pv.vendor_id,
pvs.vendor_site_id,
xah.application_id,
xal.ae_line_num,
xdl.ref_ae_header_id,
xdl.temp_line_num,
xe.event_id,
gcc1.code_combination_id ae_code_combination_id
,
GCC.SEGMENT2 GCC#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC#50353#ACCOUNT#DESCR,
GCC.SEGMENT1 GCC#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC#50353#COMPANY#DESCR,
GCC.SEGMENT6 GCC#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC#50353#DEPARTMENT#DESCR,
GCC.SEGMENT8 GCC#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC#50353#FUTURE#DESCR,
GCC.SEGMENT7 GCC#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC#50353#IC#DESCR,
GCC.SEGMENT4 GCC#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT4,
'MAS_GL_COA_LOB')
GCC#50353#LOB#DESCR,
GCC.SEGMENT5 GCC#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC#50353#LOCATIONS#DESCR,
GCC.SEGMENT3 GCC#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC#50353#QUALIFIER#DESCR,
GCC1.SEGMENT2 GCC1#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC1#50353#ACCOUNT#DESCR,
GCC1.SEGMENT1 GCC1#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC1#50353#COMPANY#DESCR,
GCC1.SEGMENT6 GCC1#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC1#50353#DEPARTMENT#DESCR,
GCC1.SEGMENT8 GCC1#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC1#50353#FUTURE#DESCR,
GCC1.SEGMENT7 GCC1#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC1#50353#IC#DESCR,
GCC1.SEGMENT4 GCC1#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT4,
'MAS_GL_COA_LOB')
GCC1#50353#LOB#DESCR,
GCC1.SEGMENT5 GCC1#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC1#50353#LOCATIONS#DESCR,
GCC1.SEGMENT3 GCC1#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC1#50353#QUALIFIER#DESCR
FROM ap_invoices_all ai,
ap_self_assessed_tax_dist aid,
po_vendors pv,
po_vendor_sites_all pvs,
xla_distribution_links xdl,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
gl_code_combinations_kfv gcc,
gl_code_combinations_kfv gcc1,
gl_ledgers gsob,
gl_import_references gir,
gl_je_lines jl,
gl_je_headers jh,
gl_je_batches jb,
gl_je_sources jes,
gl_je_categories jec,
hr_operating_units hou
WHERE 1 = 1
-- SL Joins
AND ai.invoice_id = aid.invoice_id
AND pv.vendor_id = ai.vendor_id
AND pvs.vendor_site_id = ai.vendor_site_id
AND aid.dist_code_combination_id = gcc.code_combination_id(+)
-- SLA - SL joins
AND xdl.ae_header_id = xal.ae_header_id(+)
AND xdl.ae_line_num = xal.ae_line_num(+)
AND xal.application_id(+) = 200
AND xal.ae_header_id = xah.ae_header_id(+)
AND xah.event_id = xe.event_id(+)
AND aid.invoice_distribution_id =
xdl.source_distribution_id_num_1(+)
AND xdl.source_distribution_type(+) = 'AP_INV_DIST'
AND xal.code_combination_id = gcc1.code_combination_id(+)
AND xah.ledger_id = gsob.ledger_id(+)
-- SLA : GIR Joins
AND xal.gl_sl_link_id = gir.gl_sl_link_id(+)
AND xal.gl_sl_link_table = gir.gl_sl_link_table(+)
-- GIR : GL Joins
AND gir.je_header_id = jl.je_header_id(+)
AND gir.je_line_num = jl.je_line_num(+)
-- GL Joins
AND jl.je_header_id = jh.je_header_id(+)
AND jh.je_batch_id = jb.je_batch_id(+)
AND jh.je_source = jes.je_source_name(+)
AND jh.je_category = jec.je_category_name(+)
AND ai.org_id = hou.organization_id
and ai.invoice_num ='MWS11063'
--EIS_AP_INV_TO_GL_V
SELECT
gsob.NAME ledger_name,
hou.NAME operating_unit,
gsob.currency_code ledger_currency_code,
gcc.concatenated_segments AP_DISTRIBUTION_ACCOUNT,
'Payables' ae_source,
gcc1.concatenated_segments gl_account,
xah.je_category_name ae_category_name,
xah.period_name period_name,
xah.accounting_date ap_accounting_date,
xal.ae_line_num ae_line_number,
xal.accounting_class_code ap_line_type_lookup_code,
xe.event_number accounting_even_number,
xah.gl_transfer_status_code ap_gl_transfer_flag,
pv.vendor_name supplier,
ai.invoice_num ap_invoice_num,
ph.segment1 po_number,
prh.segment1 REQUISITION_num,
xxeis.eis_rs_ap_fin_com_util_pkg.eis_get_po_requestor (
prl.to_person_id
)
requestor_name,
ai.invoice_amount ap_invoice_amt,
ai.freight_amount ap_invoice_freight_amt,
ai.amount_paid ap_invoice_amt_paid,
ai.pay_group_lookup_code invoice_pay_group,
ai.posting_status invoice_posting_status,
ai.description ap_invoice_description,
ai.invoice_date ap_invoice_date,
ai.creation_date ap_invoice_creation_date,
ai.invoice_currency_code ap_invoice_currency_code,
NVL (ai.discount_amount_taken, 0) ap_invoice_disc_taken_amount,
TRUNC (xah.accounting_date) ap_gl_date,
xal.currency_conversion_date exchange_date,
xal.currency_conversion_rate exchange_rate,
xal.currency_conversion_type exchange_rate_type,
ai.goods_received_date goods_received_date,
NVL (ai.payment_amount_total, 0) invoice_pymt_total_amount,
pv.customer_num vendor_customer_number,
--pv.vendor_name vendor_name,
pv.segment1 vendor_number,
pvs.vendor_site_code supplier_site,
pvs.customer_num vendor_site_customer_num,
pvs.address_line1
|| CHR (10)
|| pvs.address_line2
|| CHR (10)
|| pvs.address_line3
|| CHR (10)
|| pvs.city
|| ','
|| pvs.state
|| ','
|| pvs.country
vendor_address
,
xdl.unrounded_entered_dr sla_entered_dr,
xdl.unrounded_entered_cr sla_entered_cr,
xdl.unrounded_accounted_dr sla_accounted_dr,
xdl.unrounded_accounted_cr sla_accounted_cr,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
sla_net_entered_amt,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
sla_net_accounted_amt
,
ai.invoice_id,
xah.ae_header_id,
--xal.ae_line_id, -- r12
gcc.code_combination_id ap_code_combination_id,
xal.gl_sl_link_id gl_sl_link_id,
jb.NAME batch_name,
jb.description batch_description,
jh.NAME je_name,
jh.description je_description,
jh.je_source je_source,
jh.posted_date je_posted_date,
jl.je_line_num je_line_num,
DECODE (
jh.status,
'P',
'Posted',
'U',
'Unposted',
'F',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'K',
'Error10 - Showing unbalanced intercompany journal entry',
'Z',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'Unknown'
)
je_status,
DECODE (jh.actual_flag,
'A',
'Actual',
'B',
'Budget',
'E',
'Encumbrance')
je_type
,
DECODE (
xah.gl_transfer_status_code,
'Y',
DECODE (gir.gl_sl_link_id,
NULL, 'Transferred',
DECODE (jh.status, 'P', 'Posted', 'Imported')),
'N',
'Not-Transferred',
'Not-Transferred'
)
reconcile_status
,
jh.je_header_id,
jb.je_batch_id,
gsob.ledger_id
,
jl.entered_dr gl_entered_dr,
jl.entered_cr gl_entered_cr,
jl.accounted_dr gl_accounted_dr,
jl.accounted_cr gl_accounted_cr,
NVL (jl.entered_dr, 0) - NVL (jl.entered_cr, 0) gl_net_entered_amt,
NVL (jl.accounted_dr, 0) - NVL (jl.accounted_cr, 0)
gl_net_accounted_amt
,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
)
ap_gl_net_entered_amt,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
)
ap_gl_net_accounted_amt,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_dr, 0))
ap_gl_entered_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_cr, 0))
ap_gl_entered_cr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_dr, 0))
ap_gl_accounted_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_cr, 0))
ap_gl_accounted_cr,
--Added U.Keys
aid.distribution_line_number,
aid.invoice_line_number,
hou.organization_id,
pv.vendor_id,
pvs.vendor_site_id,
xah.application_id,
xal.ae_line_num,
xdl.ref_ae_header_id,
xdl.temp_line_num,
xe.event_id,
gcc1.code_combination_id ae_code_combination_id,
GCC.SEGMENT2 GCC#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC#50353#ACCOUNT#DESCR,
GCC.SEGMENT1 GCC#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC#50353#COMPANY#DESCR,
GCC.SEGMENT6 GCC#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC#50353#DEPARTMENT#DESCR,
GCC.SEGMENT8 GCC#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC#50353#FUTURE#DESCR,
GCC.SEGMENT7 GCC#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC#50353#IC#DESCR,
GCC.SEGMENT4 GCC#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT4,
'MAS_GL_COA_LOB')
GCC#50353#LOB#DESCR,
GCC.SEGMENT5 GCC#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC#50353#LOCATIONS#DESCR,
GCC.SEGMENT3 GCC#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC#50353#QUALIFIER#DESCR,
GCC1.SEGMENT2 GCC1#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC1#50353#ACCOUNT#DESCR,
GCC1.SEGMENT1 GCC1#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC1#50353#COMPANY#DESCR,
GCC1.SEGMENT6 GCC1#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC1#50353#DEPARTMENT#DESCR,
GCC1.SEGMENT8 GCC1#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC1#50353#FUTURE#DESCR,
GCC1.SEGMENT7 GCC1#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC1#50353#IC#DESCR,
GCC1.SEGMENT4 GCC1#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT4,
'MAS_GL_COA_LOB')
GCC1#50353#LOB#DESCR,
GCC1.SEGMENT5 GCC1#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC1#50353#LOCATIONS#DESCR,
GCC1.SEGMENT3 GCC1#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC1#50353#QUALIFIER#DESCR
FROM ap_invoices_all ai,
ap_invoice_distributions_All aid,
po_distributions_All pd,
po_headers_all ph,
po_requisition_headers_all prh,
po_requisition_lines_all prl,
po_req_distributions_all prd,
po_vendors pv,
po_vendor_sites_all pvs,
xla_distribution_links xdl,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
gl_code_combinations_kfv gcc,
gl_code_combinations_kfv gcc1,
gl_ledgers gsob,
gl_import_references gir,
gl_je_lines jl,
gl_je_headers jh,
gl_je_batches jb,
gl_je_sources jes,
gl_je_categories jec,
hr_operating_units hou
WHERE 1 = 1
-- SL Joins
AND ai.invoice_id = aid.invoice_id
AND pv.vendor_id = ai.vendor_id
AND pvs.vendor_site_id = ai.vendor_site_id
AND aid.po_distribution_id = pd.po_distribution_id(+)
AND pd.po_header_id = ph.po_header_id(+)
AND pd.req_distribution_id = prd.distribution_id(+)
AND prd.requisition_line_id = prl.requisition_line_id(+)
AND prl.requisition_header_id = prh.requisition_header_id(+)
AND aid.dist_code_combination_id = gcc.code_combination_id(+)
-- SLA - SL joins
AND xdl.ae_header_id = xal.ae_header_id(+)
AND xdl.ae_line_num = xal.ae_line_num(+)
AND xal.application_id(+) = 200
AND xal.ae_header_id = xah.ae_header_id(+)
AND xah.event_id = xe.event_id(+)
AND aid.invoice_distribution_id =
xdl.source_distribution_id_num_1(+)
AND xdl.source_distribution_type(+) = 'AP_INV_DIST'
AND xal.code_combination_id = gcc1.code_combination_id(+)
AND xah.ledger_id = gsob.ledger_id(+)
-- SLA : GIR Joins
AND xal.gl_sl_link_id = gir.gl_sl_link_id(+)
AND xal.gl_sl_link_table = gir.gl_sl_link_table(+)
-- GIR : GL Joins
AND gir.je_header_id = jl.je_header_id(+)
AND gir.je_line_num = jl.je_line_num(+)
-- GL Joins
AND jl.je_header_id = jh.je_header_id(+)
AND jh.je_batch_id = jb.je_batch_id(+)
AND jh.je_source = jes.je_source_name(+)
AND jh.je_category = jec.je_category_name(+)
AND ai.org_id = hou.organization_id
and ai.invoice_num ='MWS11063'
UNION
-- self assessed tax lines.. these are not stored in ap distributions table
SELECT --<== Sub-Ledger fields
gsob.NAME ledger_name,
hou.NAME operating_unit,
gsob.currency_code ledger_currency_code,
gcc.concatenated_segments AP_DISTRIBUTION_ACCOUNT,
'Payables' ae_source,
gcc1.concatenated_segments gl_account,
--xah.je_category_name ae_category,
xah.je_category_name ae_category_name,
xah.period_name period_name,
xah.accounting_date ap_accounting_date,
xal.ae_line_num ae_line_number,
xal.accounting_class_code ap_line_type_lookup_code,
xe.event_number accounting_even_number,
xah.gl_transfer_status_code ap_gl_transfer_flag,
pv.vendor_name supplier,
ai.invoice_num ap_invoice_num,
NULL po_number,
NULL requisition_num,
NULL requestor_name,
ai.invoice_amount ap_invoice_amt,
ai.freight_amount ap_invoice_freight_amt,
ai.amount_paid ap_invoice_amt_paid,
ai.pay_group_lookup_code invoice_pay_group,
ai.posting_status invoice_posting_status,
ai.description ap_invoice_description,
ai.invoice_date ap_invoice_date,
ai.creation_date ap_invoice_creation_date,
ai.invoice_currency_code ap_invoice_currency_code,
NVL (ai.discount_amount_taken, 0) ap_invoice_disc_taken_amount,
TRUNC (xah.accounting_date) ap_gl_date,
xal.currency_conversion_date exchange_date,
xal.currency_conversion_rate exchange_rate,
xal.currency_conversion_type exchange_rate_type,
ai.goods_received_date goods_received_date,
NVL (ai.payment_amount_total, 0) invoice_pymt_total_amount,
pv.customer_num vendor_customer_number,
--pv.vendor_name vendor_name,
pv.segment1 vendor_number,
pvs.vendor_site_code supplier_site,
pvs.customer_num vendor_site_customer_num,
pvs.address_line1
|| CHR (10)
|| pvs.address_line2
|| CHR (10)
|| pvs.address_line3
|| CHR (10)
|| pvs.city
|| ','
|| pvs.state
|| ','
|| pvs.country
vendor_address
,
xdl.unrounded_entered_dr sla_entered_dr,
xdl.unrounded_entered_cr sla_entered_cr,
xdl.unrounded_accounted_dr sla_accounted_dr,
xdl.unrounded_accounted_cr sla_accounted_cr,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
sla_net_entered_amt,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
sla_net_accounted_amt
,
ai.invoice_id,
xah.ae_header_id,
gcc.code_combination_id ap_code_combination_id,
xal.gl_sl_link_id gl_sl_link_id,
jb.NAME batch_name,
jb.description batch_description,
jh.NAME je_name,
jh.description je_description,
jh.je_source je_source,
jh.posted_date je_posted_date,
jl.je_line_num je_line_num,
DECODE (
jh.status,
'P',
'Posted',
'U',
'Unposted',
'F',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'K',
'Error10 - Showing unbalanced intercompany journal entry',
'Z',
'Error7 - Showing invalid journal entry lines or no journal entry lines',
'Unknown'
)
je_status,
DECODE (jh.actual_flag,
'A',
'Actual',
'B',
'Budget',
'E',
'Encumbrance')
je_type
,
DECODE (
xah.gl_transfer_status_code,
'Y',
DECODE (gir.gl_sl_link_id,
NULL, 'Transferred',
DECODE (jh.status, 'P', 'Posted', 'Imported')),
'N',
'Not-Transferred',
'Not-Transferred'
)
reconcile_status
,
jh.je_header_id,
jb.je_batch_id,
gsob.ledger_id
,
jl.entered_dr gl_entered_dr,
jl.entered_cr gl_entered_cr,
jl.accounted_dr gl_accounted_dr,
jl.accounted_cr gl_accounted_cr,
NVL (jl.entered_dr, 0) - NVL (jl.entered_cr, 0) gl_net_entered_amt,
NVL (jl.accounted_dr, 0) - NVL (jl.accounted_cr, 0)
gl_net_accounted_amt
,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_entered_dr, 0)
- NVL (xdl.unrounded_entered_cr, 0)
)
ap_gl_net_entered_amt,
DECODE (
gir.gl_sl_link_id,
NULL,
0,
NVL (xdl.unrounded_accounted_dr, 0)
- NVL (xdl.unrounded_accounted_cr, 0)
)
ap_gl_net_accounted_amt,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_dr, 0))
ap_gl_entered_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_entered_cr, 0))
ap_gl_entered_cr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_dr, 0))
ap_gl_accounted_dr,
DECODE (gir.gl_sl_link_id,
NULL, 0,
NVL (xdl.unrounded_accounted_cr, 0))
ap_gl_accounted_cr,
aid.distribution_line_number,
aid.invoice_line_number,
hou.organization_id,
pv.vendor_id,
pvs.vendor_site_id,
xah.application_id,
xal.ae_line_num,
xdl.ref_ae_header_id,
xdl.temp_line_num,
xe.event_id,
gcc1.code_combination_id ae_code_combination_id
,
GCC.SEGMENT2 GCC#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC#50353#ACCOUNT#DESCR,
GCC.SEGMENT1 GCC#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC#50353#COMPANY#DESCR,
GCC.SEGMENT6 GCC#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC#50353#DEPARTMENT#DESCR,
GCC.SEGMENT8 GCC#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC#50353#FUTURE#DESCR,
GCC.SEGMENT7 GCC#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC#50353#IC#DESCR,
GCC.SEGMENT4 GCC#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT4,
'MAS_GL_COA_LOB')
GCC#50353#LOB#DESCR,
GCC.SEGMENT5 GCC#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC#50353#LOCATIONS#DESCR,
GCC.SEGMENT3 GCC#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC#50353#QUALIFIER#DESCR,
GCC1.SEGMENT2 GCC1#50353#ACCOUNT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT2,
'MAS_GL_COA_ACCOUNT')
GCC1#50353#ACCOUNT#DESCR,
GCC1.SEGMENT1 GCC1#50353#COMPANY,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT1,
'MAS_GL_COA_COMPANY')
GCC1#50353#COMPANY#DESCR,
GCC1.SEGMENT6 GCC1#50353#DEPARTMENT,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT6,
'MAS_GL_COA_DEPARTMENT')
GCC1#50353#DEPARTMENT#DESCR,
GCC1.SEGMENT8 GCC1#50353#FUTURE,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT8,
'MAS_GL_COA_FUTURE')
GCC1#50353#FUTURE#DESCR,
GCC1.SEGMENT7 GCC1#50353#IC,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT7,
'MAS_GL_COA_COMPANY')
GCC1#50353#IC#DESCR,
GCC1.SEGMENT4 GCC1#50353#LOB,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT4,
'MAS_GL_COA_LOB')
GCC1#50353#LOB#DESCR,
GCC1.SEGMENT5 GCC1#50353#LOCATIONS,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT5,
'MAS_GL_COA_LOCATION')
GCC1#50353#LOCATIONS#DESCR,
GCC1.SEGMENT3 GCC1#50353#QUALIFIER,
xxeis.eis_rs_fin_utility.decode_vset (GCC1.SEGMENT3,
'MAS_GL_COA_ACCT_QUAL')
GCC1#50353#QUALIFIER#DESCR
FROM ap_invoices_all ai,
ap_self_assessed_tax_dist aid,
po_vendors pv,
po_vendor_sites_all pvs,
xla_distribution_links xdl,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
gl_code_combinations_kfv gcc,
gl_code_combinations_kfv gcc1,
gl_ledgers gsob,
gl_import_references gir,
gl_je_lines jl,
gl_je_headers jh,
gl_je_batches jb,
gl_je_sources jes,
gl_je_categories jec,
hr_operating_units hou
WHERE 1 = 1
-- SL Joins
AND ai.invoice_id = aid.invoice_id
AND pv.vendor_id = ai.vendor_id
AND pvs.vendor_site_id = ai.vendor_site_id
AND aid.dist_code_combination_id = gcc.code_combination_id(+)
-- SLA - SL joins
AND xdl.ae_header_id = xal.ae_header_id(+)
AND xdl.ae_line_num = xal.ae_line_num(+)
AND xal.application_id(+) = 200
AND xal.ae_header_id = xah.ae_header_id(+)
AND xah.event_id = xe.event_id(+)
AND aid.invoice_distribution_id =
xdl.source_distribution_id_num_1(+)
AND xdl.source_distribution_type(+) = 'AP_INV_DIST'
AND xal.code_combination_id = gcc1.code_combination_id(+)
AND xah.ledger_id = gsob.ledger_id(+)
-- SLA : GIR Joins
AND xal.gl_sl_link_id = gir.gl_sl_link_id(+)
AND xal.gl_sl_link_table = gir.gl_sl_link_table(+)
-- GIR : GL Joins
AND gir.je_header_id = jl.je_header_id(+)
AND gir.je_line_num = jl.je_line_num(+)
-- GL Joins
AND jl.je_header_id = jh.je_header_id(+)
AND jh.je_batch_id = jb.je_batch_id(+)
AND jh.je_source = jes.je_source_name(+)
AND jh.je_category = jec.je_category_name(+)
AND ai.org_id = hou.organization_id
and ai.invoice_num ='MWS11063'
No comments:
Post a Comment