You are on page 1of 3

Un-invoiced receipts table

SELECT poh.segment1 po_number,


porl.release_num po_release_number,
poh.po_header_id po_header_id,
pol.po_line_id po_line_id,
cpea.shipment_id po_shipment_id,
cpea.distribution_id po_distribution_id,
plt.line_type line_type,
pol.line_num line_num,
msi.concatenated_segments item_name,
mca.concatenated_segments category,
pol.item_description item_description,
pov.vendor_name vendor_name,
fnc2.currency_code accrual_currency_code,
poll.shipment_num shipment_number,
poll.unit_meas_lookup_code uom_code,
pod.distribution_num distribution_num,
ROUND(cpea.unit_price, NVL(fnc2.precision, 2)) po_unit_price,
cpea.currency_code po_currency_code,
ROUND(DECODE(NVL(fnc1.minimum_accountable_unit, 0), 0, cpea.unit_price *
cpea.currency_conversion_rate, (cpea.unit_price / fnc1.minimum_accountable_unit) *
cpea.currency_conversion_rate * fnc1.minimum_accountable_unit), NVL(fnc1.precision, 2))
func_unit_price,
gcc1.concatenated_segments charge_account,
gcc2.concatenated_segments accrual_account
FROM
(SELECT pod.po_distribution_id distribution_id,
poll.line_location_id shipment_id,
DECODE(poll.matching_basis, 'AMOUNT', 1, 0) service_flag,
DECODE (poll.matching_basis, 'AMOUNT', pod.amount_ordered - NVL(pod.amount_cancelled,
0), pod.quantity_ordered - NVL(pod.quantity_cancelled, 0)) distribution_quantity,
DECODE (poll.matching_basis, 'AMOUNT', pod.amount_ordered, pod.quantity_ordered)
quantity_ordered,
DECODE(poll.matching_basis, 'AMOUNT', poll.amount - NVL(poll.amount_cancelled, 0),
poll.quantity - NVL(poll.quantity_cancelled,0)) shipment_quantity,
DECODE(poll.matching_basis, 'AMOUNT', 1, NVL(poll.price_override, pol.unit_price)) unit_price,
NVL(poll.match_option,'P') match_option,
pol.category_id category_id,
poh.currency_code currency_code,
NVL(NVL(pod.rate,poh.rate),1) currency_conversion_rate,
poh.rate_type curr_conv_type,
pod.rate_date currency_conv_date
FROM po_distributions_all pod,
po_line_locations_all poll,
po_lines_all pol,
po_headers_all poh,
po_vendors pov,
mtl_categories_kfv mca,
mtl_default_sets_view mds
WHERE pol.po_header_id = poh.po_header_id
AND poll.po_line_id = pol.po_line_id
AND pod.line_location_id = poll.line_location_id
AND poh.type_lookup_code IN ('STANDARD', 'BLANKET','PLANNED')
AND poh.vendor_id = pov.vendor_id
Un-invoiced receipts table
AND pod.org_id =
&org_id
AND
pol.category_id =
mca.category_id
AND
mds.structure_id =
mca.structure_id
AND
mds.functional_area_id
=2
AND
poll.shipment_type <>
'PREPAYMENT'
AND
(poll.closed_date IS
NULL
OR
poll.closed_date >
TO_DATE('&end_date','DD-MM-YYYY') )
AND
(NVL(poll.accrue_on_receipt_flag,'N')
= 'N'
AND
pod.destination_type_code
= 'EXPENSE' )
AND DECODE (poll.matching_basis, 'AMOUNT', pod.amount_ordered -
NVL(pod.amount_cancelled, 0), pod.quantity_ordered - NVL(pod.quantity_cancelled, 0)) > 0
AND DECODE(poll.matching_basis, 'AMOUNT', poll.amount - NVL(poll.amount_cancelled, 0),
poll.quantity - NVL(poll.quantity_cancelled,0)) >0
AND EXISTS
(SELECT 'Get a receipt/match for this shipment'
FROM rcv_transactions rvt
WHERE rvt.po_line_location_id = poll.line_location_id
AND rvt.transaction_type IN ('RECEIVE','MATCH')
AND rvt.transaction_date <= TO_DATE('&end_date','DD-MM-YYYY')
)
)cpea,
po_headers_all poh,
po_lines_all pol,
po_line_locations_all poll,
po_distributions_all pod,
po_vendors pov,
po_line_types plt,
po_releases_all porl,
mtl_system_items_kfv msi,
fnd_currencies fnc1,
fnd_currencies fnc2,
mtl_categories_kfv mca,
gl_code_combinations_kfv gcc1,
gl_code_combinations_kfv gcc2,
gl_sets_of_books sob,
financials_system_params_all fsp
Un-invoiced receipts table
WHERE pod.po_distribution_id = cpea.distribution_id
AND poh.po_header_id = pol.po_header_id
AND pol.po_line_id = poll.po_line_id
AND poll.line_location_id = pod.line_location_id
AND pol.line_type_id = plt.line_type_id
AND porl.po_release_id = poll.po_release_id
AND poh.vendor_id = pov.vendor_id
AND msi.inventory_item_id = pol.item_id
AND (msi.organization_id IS NULL
OR (msi.organization_id = poll.ship_to_organization_id
AND msi.organization_id IS NOT NULL))
AND fnc1.currency_code = cpea.currency_code
AND fnc2.currency_code = sob.currency_code
AND cpea.category_id = mca.category_id
AND gcc1.code_combination_id = pod.code_combination_id
AND gcc2.code_combination_id = pod.accrual_account_id
AND sob.set_of_books_id = fsp.set_of_books_id
AND fsp.org_id =
&&org_id;

You might also like