Sunday 19 December 2021

PO Accrual SQL Query in Oracle Fusion

PO Accrual SQL Query in Oracle Fusion

Hi friends, we are going to discuss the PO accrual sql query in oracle fusion. We will share the detail sql query which helps to extract the complete PO accrual information's in oracle fusion. PO accrual report is one of the most important reports in financials but to develop this report is too difficult. To develop the PO accrual report, we need to put lots of efforts in query building as well the reconciliation work too. First of all , let us explain you the purpose of PO accrual report and which type of data it capture in oracle fusion application.

PO Accrual SQL Query in Oracle Fusion
PO Accrual SQL Query in Oracle Fusion


PO Accrual Report Logic :-

The simple cycle of P2P is , We do create the Purchase Orders , Once PO got approved we send the PO to supplier. Supplier send the Material to us. When PO material comes to our organization . we do PO receiving against the purchase order , then after receiving we need to punch the AP invoice in oracle fusion application. 

In PO accrual report, It captures those PO receipts against which we have not booked the AP Invoice. In simple language those receipts against which we have not yet punched the AP invoices. PO accrual report helps to find out those receipts which is not yet billed or created invoice against that so that finance department can take the action to punch these missed invoices for these suppliers.



Detail PO Accrual SQL Query to extract the Accrual data in Oracle Fusion Application

Here below is the PO accrual sql query which helps to extract the accrual information's details in oracle fusion application. You can use this report to develop the PO accrual report in oracle fusion application.

select
 cmr_po_distribution_id,
  received_qty,
   RECEIVED_AMOUT,
   received_amout_func_currency,
    INVOICED_AMT,
     invoice_amt_func_curr,
    invoice_variance_amt_func_curr,
     invoiced_qty,
    uninvoiced_qty,
    UNINVOICED_AMT,
    sold_to_business_unit_id,
    business_unit_name,
    leger_name,
    func_currency,
     category_code,
     category_name,
     inventory_item_id,
     item_code,
     description,
     deliver_to_inventory_org_id,
     destination_org,
     vendor_id,
receipt_num,
receipt_date,
quantity_shipped,
quantity_received,
quantity_delivered,
quantity_returned,
quantity_accepted,
quantity_rejected,
po_unit_price,
(quantity_shipped * po_unit_price) shipped_amt,
(quantity_received * po_unit_price) received_amt,
(quantity_delivered * po_unit_price) delivered_amt,
(quantity_returned * po_unit_price) returned_amt,
(quantity_accepted * po_unit_price) accepted_amt,
(quantity_rejected * po_unit_price) rejected_amt,
     vendor_name,
      vendor_site_id,
      party_site_name,
      category_id,
      po_number,
    line_number,
    shipment_number,
     distribution_number,
     CURRENCY_CODE,
    LINE_TYPE,
     po_price,
    price_func_currency,
     amt_func_curr,
     UOM_CODE,
     UOM_CODE1,
     CURRENCY_CONVERSION_TYPE,
    currency_conversion_rate,
    currency_conversion_date,
    po_quantity,
    PO_AMOUNT,
    po_amount_func_currency
from (select  b.cmr_po_distribution_id,
      decode(b.purchase_basis, 'GOODS', sum(nvl(b.source_doc_qty,0)), 0) as received_qty,
      DECODE(B.PURCHASE_BASIS, 'GOODS', (SUM(NVL(B.SOURCE_DOC_QTY,0)) * B.PO_PRICE), SUM(NVL(B.TRANSACTION_AMT,0)) ) AS RECEIVED_AMOUT,
      (decode(b.purchase_basis, 'GOODS', (sum(nvl(b.source_doc_qty,0)) * b.po_price), SUM(NVL(b.transaction_amt,0)) ))*(nvl(b.currency_conversion_rate, 1)) as received_amout_func_currency,
      SUM(NVL(B.INVOICED_AMT, 0)) AS INVOICED_AMT,
      SUM(NVL(B.invoice_amt_func_curr, 0)) AS invoice_amt_func_curr,
      SUM(NVL(B.invoice_variance_amt_func_curr, 0)) as invoice_variance_amt_func_curr,
      decode(b.purchase_basis, 'GOODS', sum(nvl(b.invoiced_qty, 0)), 0) as invoiced_qty,
      decode(b.purchase_basis, 'GOODS', sum(nvl(b.source_doc_qty,0)) - sum(nvl(b.invoiced_qty, 0)), 0) as uninvoiced_qty,
      DECODE(B.PURCHASE_BASIS, 'GOODS', (SUM(NVL(B.SOURCE_DOC_QTY,0)) * B.PO_PRICE - SUM(NVL(B.INVOICED_AMT, 0))),
      (SUM(NVL(B.TRANSACTION_AMT,0)) - SUM(NVL(B.INVOICED_AMT, 0)))) UNINVOICED_AMT,
      b.sold_to_business_unit_id,
      fabu.bu_name AS business_unit_name,
      lgr.name as leger_name,
      lgr.currency_code AS func_currency,
      ecv.category_code,
      ecv.category_name,
      b.inventory_item_id,
      esi.item_number AS item_code,
      nvl(esi.description,b.item_description) AS description,
      b.deliver_to_inventory_org_id,
      iod.organization_name AS destination_org,
      b.vendor_id,
(select receipt_num from rcv_shipment_headers
 a1,rcv_shipment_lines a2 where a1.shipment_header_id=a2.shipment_header_id and a2.po_line_id=(select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number ) and rownum=1) receipt_num,
(select gl_date from rcv_shipment_headers
 a1,rcv_shipment_lines a2 where a1.shipment_header_id=a2.shipment_header_id and a2.po_line_id=(select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number ) and rownum=1) receipt_date,
(select sum(a2.quantity_shipped) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_shipped,
(select sum(a2.quantity_received) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_received,
(select sum(a2.quantity_delivered) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_delivered,
(select sum(a2.quantity_returned) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_returned,
(select sum(a2.quantity_accepted) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_accepted,
(select sum(a2.quantity_rejected) from rcv_shipment_lines a2 where a2.po_line_id in (select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) quantity_rejected,
(select unit_price from po_lines_all where po_line_id=(select po_line_id from po_headers_all pha,po_lines_all pla
where pha.po_header_id=pla.po_header_id
and pha.segment1=b.po_number
and pla.line_num=b.line_number )) po_unit_price,
      psv.vendor_name,
      b.vendor_site_id,
      pssv.vendor_site_code party_site_name,
      b.category_id,
      b.po_number,
      b.line_number,
      b.shipment_number,
      b.distribution_number,
      B.CURRENCY_CODE,
      decode(B.LINE_TYPE,'GOODS','Goods','SERVICES','Services',B.LINE_TYPE) as LINE_TYPE,
      b.po_price,
      b.po_price * nvl(b.currency_conversion_rate, 1) as price_func_currency,
      DECODE(b.purchase_basis, 'SERVICES',SUM(NVL(b.transaction_amt,0))-sum(nvl(b.invoiced_amt, 0)) ,(SUM(nvl(b.source_doc_qty,0)) - sum(nvl(b.invoiced_qty, 0))) * NVL(b.po_price,0)) * nvl(b.currency_conversion_rate, 1) as amt_func_curr,
      UOM_MASTER.UNIT_OF_MEASURE UOM_CODE,
      b.uom_code UOM_CODE1,
      B.CURRENCY_CONVERSION_TYPE,
      nvl(b.currency_conversion_rate, 1) as currency_conversion_rate,
      b.currency_conversion_date,
      decode(b.purchase_basis, 'GOODS', (b.quantity_ordered - b.quantity_cancelled), 0) as po_quantity,
      DECODE(B.PURCHASE_BASIS, 'GOODS', ((B.QUANTITY_ORDERED - B.QUANTITY_CANCELLED) * NVL(PO_PRICE,0) ), (NVL(B.AMOUNT_ORDERED, 0) - NVL(B.AMOUNT_CANCELLED,0))) AS PO_AMOUNT,
      (decode(b.purchase_basis, 'GOODS', ((b.quantity_ordered - b.quantity_cancelled) * NVL(po_price,0) ), (nvl(b.amount_ordered, 0) - nvl(b.amount_cancelled,0))))*( nvl(b.currency_conversion_rate, 1)) as po_amount_func_currency
from  cmr_r_uninv_accr_dtls_v b,
      egp_system_items_vl esi,
      egp_categories_vl ecv,
      fun_all_business_units_v fabu,
      inv_organization_definitions_v iod,
      gl_ledgers lgr,
      poz_suppliers_v psv,
      POZ_SUPPLIER_SITES_ALL_M pssv,
      inv_units_of_measure_vl uom_master,
      hz_party_sites hps
      where 1=1--
      and uom_master.uom_code(+) = b.uom_code
      and   nvl(b.vendor_id, -1)        = nvl(:p_vendor_id, nvl(b.vendor_id,-1))
       AND NVL(psv.vendor_name, 1) = NVL(NVL(:p_supplier, psv.vendor_name),1)
      AND NVL(hps.party_site_name,1)  = NVL(NVL(:p_vendor_site_name, hps.party_site_name),1)
 AND hps.party_site_id  = pssv.party_site_id
      and   b.sold_to_business_unit_id = fabu.bu_id
      and   fabu.primary_ledger_id = lgr.ledger_id
      and   b.inventory_item_id = esi.inventory_item_id(+)
      and   b.deliver_to_inventory_org_id = esi.organization_id(+)
      and   b.category_id = ecv.category_id(+)
      and   b.deliver_to_inventory_org_id = iod.organization_id
      and   b.vendor_id = psv.vendor_id
      and   b.vendor_site_id = pssv.vendor_site_id
      group by  b.cmr_po_distribution_id,
     b.sold_to_business_unit_id,
     fabu.bu_name,
     lgr.name,
     lgr.currency_code,
     ecv.category_code,
     ecv.category_name,
     b.inventory_item_id,
     esi.item_number,
     esi.description,
              b.item_description,
     b.deliver_to_inventory_org_id,
     iod.organization_name,
     b.vendor_id,
     psv.vendor_name,
     b.vendor_site_id,
     pssv.vendor_site_id,
     pssv.vendor_site_code,
     b.category_id,
     b.po_number,
     b.line_number,
     b.shipment_number,
     b.distribution_number,
     b.currency_code,
     b.line_type,
     b.po_price,
     UOM_MASTER.UNIT_OF_MEASURE,
        b.uom_code,
     b.currency_conversion_type,
     b.currency_conversion_date,
     b.currency_conversion_rate,
     b.quantity_ordered,
     b.quantity_cancelled,
     b.amount_ordered,
     b.amount_cancelled,
     B.PURCHASE_BASIS

PO Accrual SQL Query in Oracle Fusion


1 comments:

Cynthia Billington said...

Impressive Thanks for the post. Usually, I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man, Keep it up. This Blog is interesting and please check out for more information Trolley Bay Kits in Australia.

Post a Comment

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *