DBA Data[Home] [Help]

APPS.AR_CC_LOCKBOX SQL Statements

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

Line: 361

|                                  invoice1_status was updated wrongly.
|  10/23/2001     Shin Matsuda     There are some other places where it updates
|                                  invoice1_status instead of invoiceN_status.
|                                  Corrected all of them.
|  10/31/2001     Shin Matsuda     Bug 2066392.  Populate amount_appliedN with
|                                  amount_applied_fromN if single currency
|                                  application.
|  11/21/2001     Shin Matsuda     Bug 2057282.  Validate/populate currency
|                                  and amount info only if l_tot_trxN is 1.
|  11/23/2001     Shin Matsuda     Bug 2119596.  Backed out NOCOPY the previous fix.
|                                  Put exception clause for no_data_found case.
|  10/28/2002     Shin Matsuda     Bug 2626005.  Modified where clause of most
|                                  update statements.  We validate CC info row
|                                  by row and we know rowid of the record, thus
|                                  the where clause can be simple rowid=l_rowid
|  05/07/2003     Rahna Kader      Bug 2926664.Modified the select statement
|                                  which is used for setting AR_PLB_DUP_INV.
|                                  Also modified the select statement which selects
|                                  the invoice currency code and amount due
|                                  remaining.
|  08/14/2003     H Yoshihara      Bug 2980051. Replaced l_only_one_lb with
| 				   l_no_batch_or_lb in get_app_info cursor
|				   to identify record correctly.
|  22/10/2003     SAPN Sarma       Bug 3113104. Replaced the get_rate function with
|				   get_rate_sql function.Also, made a check for the
|				   exchange_rate_value that is returned.
+---------------------------------------------------------------------------*/


PROCEDURE populate_add_inv_details(
       p_transmission_id IN VARCHAR2,
       p_payment_rec_type IN VARCHAR2,
       p_overflow_rec_type IN VARCHAR2,
       p_item_num IN ar_payments_interface.item_number%type,
       p_batch_name IN ar_payments_interface.batch_name%type,
       p_lockbox_number IN ar_payments_interface.lockbox_number%type,
       p_batches IN VARCHAR2,
       p_only_one_lb IN VARCHAR2,
       p_pay_unrelated_invoices IN VARCHAR2,
       p_default_exchange_rate_type IN VARCHAR2,
       enable_cross_currency IN VARCHAR2,
       p_format_amount1  IN VARCHAR,
       p_format_amount2  IN VARCHAR,
       p_format_amount3  IN VARCHAR,
       p_format_amount4  IN VARCHAR,
       p_format_amount5  IN VARCHAR,
       p_format_amount6  IN VARCHAR,
       p_format_amount7  IN VARCHAR,
       p_format_amount8  IN VARCHAR,
       p_format_amount_applied_from1  IN VARCHAR,
       p_format_amount_applied_from2  IN VARCHAR,
       p_format_amount_applied_from3  IN VARCHAR,
       p_format_amount_applied_from4  IN VARCHAR,
       p_format_amount_applied_from5  IN VARCHAR,
       p_format_amount_applied_from6  IN VARCHAR,
       p_format_amount_applied_from7  IN VARCHAR,
       p_format_amount_applied_from8  IN VARCHAR
                     ) IS
--
l_transmission_id         VARCHAR2(50);
Line: 580

   select list */

   /*  Bug 1513671:  modified cursor because amount_applied was being rounded
       to precision of receipt currency */
   /*  Bug 2980051: Replaced l_only_one_lb with l_no_batch_or_lb  */

   CURSOR get_app_info IS
       select
         pi.rowid,
         pi.resolved_matching_number1,
	 pi.resolved_matching1_date,
	 pi.resolved_matching1_installment,
	 pi.customer_id,
         pi.trans_to_receipt_rate1,
         pi.invoice_currency_code1,
         pi.amount_applied1,
         decode(l_format_amount_applied_from1,'Y',
                round(pi.amount_applied_from1/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from1),
         pi.resolved_matching_number2,
	 pi.resolved_matching2_date,
         pi.resolved_matching2_installment,
         pi.trans_to_receipt_rate2,
         pi.invoice_currency_code2,
         pi.amount_applied2,
         decode(l_format_amount_applied_from2,'Y',
                round(pi.amount_applied_from2/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from2),
         pi.resolved_matching_number3,
	 pi.resolved_matching3_date,
         pi.resolved_matching3_installment,
         pi.trans_to_receipt_rate3,
         pi.invoice_currency_code3,
         pi.amount_applied3,
         decode(l_format_amount_applied_from3,'Y',
                round(pi.amount_applied_from3/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from3),
         pi.resolved_matching_number4,
	 pi.resolved_matching4_date,
         pi.resolved_matching4_installment,
         pi.trans_to_receipt_rate4,
         pi.invoice_currency_code4,
         pi.amount_applied4,
         decode(l_format_amount_applied_from4,'Y',
                round(pi.amount_applied_from4/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from4),
         pi.resolved_matching_number5,
	 pi.resolved_matching5_date,
         pi.resolved_matching5_installment,
         pi.trans_to_receipt_rate5,
         pi.invoice_currency_code5,
         pi.amount_applied5,
         decode(l_format_amount_applied_from5,'Y',
                round(pi.amount_applied_from5/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from5),
         pi.resolved_matching_number6,
	 pi.resolved_matching6_date,
         pi.resolved_matching6_installment,
         pi.trans_to_receipt_rate6,
         pi.invoice_currency_code6,
         pi.amount_applied6,
         decode(l_format_amount_applied_from6,'Y',
                round(pi.amount_applied_from6/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from6),
         pi.resolved_matching_number7,
	 pi.resolved_matching7_date,
         pi.resolved_matching7_installment,
         pi.trans_to_receipt_rate7,
         pi.invoice_currency_code7,
         pi.amount_applied7,
         decode(l_format_amount_applied_from7,'Y',
                round(pi.amount_applied_from7/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from7),
         pi.resolved_matching_number8,
	 pi.resolved_matching8_date,
         pi.resolved_matching8_installment,
         pi.trans_to_receipt_rate8,
         pi.invoice_currency_code8,
         pi.amount_applied8,
         decode(l_format_amount_applied_from8,'Y',
                round(pi.amount_applied_from8/power(10,fc.precision),
                      fc.precision),
                pi.amount_applied_from8),
         pi.currency_code,         /* currency code of the receipt */
         pi.receipt_date
from   ar_payments_interface pi, fnd_currencies fc
       where  pi.transmission_id = l_transmission_id
       and    pi.record_type||'' in ( l_payment_rec_type, l_overflow_rec_type )
       and    pi.item_number = l_item_num
       and    pi.currency_code = fc.currency_code
       and    ( pi.batch_name = l_batch_name
                or
                ( pi.lockbox_number = l_lockbox_number
                  and
                  l_batches = 'N'
                )
                or
                l_no_batch_or_lb = 'Y'
              );
Line: 831

     SELECT receipt_date
        INTO l_receipt_date
     FROM ar_payments_interface pi
     WHERE       pi.transmission_id = l_transmission_id
          and    pi.record_type||'' in ( l_payment_rec_type )
          and    pi.item_number = l_item_num
          and    ( pi.batch_name = l_batch_name
                   or
                   ( pi.lockbox_number = l_lockbox_number
                     and
                     l_batches = 'N'
                   )
                   or
                   l_no_batch_or_lb = 'Y'
                  );
Line: 870

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx1
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number1
        AND     ps.trx_date = l_resolved_matching1_date /* Bug fix 2926664 */
        AND    (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                or
                l_pay_unrelated_invoices = 'Y'
               )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 903

                update ar_payments_interface pi
                set    invoice1_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 908

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code1,
                        trx_amt_due_rem1
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number1
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                         (select min(ps.payment_schedule_id)
                          from   ar_payment_schedules ps,
                                 ra_cust_trx_types    tt
                          where  ps.trx_number = l_matching_number1
                          and    ps.trx_date = l_resolved_matching1_date /* Bug fix 2926664 */
                          and    (EXISTS
                                   (
                                      select 'Exists from dual' from dual
					                   where l_customer_id = ps.customer_id
					                   union
					                   select 'Exists from hz_cust_acct_relate'
					                   from   hz_cust_acct_relate rel
					                   where  rel.cust_account_id = l_customer_id
					                   and    related_cust_account_id = ps.customer_id
					                   and    rel.status = 'A'
					                   and    rel.bill_to_flag = 'Y'
					                   union
					                   select 'Exists ar_paying_relationships_v'
					                   from   ar_paying_relationships_v rel,
					                          hz_cust_accounts acc
					                   where  rel.party_id = acc.party_id
					                   and    acc.cust_account_id = l_customer_id
					                   and    rel.related_cust_account_id = ps.customer_id
					                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                   )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                          and    ps.cust_trx_type_id = tt.cust_trx_type_id
                          and    ps.class NOT IN ('PMT','GUAR')
                          and    ps.status=decode(tt.allow_overapplication_flag,
                                                     'N', 'OP',
                                                     ps.status))
                AND    (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 994

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code1 = l_invoice_currency_code1
     WHERE rowid = l_rowid ;
Line: 1009

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice1_status = 'AR_PLB_CURRENCY_BAD'
    WHERE rowid = l_rowid ;
Line: 1118

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate1 =
                                             l_trans_to_receipt_rate1
                                     WHERE rowid = l_rowid;
Line: 1123

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice1_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 1141

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate1 =
                                   l_trans_to_receipt_rate1
                              WHERE rowid = l_rowid;
Line: 1163

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice1_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 1172

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate1 =
                                   l_trans_to_receipt_rate1
                              WHERE rowid = l_rowid;
Line: 1185

                                update ar_payments_interface
                                   set  amount_applied_from1 =
                                           l_amount_applied_from1
                                   where rowid = l_rowid;
Line: 1237

                               update ar_payments_interface
                                   set  amount_applied1 =
                                           l_amount_applied1
                                   where rowid = l_rowid;
Line: 1245

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice1_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 1262

                          update ar_payments_interface
                            set  amount_applied_from1 =
                                      l_amount_applied_from1
                            where rowid = l_rowid;
Line: 1311

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied1 =
                                      l_amount_applied1
                              WHERE  rowid = l_rowid;
Line: 1353

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice1_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 1366

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice1_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 1374

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice1_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 1388

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied1 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 1408

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx2
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number2
        AND     ps.trx_date = l_resolved_matching2_date /* Bug fix 2926664 */
        AND    (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                or
                l_pay_unrelated_invoices = 'Y'
               )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 1441

                update ar_payments_interface pi
                set    invoice2_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 1446

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code2,
                        trx_amt_due_rem2
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number2
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number2
                         and    ps.trx_date = l_resolved_matching2_date /* Bug fix 2926664 */
                         and (EXISTS /* subquery */
                         (
                            select 'Exists from dual' from dual
                            where l_customer_id = ps.customer_id
                            union
                            select 'Exists from hz_cust_acct_relate'
                            from   hz_cust_acct_relate rel
                            where  rel.cust_account_id = l_customer_id
                            and    related_cust_account_id = ps.customer_id
                            and    rel.status = 'A'
                            and    rel.bill_to_flag = 'Y'
                            union
                            select 'Exists ar_paying_relationships_v'
                            from   ar_paying_relationships_v rel,
                                   hz_cust_accounts acc
                            where  rel.party_id = acc.party_id
                            and    acc.cust_account_id = l_customer_id
                            and    rel.related_cust_account_id = ps.customer_id
                            and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                          )
                          or
                          l_pay_unrelated_invoices = 'Y'
                         )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and ps.status=decode(tt.allow_overapplication_flag,
						'N' , 'OP',
                                            ps.status))
                and (EXISTS /* main query */
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 1532

      UPDATE ar_payments_interface pi
         SET pi.invoice_currency_code2 = l_invoice_currency_code2
       WHERE  rowid = l_rowid;
Line: 1548

     UPDATE AR_PAYMENTS_INTERFACE
        SET invoice2_status = 'AR_PLB_CURRENCY_BAD'
     WHERE rowid = l_rowid;
Line: 1655

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate2 =
                                             l_trans_to_receipt_rate2
                                     WHERE rowid = l_rowid;
Line: 1660

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice2_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 1677

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate2 =
                                   l_trans_to_receipt_rate2
                              WHERE rowid = l_rowid;
Line: 1699

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice2_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 1708

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate2 =
                                   l_trans_to_receipt_rate2
                              WHERE rowid = l_rowid;
Line: 1722

                                 UPDATE ar_payments_interface
                                   SET  amount_applied_from2 =
                                             l_amount_applied_from2
                                   WHERE  rowid = l_rowid;
Line: 1769

                                 UPDATE ar_payments_interface
                                   SET  amount_applied2 =
                                             l_amount_applied2
                                   WHERE rowid = l_rowid;
Line: 1777

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice2_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 1794

                          UPDATE ar_payments_interface
                             SET  amount_applied_from2 =
                                           l_amount_applied_from2
                             WHERE rowid = l_rowid;
Line: 1843

                         UPDATE ar_payments_interface
                             SET  amount_applied2 =
                                         l_amount_applied2
                             WHERE rowid = l_rowid;
Line: 1885

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice2_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 1897

              UPDATE AR_PAYMENTS_INTERFACE
                  SET invoice2_status = 'AR_PLB_CURR_CONFLICT'
                    WHERE rowid = l_rowid;
Line: 1905

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice2_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 1919

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied2 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 1938

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx3
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number3
        AND     ps.trx_date = l_resolved_matching3_date /* Bug fix 2926664 */
                AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 1971

                update ar_payments_interface pi
                set    invoice3_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 1976

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code3,
                        trx_amt_due_rem3
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number3
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number3
                         and    ps.trx_date = l_resolved_matching3_date /* Bug fix 2926664 */
                         and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and ps.status=decode(tt.allow_overapplication_flag,
						'N','OP',
                                            ps.status))
                and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 2062

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code3 = l_invoice_currency_code3
     WHERE rowid = l_rowid;
Line: 2077

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice3_status = 'AR_PLB_CURRENCY_BAD'
    WHERE rowid = l_rowid;
Line: 2187

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate3 =
                                             l_trans_to_receipt_rate3
                                     WHERE rowid = l_rowid;
Line: 2192

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice3_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 2209

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate3 =
                                   l_trans_to_receipt_rate3
                              WHERE rowid = l_rowid;
Line: 2231

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice3_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 2241

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate3 =
                                   l_trans_to_receipt_rate3
                              WHERE rowid = l_rowid;
Line: 2255

                                update ar_payments_interface
                                   set  amount_applied_from3 =
                                           l_amount_applied_from3
                                   where rowid = l_rowid;
Line: 2305

                               update ar_payments_interface
                                   set  amount_applied3 =
                                           l_amount_applied3
                                   where rowid = l_rowid;
Line: 2313

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice3_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 2329

                          update ar_payments_interface
                            set  amount_applied_from3 =
                                      l_amount_applied_from3
                            where rowid = l_rowid;
Line: 2376

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied3 =
                                      l_amount_applied3
                              WHERE rowid = l_rowid;
Line: 2419

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice3_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 2432

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice3_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 2440

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice3_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 2454

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied3 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 2474

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx4
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number4
        AND     ps.trx_date = l_resolved_matching4_date /* Bug fix 2926664 */
        AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 2507

                update ar_payments_interface pi
                set    invoice4_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 2512

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code4,
                        trx_amt_due_rem4
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number4
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number4
                         and    ps.trx_date = l_resolved_matching4_date /* Bug fix 2926664 */
                         and   (EXISTS
                                (
                                        select 'Exists from dual' from dual
                                        where l_customer_id = ps.customer_id
                                        union
                                        select 'Exists from hz_cust_acct_relate'
                                        from   hz_cust_acct_relate rel
                                        where  rel.cust_account_id = l_customer_id
                                        and    related_cust_account_id = ps.customer_id
                                        and    rel.status = 'A'
                                        and    rel.bill_to_flag = 'Y'
                                        union
                                        select 'Exists ar_paying_relationships_v'
                                        from   ar_paying_relationships_v rel,
                                               hz_cust_accounts acc
                                        where  rel.party_id = acc.party_id
                                        and    acc.cust_account_id = l_customer_id
                                        and    rel.related_cust_account_id = ps.customer_id
                                        and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and ps.status=decode(tt.allow_overapplication_flag,
						'N' , 'OP',
                                            ps.status))
                       and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 2598

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code4 = l_invoice_currency_code4
     WHERE  rowid = l_rowid;
Line: 2613

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice4_status = 'AR_PLB_CURRENCY_BAD'
    WHERE  rowid = l_rowid;
Line: 2722

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate4 =
                                             l_trans_to_receipt_rate4
                                     WHERE rowid = l_rowid;
Line: 2727

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice4_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 2745

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate4 =
                                   l_trans_to_receipt_rate4
                              WHERE rowid = l_rowid;
Line: 2767

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice4_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 2777

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate4 =
                                   l_trans_to_receipt_rate4
                              WHERE rowid = l_rowid;
Line: 2790

                                update ar_payments_interface
                                   set  amount_applied_from4 =
                                           l_amount_applied_from4
                                   where rowid = l_rowid;
Line: 2839

                               update ar_payments_interface
                                   set  amount_applied4 =
                                           l_amount_applied4
                                   where rowid = l_rowid;
Line: 2847

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice4_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 2864

                          update ar_payments_interface
                            set  amount_applied_from4 =
                                      l_amount_applied_from4
                            where rowid = l_rowid;
Line: 2909

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied4 =
                                      l_amount_applied4
                              WHERE  rowid = l_rowid;
Line: 2951

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice4_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 2964

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice4_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 2972

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice4_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 2986

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied4 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 3006

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx5
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number5
        AND     ps.trx_date = l_resolved_matching5_date /* Bug fix 2926664 */
        AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 3039

                update ar_payments_interface pi
                set    invoice5_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 3044

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code5,
                        trx_amt_due_rem5
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number5
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number5
                         and    ps.trx_date = l_resolved_matching5_date /* Bug fix 2926664 */
                         and   (EXISTS
                                (
                                        select 'Exists from dual' from dual
                                        where l_customer_id = ps.customer_id
                                        union
                                        select 'Exists from hz_cust_acct_relate'
                                        from   hz_cust_acct_relate rel
                                        where  rel.cust_account_id = l_customer_id
                                        and    related_cust_account_id = ps.customer_id
                                        and    rel.status = 'A'
                                        and    rel.bill_to_flag = 'Y'
                                        union
                                        select 'Exists ar_paying_relationships_v'
                                        from   ar_paying_relationships_v rel,
                                               hz_cust_accounts acc
                                        where  rel.party_id = acc.party_id
                                        and    acc.cust_account_id = l_customer_id
                                        and    rel.related_cust_account_id = ps.customer_id
                                        and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                          and    ps.cust_trx_type_id = tt.cust_trx_type_id
                          and    ps.class NOT IN ('PMT','GUAR')
                          and ps.status=decode(tt.allow_overapplication_flag,
						'N', 'OP',
                                            ps.status))
                and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 3130

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code5 = l_invoice_currency_code5
     WHERE  rowid = l_rowid;
Line: 3145

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice5_status = 'AR_PLB_CURRENCY_BAD'
    WHERE rowid = l_rowid;
Line: 3254

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate5 =
                                             l_trans_to_receipt_rate5
                                     WHERE rowid = l_rowid;
Line: 3259

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice5_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 3277

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate5 =
                                   l_trans_to_receipt_rate5
                              WHERE rowid = l_rowid;
Line: 3299

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice5_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 3309

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate5 =
                                   l_trans_to_receipt_rate5
                              WHERE rowid = l_rowid;
Line: 3322

                                update ar_payments_interface
                                   set  amount_applied_from5 =
                                           l_amount_applied_from5
                                   where rowid = l_rowid;
Line: 3369

                               update ar_payments_interface
                                   set  amount_applied5 =
                                           l_amount_applied5
                                   where rowid = l_rowid;
Line: 3377

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice5_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 3394

                          update ar_payments_interface
                            set  amount_applied_from5 =
                                      l_amount_applied_from5
                            where rowid = l_rowid;
Line: 3440

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied5 =
                                      l_amount_applied5
                              WHERE  rowid = l_rowid;
Line: 3482

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice5_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 3495

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice5_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 3503

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice5_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 3517

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied5 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 3537

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx6
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number6
        AND     ps.trx_date = l_resolved_matching6_date /* Bug fix 2926664 */
        AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 3570

                update ar_payments_interface pi
                set    invoice6_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 3575

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code6,
                        trx_amt_due_rem6
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number6
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number6
                         and    ps.trx_date = l_resolved_matching6_date /* Bug fix 2926664 */
                         and   (EXISTS
                                (
                                        select 'Exists from dual' from dual
                                        where l_customer_id = ps.customer_id
                                        union
                                        select 'Exists from hz_cust_acct_relate'
                                        from   hz_cust_acct_relate rel
                                        where  rel.cust_account_id = l_customer_id
                                        and    related_cust_account_id = ps.customer_id
                                        and    rel.status = 'A'
                                        and    rel.bill_to_flag = 'Y'
                                        union
                                        select 'Exists ar_paying_relationships_v'
                                        from   ar_paying_relationships_v rel,
                                               hz_cust_accounts acc
                                        where  rel.party_id = acc.party_id
                                        and    acc.cust_account_id = l_customer_id
                                        and    rel.related_cust_account_id = ps.customer_id
                                        and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and    ps.status=decode(tt.allow_overapplication_flag,
						'N', 'OP',
                                            ps.status))
                and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 3661

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code6 = l_invoice_currency_code6
     WHERE  rowid = l_rowid;
Line: 3676

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice6_status = 'AR_PLB_CURRENCY_BAD'
    WHERE  rowid = l_rowid;
Line: 3785

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate6 =
                                             l_trans_to_receipt_rate6
                                     WHERE rowid = l_rowid;
Line: 3790

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice6_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 3808

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate6 =
                                   l_trans_to_receipt_rate6
                              WHERE rowid = l_rowid;
Line: 3830

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice6_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 3840

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate6 =
                                   l_trans_to_receipt_rate6
                              WHERE rowid = l_rowid;
Line: 3853

                                update ar_payments_interface
                                   set  amount_applied_from6 =
                                           l_amount_applied_from6
                                   where rowid = l_rowid;
Line: 3900

                               update ar_payments_interface
                                   set  amount_applied6 =
                                           l_amount_applied6
                                   where rowid = l_rowid;
Line: 3908

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice6_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 3925

                          update ar_payments_interface
                            set  amount_applied_from6 =
                                      l_amount_applied_from6
                            where rowid = l_rowid;
Line: 3970

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied6 =
                                      l_amount_applied6
                              WHERE  rowid = l_rowid;
Line: 4012

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice6_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 4025

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice6_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 4033

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice6_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 4047

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied6 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 4067

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx7
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number7
        AND     ps.trx_date = l_resolved_matching7_date /* Bug fix 2926664 */
        AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 4100

                update ar_payments_interface pi
                set    invoice7_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 4105

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code7,
                        trx_amt_due_rem7
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number7
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number7
                         and    ps.trx_date = l_resolved_matching7_date /* Bug fix 2926664 */
                         and   (EXISTS
                                (
                                        select 'Exists from dual' from dual
                                        where l_customer_id = ps.customer_id
                                        union
                                        select 'Exists from hz_cust_acct_relate'
                                        from   hz_cust_acct_relate rel
                                        where  rel.cust_account_id = l_customer_id
                                        and    related_cust_account_id = ps.customer_id
                                        and    rel.status = 'A'
                                        and    rel.bill_to_flag = 'Y'
                                        union
                                        select 'Exists ar_paying_relationships_v'
                                        from   ar_paying_relationships_v rel,
                                               hz_cust_accounts acc
                                        where  rel.party_id = acc.party_id
                                        and    acc.cust_account_id = l_customer_id
                                        and    rel.related_cust_account_id = ps.customer_id
                                        and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and ps.status=decode(tt.allow_overapplication_flag,
						'N' , 'OP',
                                            ps.status))
                and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 4191

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code7 = l_invoice_currency_code7
     WHERE  rowid = l_rowid;
Line: 4206

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice7_status = 'AR_PLB_CURRENCY_BAD'
    WHERE  rowid = l_rowid;
Line: 4315

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate7 =
                                             l_trans_to_receipt_rate7
                                     WHERE rowid = l_rowid;
Line: 4320

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice7_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 4338

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate7 =
                                   l_trans_to_receipt_rate7
                              WHERE rowid = l_rowid;
Line: 4360

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice7_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 4370

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate7 =
                                   l_trans_to_receipt_rate7
                              WHERE rowid = l_rowid;
Line: 4383

                                update ar_payments_interface
                                   set  amount_applied_from7 =
                                           l_amount_applied_from7
                                   where rowid = l_rowid;
Line: 4430

                               update ar_payments_interface
                                   set  amount_applied7 =
                                           l_amount_applied7
                                   where rowid = l_rowid;
Line: 4438

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice7_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 4455

                          update ar_payments_interface
                            set  amount_applied_from7 =
                                      l_amount_applied_from7
                            where rowid = l_rowid;
Line: 4501

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied7 =
                                      l_amount_applied7
                              WHERE  rowid = l_rowid;
Line: 4543

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice7_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 4556

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice7_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 4564

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice7_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 4578

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied7 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 4598

        SELECT  sum(count(distinct ps.customer_trx_id))
        INTO    l_tot_trx8
        FROM    ar_payment_schedules ps
        WHERE   ps.trx_number = l_matching_number8
        AND     ps.trx_date = l_resolved_matching8_date /* Bug fix 2926664 */
        AND (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
        GROUP BY ps.customer_trx_id
        HAVING sum(ps.amount_due_remaining) <> 0;
Line: 4631

                update ar_payments_interface pi
                set    invoice8_status = 'AR_PLB_DUP_INV'
                where rowid = l_rowid;
Line: 4636

                SELECT  invoice_currency_code,
                        amount_due_remaining
                INTO    ps_currency_code8,
                        trx_amt_due_rem8
                FROM    ar_payment_schedules ps,
                        ra_cust_trx_types    tt
                WHERE   ps.trx_number = l_matching_number8
                AND     ps.status = decode(tt.allow_overapplication_flag,
                               'N', 'OP',
                                ps.status)
                AND     ps.class NOT IN ('PMT','GUAR')
                AND     ps.payment_schedule_id =
                        (select min(ps.payment_schedule_id)
                         from   ar_payment_schedules ps,
                                ra_cust_trx_types    tt
                         where  ps.trx_number = l_matching_number8
                         and    ps.trx_date = l_resolved_matching8_date /* Bug fix 2926664 */
                         and   (EXISTS
                                (
                                        select 'Exists from dual' from dual
                                        where l_customer_id = ps.customer_id
                                        union
                                        select 'Exists from hz_cust_acct_relate'
                                        from   hz_cust_acct_relate rel
                                        where  rel.cust_account_id = l_customer_id
                                        and    related_cust_account_id = ps.customer_id
                                        and    rel.status = 'A'
                                        and    rel.bill_to_flag = 'Y'
                                        union
                                        select 'Exists ar_paying_relationships_v'
                                        from   ar_paying_relationships_v rel,
                                               hz_cust_accounts acc
                                        where  rel.party_id = acc.party_id
                                        and    acc.cust_account_id = l_customer_id
                                        and    rel.related_cust_account_id = ps.customer_id
                                        and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                                )
                                   or
                                   l_pay_unrelated_invoices = 'Y'
                                 )
                         and    ps.cust_trx_type_id = tt.cust_trx_type_id
                         and    ps.class NOT IN ('PMT','GUAR')
                         and ps.status=decode(tt.allow_overapplication_flag,
						'N', 'OP',
                                            ps.status))
                 and (EXISTS
                (
                   select 'Exists from dual' from dual
                   where l_customer_id = ps.customer_id
                   union
                   select 'Exists from hz_cust_acct_relate'
                   from   hz_cust_acct_relate rel
                   where  rel.cust_account_id = l_customer_id
                   and    related_cust_account_id = ps.customer_id
                   and    rel.status = 'A'
                   and    rel.bill_to_flag = 'Y'
                   union
                   select 'Exists ar_paying_relationships_v'
                   from   ar_paying_relationships_v rel,
                          hz_cust_accounts acc
                   where  rel.party_id = acc.party_id
                   and    acc.cust_account_id = l_customer_id
                   and    rel.related_cust_account_id = ps.customer_id
                   and    l_receipt_date BETWEEN effective_start_date
                                             AND effective_end_date
                )
                 or
                 l_pay_unrelated_invoices = 'Y'
                )
                AND     ps.cust_trx_type_id = tt.cust_trx_type_id;
Line: 4722

     /* update ar_payment_interface to have the invoice currency_code */
     UPDATE ar_payments_interface
        SET invoice_currency_code8 = l_invoice_currency_code8
     WHERE  rowid = l_rowid;
Line: 4737

    UPDATE AR_PAYMENTS_INTERFACE
        SET invoice8_status = 'AR_PLB_CURRENCY_BAD'
    WHERE  rowid = l_rowid;
Line: 4846

                                   UPDATE ar_payments_interface
                                     SET trans_to_receipt_rate8 =
                                             l_trans_to_receipt_rate8
                                     WHERE rowid = l_rowid;
Line: 4851

                                  UPDATE AR_PAYMENTS_INTERFACE
                                    SET invoice8_status =
                                             'AR_PLB_CC_INVALID_VALUE'
                                   WHERE rowid = l_rowid;
Line: 4869

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate8 =
                                   l_trans_to_receipt_rate8
                              WHERE rowid = l_rowid;
Line: 4891

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice8_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 4901

                             UPDATE ar_payments_interface
                                SET trans_to_receipt_rate8 =
                                   l_trans_to_receipt_rate8
                              WHERE rowid = l_rowid;
Line: 4914

                                update ar_payments_interface
                                   set  amount_applied_from8 =
                                           l_amount_applied_from8
                                   where rowid = l_rowid;
Line: 4962

                               update ar_payments_interface
                                   set  amount_applied8 =
                                           l_amount_applied8
                                   where rowid = l_rowid;
Line: 4970

                            UPDATE AR_PAYMENTS_INTERFACE
                               SET invoice8_status = 'AR_PLB_NO_EXCHANGE_RATE'
                                WHERE rowid = l_rowid;
Line: 4987

                          update ar_payments_interface
                            set  amount_applied_from8 =
                                      l_amount_applied_from8
                            where rowid = l_rowid;
Line: 5033

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET  amount_applied8 =
                                      l_amount_applied8
                              WHERE  rowid = l_rowid;
Line: 5075

                         UPDATE AR_PAYMENTS_INTERFACE
                              SET invoice8_status = 'AR_PLB_CC_INVALID_VALUE'
                         WHERE rowid = l_rowid;
Line: 5088

                 UPDATE AR_PAYMENTS_INTERFACE
                      SET invoice8_status = 'AR_PLB_CURR_CONFLICT'
                         WHERE rowid = l_rowid;
Line: 5096

		  UPDATE AR_PAYMENTS_INTERFACE
		      SET invoice8_status = 'AR_PLB_CC_INVALID_VALUE'
		  WHERE rowid = l_rowid;
Line: 5110

		UPDATE AR_PAYMENTS_INTERFACE
		      SET  amount_applied8 = l_unformat_amount
		      WHERE  rowid = l_rowid;
Line: 5322

   update ar_payments_interface pi
   set tmp_amt_applied_from1 = pi.amount_applied_from1,
       tmp_amt_applied_from2 = pi.amount_applied_from2,
       tmp_amt_applied_from3 = pi.amount_applied_from3,
       tmp_amt_applied_from4 = pi.amount_applied_from4,
       tmp_amt_applied_from5 = pi.amount_applied_from5,
       tmp_amt_applied_from6 = pi.amount_applied_from6,
       tmp_amt_applied_from7 = pi.amount_applied_from7,
       tmp_amt_applied_from8 = pi.amount_applied_from8,
       tmp_amt_applied1 = pi.amount_applied1,
       tmp_amt_applied2 = pi.amount_applied2,
       tmp_amt_applied3 = pi.amount_applied3,
       tmp_amt_applied4 = pi.amount_applied4,
       tmp_amt_applied5 = pi.amount_applied5,
       tmp_amt_applied6 = pi.amount_applied6,
       tmp_amt_applied7 = pi.amount_applied7,
       tmp_amt_applied8 = pi.amount_applied8,
       tmp_inv_currency_code1 = pi.invoice_currency_code1,
       tmp_inv_currency_code2 = pi.invoice_currency_code2,
       tmp_inv_currency_code3 = pi.invoice_currency_code3,
       tmp_inv_currency_code4 = pi.invoice_currency_code4,
       tmp_inv_currency_code5 = pi.invoice_currency_code5,
       tmp_inv_currency_code6 = pi.invoice_currency_code6,
       tmp_inv_currency_code7 = pi.invoice_currency_code7,
       tmp_inv_currency_code8 = pi.invoice_currency_code8,
       tmp_trans_to_rcpt_rate1 = pi.trans_to_receipt_rate1,
       tmp_trans_to_rcpt_rate2 = pi.trans_to_receipt_rate2,
       tmp_trans_to_rcpt_rate3 = pi.trans_to_receipt_rate3,
       tmp_trans_to_rcpt_rate4 = pi.trans_to_receipt_rate4,
       tmp_trans_to_rcpt_rate5 = pi.trans_to_receipt_rate5,
       tmp_trans_to_rcpt_rate6 = pi.trans_to_receipt_rate6,
       tmp_trans_to_rcpt_rate7 = pi.trans_to_receipt_rate7,
       tmp_trans_to_rcpt_rate8 = pi.trans_to_receipt_rate8;
Line: 5360

   update ar_payments_interface
   set amount_applied_from1 = tmp_amt_applied_from1,
       amount_applied_from2 = tmp_amt_applied_from2,
       amount_applied_from3 = tmp_amt_applied_from3,
       amount_applied_from4 = tmp_amt_applied_from4,
       amount_applied_from5 = tmp_amt_applied_from5,
       amount_applied_from6 = tmp_amt_applied_from6,
       amount_applied_from7 = tmp_amt_applied_from7,
       amount_applied_from8 = tmp_amt_applied_from8,
       amount_applied1 = tmp_amt_applied1,
       amount_applied2 = tmp_amt_applied2,
       amount_applied3 = tmp_amt_applied3,
       amount_applied4 = tmp_amt_applied4,
       amount_applied5 = tmp_amt_applied5,
       amount_applied6 = tmp_amt_applied6,
       amount_applied7 = tmp_amt_applied7,
       amount_applied8 = tmp_amt_applied8,
       invoice_currency_code1 = tmp_inv_currency_code1,
       invoice_currency_code2 = tmp_inv_currency_code2,
       invoice_currency_code3 = tmp_inv_currency_code3,
       invoice_currency_code4 = tmp_inv_currency_code4,
       invoice_currency_code5 = tmp_inv_currency_code5,
       invoice_currency_code6 = tmp_inv_currency_code6,
       invoice_currency_code7 = tmp_inv_currency_code7,
       invoice_currency_code8 = tmp_inv_currency_code8,
       trans_to_receipt_rate1 = tmp_trans_to_rcpt_rate1,
       trans_to_receipt_rate2 = tmp_trans_to_rcpt_rate2,
       trans_to_receipt_rate3 = tmp_trans_to_rcpt_rate3,
       trans_to_receipt_rate4 = tmp_trans_to_rcpt_rate4,
       trans_to_receipt_rate5 = tmp_trans_to_rcpt_rate5,
       trans_to_receipt_rate6 = tmp_trans_to_rcpt_rate6,
       trans_to_receipt_rate7 = tmp_trans_to_rcpt_rate7,
       trans_to_receipt_rate8 = tmp_trans_to_rcpt_rate8
where status <> 'AR_PLB_TRANSFERRED';