Fala Galera,
Hoje vou fazer um post mais rápido porém muito, muito útil.
Existem casos em que precisamos fazer, e saber antecipadamente, em alguma customização, quais serão os impostos que serão aplicados em algum determinado item que será vendido.
Vi essa questão resolvida de duas maneiras.
A primeira maneira de chegar nos impostos, é desenvolvendo uma solução customizada para cálculo de impostos. Sim, na minha opinião isso é loucura. Simplesmente não dá pra considerar todas as regras e exceções desses cálculos de uma maneira prática e rápida.
Inclusive, eu já vi essa solução em funcionamento. E sim, não funcionava direito. Sempre faltava considerar alguma regra, seja de regras de Uso e Consumo, seja se Cesta Básica, ou qualquer outra regra de imposto que não atendia a regra básica.
ICMS por exemplo. Algo que tivesse alguma alíquota fora da padrão de Estado Origem e Destino, já trazia a alíquota errada. E por mais que tentássemos cercar, sempre faltava alguma coisa.
Desta forma procurei outras maneiras de resolver esse problema. Foi então que caiu a fixa. Atualmente, o EBS atende, senão todas (não sei), mas a grande maioria das regras de impostos, pois a nota fiscal tem que sair corretamente, certo?
A partir daí cheguei na Segunda Maneira de Calcular os Impostos, de forma customizada, que no caso, foi apenas utilizar a roda que já foi inventada, ou seja, utilizar uma API nativa do Oracle, que já faz esse cálculo, e considere todas as regras configuradas pelo Fiscal.
A API que utilizei, encontrei dentro da tela de Ordens de Venda (OEXOEORD). Esta tela calcula uma prévia dos impostos quando fazemos o registro da mesma. Para ver, basta consultar uma ordem previamente registrada, navegar até uma das linhas, e ir no botão Ações e depois em Verificar detalhes do imposto.
Será exibida uma tela com as informações dos impostos.
Dessa forma, abrindo a tela, encontrei a API:
zx_api_pub.calculate_tax
Esta é a API responsável pelo cálculo dos impostos da Ordem de Venda e, provavelmente, seja ela também que faça os cálculos para a Nota Fiscal.
Dessa forma encontrei todos os dados e parâmetros necessários e montei uma procedure que recebe alguns parâmetros obrigatórios e faz a complexa chamada da API de cálculo de impostos.
Para testar, é necessário alterar as informações que estão sendo passadas nos parâmetros, conforme as informações da sua empresa em questão e demais informações, como item, vendedor, endereços, e demais informações.
-- Chama a rotina para carregar informações do imposto Calculate_Tax(p_org_id => 81 , p_order_type_id => 1370 , p_sold_to_org_id => 3592570 , p_organization_id => 115 , p_inventory_item_id => 11734850 , p_ship_from_org_id => 115 , p_ship_to_org_id => 112975 , p_invoice_to_org_id => 112974 , p_ordered_quantity => 5000 , p_unit_selling_price => 4.26 , p_fob_point_code => 'CIF' , p_salesrep_id => 100011117 , px_return_status => w_return_status , px_message_error => w_message_error);
No exemplo, foi necessário setar o contexto para que funcione corretamente ao rodar fora do ambiente do EBS, conforme abaixo:
MO_GLOBAL.SET_POLICY_CONTEXT(p_access_mode => 'S', p_org_id => 81);
O que essa rotina faz é carregar uma tabela temporária(zx_detail_tax_lines_gt), então, depois de rodar o bloco PL/SQL, é possível visualizar as informações do imposto a partir da Query abaixo:
SELECT a.tax_id , a.tax , a.tax_rate_code , a.tax_rate , a.unit_price , a.trx_line_quantity , a.line_amt , a.taxable_amt , a.tax_amt , a.tax_amt_included_flag , a.tax_regime_id , a.tax_regime_code , a.tax_status_id , a.tax_status_code , a.tax_rate_id , a.legal_justification_text1 , a.legal_justification_text2 , a.legal_justification_text3 FROM zx_detail_tax_lines_gt a , zx_rates_b b WHERE a.tax_rate_id = b.tax_rate_id -- AND a.tax LIKE '%C' -- Trazer apenas o que for Crédito ORDER BY a.tax_line_number;
O Resultado será assim:
O código completo está abaixo, já possível testá-lo, porém antes é necessário configurar os parâmetros, conforme comentei acima.
Se foi útil, ou se você apenas gostou, peço que compartilhe com seus contatos, poderá ser muito útil para eles.
DECLARE C_ERROR CONSTANT VARCHAR2(1) := 'E'; C_SUCCESS CONSTANT VARCHAR2(1) := 'S'; w_return_status VARCHAR2(1); w_message_error VARCHAR2(4000); PROCEDURE l (t IN VARCHAR2) IS BEGIN dbms_output.put_line (t); END l; -------------------------------------------------------------------------- FUNCTION Get_le_id(p_order_type_id NUMBER , p_sold_to_customer_id NUMBER , p_bill_to_customer_id NUMBER , p_org_id NUMBER , px_message_error OUT VARCHAR2) RETURN NUMBER IS l_invoice_source_id NUMBER; l_invoice_source VARCHAR2(50); l_order_type_rec OE_ORDER_CACHE.ORDER_TYPE_REC_TYPE; l_customer_type VARCHAR2(30); l_customer_id NUMBER; l_cust_trx_type_id NUMBER; l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS; l_legal_entity_id NUMBER; l_msg_data VARCHAR2(1000); BEGIN IF p_sold_to_customer_id IS NOT NULL THEN l_customer_type := 'SOLD_TO'; l_customer_id := p_sold_to_customer_id; ELSIF p_bill_to_customer_id IS NOT NULL THEN l_customer_type := 'BILL_TO'; l_customer_id := p_bill_to_customer_id; END IF; l_order_type_rec := OE_ORDER_CACHE.Load_Order_Type(p_order_type_id); l_invoice_source_id := l_order_type_rec.invoice_source_id; l_cust_trx_type_id := l_order_type_rec.cust_trx_type_id; IF l_invoice_source_id IS NULL THEN l_invoice_source := oe_sys_parameters.value('INVOICE_SOURCE', p_org_id); IF (l_invoice_source IS NOT NULL) THEN SELECT batch_source_id INTO l_invoice_source_id FROM ra_batch_sources WHERE name = l_invoice_source; END IF; END IF; IF l_cust_trx_type_id IS NULL THEN l_cust_trx_type_id := oe_sys_parameters.value('OE_INVOICE_TRANSACTION_TYPE_ID',p_org_id); END IF; l_legal_entity_id := XLE_BUSINESSINFO_GRP.Get_OrdertoCash_Info ( x_return_status => l_return_status, -- OUT x_msg_data => l_msg_data, -- OUT p_customer_type => l_customer_type, -- IN P_customer_type p_customer_id => l_customer_id, -- IN P_customer_id (sold_to/bill_to customer_id) p_transaction_type_id => l_cust_trx_type_id, -- IN P_transaction_type_id p_batch_source_id => l_invoice_source_id,-- IN P_batch_source_id p_operating_unit_id => p_org_id -- IN P_operating_unit_id (org_id) ); IF l_return_status <> FND_API.G_RET_STS_SUCCESS OR l_legal_entity_id = -1 THEN IF l_msg_data IS NOT NULL THEN px_message_error := 'Erro: '||l_msg_data; ELSE px_message_error := 'Erro na chamada de XLE_BUSINESSINFO_GRP.Get_OrdertoCash_Info'; END IF; RETURN -1; END IF; RETURN l_legal_entity_id; EXCEPTION WHEN OTHERS THEN px_message_error := 'Erro: '||SQLERRM; RETURN -1; END Get_le_id; -------------------------------------------------------------------------- PROCEDURE Calculate_Tax(p_org_id IN oe_order_headers_all.org_id%TYPE , p_order_type_id IN oe_order_headers_all.order_type_id%TYPE , p_sold_to_org_id IN oe_order_headers_all.sold_to_org_id%TYPE , p_organization_id IN mtl_system_items_b.organization_id%TYPE , p_inventory_item_id IN oe_order_lines_all.inventory_item_id%TYPE , p_ship_from_org_id IN oe_order_lines_all.ship_from_org_id%TYPE , p_ship_to_org_id IN oe_order_lines_all.ship_to_org_id%TYPE , p_invoice_to_org_id IN oe_order_lines_all.invoice_to_org_id%TYPE , p_ordered_quantity IN oe_order_lines_all.ordered_quantity%TYPE , p_unit_selling_price IN oe_order_lines_all.unit_selling_price%TYPE , p_fob_point_code IN oe_order_lines_all.fob_point_code%TYPE , p_salesrep_id IN oe_order_lines_all.salesrep_id%TYPE , px_return_status OUT VARCHAR2 , px_message_error OUT VARCHAR2) AS -- Busca informações básicas do Item CURSOR c_item IS SELECT a.organization_id , a.inventory_item_id , a.primary_uom_code , a.description , a.segment1 , a.global_attribute2 trx_business_category FROM mtl_system_items_vl a WHERE a.inventory_item_id = p_inventory_item_id AND a.organization_id = p_organization_id; -- Busca informações fiscais do Tipo de Transação CURSOR c_order_type IS SELECT otta.transaction_type_id order_type_id , ottt.name , NVL(otta.cust_trx_type_id, 0) cust_trx_type_id , rct.global_attribute4 tax_code , otta.currency_code currency_code FROM oe_transaction_types_all otta , oe_transaction_types_tl ottt , ra_cust_trx_types_all rct WHERE otta.transaction_type_id = ottt.transaction_type_id AND ottt.language = USERENV('LANG') AND otta.cust_trx_type_id = rct.cust_trx_type_id (+) AND otta.org_id = rct.org_id (+) AND otta.transaction_type_id = p_order_type_id; -- Busca a moeda CURSOR c_currency(p_currency_code IN fnd_currencies.currency_code%TYPE) IS SELECT c.currency_code , c.minimum_accountable_unit , c.precision FROM fnd_currencies c WHERE c.currency_code = p_currency_code; -- Busca informações do cliente e entrega CURSOR getlocinfo(p_site_org_id hz_cust_site_uses_all.site_use_id%TYPE) IS SELECT /* MOAC_SQL_CHANGE */ s_ship.site_use_id , s_ship.cust_acct_site_id , acct_site_ship.cust_account_id , party.party_id , party_site_ship.party_site_id , loc_ship.location_id FROM hz_cust_site_uses s_ship , hz_cust_acct_sites_all acct_site_ship , hz_party_sites party_site_ship , hz_locations loc_ship , hz_parties party , hz_cust_accounts_all cust_acct WHERE s_ship.site_use_id = p_site_org_id AND s_ship.cust_acct_site_id = acct_site_ship.cust_acct_site_id AND acct_site_ship.cust_account_id = cust_acct.cust_account_id AND cust_acct.party_id = party.party_id AND acct_site_ship.party_site_id = party_site_ship.party_site_id AND party_site_ship.location_id = loc_ship.location_id; -- Busca o local da organização CURSOR get_internal_loc(p_organization_id number) IS SELECT location_id FROM hr_organization_units WHERE organization_id = p_organization_id; r_item c_item%ROWTYPE; r_order_type c_order_type%ROWTYPE; r_currency c_currency%ROWTYPE; r_ship_locinfo getlocinfo%ROWTYPE; r_bill_locinfo getlocinfo%ROWTYPE; -- l_return_status VARCHAR2(1); l_msg_count NUMBER; l_msg_data VARCHAR2(2000); l_product_fisc_classification VARCHAR2(240); l_trx_line_number NUMBER; i NUMBER; l_internal_org_location_id NUMBER; l_header_id oe_order_headers.header_id%type; l_tax_date oe_order_lines.tax_date%type; l_ship_from_location_id NUMBER; l_application_id NUMBER; l_entity_code_crsr zx_detail_tax_lines_gt.entity_code%TYPE; l_event_class_code_crsr zx_detail_tax_lines_gt.event_class_code%TYPE ; l_trx_level_type_crsr zx_detail_tax_lines_gt.trx_level_type%TYPE; l_line_id NUMBER; l_inventory_org_id NUMBER; l_order_number oe_order_headers_all.order_number%TYPE; l_ar_sys_param_rec ar_system_parameters_all%ROWTYPE; l_legal_entity_id NUMBER(15); l_bill_from_location_id NUMBER; -- l_transaction_rec zx_api_pub.transaction_rec_type; l_doc_level_recalc_flag VARCHAR2(30); l_poo_party_id NUMBER; l_poo_location_id NUMBER; exit_excp EXCEPTION; PROCEDURE Add(p_field IN OUT VARCHAR2 , p_text IN VARCHAR2) IS BEGIN IF p_text IS NULL THEN RETURN; END IF; IF p_field IS NULL THEN p_field := p_text; ELSE p_field := p_field || ' - ' || p_text; END IF; END Add; BEGIN -- O cálculo deverá ser feito exatamente como a Ordem de Venda Faz -- Por esse motivo esta sendo passado o mesmo evento como sendo a partir da Ordem px_return_status := C_SUCCESS; l_entity_code_crsr := 'OE_ORDER_HEADERS'; l_event_class_code_crsr := 'SALES_TRANSACTION_TAX_QUOTE'; l_trx_level_type_crsr := 'LINE'; -- Como Não temos Ordem de Venda por se tratar de uma simulação, passamos zero para os IDs l_header_id := 0; l_order_number := 0; l_line_id := 0; l_trx_line_number := 0; -- l_tax_date := SYSDATE; l_application_id := 660; -- l_inventory_org_id := oe_sys_parameters.value('MASTER_ORGANIZATION_ID', p_org_id); -- Busca informações básicas do Item r_item := NULL; OPEN c_item; FETCH c_item INTO r_item; CLOSE c_item; -- Verifica se encontrou o item IF r_item.organization_id IS NULL THEN px_return_status := C_ERROR; px_message_error := 'Item com ID '||p_inventory_item_id || ' não encontrado na Organização com ID '||p_organization_id; RETURN; END IF; --l('trx business:'||r_item.trx_business_category); -- Busca a classificação fiscal do Item BEGIN SELECT category_concat_segs INTO l_product_fisc_classification FROM mtl_item_categories_v a WHERE a.inventory_item_id = p_inventory_item_id AND a.organization_id = p_organization_id AND a.category_set_name = 'FISCAL_CLASSIFICATION' AND a.enabled_flag = 'Y' AND rownum = 1; EXCEPTION WHEN no_Data_Found THEN px_return_status := C_ERROR; px_message_error := 'Classificação fiscal (FISCAL_CLASSIFICATION) não encontrada para o Item '||r_item.segment1 || ' da Organização com ID '||p_organization_id; RETURN; WHEN OTHERS THEN px_return_status := C_ERROR; px_message_error := 'Erro ao buscar Classificação fiscal (FISCAL_CLASSIFICATION) para o Item '||r_item.segment1 || ' da Organização com ID '||p_organization_id||'. Erro: '||SQLERRM; RETURN; END; --l('l_product_fisc_classification: '||l_product_fisc_classification); -- Busca informações do AR l_AR_Sys_Param_Rec := OE_Sys_Parameters_Pvt.Get_AR_Sys_Params; -- Busca informações r_order_type := NULL; OPEN c_order_type; FETCH c_order_type INTO r_order_type; CLOSE c_order_type; -- Verifica se encontrou o tipo de transação IF r_order_type.order_type_id IS NULL THEN px_return_status := C_ERROR; px_message_error := 'Tipo de transação com ID '||p_order_type_id || ' não encontrado.'; RETURN; END IF; --l('Customer trx type id is:'||r_order_type.cust_trx_type_id); --l('l_tax_code is:'||r_order_type.tax_code); --l('l_currency_code: '||r_order_type.currency_code); -- Verifica se encontrou tipo de transação do AR associado com o Tipo de Ordem -- Caso não encontre o tipo de transação no tipo de ordem do OM IF r_order_type.cust_trx_type_id = 0 THEN SELECT NVL(oe_sys_parameters.value('OE_INVOICE_TRANSACTION_TYPE_ID', p_org_id), 0) --moac INTO r_order_type.cust_trx_type_id FROM DUAL; --l( 'CUSTOMER TRANSACTION TYPE ID FROM PROFILE : '||r_order_type.cust_trx_type_id); END IF; --code changes made for bug 1883552 end --l('Customer trx type id is:'||r_order_type.cust_trx_type_id); -- Busca informações da Moeda r_currency := NULL; OPEN c_currency(r_order_type.currency_code); FETCH c_currency INTO r_currency; CLOSE c_currency; -- Verifica se encontrou informações da Moeda IF r_currency.currency_code IS NULL THEN l('Moeda '||r_order_type.currency_code||' não encontrada'); END IF; r_ship_locinfo := NULL; IF p_ship_to_org_id IS NOT NULL THEN OPEN getlocinfo(p_ship_to_org_id); FETCH getlocinfo INTO r_ship_locinfo; CLOSE getlocinfo; -- Verifica se encontrou informações de entrega IF r_ship_locinfo.site_use_id IS NULL THEN l('Não encontrada informações para ship_to_org_id: '||p_ship_to_org_id); END IF; END IF; r_bill_locinfo := NULL; IF p_invoice_to_org_id IS NOT NULL THEN OPEN getlocinfo(p_invoice_to_org_id); FETCH getlocinfo INTO r_bill_locinfo; CLOSE getlocinfo; -- Verifica se encontrou informações de entrega IF r_bill_locinfo.site_use_id IS NULL THEN l('Não encontrada informações para invoice_to_org_id: '||p_invoice_to_org_id); END IF; END IF; -- Busca informações da Organização OPEN get_internal_loc(p_org_id); FETCH get_internal_loc INTO l_internal_org_location_id; CLOSE get_internal_loc; -- bug 4622791 IF p_ship_from_org_id IS NOT NULL THEN BEGIN SELECT location_id INTO l_ship_from_location_id FROM hr_all_organization_units hu WHERE hu.organization_id = p_ship_from_org_id; EXCEPTION WHEN OTHERS THEN px_return_status := C_ERROR; px_message_error := 'Organização ID '||p_ship_from_org_id||' não encontrado em hr_all_organization_units.'; RETURN; END; ELSE px_return_status := C_ERROR; px_message_error := 'Organização Depósito deve ser informada.'; RETURN; END IF; --l('l_ship_from_location_id: '||l_ship_from_location_id); -- bug 5061910: pass l_poo_party_id poa_party_id IF p_salesrep_id IS NOT NULL THEN BEGIN SELECT asgn.organization_id , hou.location_id INTO l_poo_party_id , l_poo_location_id FROM ra_salesreps_all sales , per_all_assignments_f asgn , hr_organization_units hou WHERE asgn.person_id = sales.person_id AND sales.salesrep_id = p_salesrep_id AND sales.org_id = p_org_id AND NVL(asgn.primary_flag, 'Y') = 'Y' AND hou.organization_id = asgn.organization_id AND l_tax_date BETWEEN NVL(asgn.effective_start_date,TO_DATE( '01011900', 'DDMMYYYY')) AND NVL(asgn.effective_end_date,TO_DATE( '31122199', 'DDMMYYYY')) AND assignment_type = 'E'; --l('l_poo_party_id: '||l_poo_party_id); --l('l_poo_location_id: '||l_poo_location_id); EXCEPTION WHEN OTHERS THEN l_poo_party_id := NULL; l_poo_location_id := NULL; --l('Informações não encontradas para p_salesrep_id: '||p_salesrep_id --||' e p_org_id: '||p_org_id); END; END IF; --bug6995051 BEGIN SELECT location_id INTO l_bill_from_location_id FROM hr_all_organization_units WHERE organization_id = p_org_id; EXCEPTION WHEN OTHERS THEN l_bill_from_location_id := NULL; END; --l('l_bill_from_location_id: '||l_bill_from_location_id); --l('l_poo_party_id: '|| l_poo_party_id); l_legal_entity_id := get_le_id(p_order_type_id => p_order_type_id , p_sold_to_customer_id => p_sold_to_org_id , p_bill_to_customer_id => r_bill_locinfo.cust_account_id , p_org_id => p_org_id , px_message_error => l_msg_data); --l('l_legal_entity_id: '||l_legal_entity_id); IF l_msg_data IS NOT NULL THEN px_return_status := C_ERROR; px_message_error := 'Erro ao chamar get_le_id. Erro: '||l_msg_data; RETURN; END IF; i := 1; zx_global_structures_pkg.init_trx_line_dist_tbl(i); zx_global_structures_pkg.trx_line_dist_tbl.APPLICATION_ID(i) := l_application_id; zx_global_structures_pkg.trx_line_dist_tbl.ENTITY_CODE(i) := l_entity_code_crsr; zx_global_structures_pkg.trx_line_dist_tbl.EVENT_CLASS_CODE(i) := l_event_class_code_crsr; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID(i) := l_header_id; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LEVEL_TYPE(i) := l_trx_level_type_crsr; zx_global_structures_pkg.trx_line_dist_tbl.INTERNAL_ORGANIZATION_ID(i) := p_org_id;--p_header_rec.org_id; zx_global_structures_pkg.trx_line_dist_tbl.EVENT_TYPE_CODE(i) := 'CREATE'; zx_global_structures_pkg.trx_line_dist_tbl.TRX_DATE(i) := SYSDATE; zx_global_structures_pkg.trx_line_dist_tbl.TRX_DOC_REVISION(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.LEDGER_ID(i) := l_AR_Sys_Param_Rec.set_of_books_id; zx_global_structures_pkg.trx_line_dist_tbl.TRX_CURRENCY_CODE(i) := r_order_type.currency_code;--p_header_rec.TRANSACTIONAL_CURR_CODE; zx_global_structures_pkg.trx_line_dist_tbl.CURRENCY_CONVERSION_DATE(i) := NULL;--p_header_rec.CONVERSION_RATE_DATE; zx_global_structures_pkg.trx_line_dist_tbl.CURRENCY_CONVERSION_RATE(i) := NULL;--p_header_rec.CONVERSION_RATE; zx_global_structures_pkg.trx_line_dist_tbl.CURRENCY_CONVERSION_TYPE(i) := NULL;--p_header_rec.CONVERSION_TYPE_CODE; zx_global_structures_pkg.trx_line_dist_tbl.MINIMUM_ACCOUNTABLE_UNIT(i) := r_currency.minimum_accountable_unit; zx_global_structures_pkg.trx_line_dist_tbl.PRECISION(i) := r_currency.precision; -- revisit the logic to derive legal_entity_id later when legal_entity_id approach is clarified. zx_global_structures_pkg.trx_line_dist_tbl.LEGAL_ENTITY_ID(i) := l_legal_entity_id; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.ESTABLISHMENT_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_TRX_NUMBER(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_NUMBER(i) := l_order_number;--p_header_Rec.order_number; zx_global_structures_pkg.trx_line_dist_tbl.TRX_DESCRIPTION(i) := NULL; -- VARCHAR2_240_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_COMMUNICATED_DATE(i) := NULL; -- DATE_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.BATCH_SOURCE_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.BATCH_SOURCE_NAME(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DOC_SEQ_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DOC_SEQ_NAME(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DOC_SEQ_VALUE(i) := NULL; -- VARCHAR2_240_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_DUE_DATE(i) := NULL; -- DATE_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_TYPE_DESCRIPTION(i) := NULL; -- VARCHAR2_240_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.FIRST_PTY_ORG_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.RECEIVABLES_TRX_TYPE_ID(i) := r_order_type.cust_trx_type_id; zx_global_structures_pkg.trx_line_dist_tbl.TAX_EVENT_CLASS_CODE(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TAX_EVENT_TYPE_CODE(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DOC_EVENT_STATUS(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DOCUMENT_SUB_TYPE(i) := NULL; -- VARCHAR2_240_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.SUPPLIER_TAX_INVOICE_NUMBER(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.SUPPLIER_TAX_INVOICE_DATE(i) := NULL; -- DATE_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.SUPPLIER_EXCHANGE_RATE(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TAX_INVOICE_DATE(i) := NULL; -- DATE_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TAX_INVOICE_NUMBER(i) := NULL; -- VARCHAR2_150_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.QUOTE_FLAG(i) := 'Y'; -- VARCHAR2_1_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.DEFAULT_TAXATION_COUNTRY(i) := NULL; -- VARCHAR2_2_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.CTRL_HDR_TX_APPL_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.CTRL_TOTAL_HDR_TX_AMT(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.PORT_OF_ENTRY_CODE(i) := NULL; -- VARCHAR2_30_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TAX_REPORTING_FLAG(i) := 'N'; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TAX_AMT_INCLUDED_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.COMPOUNDING_TAX_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.PROVNL_TAX_DETERMINATION_DATE(i) := NULL; -- DATE_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.INSERT_UPDATE_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_TRX_NUMBER(i) := NULL; -- VARCHAR2_150_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.START_EXPENSE_DATE(i) := NULL; -- DATE_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TRX_BATCH_ID(i) := NULL; -- NUMBER_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.RECORD_TYPE_CODE(i) := NULL; -- VARCHAR2_30_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TAX_PROCESSING_COMPLETED_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.APPLICATION_DOC_STATUS(i) := NULL; -- VARCHAR2_30_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.OVERRIDING_RECOVERY_RATE(i) := NULL; -- NUMBER_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TAX_CALCULATION_DONE_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.USER_UPD_DET_FACTORS_FLAG(i) := NULL; -- VARCHAR2_1_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.ICX_SESSION_ID(i) := NULL; -- NUMBER_tbl_type -- line level columns --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_CURRENCY_CODE(i) := NULL; -- VARCHAR2_15_tbl_type , --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_CURRENCY_CONV_DATE(i) := NULL; -- DATE_tbl_type , --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_CURRENCY_CONV_RATE(i) := NULL; -- NUMBER_tbl_type , --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_CURRENCY_CONV_TYPE(i) := NULL; -- VARCHAR2_30_tbl_type , --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_MAU(i) := NULL; -- NUMBER_tbl_type , --zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_PRECISION(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.LINE_INTENDED_USE(i) := NULL; -- VARCHAR2_240_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.INPUT_TAX_CLASSIFICATION_CODE(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.EXEMPTION_CONTROL_FLAG(i) := 'S'; --l_line_rec.TAX_EXEMPT_FLAG; zx_global_structures_pkg.trx_line_dist_tbl.EXEMPT_REASON_CODE(i) := NULL;--l_line_rec.TAX_EXEMPT_REASON_CODE; zx_global_structures_pkg.trx_line_dist_tbl.INTERFACE_ENTITY_CODE(i) := NULL; -- VARCHAR2_30_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.INTERFACE_LINE_ID(i) := NULL; -- NUMBER_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.HISTORICAL_TAX_CODE_ID(i) := NULL; -- NUMBER_tbl_type, zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_ID(i) := l_line_id;--l_line_rec.line_id; zx_global_structures_pkg.trx_line_dist_tbl.LINE_CLASS(i) := 'INVOICE'; zx_global_structures_pkg.trx_line_dist_tbl.LINE_LEVEL_ACTION(i) := 'CREATE'; zx_global_structures_pkg.trx_line_dist_tbl.TRX_SHIPPING_DATE(i) := SYSDATE;--l_trx_shipping_date; zx_global_structures_pkg.trx_line_dist_tbl.TRX_RECEIPT_DATE(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_TYPE(i) := 'LINE'; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DATE(i) := l_tax_date; zx_global_structures_pkg.trx_line_dist_tbl.TRX_BUSINESS_CATEGORY(i) := r_item.trx_business_category; zx_global_structures_pkg.trx_line_dist_tbl.LINE_INTENDED_USE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.USER_DEFINED_FISC_CLASS(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_AMT_INCLUDES_TAX_FLAG(i) := 'S'; zx_global_structures_pkg.trx_line_dist_tbl.LINE_AMT(i) := p_ordered_quantity*p_unit_selling_price; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_QUANTITY(i) := p_ordered_quantity; zx_global_structures_pkg.trx_line_dist_tbl.UNIT_PRICE(i) := p_unit_selling_price; zx_global_structures_pkg.trx_line_dist_tbl.EXEMPT_CERTIFICATE_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.EXEMPT_REASON(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CASH_DISCOUNT(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.VOLUME_DISCOUNT(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRADING_DISCOUNT(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRANSFER_CHARGE(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.TRANSPORTATION_CHARGE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.INSURANCE_CHARGE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.OTHER_CHARGE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_ID(i) := p_inventory_item_id; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_FISC_CLASSIFICATION(i):= l_product_fisc_classification; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_ORG_ID(i) := NVL(p_ship_from_org_id,l_inventory_org_id); zx_global_structures_pkg.trx_line_dist_tbl.UOM_CODE(i) := r_item.primary_uom_code; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_CODE(i) := r_item.segment1; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_CATEGORY(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_SIC_CODE(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.FOB_POINT(i) := NVL(p_fob_point_code, 'CIF'); zx_global_structures_pkg.trx_line_dist_tbl.SHIP_TO_PARTY_ID(i) := r_ship_locinfo.party_id; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_FROM_PARTY_ID(i):= p_ship_from_org_id; zx_global_structures_pkg.trx_line_dist_tbl.POA_PARTY_ID(i) := p_org_id; zx_global_structures_pkg.trx_line_dist_tbl.POO_PARTY_ID(i) := l_poo_party_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_TO_PARTY_ID(i) := r_bill_locinfo.party_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_FROM_PARTY_ID(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_TO_PARTY_SITE_ID(i) := r_ship_locinfo.party_site_id; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_FROM_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POA_PARTY_SITE_ID(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.POO_PARTY_SITE_ID(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.BILL_TO_PARTY_SITE_ID(i) := r_bill_locinfo.party_site_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_FROM_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_TO_LOCATION_ID(i) := r_ship_locinfo.location_id; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_FROM_LOCATION_ID(i) := l_ship_from_location_id; zx_global_structures_pkg.trx_line_dist_tbl.POA_LOCATION_ID(i) := l_internal_org_location_id; zx_global_structures_pkg.trx_line_dist_tbl.POO_LOCATION_ID(i) := l_poo_location_id ; zx_global_structures_pkg.trx_line_dist_tbl.BILL_TO_LOCATION_ID(i) := r_bill_locinfo.location_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_FROM_LOCATION_ID(i) := l_bill_from_location_id ; --bug6995051 zx_global_structures_pkg.trx_line_dist_tbl.ACCOUNT_CCID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ACCOUNT_STRING(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_COUNTRY(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ASSET_FLAG(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ASSET_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ASSET_ACCUM_DEPRECIATION(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ASSET_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ASSET_COST(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_LEVEL_ACTION(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_TAX_DIST_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_TAX_DIST_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TASK_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.AWARD_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.PROJECT_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.EXPENDITURE_TYPE(i) := NULL; -- VARCHAR2_30_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.EXPENDITURE_ORGANIZATION_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.EXPENDITURE_ITEM_DATE(i) := NULL; -- DATE_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DIST_AMT(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DIST_QUANTITY(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_CURR_CONV_RATE(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.ITEM_DIST_NUMBER(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_DIST_ID(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DIST_TAX_AMT(i) := NULL; -- NUMBER_tbl_type , zx_global_structures_pkg.trx_line_dist_tbl.ASSESSABLE_VALUE(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.OUTPUT_TAX_CLASSIFICATION_CODE(i) := r_order_type.tax_code; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID_LEVEL2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID_LEVEL3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID_LEVEL4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID_LEVEL5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_ID_LEVEL6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HDR_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY1(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY2(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY3(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY4(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY5(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.LINE_TRX_USER_KEY6(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_NUMBER(i) := l_trx_line_number; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DIST_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DIST_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.HISTORICAL_FLAG(i) :='N'; zx_global_structures_pkg.trx_line_dist_tbl.CTRL_HDR_TX_APPL_FLAG(i) :='N'; zx_global_structures_pkg.trx_line_dist_tbl.CTRL_TOTAL_LINE_TX_AMT(i) :=NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_DESCRIPTION(i) := r_item.description; zx_global_structures_pkg.trx_line_dist_tbl.PRODUCT_DESCRIPTION(i) := r_item.description; zx_global_structures_pkg.trx_line_dist_tbl.TRX_WAYBILL_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRX_LINE_GL_DATE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_NAME(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_DOCUMENT_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_REFERENCE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_TAXPAYER_ID(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.MERCHANT_PARTY_TAX_REG_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.PAYING_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.OWN_HQ_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRADING_HQ_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POI_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POD_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TITLE_TRANSFER_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.PAYING_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.OWN_HQ_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRADING_HQ_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POI_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POD_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TITLE_TRANSFER_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.PAYING_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.OWN_HQ_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TRADING_HQ_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POC_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POI_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.POD_LOCATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.TITLE_TRANSFER_LOCATION_ID(i):= NULL; -- Rounding parties not required for OM. No override of rounding level zx_global_structures_pkg.trx_line_dist_tbl.ROUNDING_SHIP_TO_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ROUNDING_SHIP_FROM_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ROUNDING_BILL_TO_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ROUNDING_BILL_FROM_PARTY_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RNDG_SHIP_TO_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RNDG_SHIP_FROM_PARTY_SITE_ID(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.RNDG_BILL_TO_PARTY_SITE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RNDG_BILL_FROM_PARTY_SITE_ID(i):= NULL; -- Ref_doc, applied_from, applied_to, related_doc are not applicable for OM zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_APPLICATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_EVENT_CLASS_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_HDR_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LIN_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_LINE_QUANTITY(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_APPLICATION_ID(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_EVENT_CLASS_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY1(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY2(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY3(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY4(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY5(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_HDR_TRX_USER_KEY6(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY1(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY2(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY3(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY4(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY5(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_LIN_TRX_USER_KEY6(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_DIST_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_FROM_DST_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_APPLICATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_EVENT_CLASS_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_TRX_ID(i) := NULL ; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_HDR_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_LIN_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_DIST_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJ_DOC_DST_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_DATE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_APPLICATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_EVENT_CLASS_CODE(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_HDR_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_TRX_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APP_TO_LIN_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_APPLICATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_EVENT_CLASS_CODE(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REL_DOC_HDR_TRX_USER_KEY6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.RELATED_DOC_DATE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_APPLN_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_EVNT_CLS_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_TRX_LEVEL_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REVERSED_TRX_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC7(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC8(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC9(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.NUMERIC10(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR7(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR8(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR9(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.CHAR10(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE1(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE7(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE8(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE9(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DATE10(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.internal_org_location_id(i) := l_internal_org_location_id; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_APPLICATION_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_ENTITY_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_EVENT_CLASS_CODE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_TRX_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_TRX_LEVEL_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.REF_DOC_TRX_LEVEL_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_TO_TRX_LEVEL_TYPE(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_TRX_LEVEL_TYPE(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.ADJUSTED_DOC_TRX_LEVEL_TYPE(i):= NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE1(i) := 'N'; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE2(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE3(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE4(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE5(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE6(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE7(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE8(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE9(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.DEFAULTING_ATTRIBUTE10(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SOURCE_TAX_LINE_ID(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.APPLIED_FROM_TRX_NUMBER(i) := NULL; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_THIRD_PTY_ACCT_SITE_ID(i) := r_ship_locinfo.cust_acct_site_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_THIRD_PTY_ACCT_SITE_ID(i) := r_bill_locinfo.cust_acct_site_id; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_TO_CUST_ACCT_SITE_USE_ID(i) := r_ship_locinfo.site_use_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_TO_CUST_ACCT_SITE_USE_ID(i) := r_bill_locinfo.site_use_id; zx_global_structures_pkg.trx_line_dist_tbl.SHIP_THIRD_PTY_ACCT_ID(i) := r_ship_locinfo.cust_account_id; zx_global_structures_pkg.trx_line_dist_tbl.BILL_THIRD_PTY_ACCT_ID(i) := r_bill_locinfo.cust_account_id; l_transaction_rec.application_id := l_application_id; l_transaction_rec.entity_code := l_entity_code_crsr; l_transaction_rec.event_class_code := l_event_class_code_crsr; l_transaction_rec.event_type_code := 'CREATE'; l_transaction_rec.trx_id := l_header_id; l_transaction_rec.internal_organization_id := p_org_id; zx_api_pub.calculate_tax( p_api_version => 1.0, p_init_msg_list => FND_API.G_TRUE, p_commit => NULL, p_validation_level => NULL, x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_transaction_rec => l_transaction_rec, p_quote_flag => 'Y', p_data_transfer_mode => 'PLS', x_doc_level_recalc_flag => l_doc_level_recalc_flag); -- Verifica se ocorreu algum erro IF l_return_status != FND_API.G_RET_STS_SUCCESS THEN px_return_status := C_ERROR; IF l_msg_count = 1 THEN -- there is one message raised by the API l(l_msg_data); IF l_msg_data is not null then px_message_error := l_msg_data; ELSE px_message_error := 'Erro indefinido na chamada da API zx_api_pub.calculate_tax'; END IF; ELSIF l_msg_count > 1 THEN LOOP l_msg_data := FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE); EXIT WHEN l_msg_data IS NULL; IF px_message_error IS NULL THEN px_message_error := l_msg_data; ELSE px_message_error := Substr(px_message_error || ' - '|| l_msg_data, 1, 2000); END IF; END LOOP; END IF; RAISE exit_excp; END IF; EXCEPTION WHEN exit_excp THEN ROLLBACK; WHEN OTHERS THEN ROLLBACK; px_return_status := C_ERROR; px_message_error := 'Erro inesperado. Erro: '||SQLERRM; END Calculate_Tax; BEGIN MO_GLOBAL.SET_POLICY_CONTEXT(p_access_mode => 'S', p_org_id => 81); -- Chama a rotina para carregar informações do imposto Calculate_Tax(p_org_id => 81 , p_order_type_id => 1370 , p_sold_to_org_id => 3592570 , p_organization_id => 115 , p_inventory_item_id => 11734850 , p_ship_from_org_id => 115 , p_ship_to_org_id => 112975 , p_invoice_to_org_id => 112974 , p_ordered_quantity => 5000 , p_unit_selling_price => 4.26 , p_fob_point_code => 'CIF' , p_salesrep_id => 100011117 , px_return_status => w_return_status , px_message_error => w_message_error); IF w_return_status != C_SUCCESS THEN l('ERRO: '||w_message_error); ELSE l('SUCESSO!'); END IF; END;
Se foi útil, ou se você apenas gostou, peço que compartilhe com seus contatos, poderá ser muito útil para eles.
Qualquer dúvida comenta aqui no blog.
Grande Abraço