Tuesday, 19 December 2017

Query to get AR Transactions Details

select
trx.trx_number Ref1,
to_char(trx.TRX_DATE,'DD/MM/YYYY') TRX_DATE,
hzp.party_name,
hca.account_number Account,
hca.ACCOUNT_NAME Details,
tta.NAME trx_type,
trx.PURCHASE_ORDER,
RCTL.line_number,
eitem.ITEM_NUMBER,
nvl(eitem.description ,rctl.description) LINE_DESC ,
trx.EXCHANGE_RATE,
trx.EXCHANGE_RATE_TYPE,
trx.INVOICE_CURRENCY_CODE,
trx.BR_AMOUNT,
nvl(RCTL.EXTENDED_AMOUNT,0) Goods_amount,
nvl(tax.EXTENDED_AMOUNT,0) VAT_Amount,
nvl(RCTL.EXTENDED_AMOUNT,0)+nvl(tax.EXTENDED_AMOUNT,0) Total_Value
from
ra_customer_trx_all trx,
hz_parties hzp,
hz_cust_accounts hca,
RA_CUST_TRX_TYPES_ALL tta,
ra_customer_trx_lines_all RCTL,
 egp_system_items eitem,
  ar_system_parameters_all sysp,
ra_customer_trx_lines_all tax,
hr_operating_units hou
where 1                         =1
and hzp.party_id = hca.party_id
AND hca.cust_account_id         = trx.bill_to_customer_id
and trx.CUST_TRX_TYPE_SEQ_ID = tta.CUST_TRX_TYPE_SEQ_ID
AND trx.customer_trx_id         = RCTL.customer_trx_id(+)
AND trx.complete_flag           = 'Y'
AND RCTL.LINE_TYPE              ='LINE'
AND RCTL.inventory_item_id      = eitem.inventory_item_id(+)
AND RCTL.org_id                 = sysp.org_id
AND ( (RCTL.inventory_item_id  IS NOT NULL
AND sysp.item_validation_org_id = eitem.organization_id)
OR RCTL.inventory_item_id      IS NULL)
AND trx.customer_trx_id         = tax.customer_trx_id(+)
AND (tax.LINE_TYPE               ='TAX' or tax.LINE_TYPE is null)
AND tax.LINK_TO_CUST_TRX_LINE_ID(+)=RCTL.CUSTOMER_TRX_LINE_ID
and  tta.NAME in ('Credit Memo','Invoice')
and TRX.org_id = hou.organization_id
and hou.name=<operating unit name>

No comments:

Post a Comment