SELECT F.NAME,
A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2 AS "INVOICE IMAGE ID", E.VENDOR_NAME,E.SEGMENT1 AS "VENDOR NUMBER",C.PAYMENT_NUM,
C.HOLD_FLAG AS "SCHEDULE LEVEL HOLD",
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
C.AMOUNT_REMAINING,
C.DUE_DATE,
COUNT(D.INVOICE_ID) AS "HOLDS",
C.CHECKRUN_ID AS "SELECTED FOR PAYMENT"
FROM AP_INVOICES_ALL A,
FND_USER B,
AP_PAYMENT_SCHEDULES_ALL C,
AP_HOLDS_ALL D,
PO_VENDORS E,
HR_ORGANIZATION_UNITS F
WHERE A.ORG_ID=&ORG_ID
AND A.CREATED_BY=B.USER_ID
AND A.INVOICE_ID=C.INVOICE_ID
AND A.VENDOR_ID=E.VENDOR_ID
AND A.ORG_ID=F.ORGANIZATION_ID
AND A.INVOICE_ID=D.INVOICE_ID(+)
AND D.RELEASE_LOOKUP_CODE IS NULL
AND E.VENDOR_NAME NOT LIKE 'COLT%'
AND E.VENDOR_NAME NOT LIKE 'COLT%'
GROUP BY F.NAME,A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2,E.VENDOR_NAME,E.SEGMENT1 ,C.PAYMENT_NUM,C.HOLD_FLAG,
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
A.APPROVAL_STATUS,
A.APPROVAL_DESCRIPTION,
C.AMOUNT_REMAINING,
C.DUE_DATE ,
C.CHECKRUN_ID
UNION
SELECT F.NAME,
A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2, E.VENDOR_NAME,E.SEGMENT1 AS "VENDOR NUMBER",C.PAYMENT_NUM,C.HOLD_FLAG AS "SCHEDULE LEVEL HOLD",
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
C.AMOUNT_REMAINING,
C.DUE_DATE,
0,
C.CHECKRUN_ID AS "SELECTED FOR PAYMENT"
FROM AP_INVOICES_ALL A,
FND_USER B,
AP_PAYMENT_SCHEDULES_ALL C,
AP_HOLDS_ALL D,
PO_VENDORS E,
HR_ORGANIZATION_UNITS F
WHERE A.ORG_ID=&ORG_ID
AND A.CREATED_BY=B.USER_ID
AND A.INVOICE_ID=C.INVOICE_ID
AND A.VENDOR_ID=E.VENDOR_ID
AND A.ORG_ID=F.ORGANIZATION_ID
AND A.INVOICE_ID=D.INVOICE_ID(+)
AND D.RELEASE_LOOKUP_CODE IS NOT NULL
AND D.INVOICE_ID NOT IN (SELECT INVOICE_ID FROM AP_HOLDS_ALL WHERE RELEASE_LOOKUP_CODE IS NULL)
AND E.VENDOR_NAME NOT LIKE 'COLT%'
AND E.VENDOR_NAME NOT LIKE 'COLT%'
GROUP BY F.NAME,A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2,E.VENDOR_NAME,E.SEGMENT1 ,C.PAYMENT_NUM,C.HOLD_FLAG,
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
A.APPROVAL_STATUS,
A.APPROVAL_DESCRIPTION,
C.AMOUNT_REMAINING,
C.DUE_DATE ,
C.CHECKRUN_ID
ORDER BY 1
A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2 AS "INVOICE IMAGE ID", E.VENDOR_NAME,E.SEGMENT1 AS "VENDOR NUMBER",C.PAYMENT_NUM,
C.HOLD_FLAG AS "SCHEDULE LEVEL HOLD",
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
C.AMOUNT_REMAINING,
C.DUE_DATE,
COUNT(D.INVOICE_ID) AS "HOLDS",
C.CHECKRUN_ID AS "SELECTED FOR PAYMENT"
FROM AP_INVOICES_ALL A,
FND_USER B,
AP_PAYMENT_SCHEDULES_ALL C,
AP_HOLDS_ALL D,
PO_VENDORS E,
HR_ORGANIZATION_UNITS F
WHERE A.ORG_ID=&ORG_ID
AND A.CREATED_BY=B.USER_ID
AND A.INVOICE_ID=C.INVOICE_ID
AND A.VENDOR_ID=E.VENDOR_ID
AND A.ORG_ID=F.ORGANIZATION_ID
AND A.INVOICE_ID=D.INVOICE_ID(+)
AND D.RELEASE_LOOKUP_CODE IS NULL
AND E.VENDOR_NAME NOT LIKE 'COLT%'
AND E.VENDOR_NAME NOT LIKE 'COLT%'
GROUP BY F.NAME,A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2,E.VENDOR_NAME,E.SEGMENT1 ,C.PAYMENT_NUM,C.HOLD_FLAG,
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
A.APPROVAL_STATUS,
A.APPROVAL_DESCRIPTION,
C.AMOUNT_REMAINING,
C.DUE_DATE ,
C.CHECKRUN_ID
UNION
SELECT F.NAME,
A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2, E.VENDOR_NAME,E.SEGMENT1 AS "VENDOR NUMBER",C.PAYMENT_NUM,C.HOLD_FLAG AS "SCHEDULE LEVEL HOLD",
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
C.AMOUNT_REMAINING,
C.DUE_DATE,
0,
C.CHECKRUN_ID AS "SELECTED FOR PAYMENT"
FROM AP_INVOICES_ALL A,
FND_USER B,
AP_PAYMENT_SCHEDULES_ALL C,
AP_HOLDS_ALL D,
PO_VENDORS E,
HR_ORGANIZATION_UNITS F
WHERE A.ORG_ID=&ORG_ID
AND A.CREATED_BY=B.USER_ID
AND A.INVOICE_ID=C.INVOICE_ID
AND A.VENDOR_ID=E.VENDOR_ID
AND A.ORG_ID=F.ORGANIZATION_ID
AND A.INVOICE_ID=D.INVOICE_ID(+)
AND D.RELEASE_LOOKUP_CODE IS NOT NULL
AND D.INVOICE_ID NOT IN (SELECT INVOICE_ID FROM AP_HOLDS_ALL WHERE RELEASE_LOOKUP_CODE IS NULL)
AND E.VENDOR_NAME NOT LIKE 'COLT%'
AND E.VENDOR_NAME NOT LIKE 'COLT%'
GROUP BY F.NAME,A.INVOICE_ID, A.INVOICE_NUM,A.ATTRIBUTE2,E.VENDOR_NAME,E.SEGMENT1 ,C.PAYMENT_NUM,C.HOLD_FLAG,
A.PAYMENT_CURRENCY_CODE,
A.PAY_GROUP_LOOKUP_CODE,
C.PAYMENT_METHOD_LOOKUP_CODE,
A.PAYMENT_STATUS_FLAG,
A.CREATED_BY,B.USER_NAME,
A.INVOICE_AMOUNT,
A.AMOUNT_PAID,
A.INVOICE_DATE,
A.INVOICE_RECEIVED_DATE,
A.TERMS_DATE,
A.WFAPPROVAL_STATUS,
A.APPROVAL_STATUS,
A.APPROVAL_DESCRIPTION,
C.AMOUNT_REMAINING,
C.DUE_DATE ,
C.CHECKRUN_ID
ORDER BY 1
No comments :
Post a Comment