Saturday, 26 September 2015

TDS Invoice Query -- Oracle Apps

SELECT  DISTINCT
 HRO.NAME OPERATING_UNIT
,IGCCV.SEGMENT5 GL_ACCOUNT_CODE  
,SPV.SEGMENT1 VENDOR_CODE
,SPV.VENDOR_NAME
,SPVS.VENDOR_SITE_CODE
,CONCAT('INV NO-',API.INVOICE_NUM) INVOICE_NUM
,API.INVOICE_DATE
,API.INVOICE_AMOUNT INVOICE_HEADER_AMOUNT
,JIATI.INVOICE_AMOUNT INVOICE_LINE_AMOUNT
,JIATI.TDS_INVOICE_NUM TDS_INVOICE_NUM
,APITDS.INVOICE_DATE TDS_INVOICE_DATE
,JIATI.TDS_AMOUNT TDS_INVOICE_AMOUNT
,API.GL_DATE TDS_GL_DATE
,APITDS.AMOUNT_PAID  TDS_AMOUNT_PAID
,JAP.PAN_NO
 ,ADDRESS_LINE1
 ,ADDRESS_LINE2
 ,ADDRESS_LINE3
 ,CITY
 ,STATE
 ,ZIP
 ,COUNTRY
 ,TPV.VENDOR_NAME  TDS_VENDOR
,JIATI.TDS_SECTION
,JIATI.TDS_TAX_RATE,
TRUNC(AIDA.ACCOUNTING_DATE)  ACCOUNTING_DATE,API.ORG_ID
FROM
AP_INVOICES_ALL API,
APPS.AP_INVOICES_ALL APITDS,
APPS.AP_SUPPLIERS SPV,
APPS.AP_SUPPLIERS TPV,
APPS.AP_SUPPLIER_SITES_ALL SPVS,
APPS.AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
APPS.HR_OPERATING_UNITS HRO,
APPS.JAI_AP_TDS_VENDOR_HDRS JAP,
APPS.JAI_AP_TDS_INVOICES JIATI,
GL_CODE_COMBINATIONS IGCCV
WHERE
API.VENDOR_ID=SPV.VENDOR_ID
AND   SPV.VENDOR_ID=SPVS.VENDOR_ID
AND   SPVS.VENDOR_SITE_ID= API.VENDOR_SITE_ID
AND  TPV.VENDOR_ID=APITDS.VENDOR_ID
AND   APITDS.ORG_ID=HRO.ORGANIZATION_ID
AND API.INVOICE_ID = JIATI.INVOICE_ID
AND   JAP.VENDOR_ID=API.VENDOR_ID
AND   JAP.VENDOR_SITE_ID=API.VENDOR_SITE_ID
AND APITDS.INVOICE_ID = AIDA.INVOICE_ID
AND APITDS.DESCRIPTION = JIATI.TDS_INVOICE_NUM
AND IGCCV.CODE_COMBINATION_ID = APITDS.ACCTS_PAY_CODE_COMBINATION_ID
AND API.ORG_ID = '102'
AND TRUNC(AIDA.ACCOUNTING_DATE) BETWEEN :PFROM AND :PTO
ORDER BY SPV.SEGMENT1

1 comment: