Showing posts with label AP. Show all posts
Showing posts with label AP. Show all posts
 SELECT DISTINCT
       PAPF.FULL_NAME APPROVED_BY
     , AIAH.APPROVER_COMMENTS
     , TO_CHAR(AIAH.LAST_UPDATE_DATE,'DD-MON-YYYY') APPROVAL_DATE
     , APPROVAL_HISTORY_ID
FROM
       AP_INV_APRVL_HIST_ALL AIAH
     , FND_USER              FUS
     , PER_ALL_PEOPLE_F      PAPF
WHERE
       INVOICE_ID          = :INVOICE_ID
       AND RESPONSE        = 'APPROVED'
       AND AIAH.CREATED_BY = FUS.USER_ID
       AND FUS.EMPLOYEE_ID = PAPF.PERSON_ID
 Select distinct
       AIA.INVOICE_NUM
     , AIA.INVOICE_DATE
     , JTD.TAX_CATEGORY_NAME GST_TAX_CAT
     , JTD.LINE_AMT
from
       APPS.JAI_TAX_DET_FCT_LINES_V JTD
     , AP_INVOICES_ALL              AIA
where
       AIA.INVOICE_ID               =:P_INVOICE_ID
       and JTD.TRX_NUMBER           = AIA.INVOICE_NUM
       and JTD.TAX_CATEGORY_NAME like 'GST%'
 SELECT
       JAW.REGIME_CODE
     , JAW.ACTUAL_SECTION_CODE
     , JAI.TDS_TAX_RATE
     , JAW.TAX_AMOUNT
     , JAW.PROCESS_MESSAGE
     , (
              SELECT
                     CONCATENATED_SEGMENTS
              FROM
                     GL_CODE_COMBINATIONS_KFV
              WHERE
                     CODE_COMBINATION_ID=DIST_CODE_COMBINATION_ID
       )
       ACCOUNT
     , JTC.TAX_CATEGORY_NAME
     , JCT.TAX_NAME
FROM
       JAI_AP_WTHLD_INV_TAXES JAW
     , JAI_TAX_CATEGORIES     JTC
     , JAI_CMN_TAXES_ALL      JCT
     , JAI_AP_TDS_INVOICES    JAI
WHERE
       JAI.INVOICE_ID         =JAW.INVOICE_ID
       AND JAI.INVOICE_ID     = :P_INVOICE_ID
       AND JAW.TAX_CATEGORY_ID=JTC.TAX_CATEGORY_ID
       AND JCT.TAX_ID         =JAW.TAX_TYPE_ID

SELECT DISTINCT

       hold_date

     , hold_lookup_code

     , hold_reason

FROM

       ap_holds_all

WHERE

       invoice_id     = :P_INVOICE_ID

       and STATUS_FLAG='S'

SELECT DISTINCT
       AILA.LINE_TYPE_LOOKUP_CODE LINE_TYPE
     , AILA.DESCRIPTION           INV_LINE_DESCRIPTION
     , (
              SELECT DISTINCT
                     SEGMENT1
              FROM
                     PO_HEADERS_ALL PHA
              WHERE
                     AILA.PO_HEADER_ID=PHA.PO_HEADER_ID
       )
       PO_NUM
     , (
              SELECT DISTINCT
                     TYPE_LOOKUP_CODE
              FROM
                     PO_HEADERS_ALL PHA
              WHERE
                     AILA.PO_HEADER_ID=PHA.PO_HEADER_ID
       )
       PO_TYPE
     , (
              SELECT DISTINCT
                     COMMENTS
              FROM
                     PO_HEADERS_ALL PHA
              WHERE
                     AILA.PO_HEADER_ID=PHA.PO_HEADER_ID
       )
       PO_DESCRIPTION
     , (
              SELECT DISTINCT
                     CREATION_DATE
              FROM
                     PO_HEADERS_ALL PHA
              WHERE
                     AILA.PO_HEADER_ID=PHA.PO_HEADER_ID
       )
            PO_CREATION_DATE
     , NULL NULL_RECEIPT_NUM
     , (
              SELECT DISTINCT
                     LOCATION_CODE
              FROM
                     HR_LOCATIONS HL
              WHERE
                     AILA.SHIP_TO_LOCATION_ID=HL.LOCATION_ID
       )
                                  SHIP_TO
     , NULL                       QTY_AP_LINES
     , NULL                       RATE_AP_LINES
     , AILA.AMOUNT                LINE_AMOUNT
     , APDA.LINE_TYPE_LOOKUP_CODE DIST_TYPE
     , APDA.DESCRIPTION           DIST_DESCRIPTION
     , (
              SELECT DISTINCT
                     CONCATENATED_SEGMENTS
              FROM
                     GL_CODE_COMBINATIONS_KFV
              WHERE
                     APDA.DIST_CODE_COMBINATION_ID=CODE_COMBINATION_ID
       )
                   CHARGE_ACCOUNT
     , APDA.AMOUNT DIST_AMOUNT
     , (
              SELECT DISTINCT
                     SEGMENT1
              FROM
                     PA_PROJECTS
              WHERE
                     PROJECT_ID=APDA.PROJECT_ID
       )
       PROJECT
     , (
              SELECT DISTINCT
                     NAME
              FROM
                     PA_PROJECTS
              WHERE
                     PROJECT_ID=APDA.PROJECT_ID
       )
       PROJECT_NAME
     , (
              SELECT DISTINCT
                     DESCRIPTION
              FROM
                     PA_PROJECTS
              WHERE
                     PROJECT_ID=APDA.PROJECT_ID
       )
       PROJECT_DESC
     , (
              SELECT DISTINCT
                     TASK_NAME
              FROM
                     PA_TASKS
              WHERE
                     TASK_ID=APDA.TASK_ID
       )
       TASK
     , APDA.EXPENDITURE_TYPE
     , (
              SELECT DISTINCT
                     NAME
              FROM
                     HR_ORGANIZATION_UNITS
              WHERE
                     APDA.EXPENDITURE_ORGANIZATION_ID=ORGANIZATION_ID
       )
                                                   EXPENDITURE_ORGANIZATION
     , TO_CHAR(APDA.ACCOUNTING_DATE,'DD-MON-YYYY') ACCOUNTING_DATE
FROM
       AP_INVOICES_ALL              AIA
     , AP_INVOICE_LINES_ALL         AILA
     , AP_INVOICE_DISTRIBUTIONS_ALL APDA
WHERE
       APDA.INVOICE_ID(+) = AILA.INVOICE_ID
       AND AIA.INVOICE_ID =AILA.INVOICE_ID
       AND AIA.INVOICE_ID =NVL(:P_INVOICE_NUM,AIA.INVOICE_NUM)
       AND AIA.INVOICE_DATE BETWEEN NVL(TO_DATE(:P_DATE_FROM,'YYYY/MM/DD HH24:MI:SS'),AIA.INVOICE_DATE) AND NVL(TO_DATE(:P_DATE_TO,'YYYY/MM/DD HH24:MI:SS'),AIA.INVOICE_DATE)


TCA

Sr. No.

Detail

API Name 

Module

1

Create Customer Account

HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT

TCA

2

Create a Customer Account Relationship API 

HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCT_RELATE

TCA

3

API to update a Customer Account Relationship TCA R12 

HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCT_RELATE

TCA

4

API to Update a Customer Account TCA R12 

HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT

TCA

5

Create Customer Profile

HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUSTOMER_PROFILE

TCA

6

API to Create a Customer Site TCA R12 

HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE

TCA

7

API to Create a Customer Site Use TCA R12

HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE

TCA

8

API to Create a Party Site TCA R12

HZ_PARTY_SITE_V2PUB.CREATE_PARTY_SITE

TCA

9

API to Create a Party Site Use TCA R12 

HZ_PARTY_SITE_V2PUB.CREATE_PARTY_SITE_USE

TCA

10

API to create a Person Type Party and Customer Account

HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT

TCA

11

API to Create a Phone Number (Contacts) TCA R12 

HZ_CONTACT_POINT_V2PUB.CREATE_CONTACT_POINT

TCA

12

API to create customer Addresses in TCA R12

HZ_LOCATION_V2PUB.CREATE_LOCATION

TCA

13

API to create Group in TCA R12

HZ_PARTY_V2PUB.CREATE_GROUP

TCA

14

API to populate loc_id HZ_LOCATIONS R12

HZ_TAX_ASSIGNMENT_V2PUB. CREATE_LOC_ASSIGNMENT

TCA

15

API to update a Customer Profile TCA R12 

HZ_CUSTOMER_PROFILE_V2PUB.UPDATE_CUSTOMER_PROFILE

TCA

16

API to Update Customer Address in Oracle TCA R12

HZ_LOCATION_V2PUB.UPDATE_LOCATION

TCA

17

Assign Receipt method to Customer via API 

hz_payment_method_pub.create_payment_method

TCA

18

Create Party of type Organization in Oracle TCA using API

hz_party_v2pub.create_organization

TCA

AP

19

API to apply hold on AP invoice in R12

AP_HOLDS_PKG.INSERT_SINGLE_HOLD

AP

20

API to cancel single AP invoice

AP_CANCEL_PKG.AP_CANCEL_SINGLE_INVOICE

AP

21

API to find AP INVOICE Status

 AP_INVOICES_PKG.GET_APPROVAL_STATUS

AP

22

API to release hold on AP invoice in R12

AP_HOLDS_PKG.RELEASE_SINGLE_HOLD

AP

23

Credit Memo Creation via API

 ar_credit_memo_api_pub.create_request 

AP

24

API to create Supplier in R12

pos_vendor_pub_pkg.Create_Vendor

AP

25

API to create supplier site in R12

pos_vendor_pub_pkg.create_vendor_site

AP

26

API to create or update Supplier Hub UDA attr

pos_vendor_pub_pkg.process_user_attrs_data

 

PO

27

API for Cancelling the Purchase Order (PO) Document 

PO_DOCUMENT_CONTROL_PUB.CONTROL_DOCUMENT

PO

28

API to Update Purchase Order Document (PO)

PO_CHANGE_API1_S.UPDATE_PO

PO

AOL

29

API to load value in value set

FND_FLEX_VALUES_PKG.LOAD_ROW

AOL

30

API to submit concurrent program

fnd_request.submit_request

AOL

 

 SQL Query To find the PO Vendor Name from the Purchase Order 

select ASP.* from PO_HEADERS_ALL PHA,AP_SUPPLIERS ASP
WHERE PHA.VENDOR_ID=ASP.VENDOR_ID 
AND PHA.SEGMENT1=:PO_NUMBER
AND PHA.ORG_ID=:ORG_ID


SQL Query To find the PO Vendor SITE from the Purchase Order 


select ASSA.* 
from PO_HEADERS_ALL PHA,
AP_SUPPLIER_SITES_ALL ASSA
WHERE PHA.VENDOR_SITE_ID=ASSA.VENDOR_SITE_ID
AND PHA.SEGMENT1=:PO_NUMBER
AND PHA.ORG_ID=:ORG_ID


SQL Query To find the PO Matching AP Invoice Numbers from the Purchase Order


select * 
from ap_invoice_lines_all aila,
ap_invoices_all aia,
po_headers_all pha
where aila.po_header_id=pha.po_header_id
and aila.invoice_id=aia.invoice_id
and pha.segment1=:PO_NUMBER

 Base Tables in Oracle Payables(AP):


The base tables in AP are as follows:


1) AP_INVOICES_ALL

2) AP_INVOICE_PAYMENTS_ALL

3) AP_INVOICE_DISTRIBUTIONS_ALL

4) AP_PAYMENT_SCHEDULES_ALL

5)AP_PAYMENT_HISTORY_ALL 

6)AP_CHECKS_ALL

7) AP_HOLDS_ALL 

8) AP_AE_LINES_ALL

9) AP_AE_HEADERS_ALL



1) AP_INVOICES_ALL:

AP_INVOICES_ALL contains records for invoices you enter. There is one row for each invoice you enter. An invoice can have one or more invoice distribution lines. An invoice can also have one or more scheduled payments.

An invoice of type EXPENSE REPORT must relate to a row in  AP_EXPENSE_REPORT_HEADERS_ALL unless the record has been purged from AP_EXPENSE_REPORT_HEADERS_ALL. Your Oracle Payables application uses the INTEREST type invoice for interest that it calculates on invoices that are overdue. Your Oracle Payables application links the interest invoice to the original invoice by inserting the INVOICE_ID in the AP_INVOICE_RELATIONSHIPS table.



2) AP_INVOICE_PAYMENTS_ALL:

AP_INVOICE_PAYMENTS_ALL contains records of invoice payments that you made to suppliers. There is one row for each payment you make for each invoice. There is one payment and one invoice for each payment in this table. Your Oracle Payables application updates this table when you confirm an automatic payment batch, enter a manual payment, or process a Quick payment. When you void a payment, your Oracle Payables application inserts an additional payment line that is the negative of the original payment line.

Values for POSTED_FLAG may be 'Y' for accounted payments or 'N' for unaccounted payments. Values for ACCRUAL_POSTED_FLAG may be 'Y' for accounted payments or 'N' for unaccounted payments under accrual basis accounting; values for CASH_POSTED_FLAG

may be 'Y' for accounted payments or 'N' for unaccounted payments under cash basis accounting.For manual payments and Quick payments, this table corresponds to the Select Invoices window in the Payment workbench.



 3) AP_INVOICE_DISTRIBUTIONS_ALL:

AP_INVOICE_DISTRIBUTIONS_ALL holds the distribution information that is manually entered or system-generated. There is one row for each invoice distribution. A distribution must be associated with an invoice. An invoice can have multiple distributions. 

 

4)AP_PAYMENT_SCHEDULES_ALL:

AP_PAYMENT_SCHEDULES_ALL contains information about scheduled payments for an invoice. You need one row for each time you intend to make a payment on an invoice. Your Oracle Payables application uses this information to determine when to make payments on an invoice and how much to pay in an automatic payment batch. Values for HOLD_FLAG may be ’Y’ to place a hold on the scheduled payment, or ’N’ not to do so. Values for PAYMENT_STATUS_FLAG may be ’Y’ for fully paid payment schedules, ’N’ for unpaid scheduled payments, or ’P’ for partially paid scheduled payments. For converted records, enter a value for AMOUNT_REMAINING.


5) AP_PAYMENT_HISTORY_ALL:

AP_PAYMENT_HISTORY_ALL stores the clearing/unclearing history for payments. It also stores the maturity history for future dated payments. The table contains a row for each future dated payment, once the future dated payment matures, i.e. becomes negotiable. Any time a payment is cleared or uncleared, a row is inserted into this table for the payment. The values for TRANSACTION_TYPE can be PAYMENT MATURITY, PAYMENT CLEARING, or PAYMENT UNCLEARING. Each row in this table also has the accounting status for the maturity, clearing or unclearing event. 


6) AP_CHECKS_ALL:

AP_CHECKS_ALL stores information about payments issued to suppliers or refunds received from suppliers.  You need one row for each payment you issue to a supplier or refund received from a supplier. Your Oracle Payables application uses this information to record payments you make to suppliers or refunds you receive from suppliers. Your Oracle Payables application stores the supplier name and bank account name for auditing purposes, in case either one is changed after you create the payment. Your Oracle Payables application stores address information for all payments. If you allow changes to the supplier payment address on manual payments or Quick payments, your Oracle Payables application maintains the new address information in this table. Your Oracle Payables application uses BANK_ACCOUNT_NUM, BANK_NUM, and BANK_ACCOUNT_TYPE for the supplier's bank information when you use the Electronic payment method. Your Oracle Payables application stores a dummy value for CHECK_STOCK_ID for refunds, thus, CHECK_STOCK_ID should not be treated as a foreign key to AP_CHECK_STOCKS_ALL in the case of refunds.


7) AP_HOLDS_ALL:

AP_HOLDS_ALL contains information about holds that you or your Oracle Payables application place on an invoice. For non–matching holds, there is one row for each hold placed on an invoice. For matching holds, there is one row for each hold placed on an invoice–shipment match. An invoice may have one or more corresponding rows in this table. Your Oracle Payables application does not pay invoices that have one or more unreleased holds recorded in this table. This table holds information referenced by the Invoice Holds window. In the strictest sense, AP_HOLDS_ALL has no primary key. It is possible for your Oracle Payables application to place a certain type of hold on an invoice, then release it, then place another hold of the same type (if data changes before each submission of Approval), which would result in a duplicate primary key. But for practical purposes, the primary key is a concatenation of INVOICE_ID, LINE_LOCATION_ID,and HOLD_LOOKUP_CODE.


8) AP_AE_LINES_ALL:

An accounting entry line is an entity containing a proper accounting entry with debits or credits both in transaction currency as well as functional currency along with an account and other reference information pointing to the transaction data that originated the accounting entry line. An accounting entry line is grouped with other accounting entry lines for a specific accounting entry header. Any such group of accounting entry lines should result in balanced entries in the functional currency.


9)AP_AE_HEADERS_ALL:

An accounting entry header is an entity grouping all accounting entry lines created for a given accounting event and a particular set of books. An accounting entry header can either be transferred over to GL or not at all. That is, either all its accounting entry lines are transferred or none at all. The transferred to GL status is marked in the GL_TRANSFER_FLAG. Possible values for GL_TRANSFER_FLAG are Y, N, or E. Y indicates that the accounting entry header has been transferred to GL. N indicates that the accounting entry header has not been transferred to GL due to 2 possible reasons: either the transfer process has not run or it has run but the accounting entry had an accounting error on it. E indicates that an error was encountered during the transfer to GL process.

 Task:

How to find a AP invoice is validated or not through a SQL query

Script:
SELECT i.invoice_id,
       i.invoice_amount,
       DECODE(APPS.AP_INVOICES_PKG.GET_APPROVAL_STATUS(i.invoice_id, i.invoice_amount,i.payment_status_flag,i.invoice_type_lookup_code),
               'NEVER APPROVED', 'Never Validated',
               'NEEDS REAPPROVAL', 'Needs Revalidation',
               'CANCELLED', 'Cancelled',
               'Validated') INVOICE_STATUS
  FROM ap_invoices_all i
 WHERE i.invoice_num = '&Invoice_Number';


Notes:
Invoice Distributions are validated individually and the status is stored at AP_INVOICE_DISTRIBUTIONS_ALL.match_status_flag

Validated
- If ALL of the invoice distributions have a MATCH_STATUS_FLAG = 'A'
- If MATCH_STATUS_FLAG is 'T' on ALL the distributions and org has no encumbrance enabled then Invoice would show Validated (provided there is no Unreleased Hold)
Never Validated
- If all of the invoice distributions have a MATCH_STATUS_FLAG = null or 'N'
Needs Re-validation
- If any of the invoice distributions have a MATCH_STATUS_FLAG = 'T' and the org has Encumbrance enabled
- If the invoice distributions have MATCH_STATUS_FLAG values = 'N', null and 'A' (mixed)
- If the invoice distributions have MATCH_STATUS_FLAG value = 'S' (stopped)
- If there are any rows in AP_HOLDS that do not have a release code

MATCH_STATUS_FLAG would remain 'T' if invoice has hold which does not allow Accounting.
As soon as Hold is released from Holds Tab/Invoice Workbench event status is set to 'U'.
Invoice is shown as Validated and accounting is allowed. Match_Status_Flag still remains 'T'.


AP_INV_APRVL_HIST_ALL table will give you all the details related to approval of particular invoice.


Query to get the latest transaction on particular invoice :


select created_by from AP_INV_APRVL_HIST_ALL

where invoice_id = &inv_id

and approval_history_id =

(select max(approval_history_id)   from AP_INV_APRVL_HIST_ALL 

   where invoice_id = &inv_id 

)


Query to get the Initiator of particular invoice :


select created_by from AP_INV_APRVL_HIST_ALL

where invoice_id = &inv_id

and approval_history_id =

(select min(approval_history_id) from AP_INV_APRVL_HIST_ALL 

 where invoice_id = &inv_id 

)