Вы находитесь на странице: 1из 4

----payment voucher karthick---

SELECT :p_voc_from,
:p_voc_to,
:p_ven_from,
:p_ven_to,
:p_date_from,
:p_date_to,
xel.entered_dr
,xel.entered_cr
,xel.accounted_dr
,xel.accounted_cr
,ai.invoice_num LPO_NUM
,aps.vendor_name VENDOR_NAME
,aps.segment1 VENDOR_NUMBER
,apsa.vendor_site_code VENDOR_SITE_CODE
,null org_id
,null CHECK_NUMBER
,null org_name
,ai.exchange_rate rate
,null base_amount
,null Voucher_number
,null payment_type
,xla1.meaning accounting_entry_status
,xeh.accounting_date gl_transfer_date
,decode(xeh.gl_transfer_status_code,'Y','Yes','No') gl_transfer_status_code

,xeh.je_category_name
,xlet.name event_type
,xlec.name event_class
,null payment_method
,null payment_date
,null pay_void_date
,null bank_name
,null bank_account_number
,ai.invoice_type_lookup_code invoice_type
,ai.invoice_date
,ai.cancelled_date cancelled_date
,to_char(ai.doc_sequence_value) doc_sequence_num
,ai.description comments
,xla2.meaning accounting_class_code
,xel.currency_code entered_currency
,gcck.segment1,gcck.segment2
,gcck.segment3,gcck.segment4
,gcck.segment5,gcck.segment6
,gcck.segment7,gcck.segment8
,xel.code_combination_id
,fu.user_name
,papf.full_name
FROM gl_ledgers gl
,xla_ae_headers xeh
,xla_ae_lines xel
,gl_code_combinations_kfv gcck
,xla.xla_transaction_entities xte
,ap_invoices_all ai
,ap_suppliers aps
,ap_supplier_sites_all apsa
,fnd_user fu
,per_all_people_f papf
,xla_lookups xla1
,xla_lookups xla2
,xla_event_types_tl xlet
,xla_event_classes_tl xlec
,ap_checks_all apc
WHERE xeh.application_id = 200
AND gl.ledger_id = xeh.ledger_id
AND xel.application_id = xeh.application_id
AND xel.ae_header_id(+) = xeh.ae_header_id
AND gcck.code_combination_id = xel.code_combination_id
AND xte.application_id(+) = xeh.application_id
AND xte.entity_id(+) = xeh.entity_id
AND xte.entity_code = 'AP_INVOICES'
AND xte.source_id_int_1 = ai.invoice_id(+)
AND ai.vendor_id = aps.vendor_id(+)
AND ai.vendor_site_id = apsa.vendor_site_id(+)
AND xeh.created_by = fu.user_id(+)
AND fu.employee_id = papf.person_id(+)
AND xla1.lookup_type = 'XLA_ACCOUNTING_ENTRY_STATUS'
AND xla1.lookup_code = xeh.accounting_entry_status_code
AND xla2.lookup_type = 'XLA_ACCOUNTING_CLASS'
AND xla2.lookup_code = xel.accounting_class_code
AND xlet.entity_code = xte.entity_code
AND xeh.event_type_code = xlet.event_type_code
AND xlet.event_class_code = xlec.event_class_code
AND xlec.LANGUAGE = 'US'
AND xlet.LANGUAGE = 'US'
AND xte.source_id_int_1 = apc.check_id(+)
AND apc.vendor_id = aps.vendor_id
AND apc.vendor_site_id = apsa.vendor_site_id
-- AND apc.ce_bank_acct_use_id = ceb.bank_account_id(+)
AND (sysdate between papf.effective_start_date and papf.effective_end_date
OR fu.employee_id is null)
AND xeh.balance_type_code = 'A'
AND apc.doc_sequence_value BETWEEN NVL(:p_voc_from,apc.doc_sequence_value) AND
NVL(:p_voc_to,apc.doc_sequence_value)
/* AND gl.ledger_id = :p_ledger_id
AND to_date(xeh.accounting_date,'DD-MON-YYYY')
BETWEEN TO_DATE(NVL (:p_from_date,xeh.accounting_date),'DD-MON-YYYY')
AND TO_DATE(NVL (:p_to_date,xeh.accounting_date),'DD-
MON-YYYY')
AND xeh.gl_transfer_status_code =
nvl(:p_gl_transfer_code,xeh.gl_transfer_status_code)
AND xeh.event_type_code = nvl(:p_event_type,xeh.event_type_code )
AND (aps.vendor_id = nvl(:p_vendor_id,aps.vendor_id ) OR
aps.vendor_id is null) */

UNION ALL

SELECT :p_voc_from,
:p_voc_to,
:p_ven_from,
:p_ven_to,
:p_date_from,
:p_date_to,
xel.entered_dr
,xel.entered_cr
,xel.accounted_dr
,xel.accounted_cr
,null LPO_NUM
,aps.vendor_name VENDOR_NAME
,aps.segment1 VENDOR_NUMBER
,apss.vendor_site_code party_site
,apc.org_id
,apc.check_number CHECK_NUMBER
,hou.name org_name
,null rate
,apc.base_amount base_amount
,apc.doc_sequence_value Voucher_number
,alc.DISPLAYED_FIELD PAYMENT_TYPE
,xla1.meaning accounting_entry_status
,xeh.accounting_date gl_transfer_date
,decode(xeh.gl_transfer_status_code,'Y','Yes','No')
gl_transfer_status_code
,xeh.je_category_name
,xlet.name event_type
,xlec.name event_class
,apc.payment_method_code payment_method
,apc.check_date payment_date
,apc.void_date pay_void_date
,nvl(apc.bank_account_name,ceb.bank_account_name) bank_name
,nvl(apc.bank_account_num,ceb.bank_account_num) bank_account_number
,null invoice_type
,null invoice_date
,null cancelled_date
,null doc_sequence_num
,apc.description comments
,xla2.meaning accounting_class_code
,xel.currency_code entered_currency
,gcck.segment1,gcck.segment2
,gcck.segment3,gcck.segment4
,gcck.segment5,gcck.segment6
,gcck.segment7,gcck.segment8
,xel.code_combination_id
,fu.user_name
,papf.full_name
FROM gl_ledgers gl
,xla_ae_headers xeh
,xla_ae_lines xel
,gl_code_combinations_kfv gcck
,xla.xla_transaction_entities xte
,ap_checks_all apc
,ap_suppliers aps
,ap_supplier_sites_all apss
,ce_bank_accounts ceb
,fnd_user fu
,per_all_people_f papf
,xla_lookups xla1
,xla_lookups xla2
,xla_event_types_tl xlet
,xla_event_classes_tl xlec
,HR_OPERATING_UNITS hou
,ap_lookup_codes alc
WHERE xeh.application_id = 200
AND gl.ledger_id = xeh.ledger_id
AND xel.application_id(+) = xeh.application_id
AND xel.ae_header_id(+) = xeh.ae_header_id
AND gcck.code_combination_id = xel.code_combination_id
AND xte.application_id(+) = xeh.application_id
AND xte.entity_id(+) = xeh.entity_id
AND xte.entity_code = 'AP_PAYMENTS'
AND xte.source_id_int_1 = apc.check_id(+)
AND apc.vendor_id = aps.vendor_id
AND apc.vendor_site_id = apss.vendor_site_id
AND apc.ce_bank_acct_use_id = ceb.bank_account_id(+)
AND xeh.created_by = fu.user_id(+)
AND fu.employee_id = papf.person_id(+)
AND xla1.lookup_type = 'XLA_ACCOUNTING_ENTRY_STATUS'
AND xla1.lookup_code = xeh.accounting_entry_status_code
AND xla2.lookup_type = 'XLA_ACCOUNTING_CLASS'
AND xla2.lookup_code = xel.accounting_class_code
AND xlet.entity_code = xte.entity_code
AND xeh.event_type_code = xlet.event_type_code
AND xlet.event_class_code = xlec.event_class_code
AND xlec.LANGUAGE = 'US'
AND xlet.LANGUAGE = 'US'
and apc.ORG_ID = hou.ORGANIZATION_ID
AND alc.LOOKUP_CODE = apc.PAYMENT_TYPE_FLAG
AND alc.LOOKUP_TYPE = 'PAYMENT TYPE'
AND (sysdate between papf.effective_start_date and papf.effective_end_date
OR fu.employee_id is null)
AND xeh.balance_type_code = 'A'
AND apc.doc_sequence_value BETWEEN NVL(:p_voc_from,apc.doc_sequence_value) AND
NVL(:p_voc_to,apc.doc_sequence_value)
/*AND gl.ledger_id = :p_ledger_id
AND to_date(xeh.accounting_date,'DD-MON-YYYY')
BETWEEN TO_DATE(NVL (:p_from_date,xeh.accounting_date),'DD-MON-YYYY')
AND TO_DATE(NVL (:p_to_date,xeh.accounting_date),'DD-
MON-YYYY')
AND xeh.gl_transfer_status_code =
nvl(:p_gl_transfer_code,xeh.gl_transfer_status_code)
AND xeh.event_type_code = nvl(:p_event_type,xeh.event_type_code )
AND (apc.vendor_id = nvl(:p_vendor_id,aps.vendor_id ) OR
apc.vendor_id is null) */
order by 3

Вам также может понравиться