<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: KDM DIOT V2 -->
 <REPORTS_ROW>
  <GUID>46140955F34CA748E0634C05890A38B5</GUID>
  <SQL_TEXT>select
t.id,
t.tipoprov,
t.tipooperac,
t.rfc,
t.numidfiscal,
t.invoice_id,
t.party_id,
t.party_site_id,
t.vendor_name,
t.country,
t.nationality,
t.invoice_org,
t.invoice_type,
t.amount_paid,
t.item_amount,
t.import_tax,
t.currency_code,
t.exchange_rate,
t.usehdrdff,
--
-- IVALOC
--
(select
 ltrim(to_char(round(
   decode(t.currency_code,&apos;USD&apos;,
          xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_16%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc, null)) * t.exchange_rate,
          xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_16%AP_VAT&apos;, decode(t.usehdrdff, &apos;N&apos;,t.rfc, null))
         ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number (+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl(ail.attribute13, ail.tax_classification_code) = &apos;LSRM_16%AP_VAT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode (t.usehdrdff,&apos;N&apos;,ail.attribute10, 0) = decode (t.usehdrdff,&apos;N&apos;,nvl(t.rfc,ail.attribute10), 0)
 group by
 ail.invoice_id,
 ail.prepay_invoice_id,
 ail.org_id
 union
 select
 t.amount_paid
 from
 ar_misc_cash_distributions_all mcd,
 gl_code_combinations gcc
 where
 mcd.code_combination_id = gcc.code_combination_id and
 mcd.org_id = :p_org_id and
 mcd.cash_receipt_id = t.invoice_id and
 t.import_tax = &apos;NO&apos;
 group by
 mcd.cash_receipt_id
) &quot;VALACTPAGTAS15O16IVA&quot;,
(select
 ltrim(to_char(round(
   decode(t.currency_code, &apos;USD&apos;,
          (xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_16%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc, null)) + sum(zl.taxable_amt)) * t.exchange_rate,
          (xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_16%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc,null)) + sum(zl.taxable_amt))
         ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number (+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl(ail.attribute13, ail.tax_classification_code) = &apos;LSRM_16%AP_VAT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode (t.usehdrdff,&apos;N&apos;,ail.attribute10, 0) = decode (t.usehdrdff,&apos;N&apos;,nvl(t.rfc,ail.attribute10), 0)
 group by
 ail.invoice_id,
 ail.prepay_invoice_id,
 ail.org_id
 union
 select
 ltrim(to_char(round(sum(abs(mcd.amount)),0) , &apos;99999999999990&apos;))
 from
 ar_misc_cash_distributions_all mcd,
 gl_code_combinations gcc
 where
 mcd.code_combination_id = gcc.code_combination_id and
 mcd.org_id = :p_org_id and
 mcd.cash_receipt_id = t.invoice_id and
 t.import_tax = &apos;NO&apos;
 group by
 mcd.cash_receipt_id
) &quot;IVALOC_TOTAL&quot;,
--
-- &apos;IVA8&apos;
--
(select
 ltrim(to_char(round(
   decode(t.currency_code,&apos;USD&apos;,
          xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_8%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc,null)) * t.exchange_rate,
          xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_8%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc,null))
         ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number (+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl(ail.attribute13, ail.tax_classification_code) = &apos;LSRM_8%AP_VAT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode (t.usehdrdff, &apos;N&apos;, ail.attribute10, 0) = decode (t.usehdrdff, &apos;N&apos;, nvl(t.rfc, ail.attribute10), 0)
 group by
 ail.invoice_id,
 ail.prepay_invoice_id,
 ail.org_id
) &quot;VALACTPAGTAS8IVA&quot;,
(select
 ltrim(to_char(round(
   decode(t.currency_code,&apos;USD&apos;,
          (xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_8%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc,null)) + sum(zl.taxable_amt)) * t.exchange_rate,
          (xxap_invoicerfc_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_8%AP_VAT&apos;, decode(t.usehdrdff,&apos;N&apos;,t.rfc, null)) + sum(zl.taxable_amt))
         ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number (+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl(ail.attribute13, ail.tax_classification_code) = &apos;LSRM_8%AP_VAT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode (t.usehdrdff, &apos;N&apos;, ail.attribute10, 0) = decode (t.usehdrdff, &apos;N&apos;, nvl(t.rfc, ail.attribute10), 0)
 group by
 ail.invoice_id,
 ail.prepay_invoice_id,
 ail.org_id
) &quot;IVA8_TOTAL&quot;,
--
-- IVAIMP
--
(select
 ltrim(to_char(round(
   decode (t.currency_code,&apos;USD&apos;,
           xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_IMPORT_TAX&apos;) * t.exchange_rate,
           xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_IMPORT_TAX&apos;)
          ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 ail.line_type_lookup_code = &apos;TAX&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 ail.invoice_id = zl.trx_id and
 ail.summary_tax_line_id = zl.summary_tax_line_id and
 t.import_tax = &apos;YES&apos; and
 exists
  (select
   1
   from
   ap_invoice_lines_all ail2
   where
   ail2.invoice_id = ail.invoice_id and
   ail2.line_number = zl.trx_line_number and
   nvl(ail2.attribute13, ail.tax_rate_code) = &apos;LSRM_IMPORT_TAX&apos;
  )
) &quot;MONIVAPAGNOACRIMPTAS15O16&quot;,
(select
 ltrim(to_char(round(decode(t.currency_code,&apos;USD&apos;,zl.taxable_amt * t.exchange_rate, zl.taxable_amt), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 ail.line_type_lookup_code = &apos;TAX&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 ail.invoice_id = zl.trx_id and
 ail.summary_tax_line_id = zl.summary_tax_line_id and
 t.import_tax = &apos;YES&apos; and
 exists
  (select
   1
   from
   ap_invoice_lines_all ail2
   where
   ail2.invoice_id = ail.invoice_id and
   ail2.line_number = zl.trx_line_number and
   nvl(ail2.attribute13, ail.tax_rate_code) = &apos;LSRM_IMPORT_TAX&apos;
  )
) &quot;VALACTPAGIMPBYSTAS15O16IVA&quot;,
(select
 ltrim(to_char(round(
   decode(t.currency_code,&apos;USD&apos;,
          (xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_IMPORT_TAX&apos;) + zl.taxable_amt) * t.exchange_rate,
          (xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, &apos;LSRM_IMPORT_TAX&apos;) + zl.taxable_amt)
         ),0),&apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 ail.line_type_lookup_code = &apos;TAX&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 ail.invoice_id = zl.trx_id and
 ail.summary_tax_line_id = zl.summary_tax_line_id and
 t.import_tax = &apos;YES&apos; and
 exists
  (select
   1
   from
   ap_invoice_lines_all ail2
   where
   ail2.invoice_id = ail.invoice_id and
   ail2.line_number = zl.trx_line_number and
   nvl(ail2.attribute13, ail.tax_rate_code) = &apos;LSRM_IMPORT_TAX&apos;
  )
) &quot;IVAIMP_TOTAL&quot;,
--
-- IVAOTR
--
(select
 ltrim(to_char(round(abs(decode (t.currency_code,&apos;USD&apos;,sum(nvl(ail.attribute14, zl.taxable_amt)) * t.exchange_rate, sum(nvl(ail.attribute14, zl.taxable_amt)))), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number(+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl (ail.attribute13, ail.tax_classification_code) = &apos;LSRM_EXEMPT_VAT&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode(t.usehdrdff,&apos;N&apos;,ail.attribute10, 0) = decode(t.usehdrdff,&apos;N&apos;,t.rfc, 0)
) &quot;ValActPagNoIVA&quot;,
(select
 ltrim(to_char(round(abs(decode(t.currency_code,&apos;USD&apos;,sum(ail.amount) * t.exchange_rate, sum(ail.amount))), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail
 where
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 ail.line_type_lookup_code = &apos;AWT&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 decode(t.usehdrdff,&apos;N&apos;,ail.attribute10,0) = decode(t.usehdrdff,&apos;N&apos;,t.rfc,0) and
 t.import_tax = &apos;NO&apos;
) &quot;IVARetCont&quot;,
(select
 ltrim(to_char(round(abs(decode(t.currency_code,&apos;USD&apos;,sum(ail.amount) * t.exchange_rate,sum(ail.amount))), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail
 where
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 t.import_tax = &apos;NO&apos; and
 ail.line_type_lookup_code = &apos;AWT&apos; and
 nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 decode(t.usehdrdff,&apos;N&apos;,ail.attribute10, 0) = decode(t.usehdrdff,&apos;N&apos;,t.rfc, 0) and
 exists
  (select
   1
   from
   gl_code_combinations gcc,
   fnd_lookup_values fl
   where
   gcc.segment4 = fl.meaning and
   fl.lookup_type = &apos;EMR_WT_ACCTS_LSRM&apos; and
   fl.language = userenv (&apos;LANG&apos;) and
   fl.enabled_flag = &apos;Y&apos; and
   fl.description like &apos;IVA%&apos; and
   gcc.code_combination_id = ail.default_dist_ccid
  )
) &quot;IVARet&quot;,
(select
 ltrim(to_char(round(abs(decode(t.currency_code,&apos;USD&apos;,sum(ail.amount) * t.exchange_rate,sum(ail.amount))), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail
 where
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 t.import_tax = &apos;NO&apos; and
 ail.line_type_lookup_code = &apos;AWT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 --Check line Level DFF - Send to SAT DFF
 nvl(ail.attribute5, &apos;Y&apos;) = &apos;Y&apos; and
 decode(t.usehdrdff,&apos;N&apos;,ail.attribute10,0) = decode(t.usehdrdff,&apos;N&apos;,t.rfc,0) and
 exists
  (select
   1
   from
   gl_code_combinations gcc,
   fnd_lookup_values fl
   where
   gcc.segment4 = fl.meaning and
   fl.lookup_type = &apos;EMR_WT_ACCTS_LSRM&apos; and
   fl.language = userenv (&apos;LANG&apos;) and
   fl.enabled_flag = &apos;Y&apos; and
   fl.description like &apos;ISR%&apos; and
   gcc.code_combination_id = ail.default_dist_ccid
  )
) &quot;ISRRet&quot;,
(select
 ltrim(to_char(round(abs(decode(t.currency_code,&apos;USD&apos;,sum(nvl(ail.attribute14, zl.taxable_amt)) * t.exchange_rate, sum(nvl(ail.attribute14, zl.taxable_amt)))), 0), &apos;99999999999990&apos;))
 from
 ap_invoice_lines_all ail,
 zx_lines zl
 where
 ail.invoice_id = zl.trx_id(+) and
 ail.line_number = zl.trx_line_number(+) and
 ail.org_id = zl.internal_organization_id and
 ail.org_id = zl.internal_organization_id(+) and
 zl.entity_code(+) = &apos;AP_INVOICES&apos; and
 ail.org_id = :p_org_id and
 ail.invoice_id = t.invoice_id and
 nvl(ail.attribute13, ail.tax_classification_code) = &apos;LSRM_0%AP_VAT&apos; and
 nvl(ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
 nvl(ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
 t.import_tax = &apos;NO&apos; and
 decode(t.usehdrdff,&apos;N&apos;,ail.attribute10,0) = decode(t.usehdrdff,&apos;N&apos;,t.rfc,0)
) &quot;ValActPagTas0IVA&quot;
--
--
from
--
--
(
select distinct
&apos;CAB&apos; id,
&apos;04&apos; tipoprov,
nvl(pvs.attribute12,&apos;85&apos;) tipooperac,
upper(decode(
 nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;,
 ail.attribute10,
 (select
  nvl(trim(rep_registration_number),&apos;XAXX010101000&apos;)
  from
  zx_party_tax_profile
  where
  party_id = pv.party_id and
  party_type_code = &apos;THIRD_PARTY&apos;
 )
)) rfc,
aia.invoice_num numidfiscal,
aia.invoice_id,
aia.party_id,
pvs.party_site_id,
upper(decode(nvl(aia.attribute10,&apos;Y&apos;), &apos;N&apos;, ail.attribute7, pv.vendor_name)) vendor_name,
upper(decode(nvl(aia.attribute10,&apos;Y&apos;), &apos;N&apos;, ail.attribute8, pvs.country)) country,
upper(decode(nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;, ail.attribute9, (select territory_short_name from fnd_territories_vl where territory_code = pvs.country))) nationality,
aia.org_id invoice_org,
aia.invoice_type_lookup_code invoice_type,
decode(nvl(aia.attribute10,&apos;Y&apos;), &apos;N&apos;, ltrim (to_char(round(decode( aia.invoice_currency_code, &apos;USD&apos;, xxap_rfc_amtpaid(aia.invoice_id, ail.org_id, ail.attribute10) * ip.exchange_rate, xxap_rfc_amtpaid(aia.invoice_id, ail.org_id, ail.attribute10)), 0), &apos;99999999999990&apos;)), ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, aia.amount_paid * ip.exchange_rate, aia.amount_paid), 0), &apos;99999999999990&apos;))) amount_paid,
decode(nvl(aia.attribute10,&apos;Y&apos;), &apos;N&apos;, ltrim (to_char(round(decode( aia.invoice_currency_code, &apos;USD&apos;, xxap_invbyrfc_item_price(aia.invoice_id, ail.org_id, null, ail.attribute10) * ip.exchange_rate, xxap_invbyrfc_item_price(aia.invoice_id, ail.org_id, null, ail.attribute10)), 0), &apos;99999999999990&apos;)), ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, xxap_invoice_item_price( aia.invoice_id, ail.prepay_invoice_id, ail.org_id) * ip.exchange_rate, xxap_invoice_item_price(aia.invoice_id, ail.prepay_invoice_id, ail.org_id)), 0), &apos;99999999999990&apos;))) item_amount,
&apos;NO&apos; import_tax,
aia.invoice_currency_code currency_code,
ip.exchange_rate,
nvl (aia.attribute10, &apos;Y&apos;) usehdrdff,
&apos;I&apos; src
from
ap_invoices_all aia,
ap_invoice_lines_all ail,
ap_invoice_distributions_all aid,
xla_transaction_entities ent,
xla_events xe,
xla_ae_headers aeh,
xla_ae_lines ael,
xla_distribution_links dl,
gl_import_references gir,
gl_je_lines jel,
gl_je_headers jeh,
gl_je_batches glb,
gl_code_combinations glc,
ap_suppliers pv,
ap_supplier_sites_all pvs,
ap_invoice_payments_all ip,
ap_checks_all ac
where
ail.invoice_id = aia.invoice_id and
aia.org_id = ail.org_id and
aia.invoice_type_lookup_code != &apos;PREPAYMENT&apos; and
--Check Header Level DFF - Send to SAT DFF
nvl (aia.attribute13, &apos;Y&apos;) = &apos;Y&apos; and
--Check line Level DFF - Send to SAT DFF
nvl (ail.attribute5, &apos;Y&apos;) = &apos;Y&apos; and
aid.invoice_id = aia.invoice_id and
aid.invoice_id = ail.invoice_id and
aid.invoice_line_number = ail.line_number and
dl.source_distribution_id_num_1 = aid.invoice_distribution_id and
dl.applied_to_source_id_num_1 = ail.invoice_id and
dl.source_distribution_type = &apos;AP_INV_DIST&apos; and
ent.source_id_int_1 = aia.invoice_id and
ent.legal_entity_id = aia.legal_entity_id and
ent.security_id_int_1 = aia.org_id and
ent.entity_code = &apos;AP_INVOICES&apos; and
ent.application_id = xe.application_id and
ent.entity_id = xe.entity_id and
aeh.application_id = ent.application_id and
aeh.entity_id = ent.entity_id and
aeh.ledger_id = ent.ledger_id and
aeh.accounting_entry_status_code = &apos;F&apos; and
aeh.gl_transfer_status_code = &apos;Y&apos; and
ael.ae_header_id = aeh.ae_header_id and
ael.application_id = aeh.application_id and
aeh.ae_header_id = dl.ae_header_id and
ael.ae_line_num = dl.ae_line_num and
xe.event_id = dl.event_id and
gir.gl_sl_link_id = ael.gl_sl_link_id and
gir.gl_sl_link_table = ael.gl_sl_link_table and
gir.reference_7 = ael.ae_header_id and
jel.je_header_id = gir.je_header_id and
jel.je_line_num = gir.je_line_num and
jel.code_combination_id = glc.code_combination_id and
aia.vendor_id = pv.vendor_id and
aia.vendor_site_id = pvs.vendor_site_id and
pvs.vendor_id = pv.vendor_id and
jeh.status = &apos;P&apos; and
jeh.actual_flag = &apos;A&apos; and
jeh.je_header_id = jel.je_header_id and
jeh.period_name = jel.period_name and
glb.je_batch_id = jeh.je_batch_id and
glb.je_batch_id = gir.je_batch_id and
pvs.org_id = aid.org_id and
pvs.org_id = aia.org_id and
ip.invoice_id = ail.invoice_id and
ip.check_id = ac.check_id and
nvl (ip.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (ip.posted_flag, &apos;N&apos;) = &apos;Y&apos; and
---- PARAMETERS ----
ip.period_name = :p_period_name and
jeh.ledger_id = :p_ledger_id and
glc.segment1 = :p_business_unit and
aia.org_id = :p_org_id and
---- PARAMETERS ----
ail.line_type_lookup_code = &apos;ITEM&apos; and
nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
--if line was incorrectly classified and the line has a tax code of mport tax -- do not include
nvl (ail.attribute13, &apos;1&apos;) != &apos;LSRM_IMPORT_TAX&apos; and
nvl (aid.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (aid.cancellation_flag, &apos;N&apos;) = &apos;N&apos; and
exists
 (select
  1
  from
  ap_invoice_lines_all aill
  where
  aill.invoice_id = ail.invoice_id and
  aill.line_type_lookup_code in (&apos;TAX&apos;, &apos;AWT&apos;) and
  aill.tax_rate_code != &apos;LSRM_IMPORT_TAX&apos;
 )
union
--invoices for prepayments
select distinct
&apos;CAB&apos; id,
&apos;04&apos; tipoprov,
nvl (pvs.attribute12,&apos;85&apos;) tipooperac,
upper(decode(
 nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;,
 ail.attribute10,
 (select
  nvl(trim(rep_registration_number), &apos;XAXX010101000&apos;)
  from
  zx_party_tax_profile
  where
  party_id = pv.party_id and
  party_type_code = &apos;THIRD_PARTY&apos;
 )
)) rfc,
aia.invoice_num numidfiscal,
aia.invoice_id,
aia.party_id,
pvs.party_site_id,
upper(decode(nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;,ail.attribute7, pv.vendor_name)) vendor_name,
upper(decode(nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;,ail.attribute8, pvs.country)) country,
upper(decode(
 nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;,
 ail.attribute9,
 (select
  territory_short_name
  from
  fnd_territories_vl
  where
  territory_code = pvs.country
 )
)) nationality,
aia.org_id invoice_org,
aia.invoice_type_lookup_code invoice_type,
decode(nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;, ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, xxap_rfc_amtpaid(aia.invoice_id, ail.org_id, ail.attribute10) * ip1.exchange_rate, xxap_rfc_amtpaid(aia.invoice_id, ail.org_id, ail.attribute10)), 0), &apos;99999999999990&apos;)), ltrim(to_char(round(decode (aia.invoice_currency_code, &apos;USD&apos;, aia.amount_paid * ip1.exchange_rate, aia.amount_paid), 0), &apos;99999999999990&apos;))) amount_paid,
decode(nvl(aia.attribute10,&apos;Y&apos;),&apos;N&apos;, ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, xxap_invbyrfc_item_price(aia.invoice_id, ail.org_id, null, ail.attribute10) * ip1.exchange_rate, xxap_invbyrfc_item_price(aia.invoice_id, ail.org_id, null, ail.attribute10)), 0), &apos;99999999999990&apos;)), ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, xxap_invoice_item_price(aia.invoice_id, ail1.prepay_invoice_id, ail.org_id) * ip1.exchange_rate, xxap_invoice_item_price(aia.invoice_id, ail1.prepay_invoice_id, ail.org_id)), 0), &apos;99999999999990&apos;))) item_amount,
&apos;NO&apos; import_tax,
aia.invoice_currency_code currency_code,
ip1.exchange_rate,
nvl (aia.attribute10, &apos;Y&apos;) usehdrdff,
&apos;I&apos; src
from
ap_invoices_all aia,
ap_invoice_lines_all ail,
ap_suppliers pv,
ap_supplier_sites_all pvs,
ap_invoice_payments_all ip1,
ap_invoice_lines_all ail1
where
ail.invoice_id = aia.invoice_id  and
aia.org_id = ail.org_id and
aia.org_id = :p_org_id and
--Check Header Level DFF - Send to SAT DFF
nvl (aia.attribute13, &apos;Y&apos;) = &apos;Y&apos; and
--Check line Level DFF - Send to SAT DFF
nvl (ail.attribute5, &apos;Y&apos;) = &apos;Y&apos; and
--PREPAYMENT invoices do not pay taxes
aia.invoice_type_lookup_code != &apos;PREPAYMENT&apos; and
ail.line_type_lookup_code = &apos;ITEM&apos; and
nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
--if line was incorrectly classified and the line has a tax code of mport tax -- do not include
nvl (ail.attribute13, &apos;1&apos;) != &apos;LSRM_IMPORT_TAX&apos; and
aia.vendor_id = pv.vendor_id and
aia.org_id = pvs.org_id and
aia.vendor_site_id = pvs.vendor_site_id and
pvs.vendor_id = pv.vendor_id and
ail.invoice_id = ail1.invoice_id and
ail1.line_type_lookup_code = &apos;PREPAY&apos; and
ip1.invoice_id = nvl (ail1.prepay_invoice_id, ail1.invoice_id) and
nvl (ip1.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (ip1.posted_flag, &apos;N&apos;) = &apos;Y&apos; and
exists
 (select
  1
  from
  ap_invoice_lines_all ail2,
  ap_invoice_distributions_all aid,
  xla_transaction_entities ent,
  xla_events xe,
  xla_ae_headers aeh,
  xla_ae_lines ael,
  xla_distribution_links dl,
  gl_import_references gir,
  gl_je_lines jel,
  gl_je_headers jeh,
  gl_je_batches glb,
  gl_code_combinations glc,
  ap_invoice_payments_all ip,
  ap_checks_all ac
  where
  1=1 and
  aid.invoice_id = aia.invoice_id and
  aid.invoice_id = ail2.invoice_id and
  aid.invoice_line_number = ail2.line_number and
  dl.source_distribution_id_num_1 in (aid.prepay_distribution_id, aid.invoice_distribution_id) and
  dl.applied_to_source_id_num_1 in (ail1.prepay_invoice_id, ail1.invoice_id) and
  dl.source_distribution_type = &apos;AP_INV_DIST&apos; and
  ent.source_id_int_1 in (ail2.prepay_invoice_id, ail2.invoice_id) and
  ent.legal_entity_id = aia.legal_entity_id and
  ent.security_id_int_1 = aid.org_id and
  ent.entity_code = &apos;AP_INVOICES&apos; and
  ent.application_id = xe.application_id and
  ent.entity_id = xe.entity_id and
  aeh.application_id = ent.application_id and
  aeh.entity_id = ent.entity_id and
  aeh.ledger_id = ent.ledger_id and
  aeh.accounting_entry_status_code = &apos;F&apos; and
  aeh.gl_transfer_status_code = &apos;Y&apos; and
  ael.ae_header_id = aeh.ae_header_id and
  ael.application_id = aeh.application_id and
  aeh.ae_header_id = dl.ae_header_id and
  ael.ae_line_num = dl.ae_line_num and
  xe.event_id = dl.event_id and
  gir.gl_sl_link_id = ael.gl_sl_link_id and
  gir.gl_sl_link_table = ael.gl_sl_link_table and
  gir.reference_7 = ael.ae_header_id and
  jel.je_header_id = gir.je_header_id and
  jel.je_line_num = gir.je_line_num and
  jel.code_combination_id = glc.code_combination_id and
  jeh.status = &apos;P&apos; and
  jeh.actual_flag = &apos;A&apos; and
  jeh.je_header_id = jel.je_header_id and
  jeh.period_name = jel.period_name and
  glb.je_batch_id = jeh.je_batch_id and
  glb.je_batch_id = gir.je_batch_id and
  --if invoice was prepaid get payment information from prepayment invoice
  ip.invoice_id = nvl(ail1.prepay_invoice_id, ail1.invoice_id) and
  ip.check_id = ac.check_id and
  nvl(ip.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
  nvl(ip.posted_flag, &apos;N&apos;) = &apos;Y&apos; and
  ---- PARAMETERS ----
  aid.period_name = :p_period_name and
  jeh.ledger_id = :p_ledger_id and
  glc.segment1 = :p_business_unit and
  ail1.org_id = :p_org_id and
  ---- PARAMETERS ----
  ail2.line_type_lookup_code = &apos;PREPAY&apos; and
  nvl(ail2.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
  nvl(ail2.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
  --if line was incorrectly classified and the line has a tax code of mport tax -- do not include
  nvl(ail2.attribute13, &apos;1&apos;) != &apos;LSRM_IMPORT_TAX&apos; and
  nvl(aid.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
  nvl(aid.cancellation_flag, &apos;N&apos;) = &apos;N&apos;
 ) and
exists
 (select
  1
  from
  ap_invoice_lines_all aill
  where
  aill.invoice_id = ail.invoice_id and
  aill.line_type_lookup_code in (&apos;TAX&apos;, &apos;AWT&apos;) and
  aill.tax_rate_code != &apos;LSRM_IMPORT_TAX&apos;
 )
union
select distinct
&apos;CAB&apos; id,
&apos;05&apos; tipoprov,
nvl (pvs.attribute12, &apos;85&apos;) tipooperac,
nvl (ail.attribute10, &apos;XEX010101000&apos;) rfc,
aia.invoice_num numidfiscal,
aia.invoice_id,
0,
0,
upper (ail.attribute7) vendor_name,
ail.attribute8 country,
ail.attribute9 nationality,
aia.org_id invoice_org,
aia.invoice_type_lookup_code invoice_type,
ltrim(to_char(round(decode(aia.invoice_currency_code, &apos;USD&apos;, xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, nvl(ail.attribute13,ail.tax_classification_code)) * ip.exchange_rate, (xxap_invoice_tax_paid(ail.invoice_id, ail.prepay_invoice_id, ail.org_id, nvl (ail.attribute13, ail.tax_classification_code)))), 0), &apos;99999999999990&apos;)) amount_paid,
ltrim(to_char(round(decode(
 aia.invoice_currency_code,&apos;USD&apos;,
 (select
  to_char(sum(taxable_amt))
  from
  ap_invoice_lines_all ail2,
  zx_lines zl
  where
  trx_id = ail.invoice_id and
  ail2.invoice_id = zl.trx_id and
  ail2.line_number = zl.trx_line_number and
  ail2.org_id = zl.internal_organization_id and
  zl.entity_code = &apos;AP_INVOICES&apos; and
  nvl(ail2.attribute13, ail2.tax_classification_code) = nvl(ail.attribute13, ail.tax_classification_code)
 ) * ip.exchange_rate,
 (select
  to_char(sum(taxable_amt))
  from
  ap_invoice_lines_all ail2,
  zx_lines zl
  where
  trx_id = ail.invoice_id and
  ail2.invoice_id = zl.trx_id and
  ail2.line_number = zl.trx_line_number and
  ail2.org_id = zl.internal_organization_id and
  zl.entity_code = &apos;AP_INVOICES&apos; and
  nvl (ail2.attribute13, ail2.tax_classification_code) = nvl (ail.attribute13, ail.tax_classification_code)
 )
), 0), &apos;99999999999990&apos;)) taxable_amount,
&apos;YES&apos; import_tax,
aia.invoice_currency_code currency_code,
ip.exchange_rate,
&apos;N&apos; usehdrdff,
&apos;I&apos; src
from
ap_invoices_all aia,
ap_invoice_lines_all ail,
ap_invoice_distributions_all aid,
xla_transaction_entities ent,
xla_events xe,
xla_ae_headers aeh,
xla_ae_lines ael,
xla_distribution_links dl,
gl_import_references gir,
gl_je_lines jel,
gl_je_headers jeh,
gl_je_batches glb,
gl_code_combinations glc,
ap_suppliers pv,
ap_supplier_sites_all pvs,
ap_invoice_payments_all ip,
ap_checks_all ac
where
ail.invoice_id = aia.invoice_id and
aia.org_id = ail.org_id and
--PREPAYMENT invoices do not pay taxes
aia.invoice_type_lookup_code != &apos;PREPAYMENT&apos; and
aid.invoice_id = aia.invoice_id and
aid.invoice_id = ail.invoice_id and
aid.invoice_line_number = ail.line_number and
ent.source_id_int_1 = aia.invoice_id and
ent.legal_entity_id = aia.legal_entity_id and
ent.security_id_int_1 = aia.org_id and
ent.entity_code = &apos;AP_INVOICES&apos; and
ent.application_id = xe.application_id and
ent.entity_id = xe.entity_id and
aeh.application_id = ent.application_id and
aeh.entity_id = ent.entity_id and
aeh.ledger_id = ent.ledger_id and
aeh.accounting_entry_status_code = &apos;F&apos; and
aeh.gl_transfer_status_code = &apos;Y&apos; and
ael.ae_header_id = aeh.ae_header_id and
ael.application_id = aeh.application_id and
aeh.ae_header_id = dl.ae_header_id and
ael.ae_line_num = dl.ae_line_num and
xe.event_id = dl.event_id and
aid.invoice_distribution_id = dl.source_distribution_id_num_1 and
gir.gl_sl_link_id = ael.gl_sl_link_id and
gir.gl_sl_link_table = ael.gl_sl_link_table and
gir.reference_7 = ael.ae_header_id and
jel.je_header_id = gir.je_header_id and
jel.je_line_num = gir.je_line_num and
jel.code_combination_id = glc.code_combination_id and
aia.vendor_id = pv.vendor_id and
aia.vendor_site_id = pvs.vendor_site_id and
pvs.vendor_id = pv.vendor_id and
jeh.status = &apos;P&apos; and
jeh.actual_flag = &apos;A&apos; and
jeh.je_header_id = jel.je_header_id and
jeh.period_name = jel.period_name and
glb.je_batch_id = jeh.je_batch_id and
glb.je_batch_id = gir.je_batch_id and
pvs.org_id = aid.org_id and
pvs.org_id = aia.org_id and
ail.invoice_id = ip.invoice_id and
ip.check_id = ac.check_id and
nvl (ip.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
---- PARAMETERS ----
ip.period_name = :p_period_name and
jeh.ledger_id = :p_ledger_id and
glc.segment1 = :p_business_unit and
aia.org_id = :p_org_id and
---- PARAMETERS ----
nvl (ail.discarded_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (ail.cancelled_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (aid.reversal_flag, &apos;N&apos;) = &apos;N&apos; and
nvl (aid.cancellation_flag, &apos;N&apos;) = &apos;N&apos; and
ip.posted_flag = &apos;Y&apos; and
ail.line_type_lookup_code = &apos;ITEM&apos; and
nvl (ail.attribute13, ail.tax_classification_code) = &apos;LSRM_IMPORT_TAX&apos;
union
select distinct
&apos;CAB&apos; id,
&apos;04&apos; tipoprov,
&apos;85&apos; tipooperac,
nvl(acr.attribute10,registration_number) rfc,
acr.receipt_number numidfiscal,
acr.cash_receipt_id,
0 party_id,
0 party_site_id,
nvl(acr.attribute7,ob.bank_name) supplier,
nvl(acr.attribute8,ob.country) country,
nvl(acr.attribute9,(select territory_short_name from fnd_territories_vl where territory_code = ob.country)) nationality,
acr.org_id receipt_org,
art.name,
ltrim(to_char(round(abs(mcd.amount),0), &apos;99999999999990&apos;)) amount_paid,
ltrim(to_char(round((ard.amount_cr - abs (mcd.amount)), 0))) taxable_amount,
&apos;NO&apos; import_tax,
acr.currency_code,
acr.exchange_rate,
&apos;N&apos; usehdrdff,
&apos;R&apos; src
from
  ar_cash_receipts_all acr,
  ar_cash_receipt_history_all acrh,
  ar_distributions_all ard,
  ar_misc_cash_distributions_all mcd,
  ar_receivables_trx_all art,
  xla_ae_headers xah,
  xla_ae_lines xal,
  xla_distribution_links xdl,
  gl_import_references glimp,
  gl_je_batches glb,
  gl_je_headers glh,
  gl_je_lines gll,
  gl_code_combinations gcc,
  fnd_lookup_values_vl lv,
  xle_fp_registrations_v xfr,
  (select
   cba.bank_id,
   bb.bank_name,
   cba.bank_account_name,
   cba.bank_account_num,
   cba.multi_currency_allowed_flag,
   cba.zero_amount_allowed,
   cba.account_classification,
   bb.bank_branch_type,
   bb.bank_branch_name,
   bb.bank_branch_number,
   bb.eft_swift_code,
   bau.bank_acct_use_id,
   ou.name,
   gcf.concatenated_segments,
   bb.country,
   bb.bank_number
   from
   ce_bank_accounts cba,
   ce_bank_acct_uses_all bau,
   cefv_bank_branches bb,
   hr_operating_units ou,
   gl_code_combinations_kfv gcf
   where
   cba.bank_account_id = bau.bank_account_id and
   cba.bank_branch_id = bb.bank_branch_id and
   ou.organization_id = bau.org_id and
   cba.asset_code_combination_id = gcf.code_combination_id and
   ou.name = &apos;LSRM OU&apos; and
   (cba.end_date is null or cba.end_date &gt; trunc(sysdate))
  ) ob
where
acr.cash_receipt_id = acrh.cash_receipt_id and
acr.org_id = acrh.org_id and
acrh.cash_receipt_history_id = ard.source_id and
acrh.org_id = ard.org_id and
acr.cash_receipt_id = mcd.cash_receipt_id and
xfr.legal_entity_id = acr.legal_entity_id and
ard.source_table = &apos;CRH&apos; and
acr.type = &apos;MISC&apos; and
xal.application_id = xah.application_id and
xah.ae_header_id = xal.ae_header_id and
xah.ae_header_id = xdl.ae_header_id and
xal.ae_line_num = xdl.ae_line_num and
xdl.application_id = xah.application_id and
xdl.source_distribution_type = &apos;AR_DISTRIBUTIONS_ALL&apos; and
xdl.source_distribution_id_num_1 = ard.line_id and
glimp.je_header_id = glh.je_header_id and
glimp.je_line_num = gll.je_line_num and
glimp.je_batch_id = glb.je_batch_id and
glh.je_header_id = gll.je_header_id and
glh.je_batch_id = glb.je_batch_id and
glimp.gl_sl_link_table = xal.gl_sl_link_table and
glimp.gl_sl_link_id = xal.gl_sl_link_id and
glimp.reference_5 = xah.entity_id and
glimp.reference_6 = xah.event_id and
glimp.reference_7 = xah.ae_header_id and
glh.je_source = &apos;Receivables&apos; and
acr.status = &apos;APP&apos; and --Applied excludes reversed
mcd.code_combination_id = gcc.code_combination_id and
gcc.segment4 = lv.meaning and --Acount Number
lv.lookup_type = &apos;EMR_RECEIPT_ACCTS_LSRM&apos; and
lv.enabled_flag = &apos;Y&apos; and
lv.end_date_active is null and
art.name = lv.description and -- Activity Name
acr.receivables_trx_id = art.receivables_trx_id and
ob.bank_acct_use_id = acr.remit_bank_acct_use_id and
---- PARAMETERS ----
gll.period_name = :p_period_name and
gll.ledger_id = :p_ledger_id and
gcc.segment1 = :p_business_unit and
acr.org_id = :p_org_id
---- PARAMETERS ----
) t
order by
t.tipoprov,
t.rfc,
t.invoice_id</SQL_TEXT>
  <ENABLED>Y</ENABLED>
  <XDO_APPLICATION_SHORT_NAME>XXAP</XDO_APPLICATION_SHORT_NAME>
  <XDO_DATA_SOURCE_CODE>XXAP_DPIVA_LSNA</XDO_DATA_SOURCE_CODE>
  <REPORT_TRANSLATIONS>
   <REPORT_TRANSLATIONS_ROW>
    <LANGUAGE>US</LANGUAGE>
    <REPORT_NAME>KDM DIOT V2</REPORT_NAME>
    <DESCRIPTION>Imported from BI Publisher (as a concurrent program)
Application: EMR XXAP
Source: EMR DPIVA Export LSNA
Short Name: XXAP_DPIVA_LSNA
DB package:

XXAP EMR DPIVA Export LSNA</DESCRIPTION>
   </REPORT_TRANSLATIONS_ROW>
  </REPORT_TRANSLATIONS>
  <CATEGORY_ASSIGNMENTS>
  </CATEGORY_ASSIGNMENTS>
  <ANCHORS>
   <ANCHORS_ROW>
    <ANCHOR>1=1</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_business_unit</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_ledger_id</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_org_id</ANCHOR>
   </ANCHORS_ROW>
   <ANCHORS_ROW>
    <ANCHOR>:p_period_name</ANCHOR>
   </ANCHORS_ROW>
  </ANCHORS>
  <PARAMETERS>
   <PARAMETERS_ROW>
    <SORT_ORDER>1</SORT_ORDER>
    <DISPLAY_SEQUENCE>10</DISPLAY_SEQUENCE>
    <ANCHOR>:p_org_id</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV custom</PARAMETER_TYPE_DSP>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
hou.organization_id id,
hou.name value,
hou.organization_id description
from
hr_operating_units hou
where name in (&apos;LSRM OU&apos;,&apos;KATO&apos;,&apos;LEROY SOMER&apos;,&apos;LSPD&apos;)
order by value,description</LOV_QUERY_DSP>
    <DEFAULT_VALUE>coalesce(xxen_util.default_operating_unit,xxen_util.previous_parameter_value(:parameter_id))</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Operating Unit</PARAMETER_NAME>
      <DESCRIPTION>Operating Unit</DESCRIPTION>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>2</SORT_ORDER>
    <DISPLAY_SEQUENCE>20</DISPLAY_SEQUENCE>
    <ANCHOR>:p_period_name</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV custom</PARAMETER_TYPE_DSP>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
glp.period_name id,
glp.period_name value,
null description
from
gl_periods glp,
gl_sets_of_books gsob,
gl_period_sets gps,
gl_period_types gpt,
hr_organization_units horu,
hr_operating_units hopu
where 
gsob.period_set_name=gps.period_set_name and 
gsob.accounted_period_type=gpt.period_type and 
gsob.set_of_books_id=hopu.set_of_books_id and 
horu.business_group_id=hopu.business_group_id and 
horu.organization_id=hopu.organization_id and 
glp.period_set_name=gsob.period_set_name and 
glp.period_type=gpt.period_type and 
horu.organization_id=nvl(:$flex$.Operating_Unit,fnd_global.org_id)
order by 
glp.start_date desc</LOV_QUERY_DSP>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Period Name</PARAMETER_NAME>
      <DESCRIPTION>Period Name</DESCRIPTION>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>3</SORT_ORDER>
    <DISPLAY_SEQUENCE>30</DISPLAY_SEQUENCE>
    <ANCHOR>:p_ledger_id</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV Oracle</PARAMETER_TYPE_DSP>
    <LOV_NAME>Ledger LOV</LOV_NAME>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
ledger_id id,
name value,
null description
from
gl_ledgers
where object_type_code=&apos;L&apos; and
ledger_id in
(select ledger_id from gl_access_set_assignments where access_set_id=fnd_profile.value(&apos;GL_ACCESS_SET_ID&apos;))
order by value,description</LOV_QUERY_DSP>
    <DEFAULT_VALUE>select
hou.set_of_books_id
from
hr_operating_units hou
where
hou.organization_id = :$flex$.Operating_Unit</DEFAULT_VALUE>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Ledger Id</PARAMETER_NAME>
      <DESCRIPTION>Ledger Id</DESCRIPTION>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
   <PARAMETERS_ROW>
    <SORT_ORDER>4</SORT_ORDER>
    <DISPLAY_SEQUENCE>40</DISPLAY_SEQUENCE>
    <ANCHOR>:p_business_unit</ANCHOR>
    <PARAMETER_TYPE_DSP>LOV custom</PARAMETER_TYPE_DSP>
    <VALIDATE_FROM_LIST_DSP>Y</VALIDATE_FROM_LIST_DSP>
    <LOV_QUERY_DSP>select
ffvv.flex_value id,
ffvv.flex_value value,
ffvv.flex_value_meaning||nvl2(ffvv.description,&apos;: &apos;||ffvv.description,null) description
from
fnd_flex_values_vl ffvv
where
ffvv.flex_value_set_id=1031523
order by
ffvv.flex_value</LOV_QUERY_DSP>
    <REQUIRED>Y</REQUIRED>
    <PARAMETER_TRANSLATIONS>
     <PARAMETER_TRANSLATIONS_ROW>
      <LANGUAGE>US</LANGUAGE>
      <PARAMETER_NAME>Business Unit</PARAMETER_NAME>
      <DESCRIPTION>Business Unit</DESCRIPTION>
     </PARAMETER_TRANSLATIONS_ROW>
    </PARAMETER_TRANSLATIONS>
   </PARAMETERS_ROW>
  </PARAMETERS>
  <PARAMETER_DEPENDENCIES>
   <PARAMETER_DEPENDENCIES_ROW>
    <FLEX_BIND>:$flex$.Operating_Unit</FLEX_BIND>
    <PARAMETER_NAME>Operating Unit</PARAMETER_NAME>
    <DEPENDENT_PARAMETER_NAME>Ledger Id</DEPENDENT_PARAMETER_NAME>
   </PARAMETER_DEPENDENCIES_ROW>
   <PARAMETER_DEPENDENCIES_ROW>
    <FLEX_BIND>:$flex$.Operating_Unit</FLEX_BIND>
    <PARAMETER_NAME>Operating Unit</PARAMETER_NAME>
    <DEPENDENT_PARAMETER_NAME>Period Name</DEPENDENT_PARAMETER_NAME>
   </PARAMETER_DEPENDENCIES_ROW>
  </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>
