<ROOT>
 <APPS_INITIALIZE_DATA>
  <USER_NAME>ENGINATICS</USER_NAME>
  <RESPONSIBILITY_KEY>SYSTEM_ADMINISTRATOR</RESPONSIBILITY_KEY>
  <APPLICATION_SHORT_NAME>SYSADMIN</APPLICATION_SHORT_NAME>
 </APPS_INITIALIZE_DATA>
<REPORTS>
<!-- loader xml for Enginatics Blitz Report: AR Aging - DIagnostic Report -->
 <REPORTS_ROW>
  <GUID>359F2BEB002311B8E0633D7D37A2C85F</GUID>
  <SQL_TEXT>select /*+ push_pred(x) */
x.*,
hcpa.cust_account_profile_id,
hcps.cust_account_profile_id
from
(
    select
     substrb(hp.party_name,1,50) cust_name,
     hca.account_number cust_no,
     nvl(sales.name,jrrev.resource_name) sort_field1,
     arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id) sort_field2,
     nvl(sales.salesrep_id, -3) salesrep_id,
     rt.name term,
     site.site_use_id,
     loc.state cust_state,
     loc.city cust_city,
     (select ftv.territory_short_name from fnd_territories_vl ftv where ftv.territory_code = loc.country) cust_country,
     decode(decode(upper(rtrim(rpad(:p_in_format_option_low, 1))),&apos;D&apos;,&apos;D&apos;,null),null,-1,acct_site.cust_acct_site_id) addr_id,
     nvl(hca.cust_account_id,-999) cust_id,
     hca.party_id,
     ps.payment_schedule_id payment_sched_id,
     ps.class class,
     ps.trx_date,
     ps.due_date,
     decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.amount_due_original * nvl(ps.exchange_rate, 1), ps.amount_due_original) amt_due_original,
     xxen_ar_arxagrw_pkg.comp_amt_due_remainingformula
      ( ps.class,
        arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id),
        ps.payment_schedule_id,
        ps.amt_due_remaining,
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted
      )  amt_due_remaining,
     ps.trx_number invnum,
     ceil(:p_in_as_of_date_low - ps.trx_date) days_past_trx,
     ceil(:p_in_as_of_date_low - ps.due_date) days_past_due,
     ps.amount_adjusted amount_adjusted,
     ps.amount_applied amount_applied,
     ps.amount_credited amount_credited,
     ps.gl_date gl_date,
     decode(ps.invoice_currency_code, gsob.currency_code, NULL, decode(ps.exchange_rate, null, &apos;*&apos;, null)) data_converted,
     nvl(ps.exchange_rate, 1) ps_exchange_rate,
     c.code_combination_id,
     c.chart_of_accounts_id,
     ci.cons_billing_number  cons_billing_number,
     arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id) invoice_type,
     ps.invoice_currency_code,
     gsob.currency_code functional_currency,
     gsob.name ledger,
     ps.org_id
    from
     hz_cust_accounts hca,
     hz_parties hp,
     (select
       a.customer_id,
       a.customer_site_use_id ,
       a.customer_trx_id,
       a.payment_schedule_id,
       a.class ,
       sum(a.primary_salesrep_id) primary_salesrep_id,
       a.term_id,
       a.trx_date,
       a.due_date,
       sum(a.amount_due_remaining) amt_due_remaining,
       a.trx_number,
       a.amount_due_original,
       a.amount_adjusted,
       a.amount_applied ,
       a.amount_credited ,
       a.amount_adjusted_pending,
       a.gl_date ,
       a.cust_trx_type_id,
       a.org_id,
       a.invoice_currency_code,
       a.exchange_rate,
       sum(a.cons_inv_id) cons_inv_id
      from
       (
        select
         ps.customer_id,
         ps.customer_site_use_id,
         ps.customer_trx_id,
         ps.payment_schedule_id,
         ps.class,
         0 primary_salesrep_id,
         ps.term_id,
         ps.trx_date,
         ps.due_date,
         nvl(sum(decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, nvl(adj.acctd_amount, 0), adj.amount)),0) * (-1)  amount_due_remaining,
         ps.trx_number,
         ps.amount_due_original,
         ps.amount_adjusted,
         ps.amount_applied,
         ps.amount_credited,
         ps.amount_adjusted_pending,
         ps.gl_date,
         ps.cust_trx_type_id,
         ps.org_id,
         ps.invoice_currency_code,
         nvl(ps.exchange_rate,1) exchange_rate,
         0 cons_inv_id
        from
         ar_payment_schedules ps,
         ar_adjustments adj
        where
            ps.gl_date &lt;= :p_in_as_of_date_low
        and ps.customer_id &gt; 0
        and  ps.gl_date_closed  &gt; :p_in_as_of_date_low
        and  decode(upper(:p_in_currency),NULL, ps.invoice_currency_code,upper(:p_in_currency)) = ps.invoice_currency_code
        and  adj.payment_schedule_id = ps.payment_schedule_id
        and  adj.status = &apos;A&apos;
        and  adj.gl_date &gt; :p_in_as_of_date_low
        and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
        and adj.org_id = ps.org_id
       group by
        ps.customer_id,
        ps.customer_site_use_id,
        ps.customer_trx_id,
        ps.class,
        ps.term_id,
        ps.trx_date,
        ps.due_date,
        ps.trx_number,
        ps.amount_due_original,
        ps.amount_adjusted,
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted_pending,
        ps.gl_date,
        ps.cust_trx_type_id,
        ps.org_id,
        ps.invoice_currency_code,
        nvl(ps.exchange_rate,1),
        ps.payment_schedule_id
       union all
       select
        ps.customer_id,
        ps.customer_site_use_id,
        ps.customer_trx_id,
        ps.payment_schedule_id,
        ps.class,
        0 primary_salesrep_id,
        ps.term_id,
        ps.trx_date,
        ps.due_date,
        nvl(sum(decode( nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;),
                        &apos;Y&apos;, (decode( ps.class,
                                      &apos;CM&apos;, decode( app.application_type, &apos;CM&apos;, app.acctd_amount_applied_from, app.acctd_amount_applied_to),
                                            app.acctd_amount_applied_to
                                    ) +
                               nvl(app.acctd_earned_discount_taken,0) +
                               nvl(app.acctd_unearned_discount_taken,0)
                              )
                           ,  ( app.amount_applied +
                               nvl(app.earned_discount_taken,0) +
                               nvl(app.unearned_discount_taken,0)
                              )
                      ) *
                decode( ps.class,
                        &apos;CM&apos;, decode(app.application_type, &apos;CM&apos;, -1, 1),
                              1
                      )
               ),0
           ) amount_due_remaining,
        ps.trx_number,
        ps.amount_due_original,
        ps.amount_adjusted,
        ps.amount_applied ,
        ps.amount_credited,
        ps.amount_adjusted_pending,
        ps.gl_date gl_date,
        ps.cust_trx_type_id,
        ps.org_id,
        ps.invoice_currency_code,
        nvl(ps.exchange_rate, 1) exchange_rate,
        0 cons_inv_id
       from
        ar_payment_schedules ps,
        ar_receivable_applications app
       where
           ps.gl_date &lt;= :p_in_as_of_date_low
       and ps.customer_id &gt; 0
       and ps.gl_date_closed  &gt; :p_in_as_of_date_low
       and decode(upper(:p_in_currency),NULL, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
       and (app.applied_payment_schedule_id = ps.payment_schedule_id or
            app.payment_schedule_id = ps.payment_schedule_id
           )
       and app.status IN (&apos;APP&apos;, &apos;ACTIVITY&apos;)
       and nvl( app.confirmed_flag, &apos;Y&apos; ) = &apos;Y&apos;
       and app.gl_date &gt; :p_in_as_of_date_low
       and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
       and app.org_id = ps.org_id
       group by
        ps.customer_id,
        ps.customer_site_use_id,
        ps.customer_trx_id,
        ps.class,
        ps.term_id,
        ps.trx_date,
        ps.due_date,
        ps.trx_number,
        ps.amount_due_original,
        ps.amount_adjusted,
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted_pending,
        ps.gl_date,
        ps.cust_trx_type_id,
        ps.org_id,
        ps.invoice_currency_code,
        nvl(ps.exchange_rate, 1),
        ps.payment_schedule_id
       union all
       select
        ps.customer_id,
        ps.customer_site_use_id,
        ps.customer_trx_id,
        ps.payment_schedule_id,
        ps.class class,
        nvl(ct.primary_salesrep_id, -3) primary_salesrep_id,
        ps.term_id,
        ps.trx_date,
        ps.due_date,
        decode( nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.acctd_amount_due_remaining, ps.amount_due_remaining) amt_due_remaining,
        ps.trx_number,
        ps.amount_due_original,
        ps.amount_adjusted,
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted_pending,
        ps.gl_date,
        ps.cust_trx_type_id,
        ps.org_id,
        ps.invoice_currency_code,
        nvl(ps.exchange_rate, 1) exchange_rate,
        ps.cons_inv_id
       from
        ar_payment_schedules ps,
        ra_customer_trx ct
       where
           ps.gl_date &lt;= :p_in_as_of_date_low
       and ps.gl_date_closed  &gt; :p_in_as_of_date_low
       and decode(upper(:p_in_currency),NULL, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
       and ps.customer_trx_id = ct.customer_trx_id
       and ps.class &lt;&gt; &apos;CB&apos;
       and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
       and ct.org_id = ps.org_id
       union all
       select
        ps.customer_id,
        ps.customer_site_use_id ,
        ps.customer_trx_id,
        ps.payment_schedule_id,
        ps.class class,
        nvl(ct.primary_salesrep_id,-3) primary_salesrep_id,
        ps.term_id,
        ps.trx_date,
        ps.due_date,
        decode( nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.acctd_amount_due_remaining, ps.amount_due_remaining) amt_due_remaining,
        ps.trx_number,
        ps.amount_due_original,
        ps.amount_adjusted,
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted_pending,
        ps.gl_date,
        ps.cust_trx_type_id,
        ps.org_id,
        ps.invoice_currency_code,
        nvl(ps.exchange_rate, 1) exchange_rate,
        ps.cons_inv_id
       from
        ar_payment_schedules ps,
        ra_customer_trx ct,
        ar_adjustments adj
       where
           ps.gl_date &lt;= :p_in_as_of_date_low
       and ps.gl_date_closed  &gt; :p_in_as_of_date_low
       and decode(upper(:p_in_currency),NULL, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
       and ps.class = &apos;CB&apos;
       and ps.customer_trx_id = adj.chargeback_customer_trx_id (+)
       and ps.org_id = adj.org_id (+)
       and adj.customer_trx_id = ct.customer_trx_id (+)
       and adj.org_id = ct.org_id (+) 
       and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
      ) a
     group by
      a.customer_id,
      a.customer_site_use_id,
      a.customer_trx_id,
      a.payment_schedule_id,
      a.class,
      a.term_id,
      a.trx_date,
      a.due_date,
      a.trx_number,
      a.amount_due_original,
      a.amount_adjusted,
      a.amount_applied,
      a.amount_credited,
      a.amount_adjusted_pending,
      a.gl_date,
      a.cust_trx_type_id,
      a.org_id,
      a.invoice_currency_code,
      a.exchange_rate
     ) ps,
     ar_cons_inv ci,
     ra_salesreps_all sales,
     jtf_rs_resource_extns_vl jrrev,
     hz_cust_site_uses site,
     hz_cust_acct_sites acct_site,
     hz_party_sites party_site,
     hz_locations loc,
     ra_cust_trx_line_gl_dist gld,
     ar_dispute_history dh,
     ra_terms rt,
     gl_code_combinations c,
     ra_customer_trx rct,
     gl_sets_of_books gsob
    where
        --upper(RTRIM(RPAD(:p_in_summary_option_low,1)) ) = &apos;I&apos;
        ps.customer_site_use_id = site.site_use_id
    and site.cust_acct_site_id = acct_site.cust_acct_site_id
    and acct_site.party_site_id = party_site.party_site_id
    and loc.location_id = party_site.location_id
    and ps.customer_id = hca.cust_account_id
    and hca.party_id = hp.party_id
    and ps.customer_trx_id = gld.customer_trx_id
    and gld.account_class = &apos;REC&apos;
    and gld.latest_rec_flag = &apos;Y&apos;
    and gld.code_combination_id = c.code_combination_id
    and ps.payment_schedule_id  =  dh.payment_schedule_id(+)
    and ps.term_id = rt.term_id (+)
    and :p_in_as_of_date_low  &gt;= nvl(dh.start_date(+), :p_in_as_of_date_low)
    and :p_in_as_of_date_low  &lt;  nvl(dh.end_date(+), :p_in_as_of_date_low + 1)
    and (   dh.dispute_history_id is null
         or dh.dispute_history_id =
              (select max(dh2.dispute_history_id)
               from   ar_dispute_history dh2
               where  dh2.payment_schedule_id = ps.payment_schedule_id
               and    :p_in_as_of_date_low  &gt;= nvl(dh2.start_date(+), :p_in_as_of_date_low)
               and    :p_in_as_of_date_low  &lt;  nvl(dh2.end_date(+), :p_in_as_of_date_low + 1)
              )
        )
    and rct.customer_trx_id = ps.customer_trx_id
    and gsob.set_of_books_id = rct.set_of_books_id
    and ps.cons_inv_id = ci.cons_inv_id(+)
    and nvl(ps.primary_salesrep_id,-3) = sales.salesrep_id
    and sales.org_id = ps.org_id
    and jrrev.resource_id = sales.resource_id
    and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
    and gld.org_id = ps.org_id
    and site.org_id = ps.org_id
    and 2=2
    union all
    select
     substrb(nvl(hp.party_name,:p_short_unid_phrase),1,50) cust_name,
     hca.account_number cust_no,
     nvl(sales.name,jrrev.resource_name),
     initcap(:p_payment_meaning),
     nvl(sales.salesrep_id,-3),
     null term,
     site.site_use_id,
     loc.state cust_state,
     loc.city cust_city,
     (select ftv.territory_short_name from fnd_territories_vl ftv where ftv.territory_code = loc.country) cust_country,
     decode(decode(upper(RTRIM(RPAD(:p_in_format_option_low, 1))),&apos;D&apos;,&apos;D&apos;,NULL),NULL,-1,acct_site.cust_acct_site_id) addr_id,
     nvl(hca.cust_account_id, -999) cust_id,
     hca.party_id,
     ps.payment_schedule_id,
     app.class,
     ps.trx_date,
     ps.due_date,
     decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.amount_due_original * nvl(ps.exchange_rate, 1), ps.amount_due_original) amt_due_original,
     xxen_ar_arxagrw_pkg.Comp_Amt_Due_RemainingFormula
      ( app.class,
        initcap(:p_payment_meaning),
        ps.payment_schedule_id,
        decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, nvl(-SUM(app.acctd_amount), 0), nvl(-SUM(app.amount), 0)), -- amount due remaining
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted
      )  amt_due_remaining,
     ps.trx_number,
     ceil(:p_in_as_of_date_low - ps.trx_date) days_past_trx,
     ceil(:p_in_as_of_date_low - ps.due_date) days_past_due,
     ps.amount_adjusted,
     ps.amount_applied,
     ps.amount_credited,
     ps.gl_date,
     decode(ps.invoice_currency_code, gsob.currency_code, NULL, decode(ps.exchange_rate, NULL, &apos;*&apos;, NULL)),
     nvl(ps.exchange_rate, 1),
     app.code_combination_id,
     app.chart_of_accounts_id,
     ci.cons_billing_number cons_billing_number,
     initcap(:p_payment_meaning),
     ps.invoice_currency_code,
     gsob.currency_code functional_currency,
     gsob.name ledger,
     ps.org_id
    from
     hz_cust_accounts hca,
     hz_parties hp,
     ar_payment_schedules ps,
     ar_cons_inv ci,
     ra_salesreps_all sales,
     jtf_rs_resource_extns_vl jrrev,
     hz_cust_site_uses site,
     hz_cust_acct_sites acct_site,
     hz_party_sites party_site,
     hz_locations loc,
     ar_cash_receipts acr,
     gl_sets_of_books gsob,
     (
      select
       c.code_combination_id,
       c.chart_of_accounts_id,
       ps.payment_schedule_id payment_schedule_id,
       decode(app.applied_payment_schedule_id,   -4,   &apos;CLAIM&apos;,   ps.class) class,
       app.acctd_amount_applied_from acctd_amount,
       app.amount_applied amount,
       app.status status
      from
       ar_receivable_applications app,
       gl_code_combinations c,
       ar_payment_schedules ps
      where
          app.gl_date &lt;= :p_in_as_of_date_low
      --and upper(RTRIM(RPAD(:p_in_summary_option_low,1)))  = &apos;I&apos;
      and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
      and ps.cash_receipt_id = app.cash_receipt_id
      and app.code_combination_id = c.code_combination_id
      and app.status in ( &apos;ACC&apos;, &apos;UNAPP&apos;, &apos;UNID&apos;,&apos;OTHER ACC&apos;)
      and nvl(app.confirmed_flag, &apos;Y&apos;) = &apos;Y&apos;
      and ps.gl_date_closed  &gt; :p_in_as_of_date_low
      and ((app.reversal_gl_date is not null and
            ps.gl_date &lt;= :p_in_as_of_date_low
           ) or
           app.reversal_gl_date is null
          )
      and decode(upper(:p_in_currency), null, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
      and nvl( ps.receipt_confirmed_flag, &apos;Y&apos; ) = &apos;Y&apos;
      and app.org_id = ps.org_id
     ) app
    where
        ps.payment_schedule_id = app.payment_schedule_id
    and ps.customer_id = hca.cust_account_id(+)
    and hca.party_id = hp.party_id(+)
    and ps.customer_site_use_id = site.site_use_id(+)
    and site.cust_acct_site_id = acct_site.cust_acct_site_id(+)
    and acct_site.party_site_id = party_site.party_site_id(+)
    and loc.location_id(+) = party_site.location_id
    and acr.cash_receipt_id = ps.cash_receipt_id
    and gsob.set_of_books_id = acr.set_of_books_id
    and ps.cons_inv_id = ci.cons_inv_id(+)
    and sales.salesrep_id = -3
    and sales.org_id  = ps.org_id
    and jrrev.resource_id = sales.resource_id
    and site.org_id (+) = ps.org_id
    and 2=2
    group by
     hp.party_name,
     hca.account_number,
     site.site_use_id,
     nvl(sales.name,jrrev.resource_name),
     nvl(sales.salesrep_id,-3),
     loc.state,
     loc.city,
     loc.country,
     acct_site.cust_acct_site_id,
     hca.cust_account_id,
     hca.party_id,
     ps.payment_schedule_id,
     ps.trx_date,
     ps.due_date,
     ps.trx_number,
     ps.amount_due_original,
     ps.amount_adjusted,
     ps.amount_applied,
     ps.amount_credited,
     ps.gl_date,
     ps.amount_in_dispute,
     ps.amount_adjusted_pending,
     ps.invoice_currency_code,
     ps.exchange_rate,
     app.class,
     app.code_combination_id,
     app.chart_of_accounts_id,
     decode( app.status, &apos;UNID&apos;, &apos;UNID&apos;,&apos;OTHER ACC&apos;,&apos;OTHER ACC&apos;,&apos;UNAPP&apos;),
     ci.cons_billing_number ,
     initcap(:p_payment_meaning),
     gsob.currency_code,
     gsob.name,
     ps.org_id
    union all
    select
     substrb(nvl(hp.party_name, :p_short_unid_phrase),1,50) cust_name,
     hca.account_number cust_no,
     nvl(sales.name,jrrev.resource_name),
     initcap(:p_risk_meaning),
     nvl(sales.salesrep_id,-3),
     null term,
     site.site_use_id,
     loc.state cust_state,
     loc.city cust_city,
     (select ftv.territory_short_name from fnd_territories_vl ftv where ftv.territory_code = loc.country) cust_country,
     decode(decode(upper(RTRIM(RPAD(:p_in_format_option_low, 1))),&apos;D&apos;,&apos;D&apos;,NULL),NULL,-1,acct_site.cust_acct_site_id) addr_id,
     nvl(hca.cust_account_id, -999) cust_id,
     hca.party_id,
     ps.payment_schedule_id,
     initcap(:p_risk_meaning),
     ps.trx_date,
     ps.due_date,
     decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.amount_due_original * nvl(ps.exchange_rate, 1), ps.amount_due_original) amt_due_original,
     xxen_ar_arxagrw_pkg.comp_amt_due_remainingformula
      ( initcap(:p_risk_meaning),
        initcap(:p_risk_meaning),
        ps.payment_schedule_id,
        decode( nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, crh.acctd_amount, crh.amount), -- amount due remaining
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted
      )  amt_due_remaining,
     ps.trx_number,
     ceil(:p_in_as_of_date_low - ps.trx_date) days_past_trx,
     ceil(:p_in_as_of_date_low - ps.due_date) days_past_due,
     ps.amount_adjusted,
     ps.amount_applied,
     ps.amount_credited,
     crh.gl_date,
     decode(ps.invoice_currency_code, gsob.currency_code, NULL, decode(crh.exchange_rate, NULL, &apos;*&apos;, NULL)),
     nvl(crh.exchange_rate, 1),
     c.code_combination_id,
     c.chart_of_accounts_id,
     ci.cons_billing_number  cons_billing_number,
     initcap(:p_risk_meaning),
     ps.invoice_currency_code,
     gsob.currency_code functional_currency,
     gsob.name ledger,
     ps.org_id
    from
     hz_cust_accounts hca,
     hz_parties hp,
     ar_payment_schedules ps,
     ar_cons_inv ci,
     hz_cust_site_uses site,
     hz_cust_acct_sites acct_site,
     hz_party_sites party_site,
     hz_locations loc,
     ar_cash_receipts cr,
     ar_cash_receipt_history crh,
     gl_code_combinations c,
     ra_salesreps_all sales,
     jtf_rs_resource_extns_vl jrrev,
     gl_sets_of_books gsob
    where
        crh.gl_date &lt;= :p_in_as_of_date_low
    --and upper(RTRIM(RPAD(:p_in_summary_option_low,1)))  = &apos;I&apos;
    and upper(:p_risk_option) != &apos;NONE&apos;
    and ps.customer_id = hca.cust_account_id(+)
    and hca.party_id = hp.party_id(+)
    and ps.cash_receipt_id = cr.cash_receipt_id
    and xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
    and cr.cash_receipt_id = crh.cash_receipt_id
    and crh.account_code_combination_id = c.code_combination_id
    and ps.customer_site_use_id = site.site_use_id(+)
    and site.cust_acct_site_id = acct_site.cust_acct_site_id(+)
    and acct_site.party_site_id = party_site.party_site_id(+)
    and loc.location_id(+) = party_site.location_id
    and decode(upper(:p_in_currency), NULL, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
    and (crh.current_record_flag = &apos;Y&apos; or crh.reversal_gl_date &gt; :p_in_as_of_date_low )
    and crh.status not in (decode(crh.factor_flag,&apos;Y&apos;,&apos;RISK_ELIMINATED&apos;,&apos;N&apos;,&apos;CLEARED&apos;),&apos;REVERSED&apos;)
    and not exists (select &apos;x&apos;
                    from ar_receivable_applications ra
                    where ra.cash_receipt_id = cr.cash_receipt_id
                    and ra.status = &apos;ACTIVITY&apos;
                    and applied_payment_schedule_id = -2)
    and cr.cash_receipt_id not in
                     (select ps.reversed_cash_receipt_id
                      from ar_payment_schedules ps
                      where ps.reversed_cash_receipt_id=cr.cash_receipt_id
                      and ps.class=&apos;DM&apos;
                      and ps.gl_date&lt;= (:p_in_as_of_date_low))
    and gsob.set_of_books_id = cr.set_of_books_id
    and ps.cons_inv_id = ci.cons_inv_id(+)
    and sales.salesrep_id = -3
    and sales.org_id = ps.org_id
    and jrrev.resource_id = sales.resource_id
    and crh.org_id = ps.org_id
    and cr.org_id = ps.org_id
    and site.org_id (+) = ps.org_id
    and 2=2
    union all
    select
     substrb(hp.party_name,1,50) cust_name,
     hca.account_number cust_no,
     nvl(sales.name,jrrev.resource_name) sort_field1,
     arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id) sort_field2,
     nvl(sales.salesrep_id, -3)  salesrep_id,
     rt.name term,
     site.site_use_id contact_site_id,
     loc.state cust_state,
     loc.city cust_city,
     (select ftv.territory_short_name from fnd_territories_vl ftv where ftv.territory_code = loc.country) cust_country,
     decode(decode(upper(rtrim(rpad(:p_in_format_option_low, 1))),&apos;D&apos;,&apos;D&apos;,null),null,-1,acct_site.cust_acct_site_id) addr_id,
     nvl(hca.cust_account_id,-999) cust_id,
     hca.party_id,
     ps.payment_schedule_id payment_sched_id,
     ps.class class,
     ps.trx_date,
     ps.due_date,
     decode(nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.amount_due_original * nvl(ps.exchange_rate, 1), ps.amount_due_original) amt_due_original,
     xxen_ar_arxagrw_pkg.comp_amt_due_remainingformula
      ( ps.class,
        arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id),
        ps.payment_schedule_id,
        decode( nvl2(:p_in_currency,&apos;N&apos;,&apos;Y&apos;), &apos;Y&apos;, ps.acctd_amount_due_remaining,ps.amount_due_remaining), -- amount due remaining
        ps.amount_applied,
        ps.amount_credited,
        ps.amount_adjusted
      )  amt_due_remaining,
     ps.trx_number invnum,
     ceil(:p_in_as_of_date_low - ps.trx_date) days_past_trx,
     ceil(:p_in_as_of_date_low - ps.due_date) days_past_due,
     ps.amount_adjusted amount_adjusted,
     ps.amount_applied amount_applied,
     ps.amount_credited amount_credited,
     ps.gl_date gl_date,
     decode(ps.invoice_currency_code, gsob.currency_code, NULL, decode(ps.exchange_rate, NULL, &apos;*&apos;, NULL)) data_converted,
     nvl(ps.exchange_rate, 1) ps_exchange_rate,
     c.code_combination_id,
     c.chart_of_accounts_id,
     ci.cons_billing_number cons_billing_number,
     arpt_sql_func_util.get_org_trx_type_details(ps.cust_trx_type_id,ps.org_id) invoice_type,
     ps.invoice_currency_code,
     gsob.currency_code functional_currency,
     gsob.name ledger,
     ps.org_id
    from
     hz_cust_accounts hca,
     hz_parties hp,
     ar_payment_schedules ps,
     ar_cons_inv ci,
     ra_salesreps_all sales,
     jtf_rs_resource_extns_vl jrrev,
     hz_cust_site_uses site,
     hz_cust_acct_sites acct_site,
     hz_party_sites party_site,
     hz_locations loc,
     ar_transaction_history th,
     ar_distributions   dist,
     gl_code_combinations c,
     ra_customer_trx ct,
     ra_terms rt,
     gl_sets_of_books gsob
    where
        ps.gl_date &lt;= :p_in_as_of_date_low
    --and   upper(RTRIM(RPAD(:p_in_summary_option_low,1)) ) = &apos;I&apos;
    and    ps.customer_site_use_id = site.site_use_id
    and    xxen_ar_arxagrw_pkg.include_org_id(ps.org_id) = &apos;Y&apos;
    and    site.cust_acct_site_id = acct_site.cust_acct_site_id
    and   acct_site.party_site_id  = party_site.party_site_id
    and   loc.location_id = party_site.location_id
    and   ps.gl_date_closed  &gt; :p_in_as_of_date_low
    and   ps.class = &apos;BR&apos;
    and   decode(upper(:p_in_currency),NULL, ps.invoice_currency_code, upper(:p_in_currency)) = ps.invoice_currency_code
    and   hca.party_id = hp.party_id
    and   th.transaction_history_id =
                  (select max(transaction_history_id)
                   from   ar_transaction_history th2,
                          ar_distributions  dist2
                   where  th2.transaction_history_id = dist2.source_id
                   and    dist2.source_table = &apos;TH&apos;
                   and    th2.gl_date &lt;= :p_in_as_of_date_low
                   and    dist2.amount_dr is not null
                   and    th2.customer_trx_id = ps.customer_trx_id)
    and   th.transaction_history_id = dist.source_id
    and   dist.source_table = &apos;TH&apos;
    and   dist.amount_dr is not null
    and   dist.source_table_secondary is NULL
    and   dist.code_combination_id = c.code_combination_id
    and   gsob.set_of_books_id = ct.set_of_books_id
    and ps.cons_inv_id = ci.cons_inv_id(+)
    and ps.customer_id = hca.cust_account_id
    and ps.customer_trx_id = ct.customer_trx_id
    and ct.customer_trx_id = th.customer_trx_id
    and nvl(ct.primary_salesrep_id,-3) = sales.salesrep_id
    and sales.org_id = ct.org_id
    and jrrev.resource_id = sales.resource_id
    and ct.org_id = ps.org_id
    and site.org_id = ps.org_id
    and ps.term_id = rt.term_id (+)
    and :p_br_enabled = &apos;Y&apos;
    and 2=2
) x,
hz_customer_profiles hcpa,
hz_customer_profiles hcps
where
3=3 and
mo_global.check_access(x.org_id) = &apos;Y&apos; and
hcpa.cust_account_id (+) = x.cust_id and
hcpa.site_use_id (+) is null and
hcps.cust_account_id (+) = x.cust_id and
hcps.site_use_id (+) = x.site_use_id</SQL_TEXT>
  <ENABLED>Y</ENABLED>
  <NUMBER_FORMAT>#,##0.00;[Red]-#,##0.00</NUMBER_FORMAT>
  <COPIED_FROM_GUID>B057D82F30B17A2DE0530100007FD563</COPIED_FROM_GUID>
  <DB_PACKAGE>XXEN_AR_ARXAGRW_PKG</DB_PACKAGE>
  <REPORT_TRANSLATIONS>
   <REPORT_TRANSLATIONS_ROW>
    <LANGUAGE>US</LANGUAGE>
    <REPORT_NAME>AR Aging - DIagnostic Report</REPORT_NAME>
   </REPORT_TRANSLATIONS_ROW>
  </REPORT_TRANSLATIONS>
  <CATEGORY_ASSIGNMENTS>
  </CATEGORY_ASSIGNMENTS>
  <ANCHORS>
   <ANCHORS_ROW>
    <ANCHOR>2=2</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>3=3</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:g_bucket_category</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:lp_org_id_in_list</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_br_enabled</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_coaid</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_conc_request_id</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_credit_option</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_credit_option_dsp</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_amt_due_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_amt_due_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_as_of_date_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_bal_segment_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_bal_segment_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_bucket_type_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_collector_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_collector_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_currency</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_customer_name_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_customer_name_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_customer_num_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_customer_num_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_format_option_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_invoice_type_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_invoice_type_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_salesrep_name_high</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_salesrep_name_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_sortoption</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_in_summary_option_low</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_min_precision</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_payment_meaning</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_rep_type</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_reporting_entity_id</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_reporting_entity_name</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_reporting_level</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_reporting_level_name</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_risk_meaning</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_risk_option</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_short_unid_phrase</ANCHOR>
   </ANCHORS_ROW>
  </ANCHORS>
  <PARAMETERS>
   <PARAMETERS_ROW>
    <SORT_ORDER>1</SORT_ORDER>
    <DISPLAY_SEQUENCE>-90</DISPLAY_SEQUENCE>
    <ANCHOR>:p_coaid</ANCHOR>
    <PARAMETER_TYPE_DSP>Number</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select
gsob.chart_of_accounts_id
from
gl_sets_of_books gsob,
ar_system_parameters asp,
hr_all_organization_units haou
where
gsob.set_of_books_id=asp.set_of_books_id and
asp.org_id=haou.organization_id and
(
:$flex$.reporting_context is null or
:$flex$.reporting_level=&apos;1000&apos; and xxen_util.contains(:$flex$.reporting_context,gsob.name)=&apos;Y&apos; or
:$flex$.reporting_level=&apos;3000&apos; and xxen_util.contains(:$flex$.reporting_context,haou.name)=&apos;Y&apos;
) and
rownum=1</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Chart of Accounts Id</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>2</SORT_ORDER>
    <DISPLAY_SEQUENCE>-80</DISPLAY_SEQUENCE>
    <ANCHOR>:p_rep_type</ANCHOR>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select lookup_code from ar_lookups where lookup_type = &apos;AR_AGING_TYPE&apos; and lookup_code=&apos;ARXAGR&apos;</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Report type</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>3</SORT_ORDER>
    <DISPLAY_SEQUENCE>-70</DISPLAY_SEQUENCE>
    <ANCHOR>:p_in_sortoption</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_ARXAGR_SORT_BY</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
lookup_code id,
meaning value,
null description
from
ar_lookups
where lookup_type=&apos;SORT_BY_ARXAGR&apos;
order by value,description</LOV_QUERY_DSP>
    <DEFAULT_VALUE>Salesperson</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Order By</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>4</SORT_ORDER>
    <DISPLAY_SEQUENCE>-60</DISPLAY_SEQUENCE>
    <ANCHOR>:p_payment_meaning</ANCHOR>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select rtrim(rpad(ARPT_SQL_FUNC_UTIL.get_lookup_meaning(&apos;INV/CM/ADJ&apos;,&apos;PMT&apos;),20))
from dual</DEFAULT_VALUE>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Payment Meaning</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>5</SORT_ORDER>
    <DISPLAY_SEQUENCE>-50</DISPLAY_SEQUENCE>
    <ANCHOR>:p_risk_meaning</ANCHOR>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select rtrim(rpad(ARPT_SQL_FUNC_UTIL.get_lookup_meaning(&apos;MISC_PHRASES&apos;,&apos;RISK&apos;),20))
from dual</DEFAULT_VALUE>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Risk Meaning</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>6</SORT_ORDER>
    <DISPLAY_SEQUENCE>-40</DISPLAY_SEQUENCE>
    <ANCHOR>:p_short_unid_phrase</ANCHOR>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select rtrim(rpad(ARPT_SQL_FUNC_UTIL.get_lookup_meaning(&apos;MISC_PHRASES&apos;,&apos;UNIDENTIFIED_PAYMENT&apos;),18))
from dual</DEFAULT_VALUE>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Unidentified Meaning</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>7</SORT_ORDER>
    <DISPLAY_SEQUENCE>-30</DISPLAY_SEQUENCE>
    <ANCHOR>:p_in_format_option_low</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_REPORT_FORMAT</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
l.lookup_code id,
l.meaning value,
null description
from
ar_lookups l
where l.lookup_type=&apos;REPORT_FORMAT&apos;
and l.enabled_flag=&apos;Y&apos;
and sysdate between nvl(l.start_date_active,sysdate)
and nvl(l.end_date_active,sysdate)
order by l.meaning,l.lookup_code
</LOV_QUERY_DSP>
    <DEFAULT_VALUE>D</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Report Format</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>8</SORT_ORDER>
    <DISPLAY_SEQUENCE>-20</DISPLAY_SEQUENCE>
    <ANCHOR>&amp;lp_bal_seg_p</ANCHOR>
    <SQL_TEXT>&lt;parameter_value&gt;</SQL_TEXT>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select nvl(
(
select fifsv.form_left_prompt
  from   fnd_segment_attribute_values fsav
     ,   fnd_id_flex_segments_vl      fifsv
  where  fsav.application_id    = 101
  and    fsav.id_flex_code      = &apos;GL#&apos;
  and    fsav.segment_attribute_type = &apos;GL_BALANCING&apos;
  and    fsav.id_flex_num       =
          (
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            where :$flex$.reporting_level  = &apos;1000&apos;
            and   :$flex$.reporting_context is not null
            and   xxen_util.contains(:$flex$.reporting_context,gsob.name) = &apos;Y&apos;
            union
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            ,    ar_system_parameters aps
            ,    hr_all_organization_units haou
            where gsob.set_of_books_id = aps.set_of_books_id
            and   haou.organization_id = aps.set_of_books_id
            and   :$flex$.reporting_level  = &apos;3000&apos;
            and   :$flex$.reporting_context is not null
            and   xxen_util.contains(:$flex$.reporting_context,haou.name) = &apos;Y&apos;
            union
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            ,    ar_system_parameters aps
            where gsob.set_of_books_id = aps.set_of_books_id
            and  :$flex$.reporting_context is null
          )
  and    fsav.attribute_value   = &apos;Y&apos;
  and    fifsv.application_id   = fsav.application_id
  and    fifsv.id_flex_code     = fsav.id_flex_code
  and    fifsv.id_flex_num      = fsav.id_flex_num
  and    fifsv.application_column_name = fsav.application_column_name
),
&apos;Balancing Segment&apos;)
from dual</DEFAULT_VALUE>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Balancing Segment Label</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>9</SORT_ORDER>
    <DISPLAY_SEQUENCE>-10</DISPLAY_SEQUENCE>
    <ANCHOR>&amp;lp_acc_seg_p</ANCHOR>
    <SQL_TEXT>&lt;parameter_value&gt;</SQL_TEXT>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>select nvl(
(
select fifsv.form_left_prompt
  from   fnd_segment_attribute_values fsav
     ,   fnd_id_flex_segments_vl      fifsv
  where  fsav.application_id    = 101
  and    fsav.id_flex_code      = &apos;GL#&apos;
  and    fsav.segment_attribute_type = &apos;GL_ACCOUNT&apos;
  and    fsav.id_flex_num       =
          (
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            where :$flex$.reporting_level  = &apos;1000&apos;
            and   :$flex$.reporting_context is not null
            and   xxen_util.contains(:$flex$.reporting_context,gsob.name) = &apos;Y&apos;
            union
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            ,    ar_system_parameters aps
            ,    hr_all_organization_units haou
            where gsob.set_of_books_id = aps.set_of_books_id
            and   haou.organization_id = aps.set_of_books_id
            and   :$flex$.reporting_level  = &apos;3000&apos;
            and   :$flex$.reporting_context is not null
            and   xxen_util.contains(:$flex$.reporting_context,haou.name) = &apos;Y&apos;
            union
            select distinct case when count(distinct gsob.chart_of_accounts_id) over () = 1 then gsob.chart_of_accounts_id else null end
            from gl_sets_of_books gsob
            ,    ar_system_parameters aps
            where gsob.set_of_books_id = aps.set_of_books_id
            and  :$flex$.reporting_context is null
          )
  and    fsav.attribute_value   = &apos;Y&apos;
  and    fifsv.application_id   = fsav.application_id
  and    fifsv.id_flex_code     = fsav.id_flex_code
  and    fifsv.id_flex_num      = fsav.id_flex_num
  and    fifsv.application_column_name = fsav.application_column_name
),
&apos;Account&apos;)
from dual</DEFAULT_VALUE>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Account Segment Label</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>10</SORT_ORDER>
    <DISPLAY_SEQUENCE>40</DISPLAY_SEQUENCE>
    <ANCHOR>:p_in_as_of_date_low</ANCHOR>
    <PARAMETER_TYPE_DSP>Date</PARAMETER_TYPE_DSP>
    <DEFAULT_VALUE>sysdate</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>As Of Date</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>11</SORT_ORDER>
    <DISPLAY_SEQUENCE>70</DISPLAY_SEQUENCE>
    <ANCHOR>:p_credit_option_dsp</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV custom</PARAMETER_TYPE_DSP>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
l.meaning value,
l.description description
from
ar_lookups l
where l.lookup_type=&apos;OPEN_CREDITS&apos;
and l.enabled_flag=&apos;Y&apos;
and sysdate between nvl(l.start_date_active,sysdate)
and nvl(l.end_date_active,sysdate)
order by l.meaning</LOV_QUERY_DSP>
    <DEFAULT_VALUE>select meaning
from ar_lookups
where lookup_type = &apos;OPEN_CREDITS&apos;
and lookup_code = &apos;SUMMARY&apos;</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Show On Account</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>12</SORT_ORDER>
    <DISPLAY_SEQUENCE>80</DISPLAY_SEQUENCE>
    <ANCHOR>:p_risk_option</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_SHOW_RISK</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
l.lookup_code id,
l.meaning value,
null description
from
ar_lookups l
where l.lookup_type=&apos;SHOW_RISK&apos;
order by l.meaning,l.lookup_code</LOV_QUERY_DSP>
    <DEFAULT_VALUE>NONE</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Show Receipts At Risk</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>13</SORT_ORDER>
    <DISPLAY_SEQUENCE>120</DISPLAY_SEQUENCE>
    <ANCHOR>2=2</ANCHOR>
    <SQL_TEXT>hp.party_name = :p_in_customer_name</SQL_TEXT>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_CUSTOMER_NAME_WIDE</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <FILTER_BEFORE_DISPLAY_DSP>Y</FILTER_BEFORE_DISPLAY_DSP>
    <LOV_QUERY_DSP>select
party.party_name id,
party.party_name value,
null description
from
hz_cust_accounts cu,hz_parties party
where cu.party_id=party.party_id
and exists (select cas.cust_account_id from hz_cust_acct_sites cas
where cas.cust_account_id=cu.cust_account_id)
order by value,description</LOV_QUERY_DSP>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Customer Name</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>14</SORT_ORDER>
    <DISPLAY_SEQUENCE>150</DISPLAY_SEQUENCE>
    <ANCHOR>2=2</ANCHOR>
    <SQL_TEXT>hca.account_number = :p_in_customer_num</SQL_TEXT>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_CUSTOMER_NUMBER</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <FILTER_BEFORE_DISPLAY_DSP>Y</FILTER_BEFORE_DISPLAY_DSP>
    <LOV_QUERY_DSP>select
cust.account_number id,
cust.account_number value,
null description
from
hz_cust_accounts cust,hz_parties party
where cust.party_id=party.party_id
order by cust.account_number</LOV_QUERY_DSP>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Customer Number</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>15</SORT_ORDER>
    <DISPLAY_SEQUENCE>180</DISPLAY_SEQUENCE>
    <ANCHOR>:p_in_currency</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>AR_SRS_CURRENCY</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
currency_code id,
currency_code value,
name description
from
fnd_currencies_vl
where currency_flag=&apos;Y&apos;
and enabled_flag in (&apos;Y&apos;,&apos;N&apos;)
order by currency_code</LOV_QUERY_DSP>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Entered Currency</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>16</SORT_ORDER>
    <DISPLAY_SEQUENCE>190</DISPLAY_SEQUENCE>
    <ANCHOR>3=3</ANCHOR>
    <SQL_TEXT>x.invnum=:p_trx_number</SQL_TEXT>
    <PARAMETER_TYPE_DSP>Char</PARAMETER_TYPE_DSP>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Transaction Number</PARAMETER_NAME>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
  </PARAMETERS>
  <PARAMETER_DEPENDENCIES>
  </PARAMETER_DEPENDENCIES>
  <TEMPLATES>
  </TEMPLATES>
  <DEFAULT_TEMPLATES>
  </DEFAULT_TEMPLATES>
  <UPLOAD_COLUMNS>
  </UPLOAD_COLUMNS>
  <UPLOAD_PARAMETERS>
  </UPLOAD_PARAMETERS>
  <UPLOAD_SQLS>
  </UPLOAD_SQLS>
  <UPLOAD_DEPENDENCIES>
  </UPLOAD_DEPENDENCIES>
 </REPORTS_ROW>
</REPORTS>
</ROOT>
