Wednesday, 22 January 2020

Query to fetch Prepayment amount used from a Prepayment invoice


Query to fetch Prepayment used from a Prepayment invoice
  SELECT SUM(total_dist_amount -
         NVL(prepay_amount_remaining, total_dist_amount))
    FROM ap_invoice_distributions_all aid,
         ap_invoice_lines_all ail
   WHERE aid.invoice_id = &P_invoice_id
     AND aid.invoice_id = ail.invoice_id
     AND aid.invoice_line_number = ail.line_number
     AND ail.line_type_lookup_code <> 'TAX'
     AND aid.line_type_lookup_code IN
         ('ITEM', 'ACCRUAL', 'REC_TAX', 'NONREC_TAX')
     AND NVL(reversal_flag,'N') <> 'Y';

No comments:

Post a Comment