SELECT hp.party_name
customer_name, rt.NAME
payment_terms,       
      
sum(lgd.amount)
  FROM
ra_customer_trx_all rct,
      
ra_cust_trx_types_all rctt,
      
hz_cust_accounts_all hca,
      
ra_customer_trx_lines_all rctl,
      
ra_customer_trx_lines_all tax_rctl,
      
ra_customer_trx_lines_all fr_rctl,
      
ra_terms rt,
      
hz_parties hp,
      
ra_cust_trx_line_gl_dist_all lgd,
      
ra_customer_trx_lines ctl_line,
      
ar_lookups al_class,
      
ar_lookups al_type,
      
ra_rules rr
 WHERE rctt.cust_trx_type_id
= rct.cust_trx_type_id
   AND rct.sold_to_customer_id
= hca.cust_account_id
   AND rct.customer_trx_id
= rctl.customer_trx_id
   AND
tax_rctl.customer_trx_id(+) = rct.customer_trx_id
   AND
tax_rctl.line_type(+) = 'TAX'
   AND
fr_rctl.customer_trx_id(+) = rct.customer_trx_id
   AND
fr_rctl.line_type(+) = 'FREIGHT'
   AND hca.account_number
= 12345
   AND rct.trx_date
between to_date('01-JAN-2015','DD-MON-YYYY') and to_date('30-JUN-2015','DD-MON-YYYY')
   AND rct.term_id
= rt.term_id
   AND hp.party_id
= hca.party_id
   AND lgd.customer_trx_line_id
= rctl.customer_trx_line_id (+)
   --AND
rct.customer_trx_id = 7451947
   AND rctl.link_to_cust_trx_line_id
= ctl_line.customer_trx_line_id(+)
   AND
al_class.lookup_type = 'AUTOGL_TYPE'
   AND
al_class.lookup_code = lgd.account_class
   AND
al_type.lookup_type (+)= 'STD_LINE_TYPE'
   AND al_type.lookup_code
(+) = rctl.line_type
   AND rctl.accounting_rule_id
= rr.rule_id (+)
   AND lgd.account_class
= 'REV'   
   group by hp.party_name, rt.NAME
No comments:
Post a Comment