Thursday, 16 July 2020

Query to find Credit memo and debit memo of a particular Order

select rca_cm.interface_header_attribute1 so_number,rca_cm.trx_number cm_number, rca_dm.trx_number dm_number,ps_cm.AMOUNT_DUE_ORIGINAL cm_amt_original, ps_cm.amount_due_remaining cm_amt_due_remaining, ps_dm.AMOUNT_DUE_ORIGINAL dm_amt_original, ps_dm.amount_due_remaining dm_amt_remaining
 from apps.ra_customer_trx_all rca_cm
    , apps.ra_customer_trx_all rca_dm   
    , apps.RA_CUST_TRX_TYPES_ALL  rtt_cm
    , apps.RA_CUST_TRX_TYPES_ALL  rtt_dm
    , apps.AR_PAYMENT_SCHEDULES_ALL ps_cm
    , apps.AR_PAYMENT_SCHEDULES_ALL ps_dm
 where rca_cm.interface_header_attribute1 = '40642183'
 and   rca_cm.org_id=rtt_cm.org_id
 and   rtt_cm.type='CM'
 and   rca_cm.cust_trx_type_id=rtt_cm.CUST_TRX_TYPE_ID
 and   rca_cm.interface_header_attribute1=rca_dm.interface_header_attribute1
 and   rtt_dm.type='DM'
 and   rca_dm.org_id=rtt_dm.org_id
 and   rca_dm.cust_trx_type_id=rtt_dm.CUST_TRX_TYPE_ID
 and   ps_cm.class='CM'
 and   ps_cm.status='OP'
 and   ps_cm.customer_trx_id=rca_cm.customer_trx_id
 and   ps_dm.class='DM'
 and   ps_dm.status='OP'
 and   ps_dm.customer_trx_id=rca_dm.customer_trx_id

No comments:

Post a Comment