DBA Data[Home] [Help]

APPS.ARP_MAINTAIN_PS2 SQL Statements

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

Line: 62

Binary Integer to Number(15) for all record types  select_ips_rec_type,
select_ira_rec_type,select_ups_rec_type, select_iad_rec_type.
*/


TYPE select_ips_rec_type IS RECORD
(
  customer_trx_id 		NUMBER(15),
  trx_number			ra_customer_trx.trx_number%type,
  cust_trx_type_id		NUMBER(15),
  trx_type			ra_cust_trx_types.type%type,
  trx_date			DATE,
  gl_date			DATE,
  customer_id			NUMBER(15),
  site_use_id			NUMBER(15),
  reversed_cash_receipt_id	NUMBER(15),
  currency_code			ra_customer_trx.invoice_currency_code%type,
  precision			NUMBER,
  min_acc_unit			NUMBER,
  exchange_rate_type		ra_customer_trx.exchange_rate_type%type,
  exchange_rate			NUMBER,
  exchange_date			DATE,
  term_id			NUMBER(15),
  first_installment_code	ra_terms.first_installment_code%type,
  rec_acctd_amount		NUMBER,
  total_line_amount		NUMBER,
  total_tax_amount		NUMBER,
  total_freight_amount		NUMBER,
  total_charges_amount		NUMBER,
  term_sequence_num		NUMBER,
  percent			NUMBER,
  due_date			DATE
);
Line: 97

TYPE select_ira_rec_type IS RECORD
(
  customer_trx_id 		NUMBER(15),
  trx_number			ra_customer_trx.trx_number%type,
  cust_trx_type_id		NUMBER(15),
  post_to_gl_flag		ra_cust_trx_types.post_to_gl%type,
  credit_method		        ra_customer_trx.credit_method_for_installments%type,
  trx_date			DATE,
  gl_date			DATE,
  customer_id			NUMBER(15),
  site_use_id			NUMBER(15),
  currency_code			ra_customer_trx.invoice_currency_code%type,
  precision			NUMBER,
  min_acc_unit			NUMBER,
  exchange_rate_type		ra_customer_trx.exchange_rate_type%type,
  exchange_rate			NUMBER,
  exchange_date			DATE,
  rec_acctd_amount		NUMBER,
  total_cm_line_amount		NUMBER,
  total_cm_tax_amount		NUMBER,
  total_cm_freight_amount	NUMBER,
  total_cm_charges_amount	NUMBER,
  code_combination_id		NUMBER(15),
  gl_date_closed		DATE,
  actual_date_closed		DATE,
  inv_customer_trx_id 		NUMBER(15),
  inv_precision			NUMBER,
  inv_min_acc_unit		NUMBER,
  inv_exchange_rate		NUMBER,
  inv_payment_schedule_id 	NUMBER(15),
  inv_amount_due_remaining	NUMBER,
  inv_acctd_amt_due_rem		NUMBER,
  inv_line_remaining		NUMBER,
  inv_tax_remaining		NUMBER,
  inv_freight_remaining		NUMBER,
  inv_charges_remaining		NUMBER,
  inv_amount_credited		NUMBER
);
Line: 136

TYPE select_ups_rec_type IS RECORD
(
  set_of_books_id		NUMBER(15),
  customer_trx_id 		NUMBER(15),
  post_to_gl_flag		ra_cust_trx_types.post_to_gl%type,
  trx_date			DATE,
  gl_date			DATE,
  precision			NUMBER,
  min_acc_unit			NUMBER,
  adjusted_trx_id 	        NUMBER(15),
  subsequent_trx_id 		NUMBER(15),
  commitment_trx_id 		NUMBER(15),
  commitment_type		ra_cust_trx_types.type%type,
  ps_currency_code		ra_customer_trx.invoice_currency_code%type,
  ps_exchange_rate		NUMBER,
  ps_precision			NUMBER,
  ps_min_acc_unit	        NUMBER,
  code_combination_id		NUMBER(15),
  gl_date_closed		DATE,
  actual_date_closed		DATE,
  total_line_amount		NUMBER,
  payment_schedule_id 		NUMBER(15),
  amount_due_remaining		NUMBER,
  acctd_amt_due_rem		NUMBER,
  line_remaining		NUMBER,
  amount_adjusted		NUMBER,
  percent			NUMBER,
  allocate_tax_freight          ra_cust_trx_types_all.allocate_tax_freight%type,
  adjustment_type               ar_adjustments_all.type%type,
  tax_remaining                 NUMBER,
  freight_remaining             NUMBER,
  total_tax_amount              NUMBER,
  total_freight_amount          NUMBER
);
Line: 172

TYPE select_iad_rec_type IS RECORD
(
  set_of_books_id		NUMBER(15),
  customer_trx_id 		NUMBER(15),
  post_to_gl_flag		ra_cust_trx_types.post_to_gl%type,
  trx_date			DATE,
  gl_date			DATE,
  precision			NUMBER,
  min_acc_unit			NUMBER,
  adjusted_trx_id 		NUMBER(15),
  invoice_trx_id 		NUMBER(15),
  ps_currency_code		ra_customer_trx.invoice_currency_code%type,
  ps_exchange_rate		NUMBER,
  ps_precision			NUMBER,
  ps_min_acc_unit		NUMBER,
  commitment_code		NUMBER(15),
  code_combination_id		NUMBER(15),
  gl_date_closed		DATE,
  actual_date_closed		DATE,
  total_cm_line_amount		NUMBER,
  total_inv_adj_amount		NUMBER,
  total_inv_line_remaining	NUMBER,
  payment_schedule_id 		NUMBER(15),
  ps_amount_due_remaining	NUMBER,
  ps_acctd_amt_due_rem		NUMBER,
  ps_line_original		NUMBER,
  ps_line_remaining		NUMBER,
  ps_tax_original               NUMBER,
  ps_tax_remaining              NUMBER,
  ps_freight_original           NUMBER,
  ps_freight_remaining          NUMBER,
  ps_amount_adjusted		NUMBER,
  allocate_tax_freight          ra_cust_trx_types.allocate_tax_freight%type,
  adjustment_type               ar_adjustments.type%type,
  total_cm_tax_amount           NUMBER,
  total_cm_frt_amount           NUMBER,
--  total_inv_line_adj          NUMBER,
--  total_inv_tax_adj           NUMBER,
--  total_inv_frt_adj           NUMBER,
  inv_line_adj                  NUMBER,
  inv_tax_adj                   NUMBER,
  inv_frt_adj                   NUMBER
);
Line: 451

        p_select_c 		IN OUT NOCOPY INTEGER,
        p_insert_ps_c 		IN OUT NOCOPY INTEGER ) IS

    l_insert_ps_sql	VARCHAR2(5000);
Line: 455

    l_select_sql	VARCHAR2(5000);
Line: 465

    l_select_sql :=
'SELECT
/* :user_id, */
ctl.customer_trx_id,
/* null, */
sum(decode(ctl.line_type, ''LINE'', ctl.extended_amount,
                        ''CB'', ctl.extended_amount, 0)),
sum(decode(ctl.line_type, ''TAX'', ctl.extended_amount, 0)),
sum(decode(ctl.line_type, ''FREIGHT'', ctl.extended_amount, 0)),
t.term_id,
tl.sequence_num,
/* Bug fix 5589303, If billing_date is not null, billing_date shall be used to calculate due date */
decode(ctt.type, ''CM'', ct.trx_date, nvl(tl.due_date,
    decode(tl.due_days,
           null,
           decode(least(to_number(substrb(nvl(ct.billing_date, ct.trx_date),1,2)),
                        nvl(t.due_cutoff_day,32)),
                  t.due_cutoff_day,
                  last_day(add_months(nvl(ct.billing_date, ct.trx_date),
                                      tl.due_months_forward)) +
                  least(tl.due_day_of_month,
                        to_number(substrb(last_day(add_months(
                               nvl(ct.billing_date, ct.trx_date),
                               tl.due_months_forward + 1)),1,2))),
                  last_day(add_months(nvl(ct.billing_date, ct.trx_date),
                                      (tl.due_months_forward - 1)))
                  + least(tl.due_day_of_month,
                          to_number(substrb(last_day(add_months(
                               nvl(ct.billing_date, ct.trx_date),
                               tl.due_months_forward)),1,2)))),
           nvl(ct.billing_date, ct.trx_date) + tl.due_days))),
ct.bill_to_customer_id,
ctt.type,
ct.bill_to_site_use_id,
ct.cust_trx_type_id,
ct.invoice_currency_code,
/* null, */
ct.exchange_rate_type,
ct.exchange_rate,
ct.exchange_date,
ct.trx_number,
ct.trx_date,
tl.relative_amount / t.base_amount,
c.precision,
/* 1, */
t.first_installment_code,
c.minimum_accountable_unit,
nvl(ctlgd.gl_date, ct.trx_date),
nvl(ctlgd.acctd_amount, 0),
/* null, */
/* :raagixlul, */
sum(decode(ctl.line_type, ''CHARGES'', ctl.extended_amount, 0)),
ct.reversed_cash_receipt_id 	/* Bug3328690 */
FROM
ra_terms t,
ra_terms_lines tl,
ra_cust_trx_types ctt,
ra_customer_trx ct,
ra_cust_trx_line_gl_dist ctlgd,
fnd_currencies c,
ra_customer_trx_lines ctl
WHERE  ct.customer_trx_id = :customer_trx_id
AND    ctl.customer_trx_id = ctlgd.customer_trx_id
AND    ctlgd.account_class = ''REC''
AND    ctlgd.latest_rec_flag = ''Y''
AND    ctl.customer_trx_id = ct.customer_trx_id
AND    ct.invoice_currency_code = c.currency_code
AND    ct.cust_trx_type_id = ctt.cust_trx_type_id
AND    ctt.accounting_affect_flag = ''Y''  /* Open Receivables = Y */
AND    ct.term_id = t.term_id(+)
AND    t.term_id = tl.term_id(+)
and    not (ctt.type = ''CM'' and ct.previous_customer_trx_id is not NULL)
GROUP BY
ctl.customer_trx_id,
t.term_id,
tl.relative_amount,
t.base_amount,
tl.sequence_num,
tl.due_date,
tl.due_days,
ct.trx_date,
t.due_cutoff_day,
tl.due_months_forward,
tl.due_day_of_month,
ct.bill_to_customer_id,
ctt.type,
ct.bill_to_site_use_id,
ct.cust_trx_type_id,
ct.invoice_currency_code,
ct.exchange_rate_type,
ct.exchange_rate,
ct.exchange_date,
ct.trx_number,
c.minimum_accountable_unit,
t.first_installment_code,
ctlgd.gl_date,
ctlgd.acctd_amount,
c.precision,
ct.reversed_cash_receipt_id,	/*Bug3328690 */
ct.billing_date
ORDER BY
ctl.customer_trx_id,
tl.sequence_num';
Line: 569

    debug('  select_sql = ' || CRLF ||
          l_select_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 572

    debug('  len(select_sql) = '||
          to_char(length(l_select_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 580

    l_insert_ps_sql :=
'INSERT INTO AR_PAYMENT_SCHEDULES
(
created_by,
creation_date,
last_updated_by,
last_update_date,
last_update_login,
request_id,
program_application_id,
program_id,
program_update_date,
payment_schedule_id,
customer_trx_id,
amount_due_original,
amount_due_remaining,
acctd_amount_due_remaining,
amount_line_items_original,
amount_line_items_remaining,
tax_original,
tax_remaining,
freight_original,
freight_remaining,
receivables_charges_charged,
receivables_charges_remaining,
amount_credited,
amount_applied,
term_id,
terms_sequence_number,
due_date,
customer_id,
class,
customer_site_use_id,
cust_trx_type_id,
number_of_due_dates,
status,
invoice_currency_code,
actual_date_closed,
exchange_rate_type,
exchange_rate,
exchange_date,
trx_number,
trx_date,
gl_date_closed,
gl_date,
reversed_cash_receipt_id
,org_id
)
VALUES
(
:user_id,   	/* created_by */
sysdate,	/* creation_date */
:user_id,	/* last_updated_by */
sysdate,	/* last_update_date */
:login_id,	/* last_update_login */
:request_id,  		/* request_id */
decode(:application_id,
       -1, null, :application_id), 		/* program_application_id */
decode(:program_id, -1, null, :program_id), 		/* program_id */
sysdate,		/* program_update_date */
:payment_schedule_id,
:customer_trx_id,	/* customer_trx_id */
:line_amt + nvl(:tax_amt, 0) + nvl(:frt_amt, 0) +
    nvl(:charge_amt, 0),  /* ado */
:line_amt + nvl(:tax_amt, 0) + nvl(:frt_amt, 0) +
    nvl(:charge_amt, 0),  /* adr */
:acctd_adr,		/* acctd_amount_due_remaining */
:line_amt,	/* alio */
:line_amt,	/* alir */
nvl(:tax_amt, 0),	/* tax_original */
nvl(:tax_amt, 0),	/* tax_remaining */
nvl(:frt_amt, 0),	/* freight_original */
nvl(:frt_amt, 0),	/* freight_remaining */
nvl(:charge_amt, 0),	/* receivables_charges_charged */
nvl(:charge_amt, 0),	/* receivables_charges_remaining */
null,		/* amount_credited */
null,		/* amount_applied */
:term_id,		/* term_id */
nvl(:terms_sequence_number,1),	/* terms_sequence_number */
:due_date,
:customer_id,
:type,		/* class */
:site_use_id,	/* customer_site_use_id */
:cust_trx_type_id,	/* cust_trx_type_id */
:number_of_due_dates,	/* number_of_due_dates */
decode(:line_amt + nvl(:tax_amt, 0) + nvl(:frt_amt, 0)+ nvl(:charge_amt, 0),
       0, ''CL'', ''OP''),		/* status */
:currency_code,
       nvl(decode(:line_amt + nvl(:tax_amt,0) + nvl(:frt_amt,0)+
       nvl(:charge_amt,0),
           0, :trx_date, null), to_date(''12/31/4712'',''MM/DD/YYYY'')),/* bug#2678029 lgandhi actual_date_closed */
:exchange_rate_type,
:exchange_rate,
:exchange_date,
:trx_number,
:trx_date,
       nvl(decode(:line_amt + nvl(:tax_amt, 0) + nvl(:frt_amt, 0) +
		nvl(:charge_amt, 0),
              0, nvl(:gl_date, :trx_date), null),to_date(''12/31/4712'',''MM/DD/YYYY'')),		/* gl_date_closed */
nvl(:gl_date, :trx_date),
:reversed_cash_receipt_id
, :org_id--arp_standard.sysparm.org_id /* SSA changes anuj */
)' ;
Line: 684

    debug('  insert_ps_sql = ' || CRLF ||
          l_insert_ps_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 687

    debug('  len(insert_ps_sql) = '||
          to_char(length(l_insert_ps_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 700

        p_insert_ps_c := dbms_sql.open_cursor;
Line: 701

        dbms_sql.parse( p_insert_ps_c, l_insert_ps_sql,
                        dbms_sql.v7 );
Line: 704

        p_select_c := dbms_sql.open_cursor;
Line: 705

        dbms_sql.parse( p_select_c, l_select_sql,
                        dbms_sql.v7 );
Line: 727

PROCEDURE define_ips_select_columns(
	p_select_c   IN INTEGER,
        p_select_rec IN select_ips_rec_type ) IS

BEGIN

    print_fcn_label2( 'arp_maintain_ps2.define_ips_select_columns()+' );
Line: 735

    dbms_sql.define_column( p_select_c, 1, p_select_rec.customer_trx_id );
Line: 736

    dbms_sql.define_column( p_select_c, 2, p_select_rec.total_line_amount );
Line: 737

    dbms_sql.define_column( p_select_c, 3, p_select_rec.total_tax_amount );
Line: 738

    dbms_sql.define_column( p_select_c, 4, p_select_rec.total_freight_amount );
Line: 739

    dbms_sql.define_column( p_select_c, 5, p_select_rec.term_id );
Line: 740

    dbms_sql.define_column( p_select_c, 6, p_select_rec.term_sequence_num );
Line: 741

    dbms_sql.define_column( p_select_c, 7, p_select_rec.due_date );
Line: 742

    dbms_sql.define_column( p_select_c, 8, p_select_rec.customer_id );
Line: 743

    dbms_sql.define_column( p_select_c, 9, p_select_rec.trx_type, 20 );
Line: 744

    dbms_sql.define_column( p_select_c, 10, p_select_rec.site_use_id );
Line: 745

    dbms_sql.define_column( p_select_c, 11, p_select_rec.cust_trx_type_id );
Line: 746

    dbms_sql.define_column( p_select_c, 12,
			    p_select_rec.currency_code, 15 );
Line: 748

    dbms_sql.define_column( p_select_c, 13,
                            p_select_rec.exchange_rate_type, 30 );
Line: 750

    dbms_sql.define_column( p_select_c, 14, p_select_rec.exchange_rate );
Line: 751

    dbms_sql.define_column( p_select_c, 15, p_select_rec.exchange_date );
Line: 752

    dbms_sql.define_column( p_select_c, 16, p_select_rec.trx_number, 20 );
Line: 753

    dbms_sql.define_column( p_select_c, 17, p_select_rec.trx_date );
Line: 754

    dbms_sql.define_column( p_select_c, 18, p_select_rec.percent );
Line: 755

    dbms_sql.define_column( p_select_c, 19, p_select_rec.precision );
Line: 756

    dbms_sql.define_column( p_select_c, 20,
			    p_select_rec.first_installment_code, 12 );
Line: 758

    dbms_sql.define_column( p_select_c, 21,
			    p_select_rec.min_acc_unit );
Line: 760

    dbms_sql.define_column( p_select_c, 22, p_select_rec.gl_date );
Line: 762

    dbms_sql.define_column( p_select_c, 23, p_select_rec.rec_acctd_amount );
Line: 763

    dbms_sql.define_column( p_select_c, 24,
			    p_select_rec.total_charges_amount );
Line: 765

    dbms_sql.define_column( p_select_c, 25,p_select_rec.reversed_cash_receipt_id); /*Bug3328690 */
Line: 768

    print_fcn_label2( 'arp_maintain_ps2.define_ips_select_columns()-' );
Line: 772

        debug('EXCEPTION: arp_maintain_ps2.define_ips_select_columns()',
	      MSG_LEVEL_BASIC);
Line: 775

END define_ips_select_columns;
Line: 779

PROCEDURE get_ips_column_values( p_select_c   IN INTEGER,
                             p_select_rec IN OUT NOCOPY select_ips_rec_type ) IS
/* Bug 460927 - Modified IN to IN OUT in the above line - Oracle 8 */
BEGIN
    print_fcn_label2( 'arp_maintain_ps2.get_ips_column_values()+' );
Line: 785

    dbms_sql.column_value( p_select_c, 1, p_select_rec.customer_trx_id );
Line: 786

    dbms_sql.column_value( p_select_c, 2, p_select_rec.total_line_amount );
Line: 787

    dbms_sql.column_value( p_select_c, 3, p_select_rec.total_tax_amount );
Line: 788

    dbms_sql.column_value( p_select_c, 4, p_select_rec.total_freight_amount );
Line: 789

    dbms_sql.column_value( p_select_c, 5, p_select_rec.term_id );
Line: 790

    dbms_sql.column_value( p_select_c, 6, p_select_rec.term_sequence_num );
Line: 791

    dbms_sql.column_value( p_select_c, 7, p_select_rec.due_date );
Line: 792

    dbms_sql.column_value( p_select_c, 8, p_select_rec.customer_id );
Line: 793

    dbms_sql.column_value( p_select_c, 9, p_select_rec.trx_type );
Line: 794

    dbms_sql.column_value( p_select_c, 10, p_select_rec.site_use_id );
Line: 795

    dbms_sql.column_value( p_select_c, 11, p_select_rec.cust_trx_type_id );
Line: 796

    dbms_sql.column_value( p_select_c, 12,
			    p_select_rec.currency_code );
Line: 798

    dbms_sql.column_value( p_select_c, 13,
                            p_select_rec.exchange_rate_type );
Line: 800

    dbms_sql.column_value( p_select_c, 14, p_select_rec.exchange_rate );
Line: 801

    dbms_sql.column_value( p_select_c, 15, p_select_rec.exchange_date );
Line: 802

    dbms_sql.column_value( p_select_c, 16, p_select_rec.trx_number );
Line: 803

    dbms_sql.column_value( p_select_c, 17, p_select_rec.trx_date );
Line: 804

    dbms_sql.column_value( p_select_c, 18, p_select_rec.percent );
Line: 805

    dbms_sql.column_value( p_select_c, 19, p_select_rec.precision );
Line: 806

    dbms_sql.column_value( p_select_c, 20,
			    p_select_rec.first_installment_code );
Line: 808

    dbms_sql.column_value( p_select_c, 21,
			    p_select_rec.min_acc_unit );
Line: 810

    dbms_sql.column_value( p_select_c, 22, p_select_rec.gl_date );
Line: 812

    dbms_sql.column_value( p_select_c, 23, p_select_rec.rec_acctd_amount );
Line: 813

    dbms_sql.column_value( p_select_c, 24, p_select_rec.total_charges_amount );
Line: 814

    dbms_sql.column_value( p_select_c, 25, p_select_rec.reversed_cash_receipt_id); /*Bug3328690 */
Line: 846

PROCEDURE dump_ips_select_rec( p_select_rec IN select_ips_rec_type ) IS
BEGIN

    print_fcn_label2( 'arp_maintain_ps2.dump_ips_select_rec()+' );
Line: 851

    debug( '  Dumping select record: ', MSG_LEVEL_DEBUG );
Line: 853

           || p_select_rec.customer_trx_id, MSG_LEVEL_DEBUG );
Line: 855

           || p_select_rec.trx_number, MSG_LEVEL_DEBUG );
Line: 857

           || p_select_rec.cust_trx_type_id, MSG_LEVEL_DEBUG );
Line: 859

           || p_select_rec.trx_type, MSG_LEVEL_DEBUG );
Line: 861

           || p_select_rec.trx_date, MSG_LEVEL_DEBUG );
Line: 863

           || p_select_rec.gl_date, MSG_LEVEL_DEBUG );
Line: 865

           || p_select_rec.customer_id, MSG_LEVEL_DEBUG );
Line: 867

           || p_select_rec.site_use_id, MSG_LEVEL_DEBUG );
Line: 869

           || p_select_rec.reversed_cash_receipt_id, MSG_LEVEL_DEBUG );
Line: 871

           || p_select_rec.currency_code, MSG_LEVEL_DEBUG );
Line: 873

           || p_select_rec.precision, MSG_LEVEL_DEBUG );
Line: 875

           || p_select_rec.min_acc_unit, MSG_LEVEL_DEBUG );
Line: 877

           || p_select_rec.exchange_rate_type, MSG_LEVEL_DEBUG );
Line: 879

           || p_select_rec.exchange_rate, MSG_LEVEL_DEBUG );
Line: 881

           || p_select_rec.exchange_date, MSG_LEVEL_DEBUG );
Line: 883

           || p_select_rec.term_id, MSG_LEVEL_DEBUG );
Line: 885

           || p_select_rec.first_installment_code, MSG_LEVEL_DEBUG );
Line: 887

           || p_select_rec.rec_acctd_amount, MSG_LEVEL_DEBUG );
Line: 889

           || p_select_rec.total_line_amount, MSG_LEVEL_DEBUG );
Line: 891

           || p_select_rec.total_tax_amount, MSG_LEVEL_DEBUG );
Line: 893

           || p_select_rec.total_freight_amount, MSG_LEVEL_DEBUG );
Line: 895

           || p_select_rec.total_charges_amount, MSG_LEVEL_DEBUG );
Line: 897

           || p_select_rec.term_sequence_num, MSG_LEVEL_DEBUG );
Line: 899

           || p_select_rec.percent, MSG_LEVEL_DEBUG );
Line: 901

           || p_select_rec.due_date, MSG_LEVEL_DEBUG );
Line: 903

    print_fcn_label2( 'arp_maintain_ps2.dump_ips_select_rec()-' );
Line: 907

        debug( 'EXCEPTION: arp_maintain_ps2.dump_ips_select_rec()',
               MSG_LEVEL_BASIC );
Line: 910

END dump_ips_select_rec;
Line: 918

        p_insert_ps_c		IN INTEGER,
	p_select_rec		IN select_ips_rec_type,
	p_number_of_due_dates	IN NUMBER,
	p_percent_t		IN number_table_type,
	p_terms_sequence_num_t	IN number_table_type,
	p_due_date_t		IN date_table_type,
	p_line_amount_t		IN OUT NOCOPY number_table_type,
	p_tax_amount_t		IN OUT NOCOPY number_table_type,
	p_freight_amount_t	IN OUT NOCOPY number_table_type,
	p_charges_amount_t	IN OUT NOCOPY number_table_type,
	p_acctd_amt_due_rem_t	IN OUT NOCOPY number_table_type ) IS

    l_ignore 		INTEGER;
Line: 949

		p_select_rec.currency_code,
		p_select_rec.total_line_amount,
		p_percent_t,
		p_line_amount_t );
Line: 959

		p_select_rec.currency_code,
		p_select_rec.total_charges_amount,
		p_percent_t,
		p_charges_amount_t );
Line: 968

    IF( p_select_rec.first_installment_code = 'INCLUDE' ) THEN

        --------------------------------------------------------------------
        -- Put tax in 1st installment
        --------------------------------------------------------------------
        p_tax_amount_t( 0 ) := p_select_rec.total_tax_amount;
Line: 982

        p_freight_amount_t( 0 ) := p_select_rec.total_freight_amount;
Line: 996

		p_select_rec.currency_code,
		p_select_rec.total_tax_amount,
		p_percent_t,
		p_tax_amount_t );
Line: 1006

		p_select_rec.currency_code,
		p_select_rec.total_freight_amount,
		p_percent_t,
		p_freight_amount_t );
Line: 1018

	p_select_rec.exchange_rate,
	p_line_amount_t,
	p_tax_amount_t,
	p_freight_amount_t,
	p_charges_amount_t,
	p_acctd_amt_due_rem_t,
	p_select_rec.rec_acctd_amount );
Line: 1038

	    debug( '  Binding insert_ps_c', MSG_LEVEL_DEBUG );
Line: 1040

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 1044

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 1048

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'request_id',
                                    p_profile_info.request_id );
Line: 1052

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'application_id',
                                    p_profile_info.application_id );
Line: 1056

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'program_id',
                                    p_profile_info.conc_program_id );
Line: 1063

            SELECT ar_payment_schedules_s.nextval
              INTO l_ps_id
             FROM dual;
Line: 1067

            dbms_sql.bind_variable( p_insert_ps_c,
                                    'payment_schedule_id',
                                    l_ps_id );
Line: 1072

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'customer_trx_id',
                                    p_select_rec.customer_trx_id );
Line: 1076

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'line_amt',
                                    p_line_amount_t(i) );
Line: 1080

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'tax_amt',
                                    p_tax_amount_t(i) );
Line: 1084

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'frt_amt',
                                    p_freight_amount_t(i) );
Line: 1088

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'charge_amt',
                                    p_charges_amount_t(i) );
Line: 1092

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'acctd_adr',
                                    p_acctd_amt_due_rem_t(i) );
Line: 1096

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'terms_sequence_number',
                                    p_terms_sequence_num_t(i) );
Line: 1100

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'due_date',
                                    p_due_date_t(i) );
Line: 1104

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'term_id',
                                    p_select_rec.term_id );
Line: 1108

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'customer_id',
                                    p_select_rec.customer_id );
Line: 1112

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'type',
                                    p_select_rec.trx_type );
Line: 1116

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'site_use_id',
                                    p_select_rec.site_use_id );
Line: 1120

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'cust_trx_type_id',
                                    p_select_rec.cust_trx_type_id );
Line: 1124

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'currency_code',
                                    p_select_rec.currency_code );
Line: 1128

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'trx_date',
                                    p_select_rec.trx_date );
Line: 1132

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'gl_date',
                                    p_select_rec.gl_date );
Line: 1136

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'trx_number',
                                    p_select_rec.trx_number );
Line: 1140

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_rate_type',
                                    p_select_rec.exchange_rate_type );
Line: 1144

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_rate',
                                    p_select_rec.exchange_rate );
Line: 1148

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_date',
                                    p_select_rec.exchange_date );
Line: 1152

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'number_of_due_dates',
                                    p_number_of_due_dates );
Line: 1156

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'reversed_cash_receipt_id',
                                    p_select_rec.reversed_cash_receipt_id );
Line: 1161

            dbms_sql.bind_variable( p_insert_ps_c,
		                            'org_id',
                                    arp_standard.sysparm.org_id /* SSA changes anuj */ );
Line: 1167

            debug( 'EXCEPTION: Error in binding rule_insert_dist_c',
                   MSG_LEVEL_BASIC );
Line: 1176

	    debug( '  Inserting payment schedules', MSG_LEVEL_DEBUG );
Line: 1177

            l_ignore := dbms_sql.execute( p_insert_ps_c );
Line: 1178

            debug( to_char(l_ignore) || ' row(s) inserted',
		           MSG_LEVEL_DEBUG );
Line: 1188

                         JL_BR_SPED_PKG.SET_TRX_LOCK_STATUS(p_select_rec.customer_trx_id);
Line: 1199

            | Call central MRC library for insertion    |
            | into MRC tables                           |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'INSERT',
                      p_table_name       => 'AR_PAYMENT_SCHEDULES',
                      p_mode             => 'SINGLE',
                      p_key_value        => l_ps_id);
Line: 1211

            debug( 'EXCEPTION: Error executing insert ps stmt',
                   MSG_LEVEL_BASIC );
Line: 1230

PROCEDURE insert_inv_ps_private(
	p_system_info		IN arp_trx_global.system_info_rec_type,
	p_profile_info 		IN arp_trx_global.profile_rec_type,
	p_customer_trx_id 		IN BINARY_INTEGER,
	p_reversed_cash_receipt_id	IN BINARY_INTEGER ) IS

    l_ignore 			INTEGER;
Line: 1251

    l_select_rec		select_ips_rec_type;
Line: 1255

    PROCEDURE load_tables( p_select_rec IN select_ips_rec_type ) IS

    BEGIN
        print_fcn_label2('arp_maintain_ps2.load_tables()+' );
Line: 1261

				p_select_rec.term_sequence_num;
Line: 1262

        l_percent_t( l_table_index ) := p_select_rec.percent;
Line: 1263

        l_due_date_t( l_table_index ) := p_select_rec.due_date;
Line: 1305

    print_fcn_label( 'arp_maintain_ps2.insert_inv_ps_private()+' );
Line: 1310

    IF( NOT( dbms_sql.is_open( ips_select_c ) AND
	     dbms_sql.is_open( ips_insert_ps_c ) )) THEN

        build_ips_sql( system_info,
		       profile_info,
		       ips_select_c,
		       ips_insert_ps_c );
Line: 1320

    define_ips_select_columns( ips_select_c, l_select_rec );
Line: 1325

    dbms_sql.bind_variable( ips_select_c,
			    'customer_trx_id',
			    p_customer_trx_id );
Line: 1332

    debug( '  Executing select sql', MSG_LEVEL_DEBUG );
Line: 1335

        l_ignore := dbms_sql.execute( ips_select_c );
Line: 1339

          debug( 'EXCEPTION: Error executing select sql',
		 MSG_LEVEL_BASIC );
Line: 1351

            IF dbms_sql.fetch_rows( ips_select_c ) > 0  THEN

	        debug('  Fetched a row', MSG_LEVEL_DEBUG );
Line: 1358

		dbms_sql.column_value( ips_select_c, 1, l_customer_trx_id );
Line: 1368

				ips_insert_ps_c,
				l_select_rec,
				l_table_index,
				l_percent_t,
				l_terms_sequence_num_t,
				l_due_date_t,
				l_line_amount_t,
				l_tax_amount_t,
				l_freight_amount_t,
				l_charges_amount_t,
				l_acctd_amt_due_rem_t );
Line: 1388

		get_ips_column_values( ips_select_c, l_select_rec );
Line: 1396

		   l_select_rec.reversed_cash_receipt_id :=
					p_reversed_cash_receipt_id;
Line: 1400

		dump_ips_select_rec( l_select_rec );
Line: 1402

		load_tables( l_select_rec );
Line: 1409

				ips_insert_ps_c,
				l_select_rec,
				l_table_index,
				l_percent_t,
				l_terms_sequence_num_t,
				l_due_date_t,
				l_line_amount_t,
				l_tax_amount_t,
				l_freight_amount_t,
				l_charges_amount_t,
				l_acctd_amt_due_rem_t );
Line: 1428

            debug( 'EXCEPTION: Error fetching select cursor',
                   MSG_LEVEL_BASIC );
Line: 1434

    print_fcn_label( 'arp_maintain_ps2.insert_inv_ps_private()-' );
Line: 1438

        debug( 'EXCEPTION: arp_maintain_ps2.insert_inv_ps_private()',
	       MSG_LEVEL_BASIC );
Line: 1442

END insert_inv_ps_private;
Line: 1474

        p_select_c 		IN OUT NOCOPY INTEGER,
	p_insert_ps_c 		IN OUT NOCOPY INTEGER,
	p_insert_ra_c 		IN OUT NOCOPY INTEGER,
        p_update_ps_c 		IN OUT NOCOPY INTEGER ) IS

    l_insert_ps_sql	VARCHAR2(3000);
Line: 1480

    l_insert_ra_sql	VARCHAR2(3000);
Line: 1481

    l_update_ps_sql	VARCHAR2(2000);
Line: 1482

    l_select_sql	VARCHAR2(6000);
Line: 1492

    l_select_sql :=
'SELECT
/* null, */
nvl(ct.trx_date, sysdate),
ct.bill_to_customer_id,
ct.cust_trx_type_id,
ctl.customer_trx_id,
ct.invoice_currency_code,
sum(decode(ctl.line_type,
           ''LINE'', ctl.extended_amount, 0)) /
    (count(distinct nvl(ra.receivable_application_id, -9.9)) *
     count(distinct nvl(adj.adjustment_id, -9.9))),
sum(decode(ctl.line_type, ''FREIGHT'', ctl.extended_amount, 0)) /
    (count(distinct nvl(ra.receivable_application_id, -9.9)) *
     count(distinct nvl(adj.adjustment_id, -9.9))),
sum(decode(ctl.line_type, ''TAX'', ctl.extended_amount, 0)) /
    (count(distinct nvl(ra.receivable_application_id, -9.9)) *
     count(distinct nvl(adj.adjustment_id, -9.9))),
/* null, */
ct.exchange_rate_type,
ct.exchange_rate,
ct.exchange_date,
ct.trx_number,
nvl(ctlgd.gl_date, ct.trx_date),
ctlgd_inv.code_combination_id,
ps.customer_trx_id,
ps.payment_schedule_id,
greatest(nvl(max(decode(ra.confirmed_flag,
				''Y'', ra.gl_date,
                                null, decode(ra.receivable_application_id,
					     null, nvl(ctlgd.gl_date,
					                ct.trx_date),
                                             ra.gl_date),
				nvl(ctlgd.gl_date, ct.trx_date))),
		     nvl(ctlgd.gl_date, ct.trx_date)),
                 nvl(max(decode(adj.status,
				''A'',adj.gl_date,
				nvl(ctlgd.gl_date,ct.trx_date))),
		     nvl(ctlgd.gl_date,ct.trx_date)),
                 nvl(ctlgd.gl_date, ct.trx_date)),
greatest(nvl(max(decode(ra.confirmed_flag,
                                ''Y'', ra.apply_date,
                                null, decode(ra.receivable_application_id,
                                             null, ct.trx_date,
                                             ra.apply_date),
				ct.trx_date)),
		     ct.trx_date),
                 nvl(max(decode(adj.status,
				''A'',adj.apply_date,
				ct.trx_date)),
		     ct.trx_date),
                 ct.trx_date),
c.precision,
nvl(ps.amount_line_items_remaining,0),
nvl(ps.freight_remaining,0),
nvl(ps.tax_remaining,0),
ct.bill_to_site_use_id,
/* 0, */
/* 0, */
/* 0, */
c.minimum_accountable_unit,
ctt.post_to_gl,
/* nvl(ctlgd.gl_date,ct.trx_date), */
ct.credit_method_for_installments,
nvl(ps.amount_credited,0),
ps.amount_due_remaining,
ps.acctd_amount_due_remaining,
/* null, */
/* null, */
c_inv.precision,
c_inv.minimum_accountable_unit,
ct_inv.exchange_rate,
ctlgd.acctd_amount,
/* null, */
/* null, */
/* null, */
/* null, */
sum(decode(ctl.line_type, ''CHARGES'', ctl.extended_amount, 0)) /
    (count(distinct nvl(ra.receivable_application_id, -9.9)) *
     count(distinct nvl(adj.adjustment_id, -9.9))),
/* null, */
nvl(ps.receivables_charges_remaining,0)
/* , 0 */
FROM
ar_receivable_applications ra,
ar_payment_schedules ps,
ar_adjustments adj,
ra_cust_trx_types ctt,
ra_cust_trx_line_gl_dist ctlgd,
ra_customer_trx ct,
fnd_currencies c,
fnd_currencies c_inv,
ra_customer_trx ct_inv,
ra_cust_trx_line_gl_dist ctlgd_inv,
ra_customer_trx_lines ctl
WHERE ct.customer_trx_id = :customer_trx_id
and   ctl.customer_trx_id = ct.customer_trx_id
AND    ct.cust_trx_type_id = ctt.cust_trx_type_id
AND    ctt.type = ''CM''
AND    ctt.accounting_affect_flag = ''Y''
AND    ctl.previous_customer_trx_id = ps.customer_trx_id
AND    ps.customer_trx_id = ra.applied_customer_trx_id (+)
AND    ps.customer_trx_id = adj.customer_trx_id (+)
AND    c.currency_code = ct.invoice_currency_code
AND    ct.customer_trx_id = ctlgd.customer_trx_id
AND    ctlgd.account_class = ''REC''
AND    ctlgd.latest_rec_flag = ''Y''
AND    ps.customer_trx_id = ct_inv.customer_trx_id
AND    ct_inv.customer_trx_id = ctlgd_inv.customer_trx_id
AND    ctlgd_inv.account_class = ''REC''
AND    ctlgd_inv.latest_rec_flag= ''Y''
AND    ct_inv.invoice_currency_code = c_inv.currency_code
GROUP BY
ctl.customer_trx_id,
ct.trx_date,
ct.bill_to_customer_id,
ct.cust_trx_type_id,
ct.invoice_currency_code,
ct.exchange_rate_type,
ct.exchange_rate,
ct.exchange_date,
ct.trx_number,
nvl(ctlgd.gl_date, ct.trx_date),
ctlgd_inv.code_combination_id,
ps.customer_trx_id,
ps.payment_schedule_id,
ps.freight_remaining,
ps.tax_remaining,
ps.amount_line_items_remaining,
ps.gl_date,
ra.applied_customer_trx_id,
adj.customer_trx_id,
ct.bill_to_site_use_id,
c.precision,
c.minimum_accountable_unit,
ctlgd.gl_date,
ct.trx_date,
ct.credit_method_for_installments,
ctt.post_to_gl,
ps.amount_credited,
c_inv.precision,
c_inv.minimum_accountable_unit,
ct_inv.exchange_rate,
ctlgd.acctd_amount,
ps.terms_sequence_number,
ps.amount_due_remaining,
ps.receivables_charges_remaining,
ps.acctd_amount_due_remaining
ORDER BY
ps.customer_trx_id asc,
ctl.customer_trx_id asc,
ps.terms_sequence_number';
Line: 1646

    debug('  select_sql = ' || CRLF ||
          l_select_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1649

    debug('  len(select_sql) = '||
          to_char(length(l_select_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1657

    l_insert_ps_sql :=
'INSERT INTO AR_PAYMENT_SCHEDULES
(
created_by,
creation_date,
last_updated_by,
last_update_date,
last_update_login,
request_id,
program_application_id,
program_id,
program_update_date,
payment_schedule_id,
customer_trx_id,
amount_due_original,
amount_due_remaining,
acctd_amount_due_remaining,
amount_line_items_original,
amount_line_items_remaining,
tax_original,
tax_remaining,
freight_original,
freight_remaining,
receivables_charges_charged,
receivables_charges_remaining,
amount_credited,
amount_applied,
term_id,
terms_sequence_number,
due_date,
customer_id,
class,
customer_site_use_id,
cust_trx_type_id,
number_of_due_dates,
status,
invoice_currency_code,
actual_date_closed,
exchange_rate_type,
exchange_rate,
exchange_date,
trx_number,
trx_date,
gl_date_closed,
gl_date
,org_id
)
VALUES
(
:user_id,		/* created_by */
sysdate,		/* creation_date */
:user_id,		/* last_updated_by */
sysdate,		/* last_update_date */
:login_id,		/* last_update_login */
:request_id,
decode(:application_id,
       -1, null, :application_id), 		/* program_application_id */
decode(:program_id, -1, null, :program_id),	/* program_id */
sysdate,				/* program_update_date */
:payment_schedule_id,		/* payment_schedule_id */
:customer_trx_id,
:amount_due_original,
0,				/* amount_due_remaining */
0,				/* acctd_amount_due_remaining */
:amount_line_items_original,
0,				/* amount_line_items_remaining */
:tax_original,
0,				/* tax_remaining */
:freight_original,
0,				/* freight_remaining */
:receivables_charges_charged,
0,				/* receivables_charges_remaining */
0,				/* amount_credited */
:amount_applied,
null,				/* term_id */
1,				/* terms_sequence_number */
:trx_date,
:customer_id,
''CM'',				/* class */
:site_use_id,
:cust_trx_type_id,
1,				/* number_of_due_dates */
''CL'',				/* status */
:currency_code,
nvl(:trx_date, to_date(''12/31/4712'',''MM/DD/YYYY'')),
:exchange_rate_type,
:exchange_rate,
:exchange_date,
:trx_number,
:trx_date,
nvl(:gl_date, to_date(''12/31/4712'',''MM/DD/YYYY'')),			/* gl_date_closed */
:gl_date
,:org_id --arp_standard.sysparm.org_id /* SSA changes anuj */
)' ;
Line: 1752

    debug('  insert_ps_sql = ' || CRLF ||
          l_insert_ps_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1755

    debug('  len(insert_ps_sql) = '||
          to_char(length(l_insert_ps_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1763

    l_insert_ra_sql :=
'INSERT INTO AR_RECEIVABLE_APPLICATIONS
(
created_by,
creation_date,
last_updated_by,
last_update_date,
request_id,
program_application_id,
program_id,
program_update_date,
last_update_login,
receivable_application_id,
customer_trx_id,
payment_schedule_id,
gl_date,
code_combination_id,
set_of_books_id,
display,
application_type,
apply_date,
applied_customer_trx_id,
applied_payment_schedule_id,
status,
amount_applied,
acctd_amount_applied_from,
acctd_amount_applied_to,
line_applied,
tax_applied,
freight_applied,
receivables_charges_applied,
application_rule,
postable,
posting_control_id,
cash_receipt_history_id,
ussgl_transaction_code
,org_id
)
SELECT
:user_id,		/* created_by */
sysdate,		/* creation_date */
:user_id,		/* last_updated_by */
sysdate,		/* last_update_date */
:request_id,
:application_id,
:program_id,
sysdate,		/* program_update_date */
:login_id,		/* last_update_login */
:receivable_application_id,
:customer_trx_id,
ps.payment_schedule_id,
:gl_date,
:code_combination_id,
:set_of_books_id,
''Y'',			/* display */
''CM'',			/* application_type */
:trx_date,
:applied_customer_trx_id,
:applied_payment_schedule_id,
''APP'',			/* status */
-:amount_applied,
-:acctd_amount_applied_from,
-:acctd_amount_applied_to,
-:line_applied,
-:tax_applied,
-:freight_applied,
-:receivables_charges_applied,
67,			/* application_rule */
:post_to_gl_flag,
-3,			/* posting_control_id */
null,			/* cash_receipt_history_id */
:ussgl_transaction_code /*Transaction code*/
,ps.org_id /* SSA changes anuj */
FROM AR_PAYMENT_SCHEDULES ps
/*  assumes only one ps line exists for CM */
WHERE :customer_trx_id = ps.customer_trx_id';
Line: 1840

    debug('  insert_ra_sql = ' || CRLF ||
          l_insert_ra_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1843

    debug('  len(insert_ra_sql) = '||
          to_char(length(l_insert_ra_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1852

    l_update_ps_sql :=
'UPDATE AR_PAYMENT_SCHEDULES
SET
last_update_date = sysdate,
last_updated_by = :user_id,
last_update_login = :login_id,
status = decode(:amount_due_remaining, 0, ''CL'', ''OP''),
gl_date_closed = decode(:amount_due_remaining, 0, :gl_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
actual_date_closed =
	decode(:amount_due_remaining, 0, :actual_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
amount_due_remaining = :amount_due_remaining,
acctd_amount_due_remaining = :acctd_amount_due_remaining,
amount_line_items_remaining = :amount_line_items_remaining,
freight_remaining = :freight_remaining,
tax_remaining = :tax_remaining,
receivables_charges_remaining = :receivables_charges_remaining,
amount_credited = :amount_credited
WHERE payment_schedule_id = :applied_payment_schedule_id';
Line: 1871

    debug('  update_ps_sql = ' || CRLF ||
          l_update_ps_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1874

    debug('  len(update_ps_sql) = '||
          to_char(length(l_update_ps_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 1887

	debug( '  Parsing insert_ps_c', MSG_LEVEL_DEBUG );
Line: 1888

        p_insert_ps_c := dbms_sql.open_cursor;
Line: 1889

        dbms_sql.parse( p_insert_ps_c, l_insert_ps_sql,
                        dbms_sql.v7 );
Line: 1892

	debug( '  Parsing insert_ra_c', MSG_LEVEL_DEBUG );
Line: 1893

        p_insert_ra_c := dbms_sql.open_cursor;
Line: 1894

        dbms_sql.parse( p_insert_ra_c, l_insert_ra_sql,
                        dbms_sql.v7 );
Line: 1897

	debug( '  Parsing update_ps_c', MSG_LEVEL_DEBUG );
Line: 1898

        p_update_ps_c := dbms_sql.open_cursor;
Line: 1899

        dbms_sql.parse( p_update_ps_c, l_update_ps_sql,
                        dbms_sql.v7 );
Line: 1902

	debug( '  Parsing select_c', MSG_LEVEL_DEBUG );
Line: 1903

        p_select_c := dbms_sql.open_cursor;
Line: 1904

        dbms_sql.parse( p_select_c, l_select_sql,
                        dbms_sql.v7 );
Line: 1929

PROCEDURE define_ira_select_columns(
	p_select_c   IN INTEGER,
        p_select_rec IN select_ira_rec_type ) IS

BEGIN

    print_fcn_label2( 'arp_maintain_ps2.define_ira_select_columns()+' );
Line: 1937

    dbms_sql.define_column( p_select_c, 1, p_select_rec.trx_date );
Line: 1938

    dbms_sql.define_column( p_select_c, 2, p_select_rec.customer_id );
Line: 1939

    dbms_sql.define_column( p_select_c, 3, p_select_rec.cust_trx_type_id );
Line: 1940

    dbms_sql.define_column( p_select_c, 4, p_select_rec.customer_trx_id );
Line: 1941

    dbms_sql.define_column( p_select_c, 5, p_select_rec.currency_code, 15 );
Line: 1942

    dbms_sql.define_column( p_select_c, 6, p_select_rec.total_cm_line_amount );
Line: 1943

    dbms_sql.define_column( p_select_c, 7,
				p_select_rec.total_cm_freight_amount );
Line: 1945

    dbms_sql.define_column( p_select_c, 8, p_select_rec.total_cm_tax_amount );
Line: 1946

    dbms_sql.define_column( p_select_c, 9,
                            p_select_rec.exchange_rate_type, 30 );
Line: 1948

    dbms_sql.define_column( p_select_c, 10, p_select_rec.exchange_rate );
Line: 1949

    dbms_sql.define_column( p_select_c, 11, p_select_rec.exchange_date );
Line: 1950

    dbms_sql.define_column( p_select_c, 12, p_select_rec.trx_number, 20 );
Line: 1951

    dbms_sql.define_column( p_select_c, 13, p_select_rec.gl_date );
Line: 1952

    dbms_sql.define_column( p_select_c, 14, p_select_rec.code_combination_id );
Line: 1953

    dbms_sql.define_column( p_select_c, 15, p_select_rec.inv_customer_trx_id );
Line: 1954

    dbms_sql.define_column( p_select_c, 16,
				p_select_rec.inv_payment_schedule_id );
Line: 1956

    dbms_sql.define_column( p_select_c, 17, p_select_rec.gl_date_closed );
Line: 1957

    dbms_sql.define_column( p_select_c, 18, p_select_rec.actual_date_closed );
Line: 1958

    dbms_sql.define_column( p_select_c, 19, p_select_rec.precision );
Line: 1959

    dbms_sql.define_column( p_select_c, 20, p_select_rec.inv_line_remaining );
Line: 1960

    dbms_sql.define_column( p_select_c, 21,
				p_select_rec.inv_freight_remaining );
Line: 1962

    dbms_sql.define_column( p_select_c, 22, p_select_rec.inv_tax_remaining );
Line: 1963

    dbms_sql.define_column( p_select_c, 23, p_select_rec.site_use_id );
Line: 1964

    dbms_sql.define_column( p_select_c, 24,
			    p_select_rec.min_acc_unit );
Line: 1966

    dbms_sql.define_column( p_select_c, 25,
			    p_select_rec.post_to_gl_flag, 1 );
Line: 1968

    dbms_sql.define_column( p_select_c, 26,
			    p_select_rec.credit_method, 30 );
Line: 1970

    dbms_sql.define_column( p_select_c, 27,
			    p_select_rec.inv_amount_credited );
Line: 1972

    dbms_sql.define_column( p_select_c, 28,
			    p_select_rec.inv_amount_due_remaining );
Line: 1974

    dbms_sql.define_column( p_select_c, 29,
			    p_select_rec.inv_acctd_amt_due_rem );
Line: 1976

    dbms_sql.define_column( p_select_c, 30, p_select_rec.inv_precision );
Line: 1977

    dbms_sql.define_column( p_select_c, 31,
				p_select_rec.inv_min_acc_unit );
Line: 1979

    dbms_sql.define_column( p_select_c, 32, p_select_rec.inv_exchange_rate );
Line: 1980

    dbms_sql.define_column( p_select_c, 33, p_select_rec.rec_acctd_amount );
Line: 1981

    dbms_sql.define_column( p_select_c, 34,
				p_select_rec.total_cm_charges_amount );
Line: 1983

    dbms_sql.define_column( p_select_c, 35,
				p_select_rec.inv_charges_remaining );
Line: 1987

    print_fcn_label2( 'arp_maintain_ps2.define_ira_select_columns()-' );
Line: 1991

        debug('EXCEPTION: arp_maintain_ps2.define_ira_select_columns()',
	      MSG_LEVEL_BASIC);
Line: 1994

END define_ira_select_columns;
Line: 1998

PROCEDURE get_ira_column_values( p_select_c   IN INTEGER,
                             p_select_rec IN OUT NOCOPY select_ira_rec_type ) IS
/* Bug 460927 - Modified IN to IN OUT oin the above line - oracle 8 */
BEGIN
    print_fcn_label2( 'arp_maintain_ps2.get_ira_column_values()+' );
Line: 2004

    dbms_sql.column_value( p_select_c, 1, p_select_rec.trx_date );
Line: 2005

    dbms_sql.column_value( p_select_c, 2, p_select_rec.customer_id );
Line: 2006

    dbms_sql.column_value( p_select_c, 3, p_select_rec.cust_trx_type_id );
Line: 2007

    dbms_sql.column_value( p_select_c, 4, p_select_rec.customer_trx_id );
Line: 2008

    dbms_sql.column_value( p_select_c, 5, p_select_rec.currency_code );
Line: 2009

    dbms_sql.column_value( p_select_c, 6, p_select_rec.total_cm_line_amount );
Line: 2010

    dbms_sql.column_value( p_select_c, 7,
				p_select_rec.total_cm_freight_amount );
Line: 2012

    dbms_sql.column_value( p_select_c, 8, p_select_rec.total_cm_tax_amount );
Line: 2013

    dbms_sql.column_value( p_select_c, 9,
                            p_select_rec.exchange_rate_type );
Line: 2015

    dbms_sql.column_value( p_select_c, 10, p_select_rec.exchange_rate );
Line: 2016

    dbms_sql.column_value( p_select_c, 11, p_select_rec.exchange_date );
Line: 2017

    dbms_sql.column_value( p_select_c, 12, p_select_rec.trx_number );
Line: 2018

    dbms_sql.column_value( p_select_c, 13, p_select_rec.gl_date );
Line: 2019

    dbms_sql.column_value( p_select_c, 14, p_select_rec.code_combination_id );
Line: 2020

    dbms_sql.column_value( p_select_c, 15, p_select_rec.inv_customer_trx_id );
Line: 2021

    dbms_sql.column_value( p_select_c, 16,
				p_select_rec.inv_payment_schedule_id );
Line: 2023

    dbms_sql.column_value( p_select_c, 17, p_select_rec.gl_date_closed );
Line: 2024

    dbms_sql.column_value( p_select_c, 18, p_select_rec.actual_date_closed );
Line: 2025

    dbms_sql.column_value( p_select_c, 19, p_select_rec.precision );
Line: 2026

    dbms_sql.column_value( p_select_c, 20, p_select_rec.inv_line_remaining );
Line: 2027

    dbms_sql.column_value( p_select_c, 21,
				p_select_rec.inv_freight_remaining );
Line: 2029

    dbms_sql.column_value( p_select_c, 22, p_select_rec.inv_tax_remaining );
Line: 2030

    dbms_sql.column_value( p_select_c, 23, p_select_rec.site_use_id );
Line: 2031

    dbms_sql.column_value( p_select_c, 24,
			    p_select_rec.min_acc_unit );
Line: 2033

    dbms_sql.column_value( p_select_c, 25,
			    p_select_rec.post_to_gl_flag );
Line: 2035

    dbms_sql.column_value( p_select_c, 26,
			    p_select_rec.credit_method );
Line: 2037

    dbms_sql.column_value( p_select_c, 27,
			    p_select_rec.inv_amount_credited );
Line: 2039

    dbms_sql.column_value( p_select_c, 28,
			    p_select_rec.inv_amount_due_remaining );
Line: 2041

    dbms_sql.column_value( p_select_c, 29,
			    p_select_rec.inv_acctd_amt_due_rem );
Line: 2043

    dbms_sql.column_value( p_select_c, 30, p_select_rec.inv_precision );
Line: 2044

    dbms_sql.column_value( p_select_c, 31,
				p_select_rec.inv_min_acc_unit );
Line: 2046

    dbms_sql.column_value( p_select_c, 32, p_select_rec.inv_exchange_rate );
Line: 2047

    dbms_sql.column_value( p_select_c, 33, p_select_rec.rec_acctd_amount );
Line: 2048

    dbms_sql.column_value( p_select_c, 34,
				p_select_rec.total_cm_charges_amount );
Line: 2050

    dbms_sql.column_value( p_select_c, 35,
				p_select_rec.inv_charges_remaining );
Line: 2084

PROCEDURE dump_ira_select_rec( p_select_rec IN select_ira_rec_type ) IS
BEGIN

    print_fcn_label2( 'arp_maintain_ps2.dump_ira_select_rec()+' );
Line: 2089

    debug( '  Dumping select record: ', MSG_LEVEL_DEBUG );
Line: 2091

           || p_select_rec.customer_trx_id, MSG_LEVEL_DEBUG );
Line: 2093

           || p_select_rec.trx_number, MSG_LEVEL_DEBUG );
Line: 2095

           || p_select_rec.cust_trx_type_id, MSG_LEVEL_DEBUG );
Line: 2097

           || p_select_rec.post_to_gl_flag, MSG_LEVEL_DEBUG );
Line: 2099

           || p_select_rec.credit_method, MSG_LEVEL_DEBUG );
Line: 2101

           || p_select_rec.trx_date, MSG_LEVEL_DEBUG );
Line: 2103

           || p_select_rec.gl_date, MSG_LEVEL_DEBUG );
Line: 2105

           || p_select_rec.customer_id, MSG_LEVEL_DEBUG );
Line: 2107

           || p_select_rec.site_use_id, MSG_LEVEL_DEBUG );
Line: 2109

           || p_select_rec.currency_code, MSG_LEVEL_DEBUG );
Line: 2111

           || p_select_rec.precision, MSG_LEVEL_DEBUG );
Line: 2113

           || p_select_rec.min_acc_unit, MSG_LEVEL_DEBUG );
Line: 2115

           || p_select_rec.exchange_rate_type, MSG_LEVEL_DEBUG );
Line: 2117

           || p_select_rec.exchange_rate, MSG_LEVEL_DEBUG );
Line: 2119

           || p_select_rec.exchange_date, MSG_LEVEL_DEBUG );
Line: 2121

           || p_select_rec.rec_acctd_amount, MSG_LEVEL_DEBUG );
Line: 2123

           || p_select_rec.total_cm_line_amount, MSG_LEVEL_DEBUG );
Line: 2125

           || p_select_rec.total_cm_tax_amount, MSG_LEVEL_DEBUG );
Line: 2127

           || p_select_rec.total_cm_freight_amount, MSG_LEVEL_DEBUG );
Line: 2129

           || p_select_rec.total_cm_charges_amount, MSG_LEVEL_DEBUG );
Line: 2131

           || p_select_rec.code_combination_id, MSG_LEVEL_DEBUG );
Line: 2133

           || p_select_rec.gl_date_closed, MSG_LEVEL_DEBUG );
Line: 2135

           || p_select_rec.actual_date_closed, MSG_LEVEL_DEBUG );
Line: 2137

           || p_select_rec.inv_customer_trx_id, MSG_LEVEL_DEBUG );
Line: 2139

           || p_select_rec.inv_precision, MSG_LEVEL_DEBUG );
Line: 2141

           || p_select_rec.inv_min_acc_unit, MSG_LEVEL_DEBUG );
Line: 2143

           || p_select_rec.inv_exchange_rate, MSG_LEVEL_DEBUG );
Line: 2145

           || p_select_rec.inv_payment_schedule_id, MSG_LEVEL_DEBUG );
Line: 2147

           || p_select_rec.inv_amount_due_remaining, MSG_LEVEL_DEBUG );
Line: 2149

           || p_select_rec.inv_acctd_amt_due_rem, MSG_LEVEL_DEBUG );
Line: 2151

           || p_select_rec.inv_line_remaining, MSG_LEVEL_DEBUG );
Line: 2153

           || p_select_rec.inv_tax_remaining, MSG_LEVEL_DEBUG );
Line: 2155

           || p_select_rec.inv_freight_remaining, MSG_LEVEL_DEBUG );
Line: 2157

           || p_select_rec.inv_charges_remaining, MSG_LEVEL_DEBUG );
Line: 2159

           || p_select_rec.inv_amount_credited, MSG_LEVEL_DEBUG );
Line: 2161

    print_fcn_label2( 'arp_maintain_ps2.dump_ira_select_rec()-' );
Line: 2165

        debug( 'EXCEPTION: arp_maintain_ps2.dump_ira_select_rec()',
               MSG_LEVEL_BASIC );
Line: 2168

END dump_ira_select_rec;
Line: 2304

	p_select_rec		IN select_ira_rec_type,
	p_count			IN NUMBER,
	p_cm_amount		IN NUMBER,
	p_inv_rem_t		IN OUT NOCOPY number_table_type,
	p_cm_applied_amt_t  	IN OUT NOCOPY number_table_type ) IS

    l_cm_amount_sign	NUMBER;
Line: 2420

		p_select_rec.currency_code,
		l_apply_amount,
		l_percent_t,
		p_cm_applied_amt_t );
Line: 2458

        p_insert_ps_c			IN INTEGER,
        p_insert_ra_c			IN INTEGER,
        p_update_ps_c			IN INTEGER,
	p_select_rec			IN select_ira_rec_type,
        p_number_records		IN NUMBER,
        p_inv_ps_id_t			IN id_table_type,
        p_inv_amount_due_rem_t 		IN OUT NOCOPY number_table_type,
        p_inv_acctd_amt_due_rem_t	IN OUT NOCOPY number_table_type,
        p_inv_line_rem_t 		IN OUT NOCOPY number_table_type,
        p_inv_tax_rem_t 		IN OUT NOCOPY number_table_type,
        p_inv_freight_rem_t 		IN OUT NOCOPY number_table_type,
        p_inv_charges_rem_t 		IN OUT NOCOPY number_table_type,
        p_inv_amount_credited_t 	IN OUT NOCOPY number_table_type,
        p_line_applied_t 		IN OUT NOCOPY number_table_type,
        p_tax_applied_t 		IN OUT NOCOPY number_table_type,
        p_freight_applied_t 		IN OUT NOCOPY number_table_type,
        p_charges_applied_t 		IN OUT NOCOPY number_table_type,
        p_acctd_amt_applied_from_t	IN OUT NOCOPY number_table_type,
        p_acctd_amt_applied_to_t	IN OUT NOCOPY number_table_type ) IS

     CURSOR get_appl_info (p_rec_app_id NUMBER) IS
            SELECT payment_schedule_id,
                   applied_payment_schedule_id
            from   ar_receivable_applications
            where receivable_application_id = p_rec_app_id;
Line: 2509

    IF( p_select_rec.credit_method in (FIFO, LIFO) ) THEN

	IF( p_select_rec.credit_method = FIFO ) THEN
	    debug( '  FIFO processing', MSG_LEVEL_DEBUG );
Line: 2530

		p_select_rec.total_cm_line_amount,
		p_inv_line_rem_t,
		p_line_applied_t );
Line: 2541

		p_select_rec.total_cm_tax_amount,
		p_inv_tax_rem_t,
		p_tax_applied_t );
Line: 2552

		p_select_rec.total_cm_freight_amount,
		p_inv_freight_rem_t,
		p_freight_applied_t );
Line: 2563

		p_select_rec.total_cm_charges_amount,
		p_inv_charges_rem_t,
		p_charges_applied_t );
Line: 2576

		p_select_rec,
		p_number_records,
		p_select_rec.total_cm_line_amount,
		p_inv_line_rem_t,
		p_line_applied_t );
Line: 2586

		p_select_rec,
		p_number_records,
		p_select_rec.total_cm_tax_amount,
		p_inv_tax_rem_t,
		p_tax_applied_t );
Line: 2596

		p_select_rec,
		p_number_records,
		p_select_rec.total_cm_freight_amount,
		p_inv_freight_rem_t,
		p_freight_applied_t );
Line: 2606

		p_select_rec,
		p_number_records,
		p_select_rec.total_cm_charges_amount,
		p_inv_charges_rem_t,
		p_charges_applied_t );
Line: 2628

	-- Update amount_credited
        --------------------------------------------------------------------
        p_inv_amount_credited_t( i ) :=
		p_inv_amount_credited_t( i ) + l_amount_applied ;
Line: 2641

		p_select_rec.inv_exchange_rate,
		'+',			-- type
		p_inv_amount_due_rem_t( i ),	-- master_from
		p_inv_acctd_amt_due_rem_t( i ),	-- acctd_master_from
		l_amount_applied,	-- detail
		l_new_inv_adr,		-- master_to
		l_new_inv_acctd_adr,	-- acctd_master_to
		l_new_acctd_amt_applied_to	-- acctd_detail
	);
Line: 2652

	-- Update amounts
        --------------------------------------------------------------------
	p_inv_amount_due_rem_t( i ) := l_new_inv_adr;
Line: 2666

		p_select_rec.exchange_rate,
		p_line_applied_t,
		p_tax_applied_t,
		p_freight_applied_t,
		p_charges_applied_t,
		p_acctd_amt_applied_from_t,
		p_select_rec.rec_acctd_amount );
Line: 2684

	    debug( '  Binding insert_ps_c', MSG_LEVEL_DEBUG );
Line: 2686

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 2690

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 2694

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'request_id',
                                    p_profile_info.request_id );
Line: 2698

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'application_id',
                                    p_profile_info.application_id );
Line: 2702

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'program_id',
                                    p_profile_info.conc_program_id );
Line: 2707

            SELECT ar_payment_schedules_s.nextval
              INTO l_ps_id
             FROM dual;
Line: 2711

            dbms_sql.bind_variable( p_insert_ps_c,
                                    'payment_schedule_id',
                                    l_ps_id );
Line: 2715

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'customer_trx_id',
                                    p_select_rec.customer_trx_id );
Line: 2719

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'amount_due_original',
                                    p_select_rec.total_cm_line_amount +
                                    p_select_rec.total_cm_tax_amount +
                                    p_select_rec.total_cm_freight_amount +
                                    p_select_rec.total_cm_charges_amount );
Line: 2726

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'amount_line_items_original',
                                    p_select_rec.total_cm_line_amount );
Line: 2730

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'tax_original',
                                    p_select_rec.total_cm_tax_amount );
Line: 2734

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'freight_original',
                                    p_select_rec.total_cm_freight_amount );
Line: 2738

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'receivables_charges_charged',
                                    p_select_rec.total_cm_charges_amount );
Line: 2742

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'amount_applied',
                                    p_select_rec.total_cm_line_amount +
                                    p_select_rec.total_cm_tax_amount +
                                    p_select_rec.total_cm_freight_amount +
                                    p_select_rec.total_cm_charges_amount );
Line: 2749

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'trx_date',
                                    p_select_rec.trx_date );
Line: 2753

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'customer_id',
                                    p_select_rec.customer_id );
Line: 2757

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'site_use_id',
                                    p_select_rec.site_use_id );
Line: 2761

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'cust_trx_type_id',
                                    p_select_rec.cust_trx_type_id );
Line: 2765

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'currency_code',
                                    p_select_rec.currency_code );
Line: 2769

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_rate_type',
                                    p_select_rec.exchange_rate_type );
Line: 2774

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_rate',
                                    p_select_rec.exchange_rate );
Line: 2779

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'exchange_date',
                                    p_select_rec.exchange_date );
Line: 2783

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'gl_date',
                                    p_select_rec.gl_date );
Line: 2787

            dbms_sql.bind_variable( p_insert_ps_c,
		                    'trx_number',
                                    p_select_rec.trx_number );
Line: 2791

            dbms_sql.bind_variable( p_insert_ps_c,
		                           'org_id',
                                    arp_standard.sysparm.org_id /* SSA changes anuj */
 );
Line: 2800

            debug( 'EXCEPTION: Error in binding insert_ps',
                   MSG_LEVEL_BASIC );
Line: 2809

	    debug( '  Inserting CM payment schedules', MSG_LEVEL_DEBUG );
Line: 2810

            l_ignore := dbms_sql.execute( p_insert_ps_c );
Line: 2811

            debug( to_char(l_ignore) || ' row(s) inserted',
		           MSG_LEVEL_DEBUG );
Line: 2815

            | Call central MRC library for insertion    |
            | into MRC tables                           |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'INSERT',
                      p_table_name       => 'AR_PAYMENT_SCHEDULES',
                      p_mode             => 'SINGLE',
                      p_key_value        => l_ps_id);
Line: 2827

            debug( 'EXCEPTION: Error executing insert ps stmt',
                   MSG_LEVEL_BASIC );
Line: 2841

	    debug( '  Binding insert_ra_c', MSG_LEVEL_DEBUG );
Line: 2843

/*Bug :2246098-Used a bind var for insert*/

	select  ct.default_ussgl_transaction_code into l_ussgl_transaction_code
	from ra_customer_trx ct
	WHERE ct.customer_trx_id=p_select_rec.customer_trx_id;
Line: 2849

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 2853

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 2857

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'request_id',
                                    p_profile_info.request_id );
Line: 2861

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'application_id',
                                    p_profile_info.application_id );
Line: 2865

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'program_id',
                                    p_profile_info.conc_program_id );
Line: 2870

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'customer_trx_id',
                                    p_select_rec.customer_trx_id );
Line: 2874

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'gl_date',
                                    p_select_rec.gl_date );
Line: 2878

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'code_combination_id',
                                    p_select_rec.code_combination_id );
Line: 2883

			p_insert_ra_c,
			'set_of_books_id',
                	arp_standard.sysparm.set_of_books_id );
Line: 2887

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'trx_date',
                                    p_select_rec.trx_date );
Line: 2891

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'applied_customer_trx_id',
                                    p_select_rec.inv_customer_trx_id );
Line: 2896

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'applied_payment_schedule_id',
                                    p_inv_ps_id_t( i ) );
Line: 2900

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'amount_applied',
                                    p_line_applied_t( i ) +
                                    p_tax_applied_t( i ) +
                                    p_freight_applied_t( i ) +
                                    p_charges_applied_t( i ) );
Line: 2908

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'acctd_amount_applied_from',
                                    p_acctd_amt_applied_from_t( i ) );
Line: 2912

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'acctd_amount_applied_to',
                                    p_acctd_amt_applied_to_t( i ) );
Line: 2916

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'line_applied',
                                    p_line_applied_t( i ) );
Line: 2920

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'tax_applied',
                                    p_tax_applied_t( i ) );
Line: 2924

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'freight_applied',
                                    p_freight_applied_t( i ) );
Line: 2928

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'receivables_charges_applied',
                                    p_charges_applied_t( i ) );
Line: 2932

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'post_to_gl_flag',
                                    p_select_rec.post_to_gl_flag );
Line: 2936

            select ar_receivable_applications_s.nextval
            into   l_receivable_application_id
            from   dual;
Line: 2940

            dbms_sql.bind_variable( p_insert_ra_c,
		                    'receivable_application_id',
                                    l_receivable_application_id );
Line: 2944

	    dbms_sql.bind_variable( p_insert_ra_c,
                                    'ussgl_transaction_code',
                                    l_ussgl_transaction_code );
Line: 2951

            debug( 'EXCEPTION: Error in selecting sequence nextval',
                   MSG_LEVEL_BASIC );
Line: 2956

            debug( 'EXCEPTION: Error in binding insert_ra_c',
                   MSG_LEVEL_BASIC );
Line: 2965

	    debug( '  Inserting applications', MSG_LEVEL_DEBUG );
Line: 2966

            l_ignore := dbms_sql.execute( p_insert_ra_c );
Line: 2968

            debug( to_char(l_ignore) || ' row(s) inserted',
		           MSG_LEVEL_DEBUG );
Line: 2981

            debug( 'EXCEPTION: Error executing insert ra stmt',
                   MSG_LEVEL_BASIC );
Line: 2991

    l_ae_doc_rec.document_id               := p_select_rec.customer_trx_id;
Line: 3000

      SELECT class INTO l_ps_class
      FROM   ar_payment_schedules
      WHERE  customer_trx_id = p_select_rec.customer_trx_id;
Line: 3031

	    debug( '  Binding update_ps_c', MSG_LEVEL_DEBUG );
Line: 3033

            dbms_sql.bind_variable( p_update_ps_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 3037

            dbms_sql.bind_variable( p_update_ps_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 3041

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_due_remaining',
                                    p_inv_amount_due_rem_t( i ) );
Line: 3045

            dbms_sql.bind_variable( p_update_ps_c,
		                    'gl_date_closed',
                                    p_select_rec.gl_date_closed );
Line: 3049

            dbms_sql.bind_variable( p_update_ps_c,
		                    'actual_date_closed',
                                    p_select_rec.actual_date_closed );
Line: 3053

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_line_items_remaining',
                                    p_inv_line_rem_t( i ) );
Line: 3057

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_credited',
                                    p_inv_amount_credited_t( i ) );
Line: 3061

            dbms_sql.bind_variable( p_update_ps_c,
		                    'freight_remaining',
                                    p_inv_freight_rem_t( i ) );
Line: 3065

            dbms_sql.bind_variable( p_update_ps_c,
		                    'tax_remaining',
                                    p_inv_tax_rem_t( i ) );
Line: 3069

            dbms_sql.bind_variable( p_update_ps_c,
		                    'acctd_amount_due_remaining',
                                    p_inv_acctd_amt_due_rem_t( i ) );
Line: 3073

            dbms_sql.bind_variable( p_update_ps_c,
		                    'receivables_charges_remaining',
                                    p_inv_charges_rem_t( i ) );
Line: 3077

            dbms_sql.bind_variable( p_update_ps_c,
		                    'applied_payment_schedule_id',
                                    p_inv_ps_id_t( i ) );
Line: 3085

            debug( 'EXCEPTION: Error in binding update_ps_c',
                   MSG_LEVEL_BASIC );
Line: 3095

            l_ignore := dbms_sql.execute( p_update_ps_c );
Line: 3096

            debug( to_char(l_ignore) || ' row(s) updated',
		           MSG_LEVEL_DEBUG );
Line: 3100

            | Call central MRC library for update       |
            | of AR_PAYMENT_SCHEDULES                   |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'UPDATE',
                      p_table_name       => 'AR_PAYMENT_SCHEDULES',
                      p_mode             => 'SINGLE',
                      p_key_value        => p_inv_ps_id_t( i ));
Line: 3112

            debug( 'EXCEPTION: Error executing update ps stmt',
                   MSG_LEVEL_BASIC );
Line: 3114

            debug('EXCEPTION: dynamic sql that got executed '||p_update_ps_c,
                   MSG_LEVEL_BASIC);
Line: 3135

PROCEDURE insert_cm_ps_private(
	p_system_info		IN arp_trx_global.system_info_rec_type,
	p_profile_info 		IN arp_trx_global.profile_rec_type,
	p_customer_trx_id 	IN BINARY_INTEGER ) IS

    l_ignore 			INTEGER;
Line: 3173

    l_select_rec		select_ira_rec_type;
Line: 3176

    PROCEDURE load_tables( p_select_rec IN select_ira_rec_type ) IS

    BEGIN
        print_fcn_label2('arp_maintain_ps2.load_tables()+' );
Line: 3182

				p_select_rec.inv_payment_schedule_id;
Line: 3184

				p_select_rec.inv_amount_due_remaining;
Line: 3186

				p_select_rec.inv_acctd_amt_due_rem;
Line: 3188

				p_select_rec.inv_line_remaining;
Line: 3190

				p_select_rec.inv_tax_remaining;
Line: 3192

				p_select_rec.inv_freight_remaining;
Line: 3194

				p_select_rec.inv_charges_remaining;
Line: 3196

				p_select_rec.inv_amount_credited;
Line: 3290

    print_fcn_label( 'arp_maintain_ps2.insert_cm_ps_private()+' );
Line: 3295

    IF( NOT( dbms_sql.is_open( ira_select_c ) AND
	     dbms_sql.is_open( ira_insert_ps_c ) AND
	     dbms_sql.is_open( ira_insert_ra_c ) AND
	     dbms_sql.is_open( ira_update_ps_c ) )) THEN

        build_ira_sql(
		system_info,
		profile_info,
		ira_select_c,
		ira_insert_ps_c,
		ira_insert_ra_c,
		ira_update_ps_c );
Line: 3310

    define_ira_select_columns( ira_select_c, l_select_rec );
Line: 3315

    dbms_sql.bind_variable( ira_select_c,
			    'customer_trx_id',
			    p_customer_trx_id );
Line: 3322

    debug( '  Executing select sql', MSG_LEVEL_DEBUG );
Line: 3325

        l_ignore := dbms_sql.execute( ira_select_c );
Line: 3329

          debug( 'EXCEPTION: Error executing select sql',
		 MSG_LEVEL_BASIC );
Line: 3341

            IF dbms_sql.fetch_rows( ira_select_c ) > 0  THEN

	        debug('  Fetched a row', MSG_LEVEL_DEBUG );
Line: 3348

		dbms_sql.column_value( ira_select_c, 4, l_customer_trx_id );
Line: 3349

		dbms_sql.column_value( ira_select_c, 15,
					l_inv_customer_trx_id );
Line: 3380

				ira_insert_ps_c,
				ira_insert_ra_c,
				ira_update_ps_c,
				l_select_rec,
				l_table_index,
				l_inv_ps_id_t,
				l_inv_amount_due_rem_t,
				l_inv_acctd_amt_due_rem_t,
				l_inv_line_rem_t,
				l_inv_tax_rem_t,
				l_inv_freight_rem_t,
				l_inv_charges_rem_t,
				l_inv_amount_credited_t,
				l_line_applied_t,
				l_tax_applied_t,
				l_freight_applied_t,
				l_charges_applied_t,
				l_acctd_amt_applied_from_t,
				l_acctd_amt_applied_to_t );
Line: 3426

		get_ira_column_values( ira_select_c, l_select_rec );
Line: 3427

		dump_ira_select_rec( l_select_rec );
Line: 3431

		    load_tables( l_select_rec );
Line: 3446

			ira_insert_ps_c,
			ira_insert_ra_c,
			ira_update_ps_c,
			l_select_rec,
			l_table_index,
			l_inv_ps_id_t,
			l_inv_amount_due_rem_t,
			l_inv_acctd_amt_due_rem_t,
			l_inv_line_rem_t,
			l_inv_tax_rem_t,
			l_inv_freight_rem_t,
			l_inv_charges_rem_t,
			l_inv_amount_credited_t,
			l_line_applied_t,
			l_tax_applied_t,
			l_freight_applied_t,
			l_charges_applied_t,
			l_acctd_amt_applied_from_t,
			l_acctd_amt_applied_to_t );
Line: 3476

            debug( 'EXCEPTION: Error fetching select cursor',
                   MSG_LEVEL_BASIC );
Line: 3482

    print_fcn_label( 'arp_maintain_ps2.insert_cm_ps_private()-' );
Line: 3486

        debug( 'EXCEPTION: arp_maintain_ps2.insert_cm_ps_private()',
	       MSG_LEVEL_BASIC );
Line: 3490

END insert_cm_ps_private;
Line: 3524

        p_select_c 		IN OUT NOCOPY INTEGER,
	p_insert_adj_c 		IN OUT NOCOPY INTEGER,
        p_update_ps_c 		IN OUT NOCOPY INTEGER ) IS

    l_insert_adj_sql	VARCHAR2(2000);
Line: 3529

    l_update_ps_sql	VARCHAR2(2000);
Line: 3530

    l_select_sql	VARCHAR2(6000);
Line: 3540

    l_select_sql :=
'SELECT
/* :raagixuix, */
ctl.set_of_books_id,
/* -1, */
/* -''Y'',  */
/* ''LINE'', overridden below */
/* -''C'', */
/* -''A'', */
sum(ctl.extended_amount) /
  (count(distinct ps.payment_schedule_id) *
  count(distinct nvl(ra.receivable_application_id, -9.9)) *
  count(distinct nvl(adj.adjustment_id, -9.9))),
nvl(:gl_date, nvl(ctlgd.gl_date, ct.trx_date)),
ctlgd_com.code_combination_id,
decode(ctt_com.type,
       ''DEP'', ctl.customer_trx_id,
        ctl_com.customer_trx_id),
ps.payment_schedule_id,
decode(ctt_com.type,
       ''DEP'', null,
       ctl.customer_trx_id),
''Y'',      /* bugfix 2614759. Instead of ctt.post_to_gl, pass y always. */
ct_com.customer_trx_id,
tl.relative_amount / t.base_amount,
c.precision,
c.minimum_accountable_unit,
greatest(nvl(max(decode(ra.confirmed_flag,
				''Y'', ra.gl_date,
                                null,
                                   decode(ra.receivable_application_id,
					      null, nvl(ctlgd.gl_date,
					                ct.trx_date),
                                              ra.gl_date),
					nvl(ctlgd.gl_date,
                                            ct.trx_date))),
			     nvl(ctlgd.gl_date,ct.trx_date)),
	                 nvl(max(decode(adj.status,
					''A'',adj.gl_date,
					nvl(ctlgd.gl_date,
					    ct.trx_date))),
			     nvl(ctlgd.gl_date,ct.trx_date)),
	                 nvl(:gl_date, nvl(ctlgd.gl_date, ct.trx_date))),
greatest(nvl(max(decode(ra.confirmed_flag,
                                        ''Y'', ra.apply_date,
                                        null,
                                       decode(ra.receivable_application_id,
                                              null, ct.trx_date,
                                              ra.apply_date),
				       ct.trx_date)),
			     ct.trx_date),
	                 nvl(max(decode(adj.status,
					''A'',adj.apply_date,
				ct.trx_date)),
			     ct.trx_date),
	                 nvl(:apply_date, ct.trx_date),
                         ct.trx_date),
nvl(:apply_date, ct.trx_date),
ctt_com.type,
/* :raagixlul, */
/* null, */
nvl(ps.amount_line_items_remaining,0),
ps.amount_due_remaining,
ps.acctd_amount_due_remaining,
nvl(ps.amount_adjusted,0),
c_ps.precision,
c_ps.minimum_accountable_unit,
ct_ps.exchange_rate,
ctl.customer_trx_id,
ct_ps.invoice_currency_code,
ctt_com.allocate_tax_freight,
DECODE(ctt_com.allocate_tax_freight, ''Y'', ''INVOICE'',''LINE''), /*1483656 - LINE or INVOICE */
nvl(ps.tax_remaining, 0),
nvl(ps.freight_remaining, 0),
ARPT_SQL_FUNC_UTIL.get_sum_of_trx_lines(ctl.customer_trx_id, ''TAX''),
ARPT_SQL_FUNC_UTIL.get_sum_of_trx_lines(ctl.customer_trx_id, ''FREIGHT'')
FROM
ra_cust_trx_types ctt,
ra_cust_trx_types ctt_com,
ra_cust_trx_line_gl_dist ctlgd_com,
ar_payment_schedules ps,
ar_receivable_applications ra,
ar_adjustments adj,
fnd_currencies c,
ra_terms t,
ra_terms_lines tl,
ra_customer_trx ct_com,
ra_customer_trx_lines ctl_com,
ra_customer_trx ct_ps,
fnd_currencies c_ps,
ra_customer_trx_lines ctl,
ra_customer_trx ct,
ra_cust_trx_line_gl_dist ctlgd
WHERE ct.customer_trx_id = :customer_trx_id
and   ctl.customer_trx_id = ct.customer_trx_id
and   ctlgd.customer_trx_id = ct.customer_trx_id
and   ctlgd.account_class = ''REC''
and   ctlgd.latest_rec_flag = ''Y''
and   ctl.line_type = ''LINE''
and   exists
        (select ''x''
         from   ra_customer_trx trx
         where  trx.customer_trx_id = ctl.customer_trx_id)
and   ctl.initial_customer_trx_line_id is not null
and   ct.invoice_currency_code = c.currency_code
and   ct.cust_trx_type_id = ctt.cust_trx_type_id
and   ctt.type = ''INV''
and   ctl.initial_customer_trx_line_id = ctl_com.customer_trx_line_id
and   ctl_com.customer_trx_id = ct_com.customer_trx_id
and   ctl_com.customer_trx_line_id = ctlgd_com.customer_trx_line_id
and   ctlgd_com.account_class = ''REV''
and   ct_com.cust_trx_type_id = ctt_com.cust_trx_type_id
and   ps.customer_trx_id =
                decode(ctt_com.type,
                       ''DEP'', ctl.customer_trx_id,
                              ctl_com.customer_trx_id)
and   ps.customer_trx_id = ct_ps.customer_trx_id
and   ct_ps.invoice_currency_code = c_ps.currency_code
and   ps.term_id = t.term_id
and   ps.term_id = tl.term_id
and   ps.terms_sequence_number = tl.sequence_num
and   ps.customer_trx_id = ra.applied_customer_trx_id (+)
and   ps.customer_trx_id = adj.customer_trx_id (+)
GROUP BY
ctlgd_com.code_combination_id,
ctl.customer_trx_id,
ctl_com.customer_trx_id,
ps.payment_schedule_id,
/* bugfix 2614759. comment out ctt.post_to_gl, */
ctt_com.type,
ctt_com.allocate_tax_freight, /*1483656*/
ct_com.customer_trx_id,
tl.relative_amount / t.base_amount,
c.precision,
c.minimum_accountable_unit,
ra.applied_customer_trx_id,
adj.customer_trx_id,
ctlgd.gl_date,
ct.trx_date,
ctlgd_com.gl_date,
ct_com.trx_date,
ctl.set_of_books_id,
c_ps.precision,
c_ps.minimum_accountable_unit,
ct_ps.exchange_rate,
ps.amount_line_items_remaining,
ps.tax_remaining,
ps.freight_remaining,
ps.amount_due_remaining,
ps.amount_adjusted,
ps.acctd_amount_due_remaining,
ps.terms_sequence_number,
ct_ps.invoice_currency_code
ORDER BY
ct_com.customer_trx_id,
ctl.customer_trx_id,
ps.terms_sequence_number';
Line: 3699

    debug('  select_sql = ' || CRLF ||
          l_select_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3702

    debug('  len(select_sql) = '||
          to_char(length(l_select_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3710

    l_insert_adj_sql :=
'INSERT INTO AR_ADJUSTMENTS
(
created_by,
creation_date,
last_updated_by,
last_update_date,
last_update_login,
request_id,
program_application_id,
program_id,
program_update_date,
set_of_books_id,
receivables_trx_id,
automatically_generated,
type,
adjustment_type,
status,
apply_date,
adjustment_id,
gl_date,
code_combination_id,
customer_trx_id,
payment_schedule_id,
subsequent_trx_id,
postable,
adjustment_number,
created_from,
posting_control_id,
amount,
acctd_amount,
line_adjusted,
tax_adjusted,
freight_adjusted
,org_id
)
VALUES
(
:user_id,
sysdate,
:user_id,
sysdate,
:login_id,
:request_id,
:application_id,
:program_id,
sysdate,
:set_of_books_id,
-1,
''Y'',
:adjust_type,
''C'',
''A'',
:trx_date,
:adjustment_id,
:gl_date,
:code_combination_id,
:adjusted_trx_id,
:payment_schedule_id,
:subsequent_trx_id,
:post_to_gl_flag,
to_char(ar_adjustment_number_s.nextval),
''RAXTRX'',
-3,
-1 * :adj_amount,
-1 * :acctd_adj_amount,
-1 * :line_adj_amount,
-1 * :tax_adj_amount,
-1 * :frt_adj_amount
,:org_id --arp_standard.sysparm.org_id /* SSA changes anuj */
)';
Line: 3782

    debug('  insert_adj_sql = ' || CRLF ||
          l_insert_adj_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3785

    debug('  len(insert_adj_sql) = '||
          to_char(length(l_insert_adj_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3794

    l_update_ps_sql :=
'UPDATE AR_PAYMENT_SCHEDULES
SET    last_update_date = sysdate,
       last_updated_by = :user_id,
       last_update_login = :login_id,
       status = decode(:amount_due_remaining, 0, ''CL'', ''OP''),
       gl_date_closed =
               decode(:amount_due_remaining, 0, :gl_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
       actual_date_closed =
               decode(:amount_due_remaining, 0, :actual_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
       amount_due_remaining = :amount_due_remaining,
       acctd_amount_due_remaining = :acctd_amount_due_remaining,
       amount_line_items_remaining = :amount_line_items_remaining,
       amount_adjusted = :amount_adjusted,
       tax_remaining = :tax_remaining,
       freight_remaining = :freight_remaining
WHERE payment_schedule_id = :payment_schedule_id';
Line: 3812

    debug('  update_ps_sql = ' || CRLF ||
          l_update_ps_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3815

    debug('  len(update_ps_sql) = '||
          to_char(length(l_update_ps_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 3828

	debug( '  Parsing insert_adj_c', MSG_LEVEL_DEBUG );
Line: 3829

        p_insert_adj_c := dbms_sql.open_cursor;
Line: 3830

        dbms_sql.parse( p_insert_adj_c, l_insert_adj_sql,
                        dbms_sql.v7 );
Line: 3833

	debug( '  Parsing update_ps_c', MSG_LEVEL_DEBUG );
Line: 3834

        p_update_ps_c := dbms_sql.open_cursor;
Line: 3835

        dbms_sql.parse( p_update_ps_c, l_update_ps_sql,
                        dbms_sql.v7 );
Line: 3838

	debug( '  Parsing select_c', MSG_LEVEL_DEBUG );
Line: 3839

        p_select_c := dbms_sql.open_cursor;
Line: 3840

        dbms_sql.parse( p_select_c, l_select_sql,
                        dbms_sql.v7 );
Line: 3865

PROCEDURE define_ups_select_columns(
	p_select_c   IN INTEGER,
        p_select_rec IN select_ups_rec_type ) IS

BEGIN

    print_fcn_label2( 'arp_maintain_ps2.define_ups_select_columns()+' );
Line: 3873

    dbms_sql.define_column( p_select_c, 1, p_select_rec.set_of_books_id );
Line: 3874

    dbms_sql.define_column( p_select_c, 2, p_select_rec.total_line_amount );
Line: 3875

    dbms_sql.define_column( p_select_c, 3, p_select_rec.gl_date );
Line: 3876

    dbms_sql.define_column( p_select_c, 4, p_select_rec.code_combination_id );
Line: 3877

    dbms_sql.define_column( p_select_c, 5,
				p_select_rec.adjusted_trx_id );
Line: 3879

    dbms_sql.define_column( p_select_c, 6,
				p_select_rec.payment_schedule_id );
Line: 3881

    dbms_sql.define_column( p_select_c, 7,
				p_select_rec.subsequent_trx_id );
Line: 3883

    dbms_sql.define_column( p_select_c, 8,
			    p_select_rec.post_to_gl_flag, 1 );
Line: 3885

    dbms_sql.define_column( p_select_c, 9,
				p_select_rec.commitment_trx_id );
Line: 3887

    dbms_sql.define_column( p_select_c, 10, p_select_rec.percent );
Line: 3888

    dbms_sql.define_column( p_select_c, 11, p_select_rec.precision );
Line: 3889

    dbms_sql.define_column( p_select_c, 12, p_select_rec.min_acc_unit );
Line: 3890

    dbms_sql.define_column( p_select_c, 13, p_select_rec.gl_date_closed );
Line: 3891

    dbms_sql.define_column( p_select_c, 14, p_select_rec.actual_date_closed );
Line: 3892

    dbms_sql.define_column( p_select_c, 15, p_select_rec.trx_date );
Line: 3893

    dbms_sql.define_column( p_select_c, 16, p_select_rec.commitment_type, 20 );
Line: 3894

    dbms_sql.define_column( p_select_c, 17, p_select_rec.line_remaining );
Line: 3895

    dbms_sql.define_column( p_select_c, 18,
				p_select_rec.amount_due_remaining );
Line: 3897

    dbms_sql.define_column( p_select_c, 19,
				p_select_rec.acctd_amt_due_rem );
Line: 3899

    dbms_sql.define_column( p_select_c, 20,
				p_select_rec.amount_adjusted );
Line: 3901

    dbms_sql.define_column( p_select_c, 21, p_select_rec.ps_precision );
Line: 3902

    dbms_sql.define_column( p_select_c, 22, p_select_rec.ps_min_acc_unit );
Line: 3903

    dbms_sql.define_column( p_select_c, 23, p_select_rec.ps_exchange_rate );
Line: 3904

    dbms_sql.define_column( p_select_c, 24, p_select_rec.customer_trx_id );
Line: 3905

    dbms_sql.define_column( p_select_c, 25,
		p_select_rec.ps_currency_code, 15 );
Line: 3908

    dbms_sql.define_column( p_select_c, 26, p_select_rec.allocate_tax_freight,1 );
Line: 3909

    dbms_sql.define_column( p_select_c, 27, p_select_rec.adjustment_type,8 );
Line: 3910

    dbms_sql.define_column( p_select_c, 28, p_select_rec.tax_remaining );
Line: 3911

    dbms_sql.define_column( p_select_c, 29, p_select_rec.freight_remaining );
Line: 3912

    dbms_sql.define_column( p_select_c, 30, p_select_rec.total_tax_amount );
Line: 3913

    dbms_sql.define_column( p_select_c, 31, p_select_rec.total_freight_amount );
Line: 3915

    print_fcn_label2( 'arp_maintain_ps2.define_ups_select_columns()-' );
Line: 3919

        debug('EXCEPTION: arp_maintain_ps2.define_ups_select_columns()',
	      MSG_LEVEL_BASIC);
Line: 3922

END define_ups_select_columns;
Line: 3926

PROCEDURE get_ups_column_values( p_select_c   IN INTEGER,
                             p_select_rec IN OUT NOCOPY select_ups_rec_type ) IS
/* Bug 460927 - Changed IN to IN OUT in the above line - Oracle 8 */
BEGIN
    print_fcn_label2( 'arp_maintain_ps2.get_ups_column_values()+' );
Line: 3932

    dbms_sql.column_value( p_select_c, 1, p_select_rec.set_of_books_id );
Line: 3933

    dbms_sql.column_value( p_select_c, 2, p_select_rec.total_line_amount );
Line: 3934

    dbms_sql.column_value( p_select_c, 3, p_select_rec.gl_date );
Line: 3935

    dbms_sql.column_value( p_select_c, 4, p_select_rec.code_combination_id );
Line: 3936

    dbms_sql.column_value( p_select_c, 5,
				p_select_rec.adjusted_trx_id );
Line: 3938

    dbms_sql.column_value( p_select_c, 6, p_select_rec.payment_schedule_id );
Line: 3939

    dbms_sql.column_value( p_select_c, 7, p_select_rec.subsequent_trx_id );
Line: 3940

    dbms_sql.column_value( p_select_c, 8, p_select_rec.post_to_gl_flag );
Line: 3941

    dbms_sql.column_value( p_select_c, 9, p_select_rec.commitment_trx_id );
Line: 3942

    dbms_sql.column_value( p_select_c, 10, p_select_rec.percent );
Line: 3943

    dbms_sql.column_value( p_select_c, 11, p_select_rec.precision );
Line: 3944

    dbms_sql.column_value( p_select_c, 12, p_select_rec.min_acc_unit );
Line: 3945

    dbms_sql.column_value( p_select_c, 13, p_select_rec.gl_date_closed );
Line: 3946

    dbms_sql.column_value( p_select_c, 14, p_select_rec.actual_date_closed );
Line: 3947

    dbms_sql.column_value( p_select_c, 15, p_select_rec.trx_date );
Line: 3948

    dbms_sql.column_value( p_select_c, 16, p_select_rec.commitment_type );
Line: 3949

    dbms_sql.column_value( p_select_c, 17, p_select_rec.line_remaining );
Line: 3950

    dbms_sql.column_value( p_select_c, 18,
				p_select_rec.amount_due_remaining );
Line: 3952

    dbms_sql.column_value( p_select_c, 19, p_select_rec.acctd_amt_due_rem );
Line: 3953

    dbms_sql.column_value( p_select_c, 20, p_select_rec.amount_adjusted );
Line: 3954

    dbms_sql.column_value( p_select_c, 21, p_select_rec.ps_precision );
Line: 3955

    dbms_sql.column_value( p_select_c, 22, p_select_rec.ps_min_acc_unit );
Line: 3956

    dbms_sql.column_value( p_select_c, 23, p_select_rec.ps_exchange_rate );
Line: 3957

    dbms_sql.column_value( p_select_c, 24, p_select_rec.customer_trx_id );
Line: 3958

    dbms_sql.column_value( p_select_c, 25, p_select_rec.ps_currency_code );
Line: 3960

    dbms_sql.column_value( p_select_c, 26, p_select_rec.allocate_tax_freight );
Line: 3961

    dbms_sql.column_value( p_select_c, 27, p_select_rec.adjustment_type );
Line: 3962

    dbms_sql.column_value( p_select_c, 28, p_select_rec.tax_remaining );
Line: 3963

    dbms_sql.column_value( p_select_c, 29, p_select_rec.freight_remaining );
Line: 3964

    dbms_sql.column_value( p_select_c, 30, p_select_rec.total_tax_amount );
Line: 3965

    dbms_sql.column_value( p_select_c, 31, p_select_rec.total_freight_amount );
Line: 3997

PROCEDURE dump_ups_select_rec( p_select_rec IN select_ups_rec_type ) IS
BEGIN

    print_fcn_label2( 'arp_maintain_ps2.dump_ups_select_rec()+' );
Line: 4002

    debug( '  Dumping select record: ', MSG_LEVEL_DEBUG );
Line: 4004

           || p_select_rec.set_of_books_id, MSG_LEVEL_DEBUG );
Line: 4006

           || p_select_rec.customer_trx_id, MSG_LEVEL_DEBUG );
Line: 4008

           || p_select_rec.post_to_gl_flag, MSG_LEVEL_DEBUG );
Line: 4010

           || p_select_rec.trx_date, MSG_LEVEL_DEBUG );
Line: 4012

           || p_select_rec.gl_date, MSG_LEVEL_DEBUG );
Line: 4014

           || p_select_rec.precision, MSG_LEVEL_DEBUG );
Line: 4016

           || p_select_rec.min_acc_unit, MSG_LEVEL_DEBUG );
Line: 4018

           || p_select_rec.adjusted_trx_id, MSG_LEVEL_DEBUG );
Line: 4020

           || p_select_rec.subsequent_trx_id, MSG_LEVEL_DEBUG );
Line: 4022

           || p_select_rec.commitment_trx_id, MSG_LEVEL_DEBUG );
Line: 4024

           || p_select_rec.commitment_type, MSG_LEVEL_DEBUG );
Line: 4026

           || p_select_rec.ps_currency_code, MSG_LEVEL_DEBUG );
Line: 4028

           || p_select_rec.ps_exchange_rate, MSG_LEVEL_DEBUG );
Line: 4030

           || p_select_rec.ps_precision, MSG_LEVEL_DEBUG );
Line: 4032

           || p_select_rec.ps_min_acc_unit, MSG_LEVEL_DEBUG );
Line: 4034

           || p_select_rec.code_combination_id, MSG_LEVEL_DEBUG );
Line: 4036

           || p_select_rec.gl_date_closed, MSG_LEVEL_DEBUG );
Line: 4038

           || p_select_rec.actual_date_closed, MSG_LEVEL_DEBUG );
Line: 4040

           || p_select_rec.total_line_amount, MSG_LEVEL_DEBUG );
Line: 4042

           || p_select_rec.payment_schedule_id, MSG_LEVEL_DEBUG );
Line: 4044

           || p_select_rec.amount_due_remaining, MSG_LEVEL_DEBUG );
Line: 4046

           || p_select_rec.acctd_amt_due_rem, MSG_LEVEL_DEBUG );
Line: 4048

           || p_select_rec.line_remaining, MSG_LEVEL_DEBUG );
Line: 4050

           || p_select_rec.amount_adjusted, MSG_LEVEL_DEBUG );
Line: 4052

           || p_select_rec.percent, MSG_LEVEL_DEBUG );
Line: 4055

           || p_select_rec.tax_remaining, MSG_LEVEL_DEBUG );
Line: 4057

           || p_select_rec.freight_remaining, MSG_LEVEL_DEBUG );
Line: 4059

           || p_select_rec.adjustment_type, MSG_LEVEL_DEBUG );
Line: 4061

    print_fcn_label2( 'arp_maintain_ps2.dump_ups_select_rec()-' );
Line: 4065

        debug( 'EXCEPTION: arp_maintain_ps2.dump_ups_select_rec()',
               MSG_LEVEL_BASIC );
Line: 4068

END dump_ups_select_rec;
Line: 4077

        p_insert_adj_c			IN INTEGER,
        p_update_ps_c			IN INTEGER,
	p_select_rec			IN select_ups_rec_type,
        p_number_records		IN NUMBER,
        p_ps_id_t			IN id_table_type,
        p_ps_amount_due_rem_t 		IN OUT NOCOPY number_table_type,
        p_ps_acctd_amt_due_rem_t	IN OUT NOCOPY number_table_type,
        p_ps_line_rem_t 		IN OUT NOCOPY number_table_type,
        p_ps_amount_adjusted_t 		IN OUT NOCOPY number_table_type,
        p_adj_amount_t 			IN OUT NOCOPY number_table_type,
        p_acctd_adj_amount_t 		IN OUT NOCOPY number_table_type,
        p_percent_t 			IN number_table_type,
        p_ps_tax_rem_t                  IN OUT NOCOPY number_table_type,
        p_ps_freight_rem_t              IN OUT NOCOPY number_table_type,
        p_line_adj_t                    IN OUT NOCOPY number_table_type,
        p_tax_adj_t                     IN OUT NOCOPY number_table_type,
        p_frt_adj_t                     IN OUT NOCOPY number_table_type) IS


    l_ignore 			INTEGER;
Line: 4129

				p_select_rec.commitment_trx_id,
				null,	-- class
				g_oe_install_flag,	-- oe_installed_flag
				g_so_source_code 	-- so_source_code
			);
Line: 4138

    IF (p_select_rec.commitment_type = 'DEP')
    THEN
       /* Bug 3431804, 3537233
          Figure total amount remaining (L, T, and F) based on
          amounts for each PS row (installment) */
       FOR i IN p_ps_line_rem_t.FIRST..p_ps_line_rem_t.LAST LOOP
          l_line_remaining := l_line_remaining + nvl(p_ps_line_rem_t(i),0);
Line: 4178

          Guarantees use SELECT in build_ups_sql differently.
          The joins to PS are for the GUAR rather than the target
          invoice.  This means that we have to use the line totals
          from ra_customer_trx_lines instead. */
       l_line_remaining := p_select_rec.total_line_amount;
Line: 4190

    IF( p_select_rec.allocate_tax_freight = 'Y') THEN
        /* Only DEPs can allocate tax and freight */

        debug( ' allocating tax and freight (new logic)');
Line: 4199

        debug( '  total_invoice_amount='||p_select_rec.total_line_amount,
		MSG_LEVEL_DEBUG );
Line: 4203

        debug( '  total lines          = '|| p_select_rec.total_line_amount, MSG_LEVEL_DEBUG );
Line: 4204

        debug( '  total tax lines      = '|| p_select_rec.total_tax_amount, MSG_LEVEL_DEBUG );
Line: 4205

        debug( '  total freight lines  = '|| p_select_rec.total_freight_amount, MSG_LEVEL_DEBUG );
Line: 4217

                                              p_select_rec.ps_currency_code);
Line: 4224

                                              p_select_rec.ps_currency_code);
Line: 4238

        debug( '  total_line_amount='||p_select_rec.total_line_amount,
		MSG_LEVEL_DEBUG );
Line: 4272

    IF (p_select_rec.commitment_type = 'DEP')
    THEN
       distribute_amount(
                p_number_records,
                p_select_rec.ps_currency_code,
                l_total_line_adj,
                l_line_percent_t,
                p_line_adj_t);
Line: 4283

                p_select_rec.ps_currency_code,
                l_total_line_adj,
                p_percent_t,
                p_line_adj_t);
Line: 4289

    IF( p_select_rec.allocate_tax_freight = 'Y') THEN

       distribute_amount(
   		p_number_records,
   		p_select_rec.ps_currency_code,
   		l_total_tax_adj,
		l_tax_percent_t,
		p_tax_adj_t);
Line: 4300

		p_select_rec.ps_currency_code,
		l_total_frt_adj,
		l_frt_percent_t,
		p_frt_adj_t);
Line: 4325

        IF (p_select_rec.allocate_tax_freight = 'Y') THEN

           p_adj_amount_t(i) := p_adj_amount_t(i) + p_tax_adj_t(i)
                                    + p_frt_adj_t(i);
Line: 4339

           to prevent errors during insert of ADJ row */

           p_tax_adj_t(i) := NULL;
Line: 4364

		p_select_rec.ps_exchange_rate,
		'-',			-- type
		p_ps_amount_due_rem_t( i ),	-- master_from
		p_ps_acctd_amt_due_rem_t( i ),	-- acctd_master_from
		p_adj_amount_t( i ),	-- detail
		l_new_ps_adr,		-- master_to
		l_new_ps_acctd_adr,	-- acctd_master_to
		l_new_acctd_adj_amount	-- acctd_detail
	);
Line: 4375

	-- Update amt_due_rem, acctd_amt_due_rem
        --------------------------------------------------------------------
	p_ps_amount_due_rem_t( i ) := l_new_ps_adr;
Line: 4401

	    debug( '  Binding insert_adj_c', MSG_LEVEL_DEBUG );
Line: 4403

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 4407

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 4411

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'request_id',
                                    p_profile_info.request_id );
Line: 4415

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'application_id',
                                    p_profile_info.application_id );
Line: 4419

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'program_id',
                                    p_profile_info.conc_program_id );
Line: 4425

			p_insert_adj_c,
			'set_of_books_id',
                	p_select_rec.set_of_books_id );
Line: 4429

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'trx_date',
                                    p_select_rec.trx_date );
Line: 4433

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'gl_date',
                                    p_select_rec.gl_date );
Line: 4437

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'code_combination_id',
                                    p_select_rec.code_combination_id );
Line: 4441

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'adjusted_trx_id',
                                    p_select_rec.adjusted_trx_id );
Line: 4445

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'payment_schedule_id',
                                    p_ps_id_t( i ) );
Line: 4449

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'subsequent_trx_id',
                                    p_select_rec.subsequent_trx_id );
Line: 4453

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'post_to_gl_flag',
                                    p_select_rec.post_to_gl_flag );
Line: 4457

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'adj_amount',
                                    p_adj_amount_t( i ) );
Line: 4461

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'acctd_adj_amount',
                                    p_acctd_adj_amount_t( i ) );
Line: 4466

	    SELECT ar_adjustments_s.nextval
	    INTO l_adjustment_id
	    FROM   dual;
Line: 4470

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'adjustment_id',
				    l_adjustment_id );
Line: 4475

            dbms_sql.bind_variable (p_insert_adj_c,
                                    'tax_adj_amount',
                                    p_tax_adj_t(i) );
Line: 4479

            dbms_sql.bind_variable (p_insert_adj_c,
                                    'frt_adj_amount',
                                    p_frt_adj_t(i) );
Line: 4483

            dbms_sql.bind_variable (p_insert_adj_c,
                                    'line_adj_amount',
                                    p_line_adj_t(i) );
Line: 4487

            dbms_sql.bind_variable (p_insert_adj_c,
                                    'adjust_type',
                                    p_select_rec.adjustment_type);
Line: 4492

            dbms_sql.bind_variable (p_insert_adj_c,
                                    'org_id',
                                    arp_standard.sysparm.org_id /* SSA changes anuj */);
Line: 4499

            debug( 'EXCEPTION: Error in binding insert_adj_c',
                   MSG_LEVEL_BASIC );
Line: 4508

	    debug( '  Inserting adjustments', MSG_LEVEL_DEBUG );
Line: 4509

            l_ignore := dbms_sql.execute( p_insert_adj_c );
Line: 4510

            debug( to_char(l_ignore) || ' row(s) inserted',
		           MSG_LEVEL_DEBUG );
Line: 4514

            | Call central MRC library for insertion    |
            | into MRC tables                           |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'INSERT',
                      p_table_name       => 'AR_ADJUSTMENTS',
                      p_mode             => 'SINGLE',
                      p_key_value        => l_adjustment_id);
Line: 4526

            debug( 'EXCEPTION: Error executing insert ra stmt',
                   MSG_LEVEL_BASIC );
Line: 4540

	    debug( '  Binding update_ps_c', MSG_LEVEL_DEBUG );
Line: 4542

            dbms_sql.bind_variable( p_update_ps_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 4546

            dbms_sql.bind_variable( p_update_ps_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 4550

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_due_remaining',
                                    p_ps_amount_due_rem_t( i ) );
Line: 4554

            dbms_sql.bind_variable( p_update_ps_c,
		                    'gl_date_closed',
                                    p_select_rec.gl_date_closed );
Line: 4558

            dbms_sql.bind_variable( p_update_ps_c,
		                    'actual_date_closed',
                                    p_select_rec.actual_date_closed );
Line: 4562

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_line_items_remaining',
                                    p_ps_line_rem_t( i ) );
Line: 4566

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_adjusted',
                                    p_ps_amount_adjusted_t( i ) );
Line: 4570

            dbms_sql.bind_variable( p_update_ps_c,
		                    'acctd_amount_due_remaining',
                                    p_ps_acctd_amt_due_rem_t( i ) );
Line: 4574

            dbms_sql.bind_variable( p_update_ps_c,
		                    'payment_schedule_id',
                                    p_ps_id_t( i ) );
Line: 4579

            dbms_sql.bind_variable( p_update_ps_c,
		                    'tax_remaining',
                                    p_ps_tax_rem_t( i ) );
Line: 4583

            dbms_sql.bind_variable( p_update_ps_c,
		                    'freight_remaining',
                                    p_ps_freight_rem_t( i ) );
Line: 4590

            debug( 'EXCEPTION: Error in binding update_ps_c',
                   MSG_LEVEL_BASIC );
Line: 4600

            l_ignore := dbms_sql.execute( p_update_ps_c );
Line: 4601

            debug( to_char(l_ignore) || ' row(s) updated',
		           MSG_LEVEL_DEBUG );
Line: 4605

            | Call central MRC library for update       |
            | of AR_PAYMENT_SCHEDULES                   |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'UPDATE',
                      p_table_name       => 'AR_PAYMENT_SCHEDULES',
                      p_mode             => 'SINGLE',
                      p_key_value        =>  p_ps_id_t( i ));
Line: 4617

            debug( 'EXCEPTION: Error executing update ps stmt',
                   MSG_LEVEL_BASIC );
Line: 4637

	l_ae_doc_rec.source_id_old := p_select_rec.code_combination_id;
Line: 4659

PROCEDURE insert_child_adj_private(
	p_system_info		IN arp_trx_global.system_info_rec_type,
	p_profile_info 		IN arp_trx_global.profile_rec_type,
	p_customer_trx_id 	IN BINARY_INTEGER,
        p_adj_date              IN DATE,
        p_gl_date               IN DATE) IS


    l_ignore 			INTEGER;
Line: 4700

    l_select_rec		select_ups_rec_type;
Line: 4703

    PROCEDURE load_tables( p_select_rec IN select_ups_rec_type ) IS

    BEGIN
        print_fcn_label2('arp_maintain_ps2.load_tables()+' );
Line: 4711

        l_ps_id_t( l_table_index ) := p_select_rec.payment_schedule_id;
Line: 4713

				p_select_rec.amount_due_remaining;
Line: 4715

				p_select_rec.acctd_amt_due_rem;
Line: 4717

				p_select_rec.line_remaining;
Line: 4720

                                p_select_rec.tax_remaining;
Line: 4722

                                p_select_rec.freight_remaining;
Line: 4725

				p_select_rec.amount_adjusted;
Line: 4727

	l_percent_t( l_table_index ) := p_select_rec.percent;
Line: 4822

    print_fcn_label( 'arp_maintain_ps2.insert_child_adj_private()+' );
Line: 4828

    IF( NOT( dbms_sql.is_open( ups_select_c ) AND
	     dbms_sql.is_open( ups_insert_adj_c ) AND
	     dbms_sql.is_open( ups_update_ps_c ) )) THEN

        build_ups_sql(
		system_info,
		profile_info,
		ups_select_c,
		ups_insert_adj_c,
		ups_update_ps_c );
Line: 4841

    define_ups_select_columns( ups_select_c, l_select_rec );
Line: 4846

    dbms_sql.bind_variable( ups_select_c,
			    'customer_trx_id',
			    p_customer_trx_id );
Line: 4851

    dbms_sql.bind_variable( ups_select_c,
                            'gl_date',
                            p_gl_date);
Line: 4855

    dbms_sql.bind_variable( ups_select_c,
                            'apply_date',
                            p_adj_date);
Line: 4861

    debug( '  Executing select sql', MSG_LEVEL_DEBUG );
Line: 4864

        l_ignore := dbms_sql.execute( ups_select_c );
Line: 4868

          debug( 'EXCEPTION: Error executing select sql',
		 MSG_LEVEL_BASIC );
Line: 4880

            IF dbms_sql.fetch_rows( ups_select_c ) > 0  THEN

	        debug('  Fetched a row', MSG_LEVEL_DEBUG );
Line: 4887

		dbms_sql.column_value( ups_select_c, 24, l_customer_trx_id );
Line: 4888

		dbms_sql.column_value( ups_select_c, 5, l_adjusted_trx_id );
Line: 4919

				ups_insert_adj_c,
				ups_update_ps_c,
				l_select_rec,
				l_table_index,
				l_ps_id_t,
				l_ps_amount_due_rem_t,
				l_ps_acctd_amt_due_rem_t,
				l_ps_line_rem_t,
				l_ps_amount_adjusted_t,
				l_adj_amount_t,
				l_acctd_adj_amount_t,
				l_percent_t,
                                l_ps_tax_rem_t,
                                l_ps_freight_rem_t,
                                l_line_adj_t,
                                l_tax_adj_t,
                                l_frt_adj_t);
Line: 4963

		get_ups_column_values( ups_select_c, l_select_rec );
Line: 4964

		dump_ups_select_rec( l_select_rec );
Line: 4968

		    load_tables( l_select_rec );
Line: 4983

			ups_insert_adj_c,
			ups_update_ps_c,
			l_select_rec,
			l_table_index,
			l_ps_id_t,
			l_ps_amount_due_rem_t,
			l_ps_acctd_amt_due_rem_t,
			l_ps_line_rem_t,
			l_ps_amount_adjusted_t,
			l_adj_amount_t,
			l_acctd_adj_amount_t,
			l_percent_t,
                        l_ps_tax_rem_t,
                        l_ps_freight_rem_t,
                        l_line_adj_t,
                        l_tax_adj_t,
                        l_frt_adj_t);
Line: 5011

            debug( 'EXCEPTION: Error fetching select cursor',
                   MSG_LEVEL_BASIC );
Line: 5017

    print_fcn_label( 'arp_maintain_ps2.insert_child_adj_private()-' );
Line: 5021

        debug( 'EXCEPTION: arp_maintain_ps2.insert_child_adj_private()',
	       MSG_LEVEL_BASIC );
Line: 5025

END insert_child_adj_private;
Line: 5028

/* Bug 4642526 - new wrapper for insert_child_adj_private */
PROCEDURE insert_child_adj_private(p_customer_trx_id 	IN BINARY_INTEGER,
                           p_adj_date           IN DATE DEFAULT NULL,
                           p_gl_date            IN DATE DEFAULT NULL )
IS
   x_system_info arp_trx_global.system_info_rec_type;
Line: 5037

    insert_child_adj_private(x_system_info, x_profile_info,
          p_customer_trx_id, p_adj_date, p_gl_date);
Line: 5071

        p_select_c 		IN OUT NOCOPY INTEGER,
	p_insert_adj_c 		IN OUT NOCOPY INTEGER,
        p_update_ps_c 		IN OUT NOCOPY INTEGER ) IS

    l_insert_adj_sql	VARCHAR2(2000);
Line: 5076

    l_update_ps_sql	VARCHAR2(2000);
Line: 5077

    l_select_sql	VARCHAR2(8000);
Line: 5087

    l_select_sql :=
'SELECT
ctl.set_of_books_id,
ct.trx_date,
/* nvl(ps.amount_line_items_remaining, 0), */
nvl(ctlgd.gl_date, ct.trx_date),
ctlgd_com.code_combination_id,
decode(ctt_com.type,
       ''DEP'', ct_inv.customer_trx_id,
       ct_com.customer_trx_id),
ps.payment_schedule_id,
ctl.customer_trx_id,
''Y'', /* bugfix 2614759. ctt.post_to_gl */
greatest(nvl(max(decode(ra.confirmed_flag,
                                ''Y'', ra.apply_date,
                                null, decode(ra.receivable_application_id,
                                             null, ct.trx_date,
                                             ra.apply_date),
				ct.trx_date)),
		     ct.trx_date),
                 nvl(max(decode(adj.status,
				''A'',adj.apply_date,
			ct.trx_date)),
		     ct.trx_date),
                 ct.trx_date),
greatest(nvl(max(decode(ra.confirmed_flag,
				''Y'', ra.gl_date,
                                null, decode(ra.receivable_application_id,
					     null, nvl(ctlgd.gl_date,
					               ct.trx_date),
                                             ra.gl_date),
				nvl(ctlgd.gl_date, ct.trx_date))),
		     nvl(ctlgd.gl_date,ct.trx_date)),
                 nvl(max(decode(adj.status,
				''A'',adj.gl_date,
				nvl(ctlgd.gl_date,
				    ct.trx_date))),
		     nvl(ctlgd.gl_date,ct.trx_date)),
                 nvl(ctlgd.gl_date, ct.trx_date)),
c.minimum_accountable_unit,
c.precision,
sum(ctl.extended_amount) /
  (count(distinct ps.payment_schedule_id) *
   count(distinct ps_inv.payment_schedule_id) *
   count(distinct nvl(adj.adjustment_id, -9.9)) *
   count(distinct nvl(adjd.adjustment_id, -9.9)) *
   count(distinct nvl(ra.receivable_application_id, -9.9))),
nvl(sum(decode(adj.adjustment_type, ''C'', adj.amount, 0)),0) /
  (count(distinct ps.payment_schedule_id) *
   count(distinct ps_inv.payment_schedule_id) *
   count(distinct ctl.customer_trx_line_id) *
   count(distinct nvl(ra.receivable_application_id, -9.9))),
decode(ctt_com.type, ''DEP'', 1, 0),
/* nvl(ps.amount_line_items_remaining, 0), */
/* 0, */
ct_inv.customer_trx_id,
/* null, */
nvl(ps.amount_line_items_remaining, 0),
ps.amount_due_remaining,
ps.acctd_amount_due_remaining,
nvl(ps.amount_adjusted, 0),
c_ps.precision,
c_ps.minimum_accountable_unit,
decode(ctt_com.type, ''DEP'', ct_inv.exchange_rate, ct_com.exchange_rate),
sum(nvl(ps_inv.amount_line_items_remaining, 0))/
  (count(distinct ps.payment_schedule_id) *
   count(distinct ctl.customer_trx_line_id) *
   count(distinct nvl(adj.adjustment_id, -9.9)) *
   count(distinct nvl(ra.receivable_application_id, -9.9)) ),
nvl(ps.amount_line_items_original, 0),
/* 0 */
decode(ctt_com.type,
       ''DEP'', ct_inv.invoice_currency_code,
       ct_com.invoice_currency_code),
/* 1483656 */
ctt_com.allocate_tax_freight,
/* adj_type */
DECODE(ctt_com.allocate_tax_freight, ''Y'', ''INVOICE'', ''LINE''),
/* CM TAX and CM FREIGHT totals */
ARPT_SQL_FUNC_UTIL.get_sum_of_trx_lines(ctl.customer_trx_id, ''TAX''),
ARPT_SQL_FUNC_UTIL.get_sum_of_trx_lines(ctl.customer_trx_id, ''FREIGHT''),
/* inv_line_adj, inv_tax_adj, inv_frt_adj */
sum(nvl(decode(adjd.adjustment_type, ''C'', adjd.line_adjusted, 0),0)) /
  (count(distinct ps.payment_schedule_id) *
   count(distinct ps_inv.payment_schedule_id) *
   count(distinct ctl.customer_trx_line_id) *
   count(distinct adj.adjustment_id) *
   count(distinct nvl(ra.receivable_application_id, -9.9))),
sum(nvl(decode(adjd.adjustment_type, ''C'', adjd.tax_adjusted, 0),0)) /
  (count(distinct ps.payment_schedule_id) *
   count(distinct ps_inv.payment_schedule_id) *
   count(distinct ctl.customer_trx_line_id) *
   count(distinct adj.adjustment_id) *
   count(distinct nvl(ra.receivable_application_id, -9.9))),
sum(nvl(decode(adjd.adjustment_type, ''C'', adjd.freight_adjusted, 0),0)) /
  (count(distinct ps.payment_schedule_id) *
   count(distinct ps_inv.payment_schedule_id) *
   count(distinct ctl.customer_trx_line_id) *
   count(distinct adj.adjustment_id) *
   count(distinct nvl(ra.receivable_application_id, -9.9))),
NVL(ps.tax_remaining, 0),
NVL(ps.freight_remaining, 0),
NVL(ps.tax_original, 0),
NVL(ps.freight_original, 0)
FROM
ra_cust_trx_types ctt_com,
ra_cust_trx_types ctt,
ra_cust_trx_line_gl_dist ctlgd_com,
ar_payment_schedules ps,
ar_payment_schedules ps_inv,
ar_receivable_applications ra,
ar_adjustments adj,
ar_adjustments adjd,
fnd_currencies c,
fnd_currencies c_ps,
ra_customer_trx ct_com,
ra_customer_trx ct_inv,
ra_customer_trx_lines ctl,
ra_customer_trx ct,
ra_cust_trx_line_gl_dist ctlgd
WHERE ct.customer_trx_id = :customer_trx_id
and   ctl.customer_trx_id = ct.customer_trx_id
and   ctlgd.customer_trx_id = ct.customer_trx_id
and   ctlgd.account_class = ''REC''
and   ctlgd.latest_rec_flag = ''Y''
and   ctl.line_type = ''LINE''
and   exists
     (select ''x''
      from   ra_customer_trx h
      where  h.customer_trx_id = ctl.customer_trx_id)
and   ct.invoice_currency_code = c.currency_code
and   ct.cust_trx_type_id = ctt.cust_trx_type_id
and   ctt.type = ''CM''
and   ctl.previous_customer_trx_id = ct_inv.customer_trx_id
and   ct_inv.initial_customer_trx_id = ct_com.customer_trx_id
and   ct_com.cust_trx_type_id = ctt_com.cust_trx_type_id
and   ct_com.customer_trx_id = ctlgd_com.customer_trx_id
and   ctlgd_com.account_class = ''REV''
and   ps.customer_trx_id =
        decode(ctt_com.type,
               ''DEP'', ct_inv.customer_trx_id,
               ct_com.customer_trx_id)
and   decode(ctt_com.type, ''DEP'', ct_inv.invoice_currency_code,
                                ct_com.invoice_currency_code)
        = c_ps.currency_code
and   ps.customer_trx_id = ra.applied_customer_trx_id (+)
and   ps.customer_trx_id = adj.customer_trx_id (+)
and   ct_inv.customer_trx_id = ps_inv.customer_trx_id
and   decode(adj.subsequent_trx_id, null, ct_inv.customer_trx_id,
             adj.subsequent_trx_id) = ct_inv.customer_trx_id
and   ps.payment_schedule_id = adjd.payment_schedule_id (+)
and   adjd.adjustment_type (+) = ''C''
and   decode(ctt_com.type,''GUAR'', adjd.subsequent_trx_id,1)
   =  decode(ctt_com.type,''GUAR'',ctl.previous_customer_trx_id,1)
GROUP BY
ctl.set_of_books_id,
ctt_com.type,
ctt_com.allocate_tax_freight,
ctlgd.gl_date,
ct.trx_date,
ps.amount_line_items_remaining,
ctlgd_com.code_combination_id,
ct_inv.customer_trx_id,
ct_com.customer_trx_id,
ps.payment_schedule_id,
ctl.customer_trx_id,
/* Bugfix 2614759. comment out ctt.post_to_gl, */
c.minimum_accountable_unit,
c.precision,
ps.amount_due_remaining,
ps.amount_due_original,
ps.acctd_amount_due_remaining,
ps.amount_adjusted,
ps.tax_original,
ps.tax_remaining,
ps.freight_original,
ps.freight_remaining,
c_ps.precision,
c_ps.minimum_accountable_unit,
ct_inv.exchange_rate,
ct_com.exchange_rate,
ps.terms_sequence_number,
ps.amount_line_items_original,
ct_inv.invoice_currency_code,
ct_com.invoice_currency_code
ORDER BY
5 asc,  /* adjusted_trx_id */
ct_inv.customer_trx_id,
ctl.customer_trx_id,
ps.terms_sequence_number';
Line: 5280

    debug('  select_sql = ' || CRLF ||
          l_select_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5283

    debug('  len(select_sql) = '||
          to_char(length(l_select_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5296

    l_insert_adj_sql :=
'INSERT INTO AR_ADJUSTMENTS
(
created_by,
creation_date,
last_updated_by,
last_update_date,
last_update_login,
request_id,
program_application_id,
program_id,
program_update_date,
set_of_books_id,
receivables_trx_id,
automatically_generated,
type,
adjustment_type,
status,
apply_date,
adjustment_id,
gl_date,
code_combination_id,
customer_trx_id,
payment_schedule_id,
subsequent_trx_id,
postable,
adjustment_number,
created_from,
posting_control_id,
amount,
acctd_amount,
line_adjusted,
tax_adjusted,
freight_adjusted
,org_id
)
VALUES
(
:user_id,
sysdate,
:user_id,
sysdate,
:login_id,
:request_id,
:application_id,
:program_id,
sysdate,
:set_of_books_id,
-1,
''Y'',
:adj_type,
''C'',
''A'',
:trx_date,
:adjustment_id,
:gl_date,
:code_combination_id,
:adjusted_trx_id,
:payment_schedule_id,
:subsequent_trx_id,
:post_to_gl_flag,
to_char(ar_adjustment_number_s.nextval),
''RAXTRX'',
-3,
-1 * :adj_amount,
-1 * :acctd_adj_amount,
-1 * :line_adjusted,
-1 * :tax_adjusted,
-1 * :freight_adjusted
,:org_id --arp_standard.sysparm.org_id /* SSA changes anuj */
)';
Line: 5368

    debug('  insert_adj_sql = ' || CRLF ||
          l_insert_adj_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5371

    debug('  len(insert_adj_sql) = '||
          to_char(length(l_insert_adj_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5380

    l_update_ps_sql :=
'UPDATE AR_PAYMENT_SCHEDULES
SET    last_update_date = sysdate,
       last_updated_by = :user_id,
       last_update_login = :login_id,
       status = decode(:amount_due_remaining, 0, ''CL'', ''OP''),
       gl_date_closed =
               decode(:amount_due_remaining, 0, :gl_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
       actual_date_closed =
               decode(:amount_due_remaining, 0, :actual_date_closed,TO_DATE(''31-12-4712'',''DD-MM-YYYY'')),
       amount_due_remaining = :amount_due_remaining,
       acctd_amount_due_remaining = :acctd_amount_due_remaining,
       amount_line_items_remaining = :amount_line_items_remaining,
       amount_adjusted = :amount_adjusted,
       tax_remaining = :tax_remaining,
       freight_remaining = :freight_remaining
WHERE payment_schedule_id = :payment_schedule_id';
Line: 5398

    debug('  update_ps_sql = ' || CRLF ||
          l_update_ps_sql || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5401

    debug('  len(update_ps_sql) = '||
          to_char(length(l_update_ps_sql)) || CRLF,
          MSG_LEVEL_DEBUG);
Line: 5414

	debug( '  Parsing insert_adj_c', MSG_LEVEL_DEBUG );
Line: 5415

        p_insert_adj_c := dbms_sql.open_cursor;
Line: 5416

        dbms_sql.parse( p_insert_adj_c, l_insert_adj_sql,
                        dbms_sql.v7 );
Line: 5419

	debug( '  Parsing update_ps_c', MSG_LEVEL_DEBUG );
Line: 5420

        p_update_ps_c := dbms_sql.open_cursor;
Line: 5421

        dbms_sql.parse( p_update_ps_c, l_update_ps_sql,
                        dbms_sql.v7 );
Line: 5424

	debug( '  Parsing select_c', MSG_LEVEL_DEBUG );
Line: 5425

        p_select_c := dbms_sql.open_cursor;
Line: 5426

        dbms_sql.parse( p_select_c, l_select_sql,
                        dbms_sql.v7 );
Line: 5448

PROCEDURE define_iad_select_columns(
	p_select_c   IN INTEGER,
        p_select_rec IN select_iad_rec_type ) IS

BEGIN

    print_fcn_label2( 'arp_maintain_ps2.define_iad_select_columns()+' );
Line: 5456

    dbms_sql.define_column( p_select_c, 1, p_select_rec.set_of_books_id );
Line: 5457

    dbms_sql.define_column( p_select_c, 2, p_select_rec.trx_date );
Line: 5458

    dbms_sql.define_column( p_select_c, 3, p_select_rec.gl_date );
Line: 5459

    dbms_sql.define_column( p_select_c, 4, p_select_rec.code_combination_id );
Line: 5460

    dbms_sql.define_column( p_select_c, 5, p_select_rec.adjusted_trx_id );
Line: 5461

    dbms_sql.define_column( p_select_c, 6, p_select_rec.payment_schedule_id );
Line: 5462

    dbms_sql.define_column( p_select_c, 7, p_select_rec.customer_trx_id );
Line: 5463

    dbms_sql.define_column( p_select_c, 8,
			    p_select_rec.post_to_gl_flag, 1 );
Line: 5465

    dbms_sql.define_column( p_select_c, 9, p_select_rec.actual_date_closed );
Line: 5466

    dbms_sql.define_column( p_select_c, 10, p_select_rec.gl_date_closed );
Line: 5467

    dbms_sql.define_column( p_select_c, 11, p_select_rec.min_acc_unit );
Line: 5468

    dbms_sql.define_column( p_select_c, 12, p_select_rec.precision );
Line: 5469

    dbms_sql.define_column( p_select_c, 13,
				p_select_rec.total_cm_line_amount );
Line: 5471

    dbms_sql.define_column( p_select_c, 14,
				p_select_rec.total_inv_adj_amount );
Line: 5473

    dbms_sql.define_column( p_select_c, 15, p_select_rec.commitment_code );
Line: 5474

    dbms_sql.define_column( p_select_c, 16, p_select_rec.invoice_trx_id );
Line: 5475

    dbms_sql.define_column( p_select_c, 17, p_select_rec.ps_line_remaining );
Line: 5476

    dbms_sql.define_column( p_select_c, 18,
				p_select_rec.ps_amount_due_remaining );
Line: 5478

    dbms_sql.define_column( p_select_c, 19,
				p_select_rec.ps_acctd_amt_due_rem );
Line: 5480

    dbms_sql.define_column( p_select_c, 20,
				p_select_rec.ps_amount_adjusted );
Line: 5482

    dbms_sql.define_column( p_select_c, 21, p_select_rec.ps_precision );
Line: 5483

    dbms_sql.define_column( p_select_c, 22, p_select_rec.ps_min_acc_unit );
Line: 5484

    dbms_sql.define_column( p_select_c, 23, p_select_rec.ps_exchange_rate );
Line: 5485

    dbms_sql.define_column( p_select_c, 24,
				p_select_rec.total_inv_line_remaining );
Line: 5487

    dbms_sql.define_column( p_select_c, 25, p_select_rec.ps_line_original );
Line: 5488

    dbms_sql.define_column( p_select_c, 26,
				p_select_rec.ps_currency_code, 15 );
Line: 5490

    dbms_sql.define_column( p_select_c, 27, p_select_rec.allocate_tax_freight, 1);
Line: 5491

    dbms_sql.define_column( p_select_c, 28, p_select_rec.adjustment_type, 8);
Line: 5492

    dbms_sql.define_column( p_select_c, 29, p_select_rec.total_cm_tax_amount);
Line: 5493

    dbms_sql.define_column( p_select_c, 30, p_select_rec.total_cm_frt_amount);
Line: 5494

    dbms_sql.define_column( p_select_c, 31, p_select_rec.inv_line_adj);
Line: 5495

    dbms_sql.define_column( p_select_c, 32, p_select_rec.inv_tax_adj);
Line: 5496

    dbms_sql.define_column( p_select_c, 33, p_select_rec.inv_frt_adj);
Line: 5497

    dbms_sql.define_column( p_select_c, 34, p_select_rec.ps_tax_remaining);
Line: 5498

    dbms_sql.define_column( p_select_c, 35, p_select_rec.ps_freight_remaining);
Line: 5499

    dbms_sql.define_column( p_select_c, 36, p_select_rec.ps_tax_original);
Line: 5500

    dbms_sql.define_column( p_select_c, 37, p_select_rec.ps_freight_remaining);
Line: 5502

    print_fcn_label2( 'arp_maintain_ps2.define_iad_select_columns()-' );
Line: 5506

        debug('EXCEPTION: arp_maintain_ps2.define_iad_select_columns()',
	      MSG_LEVEL_BASIC);
Line: 5509

END define_iad_select_columns;
Line: 5513

PROCEDURE get_iad_column_values( p_select_c   IN INTEGER,
                             p_select_rec IN OUT NOCOPY select_iad_rec_type ) IS
/* Bug 460927 - Changed IN to IN OUT in the above line - Oracle 8 */
BEGIN
    print_fcn_label2( 'arp_maintain_ps2.get_iad_column_values()+' );
Line: 5519

    dbms_sql.column_value( p_select_c, 1, p_select_rec.set_of_books_id );
Line: 5520

    dbms_sql.column_value( p_select_c, 2, p_select_rec.trx_date );
Line: 5521

    dbms_sql.column_value( p_select_c, 3, p_select_rec.gl_date );
Line: 5522

    dbms_sql.column_value( p_select_c, 4, p_select_rec.code_combination_id );
Line: 5523

    dbms_sql.column_value( p_select_c, 5, p_select_rec.adjusted_trx_id );
Line: 5524

    dbms_sql.column_value( p_select_c, 6, p_select_rec.payment_schedule_id );
Line: 5525

    dbms_sql.column_value( p_select_c, 7, p_select_rec.customer_trx_id );
Line: 5526

    dbms_sql.column_value( p_select_c, 8, p_select_rec.post_to_gl_flag );
Line: 5527

    dbms_sql.column_value( p_select_c, 9, p_select_rec.actual_date_closed );
Line: 5528

    dbms_sql.column_value( p_select_c, 10, p_select_rec.gl_date_closed );
Line: 5529

    dbms_sql.column_value( p_select_c, 11, p_select_rec.min_acc_unit );
Line: 5530

    dbms_sql.column_value( p_select_c, 12, p_select_rec.precision );
Line: 5531

    dbms_sql.column_value( p_select_c, 13, p_select_rec.total_cm_line_amount );
Line: 5532

    dbms_sql.column_value( p_select_c, 14, p_select_rec.total_inv_adj_amount );
Line: 5533

    dbms_sql.column_value( p_select_c, 15, p_select_rec.commitment_code );
Line: 5534

    dbms_sql.column_value( p_select_c, 16, p_select_rec.invoice_trx_id );
Line: 5535

    dbms_sql.column_value( p_select_c, 17, p_select_rec.ps_line_remaining );
Line: 5536

    dbms_sql.column_value( p_select_c, 18,
				p_select_rec.ps_amount_due_remaining );
Line: 5538

    dbms_sql.column_value( p_select_c, 19,
				p_select_rec.ps_acctd_amt_due_rem );
Line: 5540

    dbms_sql.column_value( p_select_c, 20,
				p_select_rec.ps_amount_adjusted );
Line: 5542

    dbms_sql.column_value( p_select_c, 21, p_select_rec.ps_precision );
Line: 5543

    dbms_sql.column_value( p_select_c, 22, p_select_rec.ps_min_acc_unit );
Line: 5544

    dbms_sql.column_value( p_select_c, 23, p_select_rec.ps_exchange_rate );
Line: 5545

    dbms_sql.column_value( p_select_c, 24,
				p_select_rec.total_inv_line_remaining );
Line: 5547

    dbms_sql.column_value( p_select_c, 25, p_select_rec.ps_line_original );
Line: 5548

    dbms_sql.column_value( p_select_c, 26, p_select_rec.ps_currency_code );
Line: 5549

    dbms_sql.column_value( p_select_c, 27, p_select_rec.allocate_tax_freight);
Line: 5550

    dbms_sql.column_value( p_select_c, 28, p_select_rec.adjustment_type);
Line: 5551

    dbms_sql.column_value( p_select_c, 29, p_select_rec.total_cm_tax_amount);
Line: 5552

    dbms_sql.column_value( p_select_c, 30, p_select_rec.total_cm_frt_amount);
Line: 5553

    dbms_sql.column_value( p_select_c, 31, p_select_rec.inv_line_adj);
Line: 5554

    dbms_sql.column_value( p_select_c, 32, p_select_rec.inv_tax_adj);
Line: 5555

    dbms_sql.column_value( p_select_c, 33, p_select_rec.inv_frt_adj);
Line: 5556

    dbms_sql.column_value( p_select_c, 34, p_select_rec.ps_tax_remaining);
Line: 5557

    dbms_sql.column_value( p_select_c, 35, p_select_rec.ps_freight_remaining);
Line: 5558

    dbms_sql.column_value( p_select_c, 36, p_select_rec.ps_tax_original);
Line: 5559

    dbms_sql.column_value( p_select_c, 37, p_select_rec.ps_freight_original);
Line: 5591

PROCEDURE dump_iad_select_rec( p_select_rec IN select_iad_rec_type ) IS
BEGIN

    print_fcn_label2( 'arp_maintain_ps2.dump_iad_select_rec()+' );
Line: 5596

    debug( '  Dumping select record: ', MSG_LEVEL_DEBUG );
Line: 5598

           || p_select_rec.set_of_books_id, MSG_LEVEL_DEBUG );
Line: 5600

           || p_select_rec.customer_trx_id , MSG_LEVEL_DEBUG );
Line: 5602

           || p_select_rec.post_to_gl_flag, MSG_LEVEL_DEBUG );
Line: 5604

           || p_select_rec.trx_date, MSG_LEVEL_DEBUG );
Line: 5606

           || p_select_rec.gl_date, MSG_LEVEL_DEBUG );
Line: 5608

           || p_select_rec.precision, MSG_LEVEL_DEBUG );
Line: 5610

           || p_select_rec.min_acc_unit, MSG_LEVEL_DEBUG );
Line: 5612

           || p_select_rec.adjusted_trx_id, MSG_LEVEL_DEBUG );
Line: 5614

           || p_select_rec.invoice_trx_id, MSG_LEVEL_DEBUG );
Line: 5616

           || p_select_rec.ps_currency_code, MSG_LEVEL_DEBUG );
Line: 5618

           || p_select_rec.ps_exchange_rate, MSG_LEVEL_DEBUG );
Line: 5620

           || p_select_rec.ps_precision, MSG_LEVEL_DEBUG );
Line: 5622

           || p_select_rec.ps_min_acc_unit, MSG_LEVEL_DEBUG );
Line: 5624

           || p_select_rec.commitment_code, MSG_LEVEL_DEBUG );
Line: 5626

           || p_select_rec.code_combination_id, MSG_LEVEL_DEBUG );
Line: 5628

           || p_select_rec.gl_date_closed, MSG_LEVEL_DEBUG );
Line: 5630

           || p_select_rec.actual_date_closed, MSG_LEVEL_DEBUG );
Line: 5632

           || p_select_rec.total_cm_line_amount, MSG_LEVEL_DEBUG );
Line: 5634

           || p_select_rec.total_inv_adj_amount, MSG_LEVEL_DEBUG );
Line: 5636

           || p_select_rec.total_inv_line_remaining, MSG_LEVEL_DEBUG );
Line: 5638

           || p_select_rec.payment_schedule_id, MSG_LEVEL_DEBUG );
Line: 5640

           || p_select_rec.ps_amount_due_remaining, MSG_LEVEL_DEBUG );
Line: 5642

           || p_select_rec.ps_acctd_amt_due_rem, MSG_LEVEL_DEBUG );
Line: 5644

           || p_select_rec.ps_line_original, MSG_LEVEL_DEBUG );
Line: 5646

           || p_select_rec.ps_line_remaining, MSG_LEVEL_DEBUG );
Line: 5648

           || p_select_rec.ps_amount_adjusted, MSG_LEVEL_DEBUG );
Line: 5651

           || p_select_rec.allocate_tax_freight, MSG_LEVEL_DEBUG);
Line: 5654

    print_fcn_label2( 'arp_maintain_ps2.dump_iad_select_rec()-' );
Line: 5658

        debug( 'EXCEPTION: arp_maintain_ps2.dump_iad_select_rec()',
               MSG_LEVEL_BASIC );
Line: 5661

END dump_iad_select_rec;
Line: 5669

        p_insert_adj_c			IN INTEGER,
        p_update_ps_c			IN INTEGER,
	p_select_rec			IN select_iad_rec_type,
        p_number_records		IN NUMBER,
        p_ps_id_t			IN id_table_type,
        p_ps_amount_due_rem_t 		IN OUT NOCOPY number_table_type,
        p_ps_acctd_amt_due_rem_t	IN OUT NOCOPY number_table_type,
        p_ps_line_orig_t 		IN number_table_type,
        p_ps_line_rem_t 		IN OUT NOCOPY number_table_type,
        p_ps_amount_adjusted_t 		IN OUT NOCOPY number_table_type,
        p_adj_amount_t 			IN OUT NOCOPY number_table_type,
        p_acctd_adj_amount_t 		IN OUT NOCOPY number_table_type,
	p_eff_adj_line_total            IN OUT NOCOPY NUMBER,
        p_eff_adj_tax_total             IN OUT NOCOPY NUMBER,
        p_eff_adj_frt_total             IN OUT NOCOPY NUMBER,
        p_eff_line_bal                  IN OUT NOCOPY NUMBER,
        p_eff_tax_bal                   IN OUT NOCOPY NUMBER,
        p_eff_frt_bal                   IN OUT NOCOPY NUMBER,
        p_line_adj_t                    IN OUT NOCOPY number_table_type,
        p_tax_adj_t                     IN OUT NOCOPY number_table_type,
        p_frt_adj_t                     IN OUT NOCOPY number_table_type,
        p_ps_tax_orig_t                 IN OUT NOCOPY number_table_type,
        p_ps_tax_rem_t                  IN OUT NOCOPY number_table_type,
        p_ps_frt_orig_t                 IN OUT NOCOPY number_table_type,
        p_ps_frt_rem_t                  IN OUT NOCOPY number_table_type,
        p_inv_line_adj_t                IN OUT NOCOPY number_table_type,
        p_inv_tax_adj_t                 IN OUT NOCOPY number_table_type,
        p_inv_frt_adj_t                 IN OUT NOCOPY number_table_type,
        p_is_new_adj_trx                IN     boolean
) IS

    l_ignore 			INTEGER;
Line: 5790

       d. INSERT adjustments
       e. UPDATE payment schedules
       f. INSERT distributions
    */

    --------------------------------------------------------------------
    -- Get total line orig/rem for adjusted ps
    --------------------------------------------------------------------
    FOR i IN 0..p_number_records - 1 LOOP
        l_total_ps_line_rem := l_total_ps_line_rem + p_ps_line_rem_t( i );
Line: 5812

        IF (p_select_rec.allocate_tax_freight = 'Y') THEN

           l_total_ps_orig := l_total_ps_orig + p_ps_tax_orig_t(i) +
                                   p_ps_frt_orig_t(i);
Line: 5851

            IF (p_select_rec.allocate_tax_freight = 'Y') THEN
                l_percent_t( i ) := (p_ps_line_rem_t( i ) + p_ps_tax_rem_t( i ) +
                                     p_ps_frt_rem_t( i )) / l_total_ps_rem;
Line: 5864

            IF (p_select_rec.allocate_tax_freight = 'Y') THEN
                l_percent_t( i ) := (p_ps_line_orig_t( i ) + p_ps_tax_orig_t( i ) +
                                     p_ps_frt_orig_t( i )) / l_total_ps_orig;
Line: 5878

    debug( '  commitment_code='||p_select_rec.commitment_code,
		MSG_LEVEL_DEBUG );
Line: 5880

    debug( '  allocate_tax_freight=' || p_select_rec.allocate_tax_freight,
                MSG_LEVEL_DEBUG );
Line: 5884

    IF( p_select_rec.commitment_code = 0 ) THEN

        ----------------------------------------------------------------
	-- GUAR case
        ----------------------------------------------------------------
        debug( '  GUAR case', MSG_LEVEL_DEBUG );
Line: 5895

                  p_select_rec.total_inv_line_remaining,
	         	MSG_LEVEL_DEBUG );
Line: 5897

        debug( '  adj_trx_id='||p_select_rec.adjusted_trx_id,
                        MSG_LEVEL_DEBUG );
Line: 5899

        debug( '  invoice_trx_id=' || p_select_rec.invoice_trx_id,
                        MSG_LEVEL_DEBUG );
Line: 5905

           select nvl(sum(adj.line_adjusted),0)
           into   l_cm_adjustment_total
           from   ar_adjustments adj,
                  ra_customer_trx ocm
           where  adj.customer_trx_id = p_select_rec.adjusted_trx_id
           and    adj.subsequent_trx_id = ocm.customer_trx_id
           and    ocm.previous_customer_trx_id = p_select_rec.invoice_trx_id;
Line: 5929

            l_reversal_adj := GREATEST(p_select_rec.total_cm_line_amount,
                                       l_max_curr_adj);
Line: 5934

            l_reversal_adj := LEAST(p_select_rec.total_cm_line_amount,
                                    l_max_curr_adj);
Line: 5944

	-- Update invoice line balance
        ----------------------------------------------------------------
	p_eff_line_bal := p_eff_line_bal +
					p_select_rec.total_cm_line_amount;
Line: 5953

	      	p_select_rec.ps_currency_code,
		l_reversal_adj,
		l_percent_t,
		p_line_adj_t );
Line: 5958

    ELSIF( p_select_rec.commitment_code = 1 ) THEN

        ----------------------------------------------------------------
	-- DEP case
        -- 1483656 - modified to allocate tax and freight
        ----------------------------------------------------------------
        debug( '  DEP case', MSG_LEVEL_DEBUG );
Line: 5973

            p_select_rec.total_cm_line_amount +
           (l_total_line_adj * -1) <= 0)
        THEN
           debug( '  l_total_ps_line_rem        = '||
                 l_total_ps_line_rem, MSG_LEVEL_DEBUG );
Line: 5978

           debug( '  p_select_rec.total_cm_line = '||
                 p_select_rec.total_cm_line_amount, MSG_LEVEL_DEBUG );
Line: 5997

        DEBUG('     p_select_rec.total_cm_line_amount = ' ||
                      p_select_rec.total_cm_line_amount,
                      MSG_LEVEL_DEBUG);
Line: 6009

           IF( p_eff_line_bal + p_select_rec.total_cm_line_amount < 0 ) THEN

                 l_reversal_adj :=
		     GREATEST( p_eff_adj_line_total,
		   	       p_eff_line_bal +
			       p_select_rec.total_cm_line_amount );
Line: 6023

	               p_select_rec.ps_currency_code,
		       l_reversal_adj,
		       l_percent_t,
		       p_line_adj_t );
Line: 6030

					p_select_rec.total_cm_line_amount;
Line: 6035

        IF (p_select_rec.allocate_tax_freight = 'Y') THEN

           debug( '   ALLOCATING TAX AND FREIGHT', MSG_LEVEL_DEBUG);
Line: 6042

           debug( '  p_select_rec.total_cm_tax = '||p_select_rec.total_cm_tax_amount,
                              MSG_LEVEL_DEBUG );
Line: 6048

               p_select_rec.total_cm_tax_amount +
              (l_total_tax_adj * -1) <= 0)
           THEN
                debug( '  REVERSING TAX', MSG_LEVEL_DEBUG );
Line: 6065

        DEBUG('     p_select_rec.total_cm_tax_amount = ' ||
                      p_select_rec.total_cm_tax_amount,
                      MSG_LEVEL_DEBUG);
Line: 6073

                IF( p_eff_tax_bal + p_select_rec.total_cm_tax_amount < 0 ) THEN

                     l_reversal_adj :=
	    	         GREATEST( p_eff_adj_tax_total,
		   	           p_eff_tax_bal +
			           p_select_rec.total_cm_tax_amount );
Line: 6086

	                    p_select_rec.ps_currency_code,
		            l_reversal_adj,
		            l_percent_t,
		            p_tax_adj_t );
Line: 6093

					p_select_rec.total_cm_tax_amount;
Line: 6100

           debug( '  p_select_rec.total_cm_frt = '||p_select_rec.total_cm_frt_amount,
                              MSG_LEVEL_DEBUG );
Line: 6106

               p_select_rec.total_cm_frt_amount +
              (l_total_frt_adj * -1) <= 0 )
           THEN
                debug( '  REVERSING FREIGHT', MSG_LEVEL_DEBUG );
Line: 6123

                IF( p_eff_frt_bal + p_select_rec.total_cm_frt_amount < 0 ) THEN

                     l_reversal_adj :=
		         GREATEST( p_eff_adj_frt_total,
		   	           p_eff_frt_bal +
			           p_select_rec.total_cm_frt_amount );
Line: 6135

	                    p_select_rec.ps_currency_code,
		            l_reversal_adj,
		            l_percent_t,
		            p_frt_adj_t );
Line: 6142

					p_select_rec.total_cm_frt_amount;
Line: 6167

        IF (p_select_rec.allocate_tax_freight = 'Y') THEN
           p_ps_tax_rem_t( i )  := p_ps_tax_rem_t( i ) - p_tax_adj_t( i );
Line: 6194

		p_select_rec.ps_exchange_rate,
		'-',			-- type
		p_ps_amount_due_rem_t( i ),	-- master_from
		p_ps_acctd_amt_due_rem_t( i ),	-- acctd_master_from
		p_adj_amount_t( i ),	-- detail
		l_new_ps_adr,		-- master_to
		l_new_ps_acctd_adr,	-- acctd_master_to
		l_new_acctd_adj_amount	-- acctd_detail
	);
Line: 6205

	-- Update amt_due_rem, acctd_amt_due_rem
        --------------------------------------------------------------------
	p_ps_amount_due_rem_t( i ) := l_new_ps_adr;
Line: 6231

	    debug( '  Binding insert_adj_c', MSG_LEVEL_DEBUG );
Line: 6233

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 6237

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 6241

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'request_id',
                                    p_profile_info.request_id );
Line: 6245

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'application_id',
                                    p_profile_info.application_id );
Line: 6249

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'program_id',
                                    p_profile_info.conc_program_id );
Line: 6255

			p_insert_adj_c,
			'set_of_books_id',
                	p_select_rec.set_of_books_id );
Line: 6259

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'trx_date',
                                    p_select_rec.trx_date );
Line: 6263

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'gl_date',
                                    p_select_rec.gl_date );
Line: 6267

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'code_combination_id',
                                    p_select_rec.code_combination_id );
Line: 6271

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'adjusted_trx_id',
                                    p_select_rec.adjusted_trx_id );
Line: 6275

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'payment_schedule_id',
                                    p_ps_id_t( i ) );
Line: 6279

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'subsequent_trx_id',
                                    p_select_rec.customer_trx_id );
Line: 6283

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'post_to_gl_flag',
                                    p_select_rec.post_to_gl_flag );
Line: 6287

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'adj_amount',
                                    p_adj_amount_t( i ) );
Line: 6291

            dbms_sql.bind_variable( p_insert_adj_c,
		                    'acctd_adj_amount',
                                    p_acctd_adj_amount_t( i ) );
Line: 6296

            SELECT ar_adjustments_s.nextval
            INTO l_adjustment_id
            FROM   dual;
Line: 6300

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'adjustment_id',
                                    l_adjustment_id );
Line: 6304

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'adj_type',
                                    p_select_rec.adjustment_type);
Line: 6308

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'line_adjusted',
                                    p_line_adj_t(i));
Line: 6312

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'tax_adjusted',
                                    p_tax_adj_t(i));
Line: 6316

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'freight_adjusted',
                                    p_frt_adj_t(i));
Line: 6320

            dbms_sql.bind_variable( p_insert_adj_c,
                                    'org_id',
                                    arp_standard.sysparm.org_id);
Line: 6326

            debug( 'EXCEPTION: Error in binding insert_adj_c',
                   MSG_LEVEL_BASIC );
Line: 6335

	    debug( '  Inserting adjustments', MSG_LEVEL_DEBUG );
Line: 6336

            l_ignore := dbms_sql.execute( p_insert_adj_c );
Line: 6337

            debug( to_char(l_ignore) || ' row(s) inserted',
		           MSG_LEVEL_DEBUG );
Line: 6341

            | Call central MRC library for insertion    |
            | into MRC tables                           |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'INSERT',
                      p_table_name       => 'AR_ADJUSTMENTS',
                      p_mode             => 'SINGLE',
                      p_key_value        => l_adjustment_id);
Line: 6353

            debug( 'EXCEPTION: Error executing insert ra stmt',
                   MSG_LEVEL_BASIC );
Line: 6367

	    debug( '  Binding update_ps_c', MSG_LEVEL_DEBUG );
Line: 6369

            dbms_sql.bind_variable( p_update_ps_c,
		                    'user_id',
                                    p_profile_info.user_id );
Line: 6373

            dbms_sql.bind_variable( p_update_ps_c,
		                    'login_id',
                                    p_profile_info.conc_login_id );
Line: 6377

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_due_remaining',
                                    p_ps_amount_due_rem_t( i ) );
Line: 6381

            dbms_sql.bind_variable( p_update_ps_c,
		                    'gl_date_closed',
                                    p_select_rec.gl_date_closed );
Line: 6385

            dbms_sql.bind_variable( p_update_ps_c,
		                    'actual_date_closed',
                                    p_select_rec.actual_date_closed );
Line: 6389

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_line_items_remaining',
                                    p_ps_line_rem_t( i ) );
Line: 6393

            dbms_sql.bind_variable( p_update_ps_c,
		                    'amount_adjusted',
                                    p_ps_amount_adjusted_t( i ) );
Line: 6397

            dbms_sql.bind_variable( p_update_ps_c,
		                    'acctd_amount_due_remaining',
                                    p_ps_acctd_amt_due_rem_t( i ) );
Line: 6401

            dbms_sql.bind_variable( p_update_ps_c,
		                    'payment_schedule_id',
                                    p_ps_id_t( i ) );
Line: 6405

            dbms_sql.bind_variable( p_update_ps_c,
		                    'tax_remaining',
                                    p_ps_tax_rem_t( i ) );
Line: 6409

            dbms_sql.bind_variable( p_update_ps_c,
		                    'freight_remaining',
                                    p_ps_frt_rem_t( i ) );
Line: 6415

            debug( 'EXCEPTION: Error in binding update_ps_c',
                   MSG_LEVEL_BASIC );
Line: 6425

            l_ignore := dbms_sql.execute( p_update_ps_c );
Line: 6426

            debug( to_char(l_ignore) || ' row(s) updated',
		           MSG_LEVEL_DEBUG );
Line: 6430

            | Call central MRC library for update       |
            | of AR_PAYMENT_SCHEDULES                   |
            +-------------------------------------------*/

           ar_mrc_engine.maintain_mrc_data(
                      p_event_mode       => 'UPDATE',
                      p_table_name       => 'AR_PAYMENT_SCHEDULES',
                      p_mode             => 'SINGLE',
                      p_key_value        => p_ps_id_t( i ));
Line: 6442

            debug( 'EXCEPTION: Error executing update ps stmt',
                   MSG_LEVEL_BASIC );
Line: 6456

	l_ae_doc_rec.source_id_old := p_select_rec.code_combination_id;
Line: 6483

PROCEDURE insert_cm_child_adj_private(
	p_system_info		IN arp_trx_global.system_info_rec_type,
	p_profile_info 		IN arp_trx_global.profile_rec_type,
	p_customer_trx_id 	IN BINARY_INTEGER ) IS

    l_ignore 			INTEGER;
Line: 6543

    l_select_rec		select_iad_rec_type;
Line: 6546

    PROCEDURE load_tables( p_select_rec IN select_iad_rec_type ) IS

    BEGIN
        print_fcn_label2('arp_maintain_ps2.load_tables()+' );
Line: 6551

        l_ps_id_t( l_table_index ) := p_select_rec.payment_schedule_id;
Line: 6553

				p_select_rec.ps_amount_due_remaining;
Line: 6555

				p_select_rec.ps_acctd_amt_due_rem;
Line: 6557

				p_select_rec.ps_line_original;
Line: 6559

				p_select_rec.ps_line_remaining;
Line: 6561

				p_select_rec.ps_amount_adjusted;
Line: 6564

                                p_select_rec.ps_tax_original;
Line: 6566

                                p_select_rec.ps_tax_remaining;
Line: 6568

                                p_select_rec.ps_freight_original;
Line: 6570

                                p_select_rec.ps_freight_remaining;
Line: 6573

                                p_select_rec.inv_line_adj;
Line: 6575

                                p_select_rec.inv_tax_adj;
Line: 6577

                                p_select_rec.inv_frt_adj;
Line: 6688

    print_fcn_label( 'arp_maintain_ps2.insert_cm_child_adj_private()+' );
Line: 6693

    IF( NOT( dbms_sql.is_open( iad_select_c ) AND
	     dbms_sql.is_open( iad_insert_adj_c ) AND
	     dbms_sql.is_open( iad_update_ps_c ) )) THEN

        build_iad_sql(
		system_info,
		profile_info,
		iad_select_c,
		iad_insert_adj_c,
		iad_update_ps_c );
Line: 6707

    define_iad_select_columns( iad_select_c, l_select_rec );
Line: 6712

    dbms_sql.bind_variable( iad_select_c,
			    'customer_trx_id',
			    p_customer_trx_id );
Line: 6719

    debug( '  Executing select sql', MSG_LEVEL_DEBUG );
Line: 6722

        l_ignore := dbms_sql.execute( iad_select_c );
Line: 6726

          debug( 'EXCEPTION: Error executing select sql',
		 MSG_LEVEL_BASIC );
Line: 6738

            IF dbms_sql.fetch_rows( iad_select_c ) > 0  THEN

	        debug('  Fetched a row', MSG_LEVEL_DEBUG );
Line: 6745

		dbms_sql.column_value( iad_select_c, 7, l_customer_trx_id );
Line: 6746

		dbms_sql.column_value( iad_select_c, 5, l_adjusted_trx_id );
Line: 6747

		dbms_sql.column_value( iad_select_c, 16, l_inv_trx_id );
Line: 6778

				iad_insert_adj_c,
				iad_update_ps_c,
				l_select_rec,
				l_table_index,
				l_ps_id_t,
				l_ps_amount_due_rem_t,
				l_ps_acctd_amt_due_rem_t,
				l_ps_line_orig_t,
				l_ps_line_rem_t,
				l_ps_amount_adjusted_t,
				l_adj_amount_t,
				l_acctd_adj_amount_t,
				l_eff_adj_line_total,
                                l_eff_adj_tax_total,
                                l_eff_adj_frt_total,
				l_eff_line_bal,
                                l_eff_tax_bal,
                                l_eff_frt_bal,
                                l_line_adj_t,
                                l_tax_adj_t,
                                l_frt_adj_t,
                                l_ps_tax_orig_t,
                                l_ps_tax_rem_t,
                                l_ps_frt_orig_t,
                                l_ps_frt_rem_t,
                                l_inv_line_adj_t,
                                l_inv_tax_adj_t,
                                l_inv_frt_adj_t,
                                l_is_new_adj_trx );
Line: 6823

/*                        dbms_sql.column_value( iad_select_c, 31,
                                                l_eff_adj_line_total );
Line: 6825

                        dbms_sql.column_value( iad_select_c, 32,
                                                l_eff_adj_tax_total );
Line: 6827

                        dbms_sql.column_value( iad_select_c, 33,
                                                l_eff_adj_frt_total );
Line: 6846

                        dbms_sql.column_value( iad_select_c, 24 ,
                                                l_eff_line_bal );
Line: 6848

                        dbms_sql.column_value( iad_select_c, 34 ,
                                                l_eff_tax_bal );
Line: 6850

                        dbms_sql.column_value( iad_select_c, 35,
                                                l_eff_frt_bal );
Line: 6857

		get_iad_column_values( iad_select_c, l_select_rec );
Line: 6858

		dump_iad_select_rec( l_select_rec );
Line: 6862

		    load_tables( l_select_rec );
Line: 6877

			iad_insert_adj_c,
			iad_update_ps_c,
			l_select_rec,
			l_table_index,
			l_ps_id_t,
			l_ps_amount_due_rem_t,
			l_ps_acctd_amt_due_rem_t,
			l_ps_line_orig_t,
			l_ps_line_rem_t,
			l_ps_amount_adjusted_t,
			l_adj_amount_t,
			l_acctd_adj_amount_t,
		        l_eff_adj_line_total,
                        l_eff_adj_tax_total,
                        l_eff_adj_frt_total,
		        l_eff_line_bal,
                        l_eff_tax_bal,
                        l_eff_frt_bal,
                        l_line_adj_t,
                        l_tax_adj_t,
                        l_frt_adj_t,
                        l_ps_tax_orig_t,
                        l_ps_tax_rem_t,
                        l_ps_frt_orig_t,
                        l_ps_frt_rem_t,
                        l_inv_line_adj_t,
                        l_inv_tax_adj_t,
                        l_inv_frt_adj_t,
                        l_is_new_adj_trx  );
Line: 6918

            debug( 'EXCEPTION: Error fetching select cursor',
                   MSG_LEVEL_BASIC );
Line: 6924

    print_fcn_label( 'arp_maintain_ps2.insert_cm_child_adj_private()-' );
Line: 6928

        debug( 'EXCEPTION: arp_maintain_ps2.insert_cm_child_adj_private()',
	       MSG_LEVEL_BASIC );
Line: 6932

END insert_cm_child_adj_private;
Line: 6944

    build_ips_sql(system_info, profile_info, ips_select_c, ips_insert_ps_c);
Line: 6958

		ira_select_c,
		ira_insert_ps_c,
		ira_insert_ra_c,
		ira_update_ps_c);
Line: 6975

		ups_select_c,
		ups_insert_adj_c,
		ups_update_ps_c);
Line: 6991

		iad_select_c,
		iad_insert_adj_c,
		iad_update_ps_c);
Line: 6999

PROCEDURE test_insert_inv_ps(
	p_customer_trx_id BINARY_INTEGER,
	p_reversed_cash_receipt_id	IN BINARY_INTEGER )
IS

BEGIN

    insert_inv_ps_private(
	system_info,
	profile_info,
	p_customer_trx_id,
	p_reversed_cash_receipt_id
	);
Line: 7017

PROCEDURE test_ai_insert_inv_ps(
		p_request_id BINARY_INTEGER,
		p_select_sql VARCHAR2 )
IS

BEGIN

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_inv_ps()+' );
Line: 7028

		       ips_select_c,
		       ips_insert_ps_c );
Line: 7035

    dbms_sql.close_cursor( ips_select_c );
Line: 7036

    ips_select_c := dbms_sql.open_cursor;
Line: 7038

    debug('  select_sql='||p_select_sql );
Line: 7040

    debug('  parsing new select sql');
Line: 7041

    dbms_sql.parse( ips_select_c, p_select_sql, dbms_sql.v7 );
Line: 7045

    insert_inv_ps_private(
	system_info,
	profile_info,
	p_request_id,
	null);
Line: 7051

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_inv_ps()-' );
Line: 7056

PROCEDURE test_insert_cm_ps( p_customer_trx_id BINARY_INTEGER )
IS

BEGIN

    insert_cm_ps_private(system_info, profile_info, p_customer_trx_id);
Line: 7067

PROCEDURE test_ai_insert_cm_ps(
		p_request_id BINARY_INTEGER,
		p_select_sql VARCHAR2 )
IS

BEGIN

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_cm_ps()+' );
Line: 7078

		       ira_select_c,
			ira_insert_ps_c,
			ira_insert_ra_c,
		       ira_update_ps_c );
Line: 7087

    dbms_sql.close_cursor( ira_select_c );
Line: 7088

    ira_select_c := dbms_sql.open_cursor;
Line: 7090

    debug('  select_sql='||p_select_sql );
Line: 7092

    debug('  parsing new select sql');
Line: 7093

    dbms_sql.parse( ira_select_c, p_select_sql, dbms_sql.v7 );
Line: 7097

    insert_cm_ps_private(system_info, profile_info, p_request_id);
Line: 7099

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_cm_ps()-' );
Line: 7103

PROCEDURE test_insert_child_adj( p_customer_trx_id BINARY_INTEGER )
IS

BEGIN

    insert_child_adj_private(system_info, profile_info, p_customer_trx_id);
Line: 7114

PROCEDURE test_ai_insert_child_adj(
		p_request_id BINARY_INTEGER,
		p_select_sql VARCHAR2 )
IS

BEGIN

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_child_adj()+' );
Line: 7125

		       ups_select_c,
			ups_insert_adj_c,
		       ups_update_ps_c );
Line: 7133

    dbms_sql.close_cursor( ups_select_c );
Line: 7134

    ups_select_c := dbms_sql.open_cursor;
Line: 7136

    debug('  select_sql='||p_select_sql );
Line: 7138

    debug('  parsing new select sql');
Line: 7139

    dbms_sql.parse( ups_select_c, p_select_sql, dbms_sql.v7 );
Line: 7143

    insert_child_adj_private(system_info, profile_info, p_request_id);
Line: 7145

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_child_adj()-' );
Line: 7150

PROCEDURE test_insert_cm_child_adj( p_customer_trx_id BINARY_INTEGER )
IS

BEGIN

    insert_cm_child_adj_private(system_info, profile_info, p_customer_trx_id);
Line: 7161

PROCEDURE test_ai_insert_cm_child_adj(
		p_request_id BINARY_INTEGER,
		p_select_sql VARCHAR2 )
IS

BEGIN

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_cm_child_adj()+' );
Line: 7172

		       iad_select_c,
			iad_insert_adj_c,
		       iad_update_ps_c );
Line: 7180

    dbms_sql.close_cursor( iad_select_c );
Line: 7181

    iad_select_c := dbms_sql.open_cursor;
Line: 7183

    debug('  select_sql='||p_select_sql );
Line: 7185

    debug('  parsing new select sql');
Line: 7186

    dbms_sql.parse( iad_select_c, p_select_sql, dbms_sql.v7 );
Line: 7190

    insert_cm_child_adj_private(system_info, profile_info, p_request_id);
Line: 7192

    print_fcn_label( 'arp_maintain_ps2.test_ai_insert_cm_child_adj()-' );