Вы находитесь на странице: 1из 6

<?xml version="1.0" encoding="UTF-8" ?

>
<!-- $Header: XXHDRINDTAXCOMPREG.xml Mohammed Yadul $ -->
<!-- $Header: XXHDRINDTAXCOMPREG.xml Mohammed Yadul $$Header:
XXHDRINDTAXCOMPREG.xml Sridhar L V for Defect #5499 $ -->
<!-- $Header: XXHDRINDTAXCOMPREG.xml Mohammed Yadul $$Header:
XXHDRINDTAXCOMPREG.xml Sridhar L V for Defect #5499 $$Header:
XXHDRINDTAXCOMPREG.xml Sridhar L V for Defect #6848 $ -->
<!-- GSCC_Category="Xdo Data Definition" -->

<dataTemplate name="XXHDRINDTAXCOMPREG" version="1.0">


<properties>
<property name="xml_tag_case" value="upper" />
</properties>
<parameters>
<parameter name="P_LEGAL_ENTITY" dataType="character"></parameter>
<parameter name="P_START_DATE" dataType="date"></parameter>
<parameter name="P_END_DATE" dataType="date"></parameter>
</parameters>
<dataQuery>
<sqlStatement name="Q_MAIN">
<![CDATA[
SELECT * FROM
(SELECT hrou.name ou_name
,gcc.segment1 legal_entity
,gcc.segment2 cost_centre
,TO_CHAR(gcc.segment4) market_sector
,ppa.segment1 project_number
--,to_char(gjh.posted_date,'DD-MON-YYYY') posted_date --Commented 6848 19-
APR-2016
,to_char(aid.accounting_date,'DD-MON-YYYY') posted_date --6848 19-APR-2016
,aia.invoice_currency_code currency_code
,'AP' transaction_type
,aia.invoice_id
,aila.line_number line_number
,NVL(zlv.tax_amt,0) vendor_charged_tax --6848 19-APR-2016
,aia.invoice_num invoice_num
,TO_CHAR(aia.invoice_date,'DD-MON-YYYY') invoice_date
,aps.vendor_name supplier_customer
,aps.segment1 supplier_number --**
,NVL(zlv.tax, aila.tax_classification_code) tax_code
,NVL(zlv.tax_jurisdiction_code, aila.tax_jurisdiction_code)
tax_jurisdiction_code
,mcb.segment1||mcb.segment2 expenditure_type
,aila.amount net_amt_in_func_cur
,apps.xxhdr_tax_rep_pkg.get_tax_adjusted(aila.invoice_id,
zlv.tax_jurisdiction_code,--
apps.xxhdr_tax_rep_pkg.tax_jurisdiction(aila.invoice_id, aila.line_number),
zlv.tax_rate,
aila.line_number) tax_amt_in_func_cur
,(aila.amount + apps.xxhdr_tax_rep_pkg.get_tax_adjusted(aila.invoice_id,

zlv.tax_jurisdiction_code,--
apps.xxhdr_tax_rep_pkg.tax_jurisdiction(aila.invoice_id, aila.line_number),
zlv.tax_rate,
aila.line_number))
gross_amt_in_fun_cur
/*,apps.xxhdr_tax_rep_pkg.get_tax_adjusted(aila.invoice_id,

apps.xxhdr_tax_rep_pkg.tax_jurisdiction(aila.invoice_id),
aila.line_number)
tax_amt_in_func_cur
,(aila.amount + apps.xxhdr_tax_rep_pkg.get_tax_adjusted(aila.invoice_id,

apps.xxhdr_tax_rep_pkg.tax_jurisdiction(aila.invoice_id),
aila.line_number))
gross_amt_in_fun_cur*/
,hls.country ship_to_country
--,hls.region_2 ship_to_state --Sridhar
,CASE
WHEN hls.country = 'US'
THEN hls.region_2
ELSE NULL
END ship_to_state
--,ass.county ship_to_county --Sridhar
,CASE
WHEN hls.country = 'US'
THEN hls.region_1
ELSE NULL
END ship_to_county
,hls.town_or_city ship_to_city
,hls.postal_code ship_to_postal_code
--,hlb.country ship_from_country
,ass.country ship_from_country
--,hlb.region_2 ship_from_state
,ass.state ship_from_state
,ass.county ship_from_county
--,hlb.town_or_city ship_from_city
,ass.city ship_from_city
--,hlb.postal_code ship_from_postal_code
,ass.zip ship_from_postal_code
,apps.xxhdr_tax_rep_pkg.acct_segment(aid.invoice_id) tax_acct_num
FROM apps.ap_invoices_all aia
--,apps.ap_invoice_lines_all aila
,apps.ap_invoice_lines_v aila
,apps.ap_invoice_distributions_all aid
,apps.xla_distribution_links PARTITION (AP) xdl
,apps.xla_ae_lines PARTITION (AP) xal
,apps.xla_ae_headers PARTITION (AP) xah
,apps.xla_events PARTITION (AP) xe
,apps.gl_import_references gir
,apps.gl_je_headers gjh
,apps.xla_event_types_tl xet
,apps.xla_event_classes_tl xect
,apps.pa_projects_all ppa
,apps.gl_code_combinations gcc
,apps.zx_lines zlv
,apps.ap_suppliers aps
,apps.ap_supplier_sites_all ass
,apps.hr_locations_all hls
--,apps.hr_locations_all hlb
,apps.mtl_categories_b mcb
,apps.hr_operating_units hrou
,apps.gl_ledgers gll --6848 19-APR-2016
WHERE aia.invoice_id = aila.invoice_id
AND aia.org_id = aila.org_id
AND aia.org_id = hrou.organization_id
AND aila.invoice_id = aid.invoice_id
AND aila.line_number = aid.invoice_line_number
AND aid.org_id = aila.org_id
--AND aid.line_type_lookup_code = 'ITEM'
AND aid.line_type_lookup_code IN ('ITEM', 'FREIGHT','MISCELLANEOUS') --02-MAY-
2016
AND aid.invoice_distribution_id = xdl.source_distribution_id_num_1
AND xdl.source_distribution_type = 'AP_INV_DIST'
--AND xdl.rounding_class_code = 'ITEM EXPENSE' --6848 02-MAY-2016
AND xdl.rounding_class_code IN ('ITEM EXPENSE', 'FREIGHT', 'MISCELLANEOUS
EXPENSE') --6848 02-MAY-2016
AND xdl.ae_line_num = xal.ae_line_num
AND xdl.ae_header_id = xah.ae_header_id
AND xal.ae_header_id = xah.ae_header_id
AND xah.event_id = xe.event_id
and xah.ledger_id = gll.ledger_id --6848 19-APR-2016
and gll.ledger_category_code= 'PRIMARY' --6848 19-APR-2016
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.je_header_id = gjh.je_header_id
AND xe.application_id = xet.application_id
AND xe.event_type_code = xet.event_type_code
AND xet.language = userenv('LANG')
AND xect.application_id = xe.application_id
AND xect.language = userenv('LANG')
AND xect.event_class_code = xet.event_class_code
AND gjh.status = 'P'
AND aid.project_id = ppa.project_id(+)
AND gcc.code_combination_id = aid.dist_code_combination_id
AND aila.invoice_id =zlv.trx_id(+)
AND aila.line_number = zlv.trx_line_number(+)
--and zlv.summary_tax_line_id = aid.summary_tax_line_id
AND aia.vendor_id = aps.vendor_id
AND aps.vendor_id = ass.vendor_id
AND aia.org_id = ass.org_id
AND aia.vendor_site_id = ass.vendor_site_id(+)
--AND ass.ship_to_location_id = hls.location_id
AND aila.ship_to_location_id = hls.location_id(+)
--AND ass.bill_to_location_id = hlb.location_id
AND aila.purchasing_category_id = mcb.category_id(+)
--AND zlv.entity_code = 'AP_INVOICES'
--AND zlv.trx_level_type = 'LINE'
AND aila.line_source <> 'SABRIX'
AND aia.org_id = :P_LEGAL_ENTITY
--AND gjh.posted_date BETWEEN :P_START_DATE AND :P_END_DATE; --Commented --6848
19-APR-2016
AND aid.accounting_date BETWEEN :P_START_DATE AND :P_END_DATE --6848 19-APR-
2016
UNION
SELECT hrou.name ou_name
,gcc.segment1 legal_entity
,gcc.segment2 cost_centre
,TO_CHAR(gcc.segment4) market_sector
,ppa.segment1 project_number
,TO_CHAR(rctd.gl_posted_date,'DD-MON-YYYY') posted_date
,gjh.currency_code
,'AR' transaction_type
,rcta.customer_trx_id invoice_id
,rctla.customer_trx_line_id line_number
,0 vendor_charged_tax --**
,rcta.trx_number invoice_num
,TO_CHAR(rcta.trx_date,'DD-MON-YYYY') invoice_date
,hp.party_name supplier_customer
,hp.party_number supplier_number --**
,zl.tax tax_code
,zl.tax_jurisdiction_code
,apps.xxhdr_tax_rep_pkg.ar_expenditure_type(rctla.customer_trx_id,
rctla.customer_trx_line_id)
expenditure_type
,rctla.extended_amount net_amt_in_func_cur
,zl.tax_amt tax_amt_in_func_cur
,(rctla.extended_amount + zl.tax_amt) gross_amt_in_fun_cur
,hl_ship.country ship_to_country
--,hl_ship.state ship_to_state
,CASE
WHEN hl_ship.country = 'US'
THEN hl_ship.state
ELSE NULL
END ship_to_state
--,hl_ship.county ship_to_county
,CASE
WHEN hl_ship.country = 'US'
THEN hl_ship.county
ELSE NULL
END ship_to_county
,hl_ship.city ship_to_city
,hl_ship.postal_code ship_to_postal_code
,hl_bill.country ship_from_country
,hl_bill.state ship_from_state
,hl_bill.county ship_from_county
,hl_bill.city ship_from_city
,hl_bill.postal_code ship_from_postal_code
,apps.xxhdr_tax_rep_pkg.ar_acct_segment(rctla.customer_trx_id) tax_acct_num
FROM apps.ra_customer_trx_all rcta
,apps.ra_customer_trx_lines_all rctla
,apps.ra_cust_trx_line_gl_dist_all rctd
,apps.zx_lines zl
,apps.hz_cust_accounts hca
,apps.hz_parties hp
,apps.hz_cust_site_uses_all hcsua_bill
,apps.hz_cust_acct_sites_all hcas_bill
,apps.hz_party_sites hps_bill
,apps.hz_locations hl_bill
,apps.hz_cust_site_uses_all hcsua_ship
,apps.hz_cust_acct_sites_all hcas_ship
,apps.hz_party_sites hps_ship
,apps.hz_locations hl_ship
,apps.gl_code_combinations gcc
,apps.pa_projects_all ppa
,apps.pa_tasks pt
,apps.xla_distribution_links PARTITION (AR) xdl
,apps.xla_ae_lines PARTITION (AR) xal
,apps.xla_ae_headers PARTITION (AR) xah
,apps.xla_events PARTITION (AR) xe
,apps.gl_import_references gir
,apps.gl_je_headers gjh
,apps.hr_operating_units hrou
,apps.pa_draft_invoice_items pdii
WHERE rcta.customer_trx_id = rctla.customer_trx_id
AND rcta.org_id = rctla.org_id
AND rcta.org_id = hrou.organization_id
AND rctla.customer_trx_id = rctd.customer_trx_id
AND rctla.customer_trx_line_id = rctd.customer_trx_line_id
AND rctla.org_id = rctd.org_id
AND zl.trx_id = rctd.customer_trx_id
AND zl.trx_line_id = rctd.customer_trx_line_id
AND zl.entity_code = 'TRANSACTIONS'
AND rcta.bill_to_customer_id = hca.cust_account_id
AND hp.party_id = hca.party_id
AND rcta.bill_to_site_use_id = hcsua_bill.site_use_id
AND hcsua_bill.site_use_code = 'BILL_TO'
AND hcas_bill.cust_acct_site_id = hcsua_bill.cust_acct_site_id
AND hps_bill.party_site_id = hcas_bill.party_site_id
AND hl_bill.location_id = hps_bill.location_id
--AND rcta.ship_to_site_use_id = hcsua_ship.site_use_id(+)
AND hcsua_ship.site_use_code(+) = 'SHIP_TO'
AND ppa.project_id = pt.project_id (+)
AND hcsua_ship.cust_acct_site_id(+) = pt.address_id
AND hcas_ship.cust_acct_site_id(+) = pt.address_id
AND ppa.project_id = pdii.project_id
AND pdii.task_id = pt.task_id
AND TO_NUMBER (rctla.interface_line_attribute2) = pdii.draft_invoice_num
AND TO_NUMBER (rctla.interface_line_attribute6) = pdii.line_num
AND rctla.org_id = ppa.org_id
AND hcas_ship.party_site_id = hps_ship.party_site_id(+)
AND hps_ship.location_id = hl_ship.location_id(+)
AND rctd.code_combination_id = gcc.code_combination_id
AND rcta.interface_header_attribute1 = ppa.segment1(+)
AND rctd.cust_trx_line_gl_dist_id = xdl.source_distribution_id_num_1
AND xdl.ae_line_num = xal.ae_line_num
AND xdl.ae_header_id = xah.ae_header_id
AND xal.ae_header_id = xah.ae_header_id
AND xah.event_id = xe.event_id
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.je_header_id = gjh.je_header_id
AND rcta.org_id = :P_LEGAL_ENTITY
AND rctd.gl_posted_date BETWEEN :P_START_DATE AND :P_END_DATE)
ORDER BY invoice_num
]]>
</sqlStatement></dataQuery>
<dataStructure>
<group name="G_MAIN" dataType="varchar2" source="Q_MAIN">
<element name="ou_name" dataType="varchar2" value="OU_NAME"/>
<element name="legal_entity" dataType="varchar2" value="LEGAL_ENTITY"/>
<element name="cost_centre" dataType="varchar2" value="COST_CENTRE"/>
<element name="market_sector" dataType="varchar2" value="MARKET_SECTOR"/>
<element name="project_number" dataType="varchar2" value="PROJECT_NUMBER"/>
<element name="posted_date" dataType="date" value="POSTED_DATE"/>
<element name="currency_code" dataType="varchar2" value="CURRENCY_CODE"/>
<element name="transaction_type" dataType="varchar2" value="TRANSACTION_TYPE"/>
<element name="invoice_id" dataType="number" value="INVOICE_ID"/>
<element name="line_number" dataType="number" value="LINE_NUMBER"/>
<element name="vendor_charged_tax" dataType="number" value="VENDOR_CHARGED_TAX"/>
<element name="invoice_num" dataType="varchar2" value="INVOICE_NUM"/>
<element name="invoice_date" dataType="date" value="INVOICE_DATE"/>
<element name="supplier_customer" dataType="varchar2" value="SUPPLIER_CUSTOMER"/>
<element name="supplier_number" dataType="VARCHAR2" value="SUPPLIER_NUMBER"/>
<element name="tax_code" dataType="varchar2" value="TAX_CODE"/>
<element name="tax_jurisdiction_code" dataType="varchar2"
value="TAX_JURISDICTION_CODE"/>
<element name="expenditure_type" dataType="varchar2" value="EXPENDITURE_TYPE"/>
<element name="taxable_amount" dataType="number" value="TAXABLE_AMOUNT"/>
<element name="tax_amt" dataType="number" value="TAX_AMT"/>
<element name="tax_rate" dataType="number" value="TAX_RATE"/>
<element name="net_amt_in_func_cur" dataType="number" value="NET_AMT_IN_FUNC_CUR"/>
<element name="tax_amt_in_func_cur" dataType="number" value="TAX_AMT_IN_FUNC_CUR"/>
<element name="gross_amt_in_fun_cur" dataType="varchar2"
value="GROSS_AMT_IN_FUN_CUR"/>
<element name="ship_to_country" dataType="varchar2" value="SHIP_TO_COUNTRY"/>
<element name="ship_to_state" dataType="varchar2" value="SHIP_TO_STATE"/>
<element name="ship_to_county" dataType="varchar2" value="SHIP_TO_COUNTY"/>
<element name="ship_to_city" dataType="varchar2" value="SHIP_TO_CITY"/>
<element name="ship_to_postal_code" dataType="varchar2"
value="SHIP_TO_POSTAL_CODE"/>
<element name="ship_from_country" dataType="varchar2" value="SHIP_FROM_COUNTRY"/>
<element name="ship_from_state" dataType="varchar2" value="SHIP_FROM_STATE"/>
<element name="ship_from_county" dataType="varchar2" value="SHIP_FROM_COUNTY"/>
<element name="ship_from_city" dataType="varchar2" value="SHIP_FROM_CITY"/>
<element name="ship_from_postal_code" dataType="varchar2"
value="SHIP_FROM_POSTAL_CODE"/>
<element name="tax_acct_num" dataType="varchar2" value="TAX_ACCT_NUM"/>
</group>
<element name="TOTAL_NUMBER_FLEX" function="count" dataType="number"
value="G_MAIN.COST_CENTRE"/>
</dataStructure>
</dataTemplate>

Вам также может понравиться