SELECT DISTINCT hou.name "Operating Unit Name",
--hou.ORGANIZATION_ID,
TRUNC (acra.receipt_date) "Receipt Date",
acra.receipt_number "Receipt Number",
rcta.trx_number "Invoice Number",
-- rcta.org_id,
decode (ara.status,
'ACC', 'On-Account',
'APP', 'Applied',
'UNID', 'Unidentified',
'UNAPP', 'Unapplied',
'ACTIVITY', 'ACTIVITY', 'None' ) "Receipt Status",
hcas.account_number "Customer Number",
hp.party_name "Customer Name",
hl1.state "Customer Ship-to State" ,
hl1.country "Country",
--apsa.amount_due_remaining
-- apsa.amount_due_original "Receipt Amount",
acra.amount "Receipt Amount",
ara.AMOUNT_APPLIED,
--apsa.Amount_line_items_original,
--apsa.tax_original,
ara.line_applied,
ara.tax_applied
FROM ar_cash_receipts_all acra,
ar_receivable_applications_all ara,
ra_customer_trx_all rcta,
ar_payment_schedules_all apsa,
hz_parties hp ,
hz_cust_accounts hcas ,
hz_cust_acct_sites_all hcasa ,
hz_party_sites hps ,
hz_contact_points hcp ,
hz_locations hl,
hr_organization_units hou,
apps.hz_cust_site_uses_all hcsua1 ,
apps.hz_cust_acct_sites_all hcasa1 ,
apps.hz_party_sites hps1 ,
apps.hz_locations hl1
WHERE acra.pay_from_customer = hcas.cust_account_id(+)
AND hcas.party_id = hp.party_id(+)
AND hp.party_id = hps.party_id
AND hcasa.party_site_id = hps.party_site_id
AND hcasa.status = 'A'
AND hps.status = 'A'
AND hps.party_site_id = hcp.owner_table_id(+)
AND hcp.contact_point_type = 'PHONE'
AND hcp.owner_table_name = 'HZ_PARTY_SITES'
AND hcp.phone_line_type = 'GEN'
AND hcp.status = 'A'
AND hps.location_id = hl.location_id
AND hcasa.org_id = hou.organization_id
AND hcasa.org_id = acra.org_id
AND hcasa.org_id = ara.org_id
AND hcasa.org_id = rcta.org_id
AND hcasa.org_id = apsa.org_id
--AND hcasa.org_id IN (103,235,237,221)
--AND hcasa.org_id =103
AND ara.cash_receipt_id =acra.cash_receipt_id
AND ara.applied_customer_trx_id=rcta.customer_trx_id
AND rcta.customer_trx_id = apsa.customer_trx_id
--AND acra.receipt_number ='13076687'
AND rcta.ship_to_site_use_id = hcsua1.site_use_id
AND hcsua1.cust_acct_site_id = hcasa1.cust_acct_site_id
AND hcasa1.party_site_id = hps1.party_site_id
AND hps1.location_id = hl1.location_id
AND rcta.org_id = hcsua1.org_id
AND rcta.org_id = hcasa1.org_id
AND to_date((to_char(trunc(acra.receipt_date),'dd-mon-rrrr') ),'dd-mon-rrrr')
BETWEEN to_date('01-Oct-2014','dd-mon-rrrr') and to_date('31-Dec-2014','dd-mon-rrrr')
--AND hl.country ='US'
ORDER BY 2,5,3;
No comments:
Post a Comment