SELECT ara.receivable_application_id, ara.cash_receipt_id,
jtl.tax_rate_id, jtl.tax_regime_id
,jtdf.det_factor_id det_factor_id
,jtl.tax_line_id tax_line_id
,(Select trx_number from ra_customer_trx_all where customer_trx_id=ara.applied_customer_trx_id)invoice_number
,trim(acr.receipt_number)receipt_number
,acr.RECEIPT_DATE
,ara.gl_date
,ara.line_applied line_applied_amt
,jtdf.line_amt trx_amount
,jtl.rounded_tax_amt_trx_curr tax_amt_trx_curr
,jtl.rounded_tax_amt_fun_curr tax_amt_fun_curr
,xal.*
FROM ar_receivable_applications_all ara,
ar_cash_receipts_all acr,
jai_tax_det_factors jtdf,
jai_tax_lines jtl
,xla.xla_transaction_entities te
,xla_ae_headers xah
,xla_ae_lines xal
WHERE trim(acr.receipt_number) = NVL(:ar_receipt_number,trim(acr.receipt_number))
AND ara.cash_receipt_id = acr.cash_receipt_id
AND ara.status = 'APP'
AND ara.display = 'Y'
AND ara.set_of_books_id = :p_ledger_id
AND ara.org_id = :p_org_id
AND ara.gl_date BETWEEN :p_start_date AND :p_end_date
AND ara.cash_receipt_id = jtdf.trx_id
AND jtdf.application_id = 222
AND jtdf.entity_code = 'RECEIPTS'
AND jtdf.event_class_code = 'RECEIPT'
AND jtdf.det_factor_id = jtl.det_factor_id
and nvl (te.source_id_int_1, -99) = acr.cash_receipt_id
and te.application_id = 222
and te.entity_code = 'RECEIPTS'
and xah.entity_id = te.entity_id
and xah.application_id = te.application_id
and xah.event_type_code ='RECP_CREATE'-- 'MANUAL'
and xah.ae_header_id = xal.ae_header_id
and xal.accounting_class_code='RECEIVABLE'
jtl.tax_rate_id, jtl.tax_regime_id
,jtdf.det_factor_id det_factor_id
,jtl.tax_line_id tax_line_id
,(Select trx_number from ra_customer_trx_all where customer_trx_id=ara.applied_customer_trx_id)invoice_number
,trim(acr.receipt_number)receipt_number
,acr.RECEIPT_DATE
,ara.gl_date
,ara.line_applied line_applied_amt
,jtdf.line_amt trx_amount
,jtl.rounded_tax_amt_trx_curr tax_amt_trx_curr
,jtl.rounded_tax_amt_fun_curr tax_amt_fun_curr
,xal.*
FROM ar_receivable_applications_all ara,
ar_cash_receipts_all acr,
jai_tax_det_factors jtdf,
jai_tax_lines jtl
,xla.xla_transaction_entities te
,xla_ae_headers xah
,xla_ae_lines xal
WHERE trim(acr.receipt_number) = NVL(:ar_receipt_number,trim(acr.receipt_number))
AND ara.cash_receipt_id = acr.cash_receipt_id
AND ara.status = 'APP'
AND ara.display = 'Y'
AND ara.set_of_books_id = :p_ledger_id
AND ara.org_id = :p_org_id
AND ara.gl_date BETWEEN :p_start_date AND :p_end_date
AND ara.cash_receipt_id = jtdf.trx_id
AND jtdf.application_id = 222
AND jtdf.entity_code = 'RECEIPTS'
AND jtdf.event_class_code = 'RECEIPT'
AND jtdf.det_factor_id = jtl.det_factor_id
and nvl (te.source_id_int_1, -99) = acr.cash_receipt_id
and te.application_id = 222
and te.entity_code = 'RECEIPTS'
and xah.entity_id = te.entity_id
and xah.application_id = te.application_id
and xah.event_type_code ='RECP_CREATE'-- 'MANUAL'
and xah.ae_header_id = xal.ae_header_id
and xal.accounting_class_code='RECEIVABLE'