Запрос для определения типа расчетного счета:
(поставщик или заказчик)
SELECT account.bank_account_num ,account.ext_bank_account_id -- Link to Bank and Branch Information ,acc_instr.instrument_id ,case when ext_payer.ext_payer_id is not null then 'CUSTOMER' when ext_iep.ext_payee_id is not null then 'SUPPLIER' end type_account ,case when ext_payer.ext_payer_id is not null then (select ac.CUSTOMER_ID || ' - ' || ac.CUSTOMER_NAME from ar_customers ac where ac.CUSTOMER_ID = ext_payer.cust_account_id) when ext_iep.ext_payee_id is not null then (select ap.vendor_id || ' - ' || ap.vendor_name from ap_suppliers ap where ap.party_id = ext_iep.payee_party_id) end owner_account_name FROM iby_ext_bank_accounts account ,iby_pmt_instr_uses_all acc_instr ,iby_external_payers_all ext_payer ,iby_external_payees_all ext_iep WHERE 1 = 1 AND account.ext_bank_account_id = acc_instr.instrument_id AND acc_instr.ext_pmt_party_id = ext_payer.ext_payer_id(+) AND acc_instr.ext_pmt_party_id = ext_iep.ext_payee_id(+) -- AND account.bank_account_num in ('','')
Последние комментарии