Saturday, 26 September 2015

Query to get the Bank details by using the AR Invoice number -- 11i Oracle Apps

SELECT  
AA.trx_number,AA.trx_date,TO_CHAR (acrh.gl_date, 'DD-MON-YYYY') "GL Date", 'R' "Type",acr.amount,
         acr.doc_sequence_value "Voucher Number",
         acr.receipt_number "Cheque Number", TO_CHAR (acr.receipt_date, 'DD-MON-YYYY')  "Cheque Date",
         rc.customer_name "Vendor Name",
         acrh.account_code_combination_id "Account Code",
         SUM (DECODE (acrh.status,
                      'REVERSED', (acrh.amount * NVL (acrh.exchange_rate, 1))
                       * -1,
                      NVL (acrh.amount, 0) * NVL (acrh.exchange_rate, 1)
                     )
             ) "Receipts",
         SUM (0) "Payments", aba.bank_account_name "Bank Name",
         aba.bank_account_num "Bank Account Number", acr.org_id "Org ID",
         arbat.NAME "Batch Number", arsour.NAME "Batch Source"
    FROM ar.ar_cash_receipt_history_all acrh,
         ar.ar_cash_receipts_all acr,
         apps.ra_customers rc,
         ap.ap_bank_accounts_all aba,
         ar.ar_batches_all arbat,
         ar.ar_batch_sources_all arsour,
(SELECT DISTINCT ac.CASH_RECEIPT_ID,ra.trx_number,ra.trx_date
  FROM ra_customer_trx_all ra ,
   ar_cash_receipts_all ac ,
   ar_receivable_applications_all aaa
   WHERE /*aaa.application_type = 'CASH'
   AND*/ aaa.cash_receipt_id = ac.cash_receipt_id
   AND aaa.applied_customer_trx_id = ra.customer_trx_id
   )AA
   WHERE acrh.cash_receipt_id = acr.cash_receipt_id
     AND acr.remittance_bank_account_id = aba.bank_account_id
     AND acr.pay_from_customer = rc.customer_id(+)
     AND arsour.batch_source_id(+) = arbat.batch_source_id
     AND acrh.batch_id = arbat.batch_id(+)
     AND acrh.status IN ('CLEARED', 'REMITTED', 'CONFIRMED', 'REVERSED')
AND acr.CASH_RECEIPT_ID =AA.CASH_RECEIPT_ID
GROUP BY AA.trx_number,AA.trx_date,acrh.gl_date,acr.amount,
         acr.doc_sequence_value,
         rc.customer_name,
         acr.receipt_number,
         acr.receipt_date,
         acrh.account_code_combination_id,
         aba.bank_account_name,
         aba.bank_account_num,
         acr.org_id,
         arbat.NAME,
         arsour.NAME

No comments:

Post a Comment