DBA Data[Home] [Help]

VIEW: APPS.TAX_EXEMPTIONS_V

Source

View Text - Preformatted

SELECT s.site_use_id SHIP_TO_SITE_USE_ID, a.cust_account_id SHIP_TO_CUSTOMER_ID, x.customer_id BILL_TO_CUSTOMER_ID, x.site_use_id EXEMPTION_SHIP_TO_SITE_USE_ID, decode(x.customer_exemption_number, null, ' ', x.customer_exemption_number) TAX_EXEMPT_NUMBER, x.reason_code TAX_EXEMPT_REASON_CODE, nvl(arl.meaning,x.reason_code) TAX_EXEMPT_REASON_MEANING, x.percent_exempt PERCENT_EXEMPT, x.status STATUS_CODE, nvl(ars.meaning, x.status) STATUS_MEANING, x.start_date START_DATE, x.end_date END_DATE, x.tax_exemption_id TAX_EXEMPTION_ID, decode( x.site_use_id, null, decode(x.location_id_segment_10, null, decode(x.location_id_segment_9, null, decode(x.location_id_segment_8, null, decode(x.location_id_segment_7, null, decode(x.location_id_segment_6, null, decode(x.location_id_segment_5, null, decode(x.location_id_segment_4, null, decode(x.location_id_segment_3, null, decode(x.location_id_segment_2, null, decode(x.location_id_segment_1, null, 11, 10), 9), 8), 7), 6), 5), 4), 3), 2), 1), 0 ) +decode( x.status, 'PRIMARY', 0, 'MANUAL', 1000, 'UNAPPROVED', 2000, 'EXPIRED', 3000, 4000 ) DISPLAY_ORDER, x.tax_code TAX_CODE FROM hz_cust_site_uses s, hz_cust_acct_sites_all a, hz_party_sites p, hz_loc_assignments la, ra_tax_exemptions x, ar_lookups ars, ar_lookups arl, ar_location_combinations c WHERE la.loc_id = c.location_id(+) and a.party_site_id = p.party_site_id and p.location_id = la.location_id and nvl(a.org_id, -99) = nvl(la.org_id, -99) and s.cust_acct_site_id = a.cust_acct_site_id and nvl(a.org_id,nvl(to_number(decode (substrb(userenv('CLIENT_INFO'),1,1), ' ' , NULL, substrb(userenv('CLIENT_INFO'),1,10))),-99)) = nvl(to_number(decode(substrb(userenv('CLIENT_INFO'),1,1), ' ',NULL,substrb(userenv('CLIENT_INFO'),1,10))),-99) and nvl(x.location_id_segment_1, nvl(c.location_id_segment_1,-1)) = nvl(c.location_id_segment_1,-1) and nvl(x.location_id_segment_2, nvl(c.location_id_segment_2,-1)) = nvl(c.location_id_segment_2,-1) and nvl(x.location_id_segment_3, nvl(c.location_id_segment_3,-1)) = nvl(c.location_id_segment_3,-1) and nvl(x.location_id_segment_4, nvl(c.location_id_segment_4,-1)) = nvl(c.location_id_segment_4,-1) and nvl(x.location_id_segment_5, nvl(c.location_id_segment_5,-1)) = nvl(c.location_id_segment_5,-1) and nvl(x.location_id_segment_6, nvl(c.location_id_segment_6,-1)) = nvl(c.location_id_segment_6,-1) and nvl(x.location_id_segment_7, nvl(c.location_id_segment_7,-1)) = nvl(c.location_id_segment_7,-1) and nvl(x.location_id_segment_8, nvl(c.location_id_segment_8,-1)) = nvl(c.location_id_segment_8,-1) and nvl(x.location_id_segment_9, nvl(c.location_id_segment_9,-1)) = nvl(c.location_id_segment_9,-1) and nvl(x.location_id_segment_10, nvl(c.location_id_segment_10,-1)) = nvl(c.location_id_segment_10,-1) and arl.lookup_type(+) = 'TAX_REASON' and arl.lookup_code(+) = x.reason_code and ars.lookup_type = 'TAX_EXEMPT_STATUS' and ars.lookup_code = x.status and x.exemption_type = 'CUSTOMER' and nvl( x.site_use_id, s.site_use_id ) = s.site_use_id
View Text - HTML Formatted

SELECT S.SITE_USE_ID SHIP_TO_SITE_USE_ID
, A.CUST_ACCOUNT_ID SHIP_TO_CUSTOMER_ID
, X.CUSTOMER_ID BILL_TO_CUSTOMER_ID
, X.SITE_USE_ID EXEMPTION_SHIP_TO_SITE_USE_ID
, DECODE(X.CUSTOMER_EXEMPTION_NUMBER
, NULL
, ' '
, X.CUSTOMER_EXEMPTION_NUMBER) TAX_EXEMPT_NUMBER
, X.REASON_CODE TAX_EXEMPT_REASON_CODE
, NVL(ARL.MEANING
, X.REASON_CODE) TAX_EXEMPT_REASON_MEANING
, X.PERCENT_EXEMPT PERCENT_EXEMPT
, X.STATUS STATUS_CODE
, NVL(ARS.MEANING
, X.STATUS) STATUS_MEANING
, X.START_DATE START_DATE
, X.END_DATE END_DATE
, X.TAX_EXEMPTION_ID TAX_EXEMPTION_ID
, DECODE( X.SITE_USE_ID
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_10
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_9
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_8
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_7
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_6
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_5
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_4
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_3
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_2
, NULL
, DECODE(X.LOCATION_ID_SEGMENT_1
, NULL
, 11
, 10)
, 9)
, 8)
, 7)
, 6)
, 5)
, 4)
, 3)
, 2)
, 1)
, 0 ) +DECODE( X.STATUS
, 'PRIMARY'
, 0
, 'MANUAL'
, 1000
, 'UNAPPROVED'
, 2000
, 'EXPIRED'
, 3000
, 4000 ) DISPLAY_ORDER
, X.TAX_CODE TAX_CODE
FROM HZ_CUST_SITE_USES S
, HZ_CUST_ACCT_SITES_ALL A
, HZ_PARTY_SITES P
, HZ_LOC_ASSIGNMENTS LA
, RA_TAX_EXEMPTIONS X
, AR_LOOKUPS ARS
, AR_LOOKUPS ARL
, AR_LOCATION_COMBINATIONS C
WHERE LA.LOC_ID = C.LOCATION_ID(+)
AND A.PARTY_SITE_ID = P.PARTY_SITE_ID
AND P.LOCATION_ID = LA.LOCATION_ID
AND NVL(A.ORG_ID
, -99) = NVL(LA.ORG_ID
, -99)
AND S.CUST_ACCT_SITE_ID = A.CUST_ACCT_SITE_ID
AND NVL(A.ORG_ID
, NVL(TO_NUMBER(DECODE (SUBSTRB(USERENV('CLIENT_INFO')
, 1
, 1)
, ' '
, NULL
, SUBSTRB(USERENV('CLIENT_INFO')
, 1
, 10)))
, -99)) = NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO')
, 1
, 1)
, ' '
, NULL
, SUBSTRB(USERENV('CLIENT_INFO')
, 1
, 10)))
, -99)
AND NVL(X.LOCATION_ID_SEGMENT_1
, NVL(C.LOCATION_ID_SEGMENT_1
, -1)) = NVL(C.LOCATION_ID_SEGMENT_1
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_2
, NVL(C.LOCATION_ID_SEGMENT_2
, -1)) = NVL(C.LOCATION_ID_SEGMENT_2
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_3
, NVL(C.LOCATION_ID_SEGMENT_3
, -1)) = NVL(C.LOCATION_ID_SEGMENT_3
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_4
, NVL(C.LOCATION_ID_SEGMENT_4
, -1)) = NVL(C.LOCATION_ID_SEGMENT_4
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_5
, NVL(C.LOCATION_ID_SEGMENT_5
, -1)) = NVL(C.LOCATION_ID_SEGMENT_5
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_6
, NVL(C.LOCATION_ID_SEGMENT_6
, -1)) = NVL(C.LOCATION_ID_SEGMENT_6
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_7
, NVL(C.LOCATION_ID_SEGMENT_7
, -1)) = NVL(C.LOCATION_ID_SEGMENT_7
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_8
, NVL(C.LOCATION_ID_SEGMENT_8
, -1)) = NVL(C.LOCATION_ID_SEGMENT_8
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_9
, NVL(C.LOCATION_ID_SEGMENT_9
, -1)) = NVL(C.LOCATION_ID_SEGMENT_9
, -1)
AND NVL(X.LOCATION_ID_SEGMENT_10
, NVL(C.LOCATION_ID_SEGMENT_10
, -1)) = NVL(C.LOCATION_ID_SEGMENT_10
, -1)
AND ARL.LOOKUP_TYPE(+) = 'TAX_REASON'
AND ARL.LOOKUP_CODE(+) = X.REASON_CODE
AND ARS.LOOKUP_TYPE = 'TAX_EXEMPT_STATUS'
AND ARS.LOOKUP_CODE = X.STATUS
AND X.EXEMPTION_TYPE = 'CUSTOMER'
AND NVL( X.SITE_USE_ID
, S.SITE_USE_ID ) = S.SITE_USE_ID