DBA Data[Home] [Help]

APPS.AP_INVOICE_LINES_UTILITY_PKG SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 48

      SELECT nvl(encumbered_flag,'N')
      FROM   ap_invoice_distributions
      WHERE  invoice_id = p_invoice_id
        AND  invoice_line_number = p_line_number;
Line: 58

      SELECT NVL(fsp.purch_encumbrance_flag,'N'),
             ai.org_id
        INTO l_purch_encumbrance_flag,
             l_org_id
        FROM ap_invoices_all ai,
             financials_system_params_all fsp
       WHERE ai.invoice_id = p_invoice_id
         AND ai.org_id = fsp.org_id;
Line: 116

 |      'S' - Selected
 |      'P' - Partial
 |      'N' - Unposted
 |      ---------------------------------------------------------------------
 |      -- Declare cursor to establish the invoice-level posting flag
 |      --
 |      -- The first two selects simply look at the posting flags (cash and/or
 |      -- accrual) for the distributions.  The rest is to cover one specific
 |      -- case when some of the distributions are fully posting (Y) and some
 |      -- are unposting (N).  The status should be partial (P).
 |      --
 |      -- MOAC.  Use ap_invoice_distributions_all table instead of SO view
 |      -- since this procedure is called when policy context is not set to
 |      -- the corresponding OU for the invoice_id
 |
 |  MODIFICATION HISTORY
 |  Date         Author             Description of Change
 |  28-MAY-04    yicao              SLA Obsolescence: Remove some accounting
 |                                  related options
 *============================================================================*/
   FUNCTION get_posting_status(
                 p_invoice_id   IN NUMBER,
                 p_line_number  IN NUMBER )
    RETURN VARCHAR2
    IS

      invoice_line_posting_flag           VARCHAR2(1);
Line: 149

      SELECT cash_posted_flag
      FROM   ap_invoice_distributions_all
      WHERE  invoice_id = p_invoice_id
      AND    invoice_line_number = p_line_number
      AND    l_cash_basis_flag = 'Y'
      UNION
      SELECT accrual_posted_flag
      FROM   ap_invoice_distributions_all
      WHERE  invoice_id = p_invoice_id
      AND    invoice_line_number = p_line_number
      AND    l_cash_basis_flag <> 'Y'
      UNION
      SELECT 'P'
      FROM   ap_invoice_distributions_all
      WHERE  invoice_id = p_invoice_id
      AND    invoice_line_number = p_line_number
      AND    ( (cash_posted_flag  = 'Y'
                AND l_cash_basis_flag = 'Y')
              OR
                (accrual_posted_flag = 'Y'
                 AND l_cash_basis_flag <> 'Y'))
      AND EXISTS
               (SELECT 'An N is also in the valid flags'
                FROM   ap_invoice_distributions_all
                WHERE  invoice_id = p_invoice_id
                AND    invoice_line_number = p_line_number
                AND    ((cash_posted_flag  = 'N'
                         AND l_cash_basis_flag = 'Y')
                OR
                       (accrual_posted_flag  = 'N'
                         AND l_cash_basis_flag <> 'Y')));
Line: 187

    |  MOAC.  Added org_id to select statement.                        |
    +-----------------------------------------------------------------*/
      BEGIN
      SELECT nvl(sob.sla_ledger_cash_basis_flag, 'N'),
             asp.org_id
      INTO l_cash_basis_flag,
           l_org_id
      FROM ap_invoices_all ai,
           ap_system_parameters_all asp,
           gl_sets_of_books sob
      WHERE ai.invoice_id = p_invoice_id
      AND ai.org_id = asp.org_id
      AND asp.set_of_books_id = sob.set_of_books_id;
Line: 286

      SELECT nvl(match_status_flag, 'N')
      FROM   ap_invoice_distributions_all
      WHERE  invoice_id = p_invoice_id
      AND    invoice_line_number =  p_line_number;
Line: 298

      SELECT NVL(fsp.purch_encumbrance_flag,'N'), ai.org_id
      INTO encumbrance_flag, l_org_id
      FROM ap_invoices_all ai,
           financials_system_params_all fsp
      WHERE ai.invoice_id = p_invoice_id
      AND ai.org_id = fsp.org_id;
Line: 308

      SELECT count(*)
      INTO   invoice_holds
      FROM   ap_holds_all
      WHERE  invoice_id = p_invoice_id
      AND    release_lookup_code is NULL;
Line: 320

      SELECT count(*)
      INTO   dist_var_hold
      FROM   ap_holds_all
      WHERE  invoice_id = p_invoice_id
      AND    hold_lookup_code = 'DIST VARIANCE'
      AND    release_lookup_code is NULL;
Line: 330

      SELECT count(*)
      INTO   l_cancelled_count
      FROM   ap_invoice_lines
      WHERE  invoice_id = p_invoice_id
        AND  line_number = p_line_number
        AND  NVL(cancelled_flag, 'N' ) = 'Y';
Line: 346

      SELECT count(*)
      INTO match_flag_cnt
      FROM ap_invoice_distributions_all aid
      WHERE aid.invoice_id = p_invoice_id
      AND aid.invoice_line_number = p_line_number
      AND aid.match_status_flag IS NOT NULL
      AND rownum < 2;
Line: 470

 |     14. return FALSE - if invoice is selected for payment
 |
 |  NOTES
 |
 |     1. If line is the prepay application/unapplication - we handle the
 |        business rule on-line. Means from UI we will make sure that one
 |        PREPAY type line can not be discarded unless it is being fully
 |        unapplied.
 |
 |  MODIFICATION HISTORY
 |  Date         Author               Description of Change
 |  03/07/03     sfeng                Created
 |
 *============================================================================*/

  Function Is_Line_Discardable(
               P_line_rec          IN  ap_invoice_lines%ROWTYPE,
               P_error_code            OUT NOCOPY VARCHAR2,
               P_calling_sequence  IN             VARCHAR2) RETURN BOOLEAN

  IS

    l_po_dist_count              NUMBER := 0;
Line: 518

    SELECT accounting_date
      FROM ap_invoice_distributions AID
     WHERE AID.invoice_id = p_line_rec.invoice_id
       AND AID.invoice_line_number = p_line_rec.line_number
       AND NVL(AID.reversal_flag, 'N') <> 'Y';
Line: 575

    SELECT org_id
    INTO   l_org_id
    FROM   ap_invoices_all
    WHERE  invoice_id = p_line_rec.invoice_id;
Line: 606

    SELECT count(*)
    INTO   l_final_close_count
    FROM   ap_invoice_lines AIL,
           po_line_locations PLL
    WHERE  AIL.invoice_id = p_line_rec.invoice_id
    AND    AIL.line_number = p_line_rec.line_number
    AND    AIL.po_line_location_id = PLL.line_location_id
    AND    PLL.closed_code = 'FINALLY CLOSED';
Line: 625

      SELECT NVL(purch_encumbrance_flag,'N')
      INTO   l_enc_enabled
      FROM   financials_system_params_all FSP,
             ap_invoices_all              AI
      WHERE  AI.invoice_id  =  p_line_rec.invoice_id
      AND    FSP.org_id     =  AI.org_id;
Line: 636

          select 'Y'
          into   l_po_not_approved
          from   po_headers POH
          where POH.po_header_id = p_line_rec.po_header_id
          and   POH.approved_flag <> 'Y';    --bug6653070
Line: 662

    SELECT count(*)
      INTO l_quick_credit_count
      FROM ap_invoices AI
     WHERE AI.invoice_id = p_line_rec.invoice_id
       AND NVL(AI.quick_credit, 'N') = 'Y';
Line: 680

    SELECT count(*)
      INTO l_active_count
      FROM ap_invoice_lines AIL
     WHERE NVL( AIL.discarded_flag, 'N' ) <> 'Y'
       AND NVL( AIL.cancelled_flag, 'N' ) <> 'Y'
       AND AIL.corrected_inv_id = p_line_rec.invoice_id
       AND AIL.corrected_line_number = p_line_rec.line_number;
Line: 706

      SELECT 1
        INTO l_quick_credit_ref_count
        FROM ap_invoices AI
       WHERE AI.credited_invoice_id = p_line_rec.invoice_id
         AND NVL(AI.quick_credit, 'N') = 'Y'
         AND AI.cancelled_date is null
         AND Rownum = 1;
Line: 741

    SELECT count(*)
    INTO   l_po_dist_count
    FROM   po_distributions_all POD,
           ap_invoice_distributions AID,
           ap_invoices ai,
           po_line_locations PLL,
           po_lines PL
    WHERE  POD.po_distribution_id = AID.po_distribution_id
    AND    POD.line_location_id = PLL.line_location_id
    AND    PLL.po_line_id = PL.po_line_id
    AND    AID.invoice_id = ai.invoice_id
    AND    AID.invoice_id = p_line_rec.invoice_id
    AND    POD.org_id = AID.org_id
    AND    AID.invoice_line_number = p_line_rec.line_number
    AND    NVL(AID.reversal_flag,'N')<>'Y'
    AND    aid.rcv_transaction_id is null  --Bug5000472
    HAVING (
            (DECODE(ai.invoice_type_lookup_code,'PREPAYMENT',
               SUM(distinct NVL(POD.quantity_financed, 0)),			--bug15935245, added distinct keyword
	           SUM(distinct NVL(POD.quantity_billed, 0)))			--bug15935245, added distinct keyword
                -
                SUM(round(decode(AID.dist_match_type,
                                'PRICE_CORRECTION', 0,
                                'AMOUNT_CORRECTION', 0,
                                 'ITEM_TO_SERVICE_PO', 0,
                                 'ITEM_TO_SERVICE_RECEIPT', 0,
                                  nvl( AID.quantity_invoiced, 0 ) +
                                  nvl( AID.corrected_quantity,0 )
               ) *
                     po_uom_s.po_uom_convert(AID.matched_uom_lookup_code,
                                   nvl(PLL.unit_meas_lookup_code,
                     PL.unit_meas_lookup_code),
                 PL.item_id), 15))
              < 0)
               OR (DECODE(ai.invoice_type_lookup_code,'PREPAYMENT',
                  SUM(distinct NVL(POD.amount_financed, 0)),			--bug15935245, added distinct keyword
		     SUM(distinct NVL(POD.amount_billed, 0))) -			--bug15935245, added distinct keyword
                  SUM(NVL(AID.amount, 0)) < 0 ))
       GROUP BY ai.invoice_type_lookup_code,AID.po_distribution_id;
Line: 802

    SELECT count(*)
    INTO   l_rcv_dist_count
    FROM   rcv_transactions RT,
           ap_invoice_distributions_all AID
    WHERE  RT.transaction_id = AID.rcv_transaction_id
    AND    AID.invoice_id = p_line_rec.invoice_id
    AND    AID.invoice_line_number = p_line_rec.line_number
    AND    AID.rcv_transaction_id is not null
    AND    NVL(AID.reversal_flag,'N')<>'Y'
    AND    (NVL(rt.quantity_billed,0) <
               (SELECT SUM(decode( AID1.dist_match_type,
                                  'PRICE_CORRECTION', 0,
                                  'AMOUNT_CORRECTION', 0,
                                  'ITEM_TO_SERVICE_PO', 0,
                                  'ITEM_TO_SERVICE_RECEIPT', 0,
                                   nvl( AID1.corrected_quantity,0 ) +
                                   nvl( AID1.quantity_invoiced,0 )
                                                        )
                                                    )
                 FROM ap_invoice_distributions_all aid1
                WHERE aid1.invoice_id = aid.invoice_id
                  AND aid1.invoice_line_number = aid.invoice_line_number
                  AND aid1.rcv_transaction_id=aid.rcv_transaction_id
                       )
             OR
             NVL(rt.amount_billed,0) <  (
                       SELECT SUM(DECODE(AID2.dist_match_type,			--Bug11783854
				'OTHER_TO_RECEIPT',0,NVL(AID2.amount,0)))
                         FROM ap_invoice_distributions_all aid2
                        WHERE aid2.invoice_id = aid.invoice_id
                         AND aid2.invoice_line_number = aid.invoice_line_number
                         AND aid2.rcv_transaction_id=aid.rcv_transaction_id
                          )
             );
Line: 849

    SELECT  count(*)
    INTO    l_invalid_acct_count
    FROM    ap_invoice_distributions D
    WHERE   D.invoice_id = p_line_rec.invoice_id
    AND     D.invoice_line_number = p_line_rec.line_number
    AND     D.posted_flag IN ('N', 'P')
    AND ((EXISTS (select 'x'
                  from gl_code_combinations C
                  where D.dist_code_combination_id = C.code_combination_id (+)
                  and (C.code_combination_id is null
                     or C.detail_posting_allowed_flag = 'N'
                     or C.start_date_active > D.accounting_date
                     or C.end_date_active < D.accounting_date
                     or C.template_id is not null
                     or C.enabled_flag <> 'Y'
                     or C.summary_flag <> 'N'
                     )))
    OR (D.dist_code_combination_id = -1));
Line: 873

        SELECT count(1)
          INTO l_valid_alt_acct_exists
          FROM ap_invoice_distributions aid
             , gl_code_combinations glcc
         WHERE aid.invoice_id           = p_line_rec.invoice_id
           AND aid.invoice_line_number  = p_line_rec.line_number
           AND aid.posted_flag IN ('N', 'P')
           AND dist_code_combination_id = glcc.code_combination_id
           AND glcc.alternate_code_combination_id IS NOT NULL
           AND EXISTS
               (
               SELECT 'Account Valid'
                 FROM gl_code_combinations glcc1
                WHERE glcc1.code_combination_id         = glcc.alternate_code_combination_id
                  AND glcc1.enabled_flag                = 'Y'
                  AND glcc1.detail_posting_allowed_flag = 'Y'
                  AND aid.accounting_date BETWEEN
                          NVL(glcc1.start_date_active, aid.accounting_date)
                      AND NVL(glcc1.end_date_active, aid.accounting_date)
               );
Line: 916

    SELECT  count(*)
    INTO    l_reference_count
    FROM    ap_invoice_distributions AID
    WHERE   NVL(AID.cancellation_flag, 'N') <> 'Y'
    AND     NVL(AID.reversal_flag, 'N') <> 'Y'
    AND     AID.invoice_id = p_line_rec.invoice_id
    AND     AID.invoice_line_number <> p_line_rec.line_number
    AND     AID.charge_applicable_to_dist_id IS NOT NULL
    AND     AID.charge_applicable_to_dist_id IN
            ( SELECT AID2.invoice_distribution_id
                FROM ap_invoice_distributions AID2
               WHERE AID2.invoice_id = p_line_rec.invoice_id
                 AND AID2.invoice_line_number = p_line_rec.line_number
                 AND NVL(AID2.cancellation_flag, 'N') <> 'Y'
                 AND NVL(AID2.reversal_flag, 'N') <> 'Y' );
Line: 946

    SELECT  count(*)
    INTO    l_pending_count
    FROM    ap_allocation_rules  AR,
            ap_allocation_rule_lines ARL
    WHERE   AR.invoice_id = p_line_rec.invoice_id
    AND     AR.invoice_id = ARL.invoice_id
    AND     AR.chrg_invoice_line_number = ARL.chrg_invoice_line_number
    AND     ARL.to_invoice_line_number = p_line_rec.line_number
    AND     AR.status = 'PENDING';
Line: 966

    SELECT  count(*)
    INTO    l_count
    FROM    ap_invoice_lines AIL,
            ap_invoices AI
    WHERE   AIL.invoice_id = P_line_rec.invoice_id
    AND     AIL.line_number = P_line_rec.line_number
    AND     AIL.line_type_lookup_code  = 'AWT'
    /*bug12865213, commented exists clause
    AND     NOT EXISTS ( SELECT invoice_distribution_id
                           FROM ap_invoice_distributions aid
                          WHERE aid.invoice_id = AIL.invoice_id
                            AND aid.invoice_line_number = AIL.line_number
                            AND awt_flag = 'M' )
    */
    AND     AI.invoice_id = AIL.invoice_id
    AND     AI.payment_status_flag in ('P', 'Y');
Line: 993

     SELECT count(*)
       INTO l_count
       FROM ap_invoice_lines AIL
      WHERE AIL.invoice_id  = P_line_rec.invoice_id
	AND AIL.line_number = P_line_rec.line_number
	AND (ail.retained_amount           IS NOT NULL AND
	     ail.retained_amount_remaining IS NOT NULL AND
             abs(ail.retained_amount) <> abs(ail.retained_amount_remaining));
Line: 1011

    SELECT count(*)
      INTO l_count
      FROM ap_invoices_all ai
     WHERE invoice_id = p_line_rec.invoice_id
       AND invoice_type_lookup_code = 'PREPAYMENT';
Line: 1028

     |  Step 14. invoice is select for payment and payment is not done |
     |           so, return FALSE (Bug #8366177)                       |
     +-----------------------------------------------------------------*/
--bug 10012646
   select  nvl(count(1),0)
      INTO l_count
      from ap_payment_schedules_all
      where invoice_id =p_line_rec.invoice_id
      and checkrun_id is not null
      and payment_status_flag <>'Y';
Line: 1040

         p_error_code := 'AP_INV_SELECTED_INVOICE';
Line: 1095

    debug_info := 'Select from ap_allocation_rules';
Line: 1097

    Select count(*)
    Into   dummy
    From   ap_allocation_rules  AR,
           ap_allocation_rule_lines ARL
    Where  AR.invoice_id = p_Invoice_Id
    And    AR.invoice_id = ARL.invoice_id
    And    AR.chrg_invoice_line_number = ARL.chrg_invoice_line_number
    And    ARL.to_invoice_line_number = p_line_number;
Line: 1152

     debug_info := 'Select from ap_invoics_all';
Line: 1158

       Select 1
       Into   dummy
       From   ap_invoices_all AI
       Where AI.credited_invoice_id = p_Invoice_Id
       AND NVL(AI.quick_credit, 'N') = 'Y'
       AND AI.cancelled_date is null
       AND Rownum = 1;
Line: 1218

    debug_info := 'Select from ap_invoice_distributions_all';
Line: 1220

    Select count(*)
    Into   dummy
    From   ap_invoice_distributions_all
    Where invoice_id = p_Invoice_Id
    And invoice_line_number = p_Line_Number
    And assets_addition_flag = 'Y';
Line: 1275

    debug_info := 'Select from ap_invoice_distributions_all';
Line: 1277

    Select count(*)
    Into   dummy
    From   ap_invoice_distributions_all
    Where invoice_id = p_Invoice_Id
    And invoice_line_number = p_Line_Number
    And accounting_event_id Is Not Null;
Line: 1332

    debug_info := 'Select from ap_invoice_lines_all';
Line: 1334

    Select count(*)
    Into   dummy
    From   ap_invoice_lines_all AIL
    Where  NVL(AIL.discarded_flag, 'N' ) <> 'Y'
    And NVL( AIL.cancelled_flag, 'N' ) <> 'Y'
    And AIL.corrected_inv_id = p_Invoice_Id
    And AIL.corrected_line_number = p_Line_Number;
Line: 1390

    debug_info := 'Select from ap_invoic_distributions_all';
Line: 1392

    Select count(*)
    Into   dummy
    From   ap_invoice_distributions_all AID
    Where   NVL(AID.cancellation_flag, 'N') <> 'Y'
    And     NVL(AID.reversal_flag, 'N') <> 'Y'
    And     AID.invoice_id = p_invoice_id
    --Bug9323585 : Commented line to check for inclusive tax also
    --And     AID.invoice_line_number <> p_line_number
    And     AID.charge_applicable_to_dist_id IS NOT NULL
    And     AID.charge_applicable_to_dist_id In
           (Select AID2.invoice_distribution_id
            From ap_invoice_distributions_all AID2
            Where AID2.invoice_id = p_Invoice_Id
            And AID2.invoice_line_number = p_Line_Number
            And NVL(AID2.cancellation_flag, 'N') <> 'Y'
            And NVL(AID2.reversal_flag, 'N') <> 'Y' );
Line: 1457

    debug_info := 'Select from ap_allocatin_rules';
Line: 1459

    Select count(*)
    Into   dummy
    From   ap_allocation_rules  AR,
           ap_allocation_rule_lines ARL
    Where  AR.invoice_id = p_Invoice_Id
    And    AR.invoice_id = ARL.invoice_id (+)
    And    AR.chrg_invoice_line_number = ARL.chrg_invoice_line_number (+)
    --Commented below condition for bug #9143555 and introduced new conditions
    -- And ARL.to_invoice_line_number (+)  = p_line_number
    And    AR.chrg_invoice_line_number  = p_line_number
    And    AR.status = 'PENDING';
Line: 1518

    debug_info := 'Select from ap_invoic_distributions_all';
Line: 1520

    Select count(*)
    Into   dummy
    From   ap_invoice_distributions_all
    Where invoice_id = p_Invoice_Id
    And invoice_line_number = p_Line_Number
    And pa_addition_flag In ('T', 'Y', 'Z') ;
Line: 1547

 |  Public FUNCTION Can_Line_Be_Deleted
 |
 |      Check if the particular invoice line can be deleted
 |
 |  PROGRAM FLOW
 |
 |       return TRUE  - if line can be deleted
 |       return FALSE - otherwise and return error code.
 |
 |  MODIFICATION HISTORY
 |  Date         Author               Description of Change
 |  03/10/13     bghose               Created
 *============================================================================*/

  FUNCTION Can_Line_Be_Deleted (p_line_rec    IN ap_invoice_lines%ROWTYPE,
                              p_error_code  OUT NOCOPY Varchar2,
                              p_Calling_Sequence  Varchar2) Return Boolean Is
    current_calling_sequence   Varchar2(2000);
Line: 1570

               'AP_INVOICE_LINES_UTILITY_PKG.Can_Line_Be_Deleted <-'||
                            p_Calling_Sequence;
Line: 1577

       p_error_code := 'AP_INV_LINE_DELETE_VALIDATED';
Line: 1583

       p_error_code := 'AP_INV_LINE_DELETE_CORR';
Line: 1589

       p_error_code := 'AP_INV_LINE_DELETE_ENCUMBERED';
Line: 1595

       p_error_code := 'AP_INV_LINE_DELETE_ACCOUNTED';
Line: 1601

       p_error_code := 'AP_INV_LINE_DELETE_PA';
Line: 1631

  End Can_Line_Be_Deleted;
Line: 1651

    Select decode(count(distinct(packet_id)),1,max(packet_id),'')
    From ap_invoice_distributions
    Where invoice_id = p_Invoice_Id
    And invoice_line_number = p_Line_Number
    And packet_id is not null;
Line: 1696

    SELECT 'Dist Total <> Invoice Line Amount'
    FROM   ap_invoice_lines AIL, ap_invoice_distributions D
    WHERE  AIL.invoice_id  = D.invoice_id
    AND    AIL.line_number = p_line_number
    AND    AIL.invoice_id  = p_invoice_id
    AND    AIL.line_number = D.invoice_line_number
    AND    (D.line_type_lookup_code <> 'RETAINAGE'
    	    OR (AIL.line_type_lookup_code = 'RETAINAGE RELEASE'
    	        and D.line_type_lookup_code = 'RETAINAGE'))
    AND    (AIL.line_type_lookup_code <> 'ITEM'
            or (AIL.line_type_lookup_code = 'ITEM'
                and (D.prepay_distribution_id IS NULL
                     or (D.prepay_distribution_id IS NOT NULL
                         and D.line_type_lookup_code NOT IN ('PREPAY', 'REC_TAX', 'NONREC_TAX')))))
    GROUP BY AIL.invoice_id, AIL.line_number, AIL.amount
    HAVING AIL.amount <> nvl(SUM(nvl(D.amount,0)),0);
Line: 1777

    SELECT count(*)
      FROM po_distributions_all POD,
           ap_invoice_distributions AID
     WHERE POD.po_distribution_id = AID.po_distribution_id
       AND AID.invoice_id = P_Invoice_Id
       AND POD.org_id = AID.org_id
       AND AID.invoice_line_number = P_Line_Number
       AND NVL(AID.reversal_flag,'N')<>'Y'
       AND ( NVL(POD.quantity_billed, 0) -
             decode( AID.dist_match_type,
                     'PRICE_CORRECTION',  0,
                     'AMOUNT_CORRECTION', 0,    /* Ampunt Based Matching */
                     'ITEM_TO_SERVICE_PO', 0,
                     'ITEM_TO_SERVICE_RECEIPT', 0,
                     nvl( AID.corrected_quantity,0 ) +
                     nvl( AID.quantity_invoiced,0 ) ) < 0
             OR
             NVL(POD.amount_billed, 0) - NVL(AID.amount, 0) < 0 );
Line: 1870

  SELECT COUNT(*)
    INTO l_count
    FROM ap_invoice_lines
   WHERE invoice_id      = p_invoice_id
     AND generate_dists <> 'D'
     AND ROWNUM = 1;
Line: 1915

    debug_info := 'Select from ap_allocatin_rules';
Line: 1917

    Select count(*)
    Into   dummy
    From   ap_allocation_rules  AR
    Where  AR.invoice_id = p_Invoice_Id
    And    AR.chrg_invoice_line_number = p_line_number
    And    AR.status = 'PENDING';
Line: 1965

   SELECT 'Y'
   INTO is_correction
   FROM ap_invoice_lines
   WHERE invoice_id = p_invoice_id
   AND line_number = p_line_number
   AND corrected_inv_id IS NOT NULL
   AND corrected_line_number IS NOT NULL;
Line: 2008

  SELECT count(*)
  INTO l_count
  FROM ap_invoice_lines_all
  WHERE corrected_inv_id = p_invoice_id
  AND corrected_line_number = p_line_number
  AND line_type_lookup_code IN ('RETROITEM')
  AND line_source = 'PO PRICE ADJUSTMENT'
  AND match_type = 'RETRO PRICE ADJUSTMENT';
Line: 2049

  SELECT 'Y'
  INTO is_po_price_adjustment
  FROM ap_invoice_lines_all
  WHERE invoice_id = p_invoice_id
  AND line_number = p_line_number
  AND line_type_lookup_code = 'RETROITEM'
  AND line_source = 'PO PRICE ADJUSTMENT'
  AND match_type = 'RETRO PRICE ADJUSTMENT';
Line: 2094

  SELECT 'Y'
  INTO is_prepayment
  FROM ap_invoice_lines
  WHERE invoice_id = p_invoice_id
  AND line_number = p_line_number
  AND line_type_lookup_code = 'PREPAY';
Line: 2143

	SELECT currency_code
	INTO l_currency_code
	FROM po_headers_all
	WHERE po_header_id IN
	  (SELECT po_header_id
	   FROM po_line_locations_all
	   WHERE line_location_id = p_line_location_id)
	AND rownum < 2;
Line: 2182

 *  Objective update ap_payment_schedules.remaining_amount for manual entry
 *  withholding lines
 *  This procedire has been moved from payment schedules library since it did
 *  not consider the
 *  ap lines model
 *  This PROCEDURE is added for Bug 6917289
 * =============================================================================================*/
PROCEDURE Manual_Withhold_Tax(p_invoice_id IN number
                             ,p_manual_withhold_amount IN number
                             ) IS

 l_inv_amt_remaining  ap_payment_schedules.amount_remaining%TYPE := 0;
Line: 2208

  SELECT nvl(payment_cross_rate,0), payment_currency_code
    INTO l_payment_cross_rate, l_payment_currency_code
    FROM ap_invoices_all
   WHERE invoice_id = p_invoice_id;
Line: 2213

  SELECT sum(nvl(amount_remaining,0)), sum(nvl(gross_amount,0))
    INTO l_inv_amt_remaining, l_gross_amount
    FROM ap_payment_schedules
   WHERE invoice_id = p_invoice_id;
Line: 2222

          update ap_payment_schedules
             set amount_remaining = (amount_remaining +
                                     ap_utilities_pkg.ap_round_currency(
                        (amount_remaining * (p_manual_withhold_amount/l_inv_amt_remaining)
                         * l_payment_cross_rate), l_payment_currency_code))
           where invoice_id = p_invoice_id;
Line: 2231

          update ap_payment_schedules
             set amount_remaining = (amount_remaining +
                                     ap_utilities_pkg.ap_round_currency(
                     (gross_amount * (p_manual_withhold_amount/l_gross_amount)
                      * l_payment_cross_rate), l_payment_currency_code)),
                 payment_status_flag = DECODE(payment_status_flag,'Y','P',payment_status_flag)
           where invoice_id = p_invoice_id;
Line: 2239

          update ap_invoices
             set payment_status_flag = DECODE(payment_status_flag,'Y','P',payment_status_flag)
           where invoice_id = p_invoice_id ;
Line: 2279

  SELECT awt_flag
    INTO l_awt_flag
    FROM ap_invoice_distributions_all
   WHERE invoice_id = p_invoice_id
     AND invoice_line_number = p_line_number
     AND rownum = 1;