Beruflich Dokumente
Kultur Dokumente
REM | Copyright (c) 1996, 2014 Oracle Corporation Redwood Shores, California, US
A|
REM |
All rights reserved.
|
REM +======================================================================+
REM NAME
REM
REM DESCRIPTION
REM
REM NOTES
REM
REM +======================================================================+
REM dbdrv: sql ~PROD ~PATH ~FILE none none none sqlplus &phase=plb+2 checkfile(1
20.13.12010000.18=120.30):~PROD:~PATH:~FILE
SET VERIFY OFF
WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
WHENEVER OSERROR EXIT FAILURE ROLLBACK;
CREATE OR REPLACE PACKAGE BODY jai_cmn_tax_defaultation_pkg AS
/* $Header: jai_cmn_tax_dflt.plb 120.38.12020000.10 2014/02/26 12:55:11 vkaranam
ship $ */
/*Bug 8371741 - Start*/
PROCEDURE get_created_from
(
p_header_id
IN NUMBER,
p_created_from OUT NOCOPY VARCHAR2
) IS
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
select jat.created_from into p_created_from
from JAI_AR_TRXS jat
where jat.customer_trx_id = p_header_id;
END;
/*Bug 8371741 - End*/
/*
Bug 8241905 - Added the procedure to get the quantity from the parent requistion
line to split the taxes in the child lines
Used Autonomous transaction as po_requistion_lines_all needs to be queried
*/
PROCEDURE ja_in_po_get_reqline_p
(
p_req_line_id IN NUMBER,
p_prev_quantity OUT NOCOPY NUMBER
) IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
select quantity into p_prev_quantity
from po_requisition_lines_all
where requisition_line_id = p_req_line_id;
END;
PROCEDURE ja_in_cust_default_taxes (
p_org_id NUMBER,
p_customer_id NUMBER,
p_ship_to_site_use_id NUMBER,
p_inventory_item_id IN NUMBER,
p_header_id NUMBER,
p_line_id NUMBER,
p_tax_category_id IN OUT NOCOPY NUMBER
)
IS
v_address_id
v_tax_category_list
v_tax_category_id
NUMBER;
VARCHAR2(30);
NUMBER;
endor_default_taxes';
-- to get tax_category_list
CURSOR tax_catg_list_cur(p_vendor_id IN NUMBER, p_vendor_site_id IN NUMBER
DEFAULT 0) IS
SELECT tax_category_list
FROM JAI_CMN_VENDOR_SITES A
WHERE a.vendor_id = p_vendor_id
AND a.vendor_site_id = p_vendor_site_id;
-- to get tax_category_id
CURSOR tax_catg_id_cur(p_tax_category_list IN VARCHAR2, p_inventory_item_id
IN NUMBER) IS
SELECT tax_category_id
FROM JAI_INV_ITM_TAXCTG_DTLS a
WHERE a.tax_category_list = p_tax_category_list
AND a.inventory_item_id = p_inventory_item_id;
BEGIN
IF p_vendor_id IS NOT NULL AND p_vendor_site_id IS NOT NULL THEN
OPEN tax_catg_list_cur(p_vendor_id, p_vendor_site_id);
FETCH tax_catg_list_cur INTO v_tax_category_list;
CLOSE tax_catg_list_cur;
END IF;
IF v_tax_category_list IS NULL THEN
OPEN tax_catg_list_cur(p_vendor_id,0);
FETCH tax_catg_list_cur INTO v_tax_category_list;
CLOSE tax_catg_list_cur;
END IF;
IF v_tax_category_list IS NOT NULL THEN
OPEN tax_catg_id_cur(v_tax_category_list ,p_inventory_item_id );
FETCH tax_catg_id_cur INTO v_tax_category_id;
CLOSE tax_catg_id_cur;
-- ELSE redundant code
-- ja_in_org_default_taxes(p_org_id, p_inventory_item_id, v_tax_category_id
);
END IF;
IF NVL(v_tax_category_id,0) = 0 THEN
/* REDUNDANT CODE
OPEN tax_catg_list_cur(p_vendor_id,0);
FETCH tax_catg_list_cur INTO v_tax_category_list;
CLOSE tax_catg_list_cur;
IF v_tax_category_list IS NOT NULL THEN
OPEN tax_catg_id_cur(v_tax_category_list ,p_inventory_item_id );
FETCH tax_catg_id_cur INTO v_tax_category_id;
CLOSE tax_catg_id_cur;
ELSE
ja_in_org_default_taxes(p_org_id, p_inventory_item_id, v_tax_categor
y_id);
END IF;
IF NVL(v_tax_category_id,0) = 0 THEN
ja_in_org_default_taxes(p_org_id, p_inventory_item_id, v_tax_categor
y_id);
END IF;
*/
ja_in_org_default_taxes(p_org_id, p_inventory_item_id, v_tax_category_id
);
END IF;
p_tax_category_id := v_tax_category_id;
/* Added by Ramananda for bug#4407165 */
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.SET_NAME('JA','JAI_EXCEPTION_OCCURED');
FND_MESSAGE.SET_TOKEN('JAI_PROCESS_MSG', lv_object_name ||'. Err:'||sqlerr
m );
app_exception.raise_exception;
END ja_in_vendor_default_taxes;
---------------******************JA_IN_ORG_DEFAULT_TAXES******************-------------------PROCEDURE ja_in_org_default_taxes(
p_org_id
NUMBER,
p_inventory_item_id IN
NUMBER,
p_tax_category_id IN OUT NOCOPY NUMBER
) IS
/*----------------------------------------------------------------------------------------CHANGE HISTORY:
Sl. YYYY/MM/DD Author and Details
----------------------------------------------------------------------------------------1 2004/09/22 Aiyer for bug#3792765. Version#115.2
Issue
Warehouse ID is not currently being allowed to be left null from the ba
se apps sales order. When placing a order from 2
different manufacturing organizations, it is required that customer tem
porarily leaves the warehouseid as Null and then
updates the same before pick release. However this is currently not all
owed by localization even though base
apps allows this feature.
Reason:The trigger ja_in_oe_order_lines_aiu_trg raises an error of warehouse n
ot found when the value of warehouse_id goes as
null from the form.
Solution:Removed this part from the trigger ja_in_oe_order_lines_aiu_trg. The pr
ocedure jai_cmn_tax_defaultation_pkg.ja_in_org_default_taxes has been modified
for the same.
During tax defaultation, if the tax category list is not found in the c
ustomer/customer site level then it is being picked up from the
item class level. Now in cases where the warehouseid is left blank in t
he base apps sales order form, the tax category id from the
master organization set for the default operating unit is picked up for
further processing
p_currency_conv_factor NUMBER,
p_creation_date
DATE,
p_created_by
NUMBER,
p_last_update_date
DATE,
p_last_updated_by
NUMBER,
p_last_update_login
NUMBER,
p_operation_flag
NUMBER DEFAULT NULL , -- for CRM this is used to
hold aso_shipments.shipment_id
p_vat_assessable_value NUMBER DEFAULT 0
/** bgowrava for forward porting bug#5631784,Following parameters are ad
ded for TCS enh.*/
, p_thhold_cat_base_tax_typ JAI_CMN_TAXES_ALL.tax_type%type default null -- t
ax type to be considered as base when calculating threshold taxes
, p_threshold_tax_cat_id
JAI_AP_TDS_THHOLD_TAXES.tax_category_id%type defau
lt null
, p_source_trx_type
jai_cmn_document_taxes.source_doc_type%type defaul
t null
, p_source_table_name
jai_cmn_document_taxes.source_table_name%type defa
ult null
, p_action
varchar2 default null
/** End bug 5631784 */
, pv_retroprice_changed IN VARCHAR2 DEFAULT 'N' --Added by Kevin Cheng for Ret
roactive Price 2008/01/13
, p_modified_by_agent_flag po_requisition_lines_all.modified_by_agent_flag%ty
pe default NULL /*Added for Bug 8241905*/
, p_parent_req_line_id
po_requisition_lines_all.parent_req_line_id%type d
efault NULL /*Added for Bug 8241905*/
, p_max_tax_line
NUMBER DEFAULT 0 /*Added for Bug 8371741*/
, p_max_rgm_tax_line
NUMBER DEFAULT 0 /*Added for Bug 8371741*/
--, pn_gst_assessable_value
NUMBER DEFAULT 0 -- Added by Jia for GST Bug#1
0043656 on 2010/09/10
, pn_customs_assessable_value NUMBER DEFAULT 0 --Added by Bo Li for Bug#11
684111 BOE Ehancement
) IS
--TYPE num_tab IS TABLE OF NUMBER(30,3) INDEX BY BINARY_INTEGER; -- sriram bug # 2812781 was 14 eaerler changed to 30
--TYPE tax_amt_num_tab IS TABLE OF NUMBER(30,3) INDEX BY BINARY_INTEGER; -sriram - bug # 2812781 was 14 eaerler changed to 30
-- Date 02/11/2006 Bug 5228046 added by SACSETHI
TYPE num_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE tax_amt_num_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE tax_adhoc_flag_tab IS TABLE OF VARCHAR2(2) INDEX BY BINARY_INTEGER;
/* rchandan bug#6030615 */
--added by Walton for inclusive tax 07-Dev-07
--------------------------------------------TYPE char_tab IS TABLE OF VARCHAR2(10)
INDEX BY BINARY_INTEGER;
lt_adhoc_tax_tab
CHAR_TAB;
lt_inclusive_tax_tab
CHAR_TAB;
ln_exclusive_price
NUMBER;
lt_tax_rate_per_rupee
NUM_TAB;
lt_cumul_tax_rate_per_rupee NUM_TAB;
ln_total_non_rate_tax
NUMBER :=0;
ln_total_inclusive_factor NUMBER;
lt_tax_amt_rate_tax_tab TAX_AMT_NUM_TAB;
lt_tax_amt_non_rate_tab TAX_AMT_NUM_TAB;
ln_bsln_amt_nr
NUMBER :=0;
ln_tax_amt_nr
NUMBER(38,10) :=0;
ln_vamt_nr
NUMBER(38,10) :=0;
ln_total_tax_per_rupee
NUMBER;
ln_assessable_value
NUMBER;
ln_vat_assessable_value NUMBER;
------------------------------------------------ln_gst_assessable_value NUMBER; -- Added by Jia for GST Bug#10043656 o
n 2010/09/10
base_tax_amount_nr_tab tax_amt_num_tab; --added by Xiao Lv for bug#8789761
ln_amount NUMBER; --Added shujuan for bug
ln_customs_assessable_value NUMBER; --Added by Bo Li for Bug#11684111 B
OE Ehancement
/* Added by Ramananda for bug#4407165 */
lv_object_name CONSTANT VARCHAR2(61) := 'jai_cmn_tax_defaultation_pkg.ja_in_
calc_prec_taxes';
p1
p2
p3
p4
p5
NUM_TAB;
NUM_TAB;
NUM_TAB;
NUM_TAB;
NUM_TAB;
v_conversion_rate
NUMBER; -- := 0; --Ramananda for File.Sql.35
v_currency_conv_factor NUMBER; -- := p_currency_conv_factor; --Ramananda f
or File.Sql.35
-- Date 01/11/2006 Bug 5228046 added by SACSETHI
-- v_tax_amt
465
-- v_func_tax_amt
-- vamt
v_tax_amt
v_func_tax_amt
vamt
v_amt
row_count
counter
max_iter
v_excise_jb
number;
number;
number ;
number;
v_modvat_flag
e
lv_recalculation_sql varchar2 (4000);
ln_exists
number (2);
ln_prev_quantity
NUMBER;
/*Bug 8241905*/
ln_tax_modified_flag VARCHAR2(1); /*Bug 8241905*/
ln_rounding_factor
NUMBER;
/*Bug 8241905*/
l_created_from
VARCHAR2(10); /*Bug 8371741*/
/*
|| Cursor will check if the given tax_categories have common taxes
*/
cursor c_chk_tax_duplication
is
select 1
from JAI_CMN_TAX_CTG_LINES
where tax_category_id in (p_tax_category_id, nvl(p_threshold_tax_cat
_id,-1))
group by tax_id
having count(tax_id) > 1;
cursor c_get_max_tax_line
is
select max(line_no) max_tax_line
from JAI_CMN_TAX_CTG_LINES cat
where cat.tax_category_id = p_tax_category_id;
cursor c_get_max_rgm_tax_line
is
select max(line_no) max_rgm_tax_line
from JAI_CMN_TAX_CTG_LINES cat, JAI_CMN_TAXES_ALL taxes
where cat.tax_category_id = p_tax_category_id
and
taxes.tax_id = cat.tax_id
and
taxes.tax_type = p_thhold_cat_base_tax_typ;
/** End Bug#5631784*/
CURSOR tax_cur(p_tax_category_id IN NUMBER) IS
SELECT a.tax_category_id, a.tax_id, a.line_no lno,
a.precedence_1 p_1, a.precedence_2 p_2,
a.precedence_3 p_3, a.precedence_4 p_4,
a.precedence_5 p_5, a.precedence_6 p_6, -- Date 31/10/2006 Bug 5228046 add
ed by SACSETHI
a.precedence_7 p_7, a.precedence_8 p_8,
a.precedence_9 p_9, a.precedence_10 p_10,
b.tax_rate, b.tax_amount, b.uom_code, b.end_date valid_date,
DECODE(rgm_tax_types.regime_Code,jai_constants.vat_regime, 4, /* ad
ded by ssumaith - bug# 4245053*/
/*jai_constants.cgst_regime, 7, -Added by Jia for GST Bug#10043656 on 2010/09/10
jai_constants.sgst_regime, 7, --Ad
ded by Jia for GST Bug#10043656 on 2010/09/10*/
jai_constants.customs_regime, 8,
--Added by Bo Li for Bug#11684111 BOE Ehancement
DECODE(UPPER(b.tax_type),
'EXCISE',
1,
'ADDL. EXCISE',
1,
'OTHER EXCISE',
1,
'TDS',
2,
'EXCISE_EDUCATION_CESS' ,1,
'CVD_EDUCATION_CESS'
,1,
0
)
) tax_type_val,
b.mod_cr_percentage, b.vendor_id, b.tax_type,nvl(b.rounding_factor,0
) rounding_factor
, inclusive_tax_flag --added by walton for inclusive tax 08-Dev-07
FROM JAI_CMN_TAX_CTG_LINES a, JAI_CMN_TAXES_ALL b ,
jai_regime_tax_types_v rgm_tax_types /* added by ssumaith - bug#
4245053*/
WHERE a.tax_category_id = p_tax_category_id
AND rgm_tax_types.tax_type (+) = b.tax_type /* added by ssumaith - bug
# 4245053*/
AND a.tax_id = b.tax_id
-- AND (b.end_date >= sysdate OR b.end_date IS NULL)
ORDER BY A.line_no;
CURSOR uom_class_cur(p_line_uom_code IN VARCHAR2, p_tax_line_uom_code IN VAR
CHAR2) IS
SELECT a.uom_class
NUMBER;
VARCHAR2(10);
lv_tax_type
ancement
lv_boe_flag
v_tax_uom_code
v_tax_line_no
BEGIN
/*******************************************************************************
******************************************
/*--------------------------------------------------------------------------------------------------------------------CHANGE HISTORY:
Procedure ja_in_calc_prec_taxes
S.No
Date
Author and Details
----------------------------------------------------------------------------------------------------------------------1.
12/07/2003
ai_om_tax.plb.
5. 24-Jan-2007
bgowrava for forward porting bug#5631784, File Version 120.3
- TCS Enhancement
Issue:
1. As a part of TCS enh. there was a requirement to defau
lt taxes using the tax category attached to
threshold setup for TCS regime in the India-Threshold setu
p UI.
2. Package should provide an API for inserting taxes in t
o new table jai_cmn_document_taxes
Fix:
To support above functionalities the following approach i
s used.
1. New parameters are added to this procedure to get th
e tax category defined for threshold limit.
(Please refer the procedure signature)
2. Whenever p_threshold_tax_cat_id is not NULL then it
means taxes from two categories needs to be merged.
one using p_tax_category_id and other is p_threshold
_tax_cat_id
3. current driving cursor (tax_cur) is modified to hand
le multiple tax categories.
3.1 For all the tax lines defined in the p_tax_cate
gory_id there is no change
3.2 For all the tax lines defined in the p_threshol
d_tax_cat_id, line_no will be changed
to ln_max_tax_line + line_no where ln_max_tax_l
ine is the maximum of line numbers for
tax lines defined in p_tax_category_id
3.3 All the precedences defined in p_threshold_tax_
cat_id will be changed as following
- If precedence refers to base precedence (i.e
. 0) it will be changed to ln_max_rgm_tax_line
where ln_max_rgm_tax_line is maximum of the
line numbers of taxes having
tax_type = p_thhold_cat_base_tax_typ (i.e. t
ax type to be considered as a base tax
when calculating threshold taxes defined usi
ng p_threshold_tax_cat_id)
S TYPE OF TAXES
Fix: Modified the code in the procedure ja_in_calc_prec_taxes.
Added a new table type variable line_no_tab
to store the line number of the tax lines. Further added
a code to initialize the tax_amt_tab table
for surcharge taxes.
14. 19-Mar-2010 Walton for bug#9288016, File Version 120.13.12010000.10
Issue: Function tax amount column is not populated correctly
Fix: in the old code, function tax amount only cover rate amou
nt, when the taxes is computed based on assessable
value, non-rate amount is not getting summed, so the fix
is to re-assign function base amount once tax amount
is computed.
15. 19-Mar-2010 JMEENA for bug#9489492
Modified the dynamic query lv_recalculation_sql and changed the
order of columns $$EXTRA_SELECT_COLUMN_LIST$$ and inclusive_tax_flag
as inclusive_tax_flag is last column in the record type.
16 10-JUN-2010 Bo Li for Bug#9780751
Issue - Round factor of vat tax is 0. But the accounting entry amount insert
ed into gl_interface table has 2 bit demical.
Fix - Set the same round factor to the functional tax amount which is used
in the gl_interface table
17. 27-aug-2010 vkaranam for bug#9692478
Issue : EXCISE CESS AND SHECESS TAXES NOT GETTING CALCULATED C
ORRECTLY ON ORDER SPLIT
Issue is due to the base tax amount not calculated correctly.
Fix:
base_tax_amount_nr_tab has been initalized correctly .
18. 10-Sep-2010 Jia for GST Bug#10043656.
19. 11-Mar-2011 Bo Li for BOE Enhancement bug#11684111
20. 16-Jan-2012 Qinglei for Bug#13547239
Issue: FUNCTIONAL TAX AMOUNT IN INDIA LOCALIZATION TAXES UI IS
INACCURATE
Fix: Rounded the functional tax amount before insert into jai_
cmn_document_taxes.
21. 07-Jun-2012 mmurtuza for bug 14591926
Issue: TAX CALCUALTION IS GOING WRONG WITH INCLUSIVE TAXES
Fix: While calculating the tax amount for exclusive taxes, added conditi
on to check if the corresponding tax line no of precedence of
exclusive tax is inclusive.
22. 27-Sep-2012 mmurtuza for bug 14675629
Issue: IN SHIP CONFIRM LOCALIZED FORM, WRONG TCS TAX AMOUNTS GETTING DEF
AULTED
Fix: Added b.tax_amount in lv_recalculation_sql and assigned it to qty_r
ate_tab(row_count)
23. 17-Jan-2012 mmurtuza for bug 16172861
Issue: INDIA LOC:INCLUSIVE CST TAX AMOUNT CALCULATED WRONGLY IN MANY SAL
ES ORDER
Fix: Added condition while calcualting ln_vamt_nr. If ln_bsln_amt_nr = 0
, only then p_tax_amount is added
24. 24-Apr-2013 mmurtuza for bug 16656728
Issue: APP-JA-460633 ERROR ENCOUNTERED IN TRANSACTION WORKBENCH
Fix: Added code to prevent adhoc taxes from becoming zero
25. 19-Dec-2013 nkodakan for bug 17831734
Issue : TAXES ARE CALCULATED BASED ON SO UOM INSTEAD OF PRIMARY UO
M CONVERSION CLASS DEF
Fix : Added a cursor get_tax_uom_code to fetch the uom_code from
jai_cmn_taxes_all and if tax uom is not equal to transaction uom then multiply w
ith
the proper conversion rate.
Future Dependencies For the release Of this Object:(Please add a row in the section below only if your bug introduces a dependency
due to spec change/ A new call to a object/
A datamodel change )
--------------------------------------------------------------------------------------------------------------------------------------------------Current Version
Current Bug
Dependent
Files
4245053
ssumaith
IN60106 +
Service Tax and VAT Infrastructure are created
4146708 +
based on the bugs - 4146708 and 4545089 respecti
vely.
4245089
********************************************************************************
*****************************************/
--Added by Kevin Cheng for Retroactive Price 2008/01/13
--=====================================================
IF pv_retroprice_changed = 'N'
THEN
--=====================================================
--Ramananda for File.Sql.35
bsln_amt := p_tax_amount ;
v_conversion_rate := 0;
v_currency_conv_factor := p_currency_conv_factor;
ln_base := 0 ;
IF transaction_name <> 'CRM_QUOTE' THEN
0
IF v_debug THEN fnd_file.put_line(fnd_file.log, ' transaction_name -> '|
|transaction_name); END IF;
--2001/03/30 Manohar Mishra
/*Start of Addition*/
OPEN get_header_info_cur;
FETCH get_header_info_cur INTO v_organization_id, v_location_id, v_batch
_source_id;
CLOSE get_header_info_cur;
OPEN get_register_code_cur(v_organization_id, v_location_id, v_batch_sou
rce_id);
FETCH get_register_code_cur INTO v_register_code;
CLOSE get_register_code_cur;
-- Vijay Shankar for Bug# 2837970
ELSE
-- this should get executed when tax defaultation is for CRM_QUOTE
v_register_code := null;
END IF;
--2001/03/30 Manohar Mishra
/*End of Addition*/
/*Bug 8241905 - Start*/
/*
Fetch Tax modified flag of the parent line to check if taxes defaulte
d based on
Tax Category attached to Vendor or Item have been modified. If 'Y' th
en the new
taxes need to be used to calculate taxes of child lines else the norm
al defaultation
c_req_tax_lines.uom,
round((c_req_tax_lines.tax_amount * p_line_quantity)/ln
_prev_quantity, ln_rounding_factor),
round((c_req_tax_lines.Tax_Target_Amount * p_line_quant
ity)/ln_prev_quantity, ln_rounding_factor),
c_req_tax_lines.tax_type, c_req_tax_lines.modvat_flag,
c_req_tax_lines.vendor_id,
c_req_tax_lines.currency,
c_req_tax_lines.creation_date, c_req_tax_lines.created_
by, c_req_tax_lines.last_update_date,
c_req_tax_lines.last_updated_by, c_req_tax_lines.last_u
pdate_login,
c_req_tax_lines.tax_category_id
);
end loop;
end if;
/*Bug 8241905 - End*/
/** bgowrava for forward porting bug#5631784*/
if
((p_tax_category_id is null
and (p_threshold_tax_cat_id is null or p_threshold_tax_cat_id <0)) or
ln_tax_modified_flag = 'Y') then
/*
Bug 8241905 - Added ln_tax_modified_flag = 'Y' to prevent taxes defau
lting in child lines from parent tax_category_id
when the taxes are modified in the parent line. The modified taxes ne
ed to used to calculate
taxes in child lines
*/
/** Both driving parameter tax_category_id and threshol_tax_category
_id are invalid hence no need to do anything */
return;
end if;
if
nvl(p_action, jai_constants.default_taxes) = jai_constants.default
_taxes then
/** Assign tax defaultation cursor object to refc_tax_cur reference by
using. Call to get_tax_cat_taxes_cur will return
a reference cursor */
if p_threshold_tax_cat_id is not null and p_threshold_tax_cat_id > 0 t
hen
/*
|| Cursor to check if same taxes exists in both tax categories
*/
ln_dup_tax_exists := null;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Open/Close/Fetch cur
sor c_chk_tax_duplication');*/ --commented by bgowrava for bug#5631784
open c_chk_tax_duplication;
fetch c_chk_tax_duplication into ln_dup_tax_exists;
close c_chk_tax_duplication;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'ln_dup_tax_exists='|
|ln_dup_tax_exists);*/ --commented by bgowrava for bug#5631784
if ln_dup_tax_exists is not null
or (nvl(p_threshold_tax_cat_id,-1) = p_tax_category_id)
then
fnd_message.set_name('JA', 'JAI_DUP_TAX_IN_TAX_CAT');
app_exception.raise_exception ;
end if;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Open/Close/Fetch cur
sor c_get_max_tax_line');*/ --commented by bgowrava for bug#5631784
open c_get_max_tax_line;
fetch c_get_max_tax_line into ln_max_tax_line;
close c_get_max_tax_line ;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Open/Close/Fetch cur
sor c_get_max_rgm_tax_line');*/ --commented by bgowrava for bug#5631784
open c_get_max_rgm_tax_line;
fetch c_get_max_rgm_tax_line into ln_max_rgm_tax_line;
close c_get_max_rgm_tax_line ;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'ln_max_tax_line='||l
n_max_tax_line||', ln_max_rgm_tax_line='||ln_max_rgm_tax_line);*/ --commented by
bgowrava for bug#5631784
end if;
/*Bug 8371741 - Start*/
if ln_max_rgm_tax_line IS NULL then
ln_max_rgm_tax_line := p_max_rgm_tax_line;
ln_max_tax_line := p_max_tax_line;
end if;
/*Bug 8371741 - End*/
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Opening ref cursor');*
/ --commented by bgowrava for bug#5631784
get_tax_cat_taxes_cur ( p_tax_category_id
=> p_tax_category_id
, p_threshold_tax_cat_id => p_threshold_tax_c
at_id
, p_max_tax_line
=> ln_max_tax_line
, p_max_rgm_tax_line
=> ln_max_rgm_tax_li
ne
, p_refc_tax_cat_taxes_cur => refc_tax_cur
);
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Cursor is opened');*/
--commented by bgowrava for bug#5631784
elsif p_action = jai_constants.recalculate_taxes then
/**
Following is a dynamic sql string which can be modifed as per requir
ement
The sql has four place holders defined as below
$$EXTRA_SELECT_COLUMN_LIST$$
- Use this place holder to select a
dditional columns in the sql.
You must also change corrospondin
g fetch statements and the record being used for fetch.
SELECT statement above should als
o be changed to include the newly added columns
as they are sharing a common curs
or and fetch record.
$$TAX_SOURCE_TABLE$$
be replaced with name of
culation
$$SOURCE_TABLE_FILTER$$
t represent a boolean condition
, 2
, ''EXCISE
_EDUCATION_CESS'',6 --modified by walton for inclusive tax
, '''||JAI
_CONSTANTS.TAX_TYPE_SH_EXC_EDU_CESS||''' , 6 /*bduvarag for the bug#5989740*/ -modified by walton for inclusive tax
, ''CVD_ED
UCATION_CESS'' ,6 --modified by walton for inclusive tax
, '''||JAI
_CONSTANTS.TAX_TYPE_SH_CVD_EDU_CESS||''' , 6 /*bduvarag for the bug#5989740*/ -modified by walton for inclusive tax
, 0
)
)
tax_type_val
, b.mod_cr_percentage
, b.vendor_id
, b.tax_type
, nvl(b.rounding_factor,0) rounding_factor
, b.adhoc_flag
$$EXTRA_SELECT_COLUMN_LIST$$
,b.inclusive_tax_flag --added by walton for inclusive tax on
08-Dev-07,--Added inclusive_tax_flag in end as it is last column in record type.
by JMEENA for bug#9489492
from $$TAX_SOURCE_TABLE$$
a
, JAI_CMN_TAXES_ALL
b
, jai_regime_tax_types_v rttv
where $$SOURCE_TABLE_FILTER$$
and rttv.tax_type (+) = b.tax_type
and a.tax_id = b.tax_id $$ADDITIONAL_WHERE_CLAUSE$$
order by a.tax_line_no $$ADDITIONAL_ORDER_BY$$';
/** No extra columns required. Dummy column (NULL) tax_category_id ne
eds to be added in the last as same record (rec) is being used
when fetching the cursor. If there is a need to override this de
fault behaviour then please replace these place holder with
desired strings which can be evaluated at runtime by sql-engine
*/
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$EXTRA_SELECT_COLUMN_LIST$$'
, ',null tax_category_id'
);
/** No additional filtering required */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$ADDITIONAL_WHERE_CLAUSE$$'
, ''
);
/** No additional sorting required */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$ADDITIONAL_ORDER_BY$$'
, ''
);
if upper(p_source_trx_type) = jai_constants.source_ttype_delivery then
jai_constants.G_AP_STANDALONE_INVOICE
THEN
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, 'a.tax_amount'
, 'a.tax_amt'
);
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_CMN_DOCUMENT_TAXES'
);
-- replace join condition
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.SOURCE_DOC_LINE_ID = ' || p_line_id ||
' and SOURCE_DOC_TYPE ='''||
jai_constants.G_AP_STANDALONE_INVOICE || ''''
);
-- Added by Zhiwei Hou for Bug#13359892 DTC enhancement on 2011/11/28 b
egin
---------------------------------------------------------------------ELSIF upper(p_source_trx_type) = 'TDS INVOICE'
THEN
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, 'a.tax_id'
, 'a.actual_tax_id'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, 'a.tax_rate'
, 'b.tax_rate'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, 'nvl(b.rounding_factor,0) rounding_factor'
, 'nvl(b.rounding_factor,99) rounding_factor'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_AP_TDS_INV_TAXES'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, ' a.invoice_id=' || p_header_id || ' and a.INVOICE_DISTRIB
UTION_ID = ' || p_line_id
);
-----------------------------------------------------------------------Added by Zhiwei Hou for Bug#13359892 DTC enhancement on 2011/11/28 end
-----------------------------------------------------------------------Added by Bo Li for bug#11684111 BOE Enhancement Begin
-------------------------------------------------------ELSIF transaction_name = 'BOE_INVOICE_UPDATE'
THEN
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'jai_boe_detail_taxes'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.boe_detail_id = '||p_line_id
);
----------------------------------------Added by Bo Li for bug#11684111 BOE Enhancement End
end if; /*pv_tax_source_table*/
/**
When control comes here, a valid sql statement hold by variable lv
_recalculate_sql
must be ready to execute.
open a dynamic select statement using OPEN-FOR statement
*/
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'TAX RECALCULATION SQL
STATEMENT');
jai_cmn_debug_contexts_pkg.print (ln_reg_id, lv_recalculation_sql);
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Opening ref cursor with
dynamic sql'); */--commented by bgowrava for bug#5631784
open refc_tax_cur for lv_recalculation_sql;
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Cursor is opened with
lv_recalculation_sql');*/ --commented by bgowrava for bug#5631784
end if; /** RECALCULATE */
/** Clear the tax table */
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Before fetching cursor r
ows and starting loop');*/ --commented by bgowrava for bug#5631784
lt_tax_table.delete;
loop
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'In Loop, row_count='||
row_count||', lt_tax_table.count='||lt_tax_table.count);*/ --commented by bgowra
va for bug#5631784
fetch refc_tax_cur into rec;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Post Fetch refc_tax_cu
r, rec.tax_id='||rec.tax_id||', rec.tax_rate='||rec.tax_rate);*/ --commented by
bgowrava for bug#5631784
exit when refc_tax_cur%notfound;
/** Add current record in the lt_tax_table for future use at the time of eit
her UPDATE or INSERT into the tables*/
--FOR rec IN tax_cur(p_tax_category_id) LOOP
lt_tax_table(lt_tax_table.count+1) := rec;
p1(row_count) := nvl(rec.p_1,-1);
p2(row_count) := nvl(rec.p_2,-1);
p3(row_count) := nvl(rec.p_3,-1);
p4(row_count) := nvl(rec.p_4,-1);
p5(row_count) := nvl(rec.p_5,-1);
p6(row_count) := nvl(rec.p_6,-1); -- Date 31/10/2006 Bug 5228046 added b
y SACSETHI ( added column from Precedence 6 to 10 )
p7(row_count) := nvl(rec.p_7,-1);
p8(row_count) := nvl(rec.p_8,-1);
p9(row_count) := nvl(rec.p_9,-1);
p10(row_count) := nvl(rec.p_10,-1);
tax_rate_tab(row_count) := NVL(rec.tax_rate,0);
line_no_tab(row_count) := rec.lno; --added for bug#9214366
--added by walton for inclusive tax on 08-Dev-07
----------------------------------------------------------------lt_tax_rate_per_rupee(row_count):=NVL(rec.tax_rate,0)/100;
ln_total_tax_per_rupee:=0;
lt_inclusive_tax_tab(row_count):=NVL(rec.inclusive_tax_flag,'N');
lt_tax_amt_rate_tax_tab(row_count):=0;
lt_tax_amt_non_rate_tab(row_count):=0;
-----------------------------------------------------------------lt_adhoc_tax_tab(row_count) := nvl(rec.adhoc_flag, 'N'); /*Added
by mmurtuza for bug 16656728*/
/*
|| The following code added by aiyer for the bug 4691616
|| Purpose:
|| rec.tax_rate = 0 means that tax_rate for such a tax line is actually
zero (i.e it is not a replacement of null value)
|| So, when rec.tax_rate = 0, tax_rate_zero_tab is populated with -9999
to identify that this tax_line actually has tax_rate = 0
|| To calculate the BASE_TAX_AMOUNT of the taxes whose tax_rate is zero
*/
IF rec.tax_rate is null THEN
/*
||Indicates qty based taxes
*/
tax_rate_zero_tab(row_count) := 0;
ELSIF rec.tax_rate = 0 THEN
/*
||Indicates 0% tax rate becasue a tax can have a rate as 0%.
*/
tax_rate_zero_tab(row_count) := -9999;
ELSE
tax_rate_zero_tab(row_count) := rec.tax_rate;
END IF;
tax_type_tab(row_count) := rec.tax_type_val;
qty_rate_tab(row_count) := rec.qty_rate; /*Added by mmurtuza for bug 14
675629*/
/*End of bug 4691616 */
-- tax_amt_tab(row_count) := 0;
/*added for bug#6498072, start*/
IF p_action = jai_constants.recalculate_taxes AND --recalculate_taxes
NVL(rec.adhoc_flag,'N') = 'Y'
--adhoc_flag='Y'
THEN
tax_amt_tab(row_count) := nvl(rec.tax_amount,0) ;
ELSE
tax_amt_tab(row_count) := 0;
END IF ;
/*bug#6498072, end*/
round_factor_tab(row_count):=rec.rounding_factor; --added by csahoo for
bug#6077133
base_tax_amt_tab(row_count) := 0;
adhoc_flag_tab(row_count):=rec.adhoc_flag ; /* rchandan bug#6030615 */
IF tax_rate_tab(row_count) = 0
AND rec.uom_code is not null --added by csahoo for bug#6498072
THEN
-- Start of bug 3749294
/*
Code added by aiyer for the bug 3749294
Check whether an exact match exists between the transaction uom and th
e setup uom (obtained through the tax_category list).
IF an exact match is found then the conversion rate is equal to 1 els
e the conversion rate between the two uom's would be
determined and tax amounts,base_tax_amounts are calculated for default
ation.
*/
Inv_Convert.inv_um_conversion( p_uom_code, rec.uom_code, p_inventory_i
tem_id, v_conversion_rate);
IF NVL(v_conversion_rate, 0) <= 0 THEN
-- pramasub start FP
/*4281841 ..rchandan..start*/
OPEN uom_class_cur(p_uom_code, rec.uom_code);
FETCH uom_class_cur INTO uom_cls;
IF uom_class_cur%FOUND THEN
Inv_Convert.inv_um_conversion( p_uom_code, rec.uom_code, 0, v_co
nversion_rate);
ELSE
v_conversion_rate := 0;
END IF;
CLOSE uom_class_cur;
/*4281841 ..rchandan..end*/
-- pramasub end FP
--Inv_Convert.inv_um_conversion( p_uom_code, rec.uom_code, 0, v_conv
ersion_rate); commented by pramasub
IF NVL(v_conversion_rate, 0) <= 0 THEN
/* for cash receipt there will be no lines. sacsethi for 6012570 (
5876390) */
if (p_uom_code is null and p_inventory_item_id is null )
and p_source_trx_type = jai_constants.ar_cash
then --
v_conversion_rate := 1;
/*
Date 22-feb-2007 Added by SACSETHI for bug 6012570 (5876390)
in This , Recalculation will be happen in Draft invoice
*/
elsif (p_uom_code is null and p_inventory_item_id is null )
and p_source_trx_type in (jai_constants.pa_draft_invoice
,jai_constants.G_AP_STANDALONE_INVOICE)
then
v_conversion_rate := 0;
else
v_conversion_rate := 0;
end if;
END IF;
END IF;
--tax_amt_tab(rec.lno) := nvl(rec.tax_amount * v_conversion_rate, 0) *
p_line_quantity; -- cbabu for EnhancementBug# 2427465, compact code
/*added for bug#6498072, start*/
IF p_action = jai_constants.recalculate_taxes THEN
/*tax_amt_tab(rec.lno) := nvl(rec.tax_amount * v_conversion_rate,
0) ;*/ --commented out by walton for inclusive tax
lt_tax_amt_non_rate_tab(rec.lno):=NVL(rec.tax_amount * v_conversio
n_rate, 0); --added by walton for inclusive tax
ELSE
/*tax_amt_tab(rec.lno) := nvl(rec.tax_amount * v_conversion_rate,
0) * p_line_quantity ;*/ --commented out by walton for inclusive tax
--added by walton for inclusive tax
lt_tax_amt_non_rate_tab(rec.lno):=NVL(rec.tax_amount * v_conversio
n_rate, 0) * p_line_quantity;
END IF ;
/*added for bug#6498072, end*/
/*commented out by walton for inclusive tax
tax_amt_tab(rec.lno):=round(tax_amt_tab(rec.lno),round_factor_tab(rec.lno));
--added by csahoo for bug#6077133
base_tax_amt_tab(rec.lno) := tax_amt_tab(rec.lno);
*/
base_tax_amt_tab(rec.lno)
:= lt_tax_amt_non_rate_tab(rec.lno); -added by walton for inclusive tax
-- End of bug 3749294
END IF;
IF rec.valid_date IS NULL OR rec.valid_date >= SYSDATE THEN
end_date_tab(row_count) := 1;
ELSE
tax_amt_tab(row_count) := 0;
end_date_tab(row_count) := 0;
END IF;
row_count := row_count + 1;
--added for bug#9214366, start
IF p_action = jai_constants.default_taxes
and p_thhold_cat_base_tax_typ = jai_constants.tax_type_tcs
THEN
tax_amt_tab(rec.lno) := 0;
END IF;
--bug#9214366, end
END LOOP;
row_count := row_count - 1;
--added by walton for inclusive tax 08-Dev-07
------------------------------------------------IF p_vat_assessable_value<>p_tax_amount
THEN
ln_vat_assessable_value:=p_vat_assessable_value;
ELSE
ln_vat_assessable_value:=1;
END IF; --End p_vat_assessable_value<>p_tax_amount
IF p_assessable_value<>p_tax_amount
THEN
ln_assessable_value:=p_assessable_value;
ELSE
ln_assessable_value:=1;
END IF; --End p_assessable_value<>p_tax_amount
---------------------------------------------------- Added by Jia for GST Bug#10043656 2010/09/10, Begin
--------------------------------------------/*
IF pn_gst_assessable_value <> p_tax_amount
THEN
ln_gst_assessable_value := pn_gst_assessable_value;
ELSE
ln_gst_assessable_value := 1;
END IF; --End pn_gst_assessable_value <> p_tax_amount
*/
---------------------------------------------- Added by Jia for GST Bug#10043656 2010/09/10, End
-- Added by Bo Li for Bug#11684111 BOE Ehancement, Begin
--------------------------------------------IF pn_customs_assessable_value <> p_tax_amount
THEN
ln_customs_assessable_value := pn_customs_assessable_value;
ELSE
ln_customs_assessable_value := 1;
END IF; --End pn_gst_assessable_value <> p_tax_amount
---------------------------------------------- Added by Bo Li for Bug#11684111 BOE Ehancement, End
FOR I IN 1..row_count LOOP
IF end_date_tab(I) <> 0 THEN
IF tax_type_tab(I) = 1 THEN
--Added by walton for inclusive tax on 08-Dec-07
-----------------------------------------------IF ln_assessable_value =1
THEN
bsln_amt:=1;
ln_bsln_amt_nr :=0;
ELSE
bsln_amt :=0;
ln_bsln_amt_nr :=ln_assessable_value;
END IF;
-----------------------------------------------/*bsln_amt := p_assessable_value;*/ --commented out by walton fo
r inclusive tax
ELSIF tax_type_tab(I) = 4 THEN
--Added by walton for inclusive tax on 08-Dec-07
-----------------------------------------------IF ln_vat_assessable_value =1
THEN
bsln_amt:=1;
ln_bsln_amt_nr :=0;
ELSE
bsln_amt :=0;
ln_bsln_amt_nr :=ln_vat_assessable_value;
END IF;
-----------------------------------------------/*bsln_amt := p_vat_assessable_value;*/ --commented out by walto
n for inclusive tax
--Added by Jia for GST Bug#10043656 on 2010/09/10, Begin
-----------------------------------------------/*
ELSIF tax_type_tab(I) = 7 THEN
IF ln_gst_assessable_value = 1
THEN
bsln_amt := 1;
ln_bsln_amt_nr := 0;
ELSE
bsln_amt := 0;
ln_bsln_amt_nr := ln_gst_assessable_value;
END IF;
*/
-------------------------------------------------Added by Jia for GST Bug#10043656 on 2010/09/10, End
--Added by Bo Li for Bug#11684111 BOE Ehancement, Begin
-----------------------------------------------ELSIF tax_type_tab(I) = 8 THEN
IF ln_customs_assessable_value = 1
THEN
bsln_amt := 1;
ln_bsln_amt_nr := 0;
ELSE
bsln_amt := 0;
ln_bsln_amt_nr := ln_customs_assessable_value;
END IF;
-------------------------------------------------Added by Bo Li for Bug#11684111 BOE Ehancement, End
--Added by walton for inclusive tax
------------------------------------ELSIF tax_type_tab(I) = 6 THEN
bsln_amt:=0;
ln_bsln_amt_nr :=0;
------------------------------------ELSE
bsln_amt:=1;
--Added by walton for inclusive tax
ln_bsln_amt_nr :=0;
--Added by walton for inclusive tax
/*bsln_amt := p_tax_amount;*/ --commented out by walton for incl
usive tax
END IF;
IF tax_rate_tab(I) <> 0 THEN
/* Commented out by Shyan for bug 10358786 on 28-Jan-2011 , Begin
= 'Y' then
+ ln_bsln_amt_nr; --added by walton for
then /*16172861*/
+ ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*161
72861*/
end if;
END IF;
END IF;
IF p3(I) < line_no_tab(I) AND p3(I) NOT IN (-1, 0) THEN --replaced I
by line_no_tab(I) for bug#9214366
IF lt_inclusive_tax_tab(P3(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(P3
(I)) IS NOT NULL then
vamt := vamt + NVL(tax_amt_tab(p3(I)), 0);
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P3(I)),
0); --added by walton for inclusive tax
END IF;
ELSIF p3(I) = 0 THEN
IF lt_inclusive_tax_tab(I)
vamt := vamt + bsln_amt;
ln_vamt_nr := ln_vamt_nr
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0)
ln_vamt_nr := ln_vamt_nr
else
= 'Y' then
+ ln_bsln_amt_nr; --added by walton for
then /*16172861*/
+ ln_bsln_amt_nr + p_tax_amount;
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*161
72861*/
end if;
END IF;
END IF;
IF p9(I) < line_no_tab(I) AND p9(I) NOT IN (-1, 0) THEN --replaced I
by line_no_tab(I) for bug#9214366
IF lt_inclusive_tax_tab(P9(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(P9
(I)) IS NOT NULL then
vamt := vamt + NVL(tax_amt_tab(p4(I)), 0);
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P9(I)),
0); --added by walton for inclusive tax
END IF;
ELSIF p9(I) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + bsln_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*161
72861*/
end if;
END IF;
END IF;
IF p10(I) < line_no_tab(I) AND p10(I) NOT IN (-1, 0) THEN --replaced
I by line_no_tab(I) for bug#9214366
IF lt_inclusive_tax_tab(P10(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(P
10(I)) IS NOT NULL then
vamt := vamt + NVL(tax_amt_tab(p10(I)), 0);
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P10(I)),
0); --added by walton for inclusive tax
END IF;
ELSIF p10(I) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + bsln_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*161
72861*/
end if;
END IF;
END IF;
OR
AND
IF tax_type_tab( I ) = 1 THEN
--Added by walton for inclusive tax on 08-Dec-07
-----------------------------------------------IF ln_assessable_value =1
THEN
v_amt:=1;
ln_bsln_amt_nr :=0;
ELSE
v_amt :=0;
ln_bsln_amt_nr :=ln_assessable_value;
END IF;
-----------------------------------------------/*v_amt := p_assessable_value;*/ --commented out by walton for i
nclusive tax
ELSIF tax_type_tab(I) = 4 THEN
--Added by walton for inclusive tax on 08-Dec-07
-----------------------------------------------IF ln_vat_assessable_value =1
THEN
v_amt:=1;
ln_bsln_amt_nr :=0;
ELSE
v_amt :=0;
ln_bsln_amt_nr :=ln_vat_assessable_value;
END IF;
-----------------------------------------------/*v_amt := p_vat_assessable_value;*/ --commented out by walton f
or inclusive tax
--Added by Jia for GST Bug#10043656 on 2010/09/10, Begin
-----------------------------------------------/*
ELSIF tax_type_tab(I) = 7 THEN
IF ln_gst_assessable_value = 1
THEN
v_amt := 1;
ln_bsln_amt_nr := 0;
ELSE
v_amt := 0;
ln_bsln_amt_nr := ln_gst_assessable_value;
END IF;
*/
-------------------------------------------------Added by Jia for GST Bug#10043656 on 2010/09/10, End
--Added by Bo Li for Bug#11684111 BOE Ehancement , Begin
-----------------------------------------------ELSIF tax_type_tab(I) = 8 THEN
IF ln_customs_assessable_value = 1
THEN
v_amt := 1;
ln_bsln_amt_nr := 0;
ELSE
v_amt := 0;
ln_bsln_amt_nr := ln_customs_assessable_value;
END IF;
-------------------------------------------------Added by Bo Li for Bug#11684111 BOE Ehancement , End
--Added by walton for inclusive tax
------------------------------------ELSIF tax_type_tab(I) = 6 THEN
v_amt:=0;
ln_bsln_amt_nr :=0;
-------------------------------------
ELSE
IF p_assessable_value IN ( 0, -1 ) OR tax_type_tab( I ) <> 1 THEN
/* v_amt := p_tax_amount;*/
v_amt:=1;
--Added by walton for inclusive tax
ln_bsln_amt_nr :=0;
--Added by walton for inclusive tax
ELSIF p_vat_assessable_value IN ( 0, -1 ) OR tax_type_tab( I ) <>
4 THEN
/* v_amt := p_tax_amount;*/
v_amt:=1;
--Added by walton for inclusive tax
ln_bsln_amt_nr :=0;
--Added by walton for inclusive tax
--Added by Jia for GST Bug#10043656 on 2010/09/10, Begin
-----------------------------------------------/*
ELSIF pn_gst_assessable_value IN ( 0, -1 ) OR tax_type_tab( I ) <>
7 THEN
v_amt := 1;
ln_bsln_amt_nr := 0;
*/
-------------------------------------------------Added by Jia for GST Bug#10043656 on 2010/09/10, End
--Added by Bo Li for Bug#11684111 BOE Ehancement , Begin
-----------------------------------------------ELSIF pn_customs_assessable_value IN ( 0, -1 ) OR tax_type_tab( I
) <> 8 THEN
v_amt := 1;
ln_bsln_amt_nr := 0;
-------------------------------------------------Added by Bo Li for Bug#11684111 BOE Ehancement, End
END IF;
END IF;
/* Commented out by Shyan for bug 10358786 on 28-Jan-2011 , Begin
-------------------------------------------------------------------IF P1( i ) <> -1 THEN
IF P1( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( P1( I ) );
ln_vamt_nr:=ln_vamt_nr+NVL(lt_tax_amt_non_rate_tab(P1(I)),0); --added by wal
ton for inclusive tax
ELSIF P1(i) = 0 THEN
vamt := vamt + v_amt;
ln_vamt_nr:=ln_vamt_nr+ln_bsln_amt_nr; --added by walton for inclusive tax
END IF;
END IF;
IF p2( i ) <> -1 THEN
IF p2( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p2( I ) );
ln_vamt_nr:=ln_vamt_nr+NVL(lt_tax_amt_non_rate_tab(P2(I)),0); --added by wal
ton for inclusive tax
ELSIF p2(i) = 0 THEN
vamt := vamt + v_amt;
ln_vamt_nr:=ln_vamt_nr+ln_bsln_amt_nr; --added by walton for inclusive tax
END IF;
END IF;
IF p3( i ) <> -1 THEN
IF p3( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p3( I ) );
ln_vamt_nr:=ln_vamt_nr+NVL(lt_tax_amt_non_rate_tab(P3(I)),0); --added by wal
ton for inclusive tax
ELSIF p3(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
ELSIF p2(i) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + v_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
IF p3(i) <> -1 THEN
IF p3(i) <> 0 THEN
IF lt_inclusive_tax_tab(P3(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(
P3(I)) IS NOT NULL then
vamt
:= vamt + tax_amt_tab(p3(I));
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P3(I)), 0
); --added by walton for inclusive tax
END IF;
ELSIF p3(i) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + v_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
IF p4(i) <> -1 THEN
IF p4(i) <> 0 THEN
IF lt_inclusive_tax_tab(P4(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(
P4(I)) IS NOT NULL then
vamt := vamt + tax_amt_tab(p4(I));
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P4(I)), 0
); --added by walton for inclusive tax
END IF;
ELSIF p4(i) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + v_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
IF p5(i) <> -1 THEN
IF p5(i) <> 0 THEN
IF lt_inclusive_tax_tab(P5(I)) = 'Y' OR lt_tax_amt_rate_tax_tab(
P5(I)) IS NOT NULL then
vamt
:= vamt + tax_amt_tab(p5(I));
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P5(I)), 0
); --added by walton for inclusive tax
END IF;
ELSIF p5(i) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + v_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
-m Precedence 6
-IF
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
IF p10(i) <> -1 THEN
IF p10(i) <> 0 THEN
IF lt_inclusive_tax_tab(P10(I)) = 'Y' OR lt_tax_amt_rate_tax_tab
(P10(I)) IS NOT NULL then
vamt := vamt + tax_amt_tab(p10(I));
ln_vamt_nr := ln_vamt_nr + NVL(lt_tax_amt_non_rate_tab(P10(I)),
0); --added by walton for inclusive tax
END IF;
ELSIF p10(i) = 0 THEN
IF lt_inclusive_tax_tab(I) = 'Y' then
vamt := vamt + v_amt;
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; --added by walton for
inclusive tax
ELSE
if (ln_bsln_amt_nr = 0) then /*16172861*/
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr + p_tax_amount;
else
ln_vamt_nr := ln_vamt_nr + ln_bsln_amt_nr; /*16
172861*/
end if;
END IF;
END IF;
END IF;
-- end bug 5228046
------------------------------------------------------------ Added by shujuan for bug 10358786 on 28-Jan-2011, End
base_tax_amt_tab(I) := vamt;
tax_target_tab(I) := vamt;
base_tax_amount_nr_tab(I):=ln_vamt_nr;/*9692478*/
------------------------------------------------------------------------------------/*Change History: jai_cmn_tax_defaultation_pkg
Last Modified By Jagdish Bhosle. 2001/04/05
The follow check will ensure that for Bond reg. Txns
excise duty will not be added to original Line amount. */
------------------------------------------------------------------------------------IF (v_register_code='BOND_REG') THEN
--- Added By Jagdish
2001/04/05
IF counter = max_iter AND tax_type_tab( I ) NOT IN ( 1, 2 ) THEN
v_func_tax_amt := v_tax_amt + ( vamt * ( tax_rate_tab( i )/100)
);
v_tax_amt := v_tax_amt + ( vamt * ( tax_rate_tab( i )/100));
ln_tax_amt_nr:=ln_tax_amt_nr+(ln_vamt_nr*(tax_rate_tab(i)/100));
--added by walton for inclusive
END IF;
ELSE
v_func_tax_amt := v_tax_amt + ( vamt * ( tax_rate_tab( i )/100));
END LOOP;
--Added by walton for inclusive tax
-------------------------------------------------------------------------------------FOR I IN 1 .. ROW_COUNT --Compute Factor
LOOP
IF lt_inclusive_tax_tab(I) = 'Y'
THEN
ln_total_tax_per_rupee := ln_total_tax_per_rupee + nvl(lt_tax_amt_rate_t
ax_tab(I),0) ;
ln_total_non_rate_tax := ln_total_non_rate_tax + nvl(lt_tax_amt_non_rate
_tab(I),0);
END IF;
END LOOP; --End Compute Factor
ln_total_tax_per_rupee := ln_total_tax_per_rupee + 1;
IF ln_total_tax_per_rupee <> 0
THEN
ln_exclusive_price := (NVL(p_tax_amount,0) - ln_total_non_rate_tax ) / l
n_total_tax_per_rupee;
END If;
FOR i in 1 .. row_count --Compute Tax Amount
Loop
-- Commented out by Shyan for bug 10358786 on 28-Jan-2011 , Begin
-------------------------------------------------------------------tax_amt_tab (i) := (lt_tax_amt_rate_tax_tab(I) * ln_exclusive_price ) +
lt_tax_amt_non_rate_tab(I);
------------------------------------------------------------------- Commented out by Shyan for bug 10358786 on 28-Jan-2011 , End
-- Added by Shyan for bug 10358786 on 28-Jan-2011 , Begin
-----------------------------------------------------------------if (lt_adhoc_tax_tab(i) = 'N') then /*Added if condition by mmurtuza for
bug 16656728*/
tax_amt_tab (i):=0;
end if;
IF lt_inclusive_tax_tab(I) = 'Y' THEN
IF (tax_type_tab(I) = 1 and ln_assessable_value>1) OR
(tax_type_tab(I) = 4 and ln_vat_assessable_value> 1) OR
/*(tax_type_tab(I) = 7 and ln_gst_assessable_value >1)
OR*/ (tax_type_tab(I) = 8 and ln_customs_assessable_value >1) -Added by Bo Li for bug#11684111 BOE Enhancement
THEN
IF tax_type_tab(I) = 1 and ln_assessable_value >1 Then
ln_amount:= ln_assessable_value;
ELSIF tax_type_tab(I) = 4 and ln_vat_assessable_value >1 Then
ln_amount:= ln_vat_assessable_value;
/*ELSIF tax_type_tab(I) = 7 and ln_gst_assessable_value >1 Then
ln_amount:= ln_gst_assessable_value;*/
ELSIF tax_type_tab(I) = 8 and ln_customs_assessable_value >1 Then
--Added by Bo Li for bug#11684111 BOE Enhancement
ln_amount:= ln_customs_assessable_value;--Added by Bo Li for bug
#11684111 BOE Enhancement
END IF;
end if;
ELSIF P2(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
IF P3(I) < line_no_tab(I) AND p3(I) NOT IN (-1, 0) then
if (NVL(lt_inclusive_tax_tab(P3(i)), 'N') = 'N') then --added
by mmurtuza for bug 14591926
tax_amt_tab(i) := tax_amt_tab(i) + tax_amt_tab(P3(i))* tax_rate_ta
b(i)/100;
end if;
ELSIF P3(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
IF P4(I) < line_no_tab(I) AND p4(I) NOT IN (-1, 0) then
if (NVL(lt_inclusive_tax_tab(P4(i)), 'N') = 'N') then --added
by mmurtuza for bug 14591926
tax_amt_tab(i) := tax_amt_tab(i) + tax_amt_tab(P4(i))* tax_rate_t
ab(i)/100;
end if;
ELSIF P4(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
IF P5(I) < line_no_tab(I) AND p5(I) NOT IN (-1, 0) then
if (NVL(lt_inclusive_tax_tab(P5(i)), 'N') = 'N') then --added
by mmurtuza for bug 14591926
tax_amt_tab(i) := tax_amt_tab(i) + tax_amt_tab(P5(i))* tax_rate_ta
b(i)/100;
end if;
ELSIF P5(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
IF P6(I) < line_no_tab(I) AND p6(I) NOT IN (-1, 0) then
if (NVL(lt_inclusive_tax_tab(P6(i)), 'N') = 'N') then --added
by mmurtuza for bug 14591926
tax_amt_tab(i) := tax_amt_tab(i) + tax_amt_tab(P6(i))* tax_rate_tab(
i)/100;
end if;
ELSIF P6(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
IF P7(I) < line_no_tab(I) AND p7(I) NOT IN (-1, 0) then
if (NVL(lt_inclusive_tax_tab(P7(i)), 'N') = 'N') then --added
by mmurtuza for bug 14591926
tax_amt_tab(i) := tax_amt_tab(i) + tax_amt_tab(P7(i))* tax_rate_tab(
i)/100;
end if;
ELSIF P7(I)=0 Then
tax_amt_tab(i) := tax_amt_tab(i) + ln_amount * tax_rate_tab(i)/1
00;
END IF;
0
IF v_debug THEN fnd_file.put_line(fnd_file.log, ' transaction_name -> '|
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Open/Close/Fetch cur
sor c_get_max_tax_line');*/ --commented by bgowrava for bug#5631784
open c_get_max_tax_line;
fetch c_get_max_tax_line into ln_max_tax_line;
close c_get_max_tax_line ;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Open/Close/Fetch cur
sor c_get_max_rgm_tax_line');*/ --commented by bgowrava for bug#5631784
open c_get_max_rgm_tax_line;
fetch c_get_max_rgm_tax_line into ln_max_rgm_tax_line;
close c_get_max_rgm_tax_line ;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'ln_max_tax_line='||l
n_max_tax_line||', ln_max_rgm_tax_line='||ln_max_rgm_tax_line);*/ --commented by
bgowrava for bug#5631784
end if;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Opening ref cursor');*
/ --commented by bgowrava for bug#5631784
get_tax_cat_taxes_cur ( p_tax_category_id
=> p_tax_category_id
, p_threshold_tax_cat_id => p_threshold_tax_c
at_id
, p_max_tax_line
=> ln_max_tax_line
, p_max_rgm_tax_line
=> ln_max_rgm_tax_li
ne
, p_refc_tax_cat_taxes_cur => refc_tax_cur
, pv_retroprice_changed
=> pv_retroprice_chan
ged --Added by Kevin Cheng for Retroactive Price 2008/01/14
);
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Cursor is opened');*/
--commented by bgowrava for bug#5631784
elsif p_action = jai_constants.recalculate_taxes then
/**
Following is a dynamic sql string which can be modifed as per requir
ement
The sql has four place holders defined as below
$$EXTRA_SELECT_COLUMN_LIST$$
- Use this place holder to select a
dditional columns in the sql.
You must also change corrospondin
g fetch statements and the record being used for fetch.
SELECT statement above should als
o be changed to include the newly added columns
as they are sharing a common curs
or and fetch record.
$$TAX_SOURCE_TABLE$$
be replaced with name of
culation
$$SOURCE_TABLE_FILTER$$
t represent a boolean condition
$$ADDITIONAL_WHERE_CLAUSE$$
tional conditions if any.
,
,
,
,
b.mod_cr_percentage
b.vendor_id
b.tax_type
nvl(b.rounding_factor,0) rounding_factor
, b.adhoc_flag
$$EXTRA_SELECT_COLUMN_LIST$$
from $$TAX_SOURCE_TABLE$$
a
, JAI_CMN_TAXES_ALL
b
, jai_regime_tax_types_v rttv
where $$SOURCE_TABLE_FILTER$$
and rttv.tax_type (+) = b.tax_type
and a.tax_id = b.tax_id $$ADDITIONAL_WHERE_CLAUSE$$
order by a.tax_line_no $$ADDITIONAL_ORDER_BY$$';
/** No extra columns required. Dummy column (NULL) tax_category_id ne
eds to be added in the last as same record (rec) is being used
when fetching the cursor. If there is a need to override this de
fault behaviour then please replace these place holder with
desired strings which can be evaluated at runtime by sql-engine
*/
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$EXTRA_SELECT_COLUMN_LIST$$'
, ',null tax_category_id'
);
/** No additional filtering required */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$ADDITIONAL_WHERE_CLAUSE$$'
, ''
);
/** No additional sorting required */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$ADDITIONAL_ORDER_BY$$'
, ''
);
if upper(p_source_trx_type) = jai_constants.source_ttype_delivery then
/** replace the correct tax source table */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_OM_WSH_LINE_TAXES'
);
/** replace join condition */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.delivery_detail_id = ' || p_line_id
);
elsif upper(p_source_trx_type) = jai_constants.bill_only_invoice then
/** For bill_only_invoice tax source table is ja_in_ra_cust_trx_tax_
lines*/
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_AR_TRX_TAX_LINES'
);
/** replace join condition */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.link_to_cust_trx_line_id = ' || p_line_id
);
/*
elsif upper(pv_tax_source_table) = '<some tax table>' then
...
...
*/
-- Date 24-Apr-2007 Added by SACSETHI for bug 6012570 (5876390)
-- in This , Recalculation will be happen in Draft invoice
--------------------------------------------------------elsif upper(p_source_trx_type) = jai_constants.PA_DRAFT_INVOICE then
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, 'a.tax_amount'
, 'a.tax_amt'
);
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_CMN_DOCUMENT_TAXES'
);
/** replace join condition */
lv_recalculation_sql :=
replace ( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.SOURCE_DOC_LINE_ID = ' || p_line_id || ' and SOURCE_DOC
_TYPE ='''|| jai_constants.PA_DRAFT_INVOICE || ''''
);
-- Added by Jason Liu for standalone invoice on 2007/08/23
---------------------------------------------------------------------ELSIF upper(p_source_trx_type) =
jai_constants.G_AP_STANDALONE_INVOICE
THEN
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, 'a.tax_amount'
, 'a.tax_amt'
);
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, '$$TAX_SOURCE_TABLE$$'
, 'JAI_CMN_DOCUMENT_TAXES'
);
-- replace join condition
lv_recalculation_sql :=
REPLACE( lv_recalculation_sql
, '$$SOURCE_TABLE_FILTER$$'
, 'a.SOURCE_DOC_LINE_ID = ' || p_line_id ||
' and SOURCE_DOC_TYPE ='''||
jai_constants.G_AP_STANDALONE_INVOICE || ''''
);
---------------------------------------------------------------------end if; /*pv_tax_source_table*/
/**
When control comes here, a valid sql statement hold by variable lv
_recalculate_sql
must be ready to execute.
open a dynamic select statement using OPEN-FOR statement
*/
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'TAX RECALCULATION SQL
STATEMENT');
jai_cmn_debug_contexts_pkg.print (ln_reg_id, lv_recalculation_sql);
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Opening ref cursor with
dynamic sql'); */--commented by bgowrava for bug#5631784
open refc_tax_cur for lv_recalculation_sql;
/* jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Cursor is opened with
lv_recalculation_sql');*/ --commented by bgowrava for bug#5631784
end if; /** RECALCULATE */
/** Clear the tax table */
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Before fetching cursor r
ows and starting loop');*/ --commented by bgowrava for bug#5631784
lt_tax_table.delete;
loop
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'In Loop, row_count='||
row_count||', lt_tax_table.count='||lt_tax_table.count);*/ --commented by bgowra
va for bug#5631784
fetch refc_tax_cur into rec;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Post Fetch refc_tax_cu
r, rec.tax_id='||rec.tax_id||', rec.tax_rate='||rec.tax_rate);*/ --commented by
bgowrava for bug#5631784
exit when refc_tax_cur%notfound;
/** End of bug 5631784*/
/** Add current record in the lt_tax_table for future use at the time of eit
her UPDATE or INSERT into the tables*/
--FOR rec IN tax_cur(p_tax_category_id) LOOP
lt_tax_table(lt_tax_table.count+1) := rec;
p1(row_count) := nvl(rec.p_1,-1);
p2(row_count) := nvl(rec.p_2,-1);
p3(row_count) := nvl(rec.p_3,-1);
p4(row_count) := nvl(rec.p_4,-1);
p5(row_count) := nvl(rec.p_5,-1);
p6(row_count) := nvl(rec.p_6,-1); -- Date 31/10/2006 Bug 5228046 added b
y SACSETHI ( added column from Precedence 6 to 10 )
p7(row_count) := nvl(rec.p_7,-1);
p8(row_count) := nvl(rec.p_8,-1);
p9(row_count) := nvl(rec.p_9,-1);
p10(row_count) := nvl(rec.p_10,-1);
tax_rate_tab(row_count) := NVL(rec.tax_rate,0);
/*
|| The following code added by aiyer for the bug 4691616
|| Purpose:
|| rec.tax_rate = 0 means that tax_rate for such a tax line is actually
zero (i.e it is not a replacement of null value)
|| So, when rec.tax_rate = 0, tax_rate_zero_tab is populated with -9999
to identify that this tax_line actually has tax_rate = 0
|| To calculate the BASE_TAX_AMOUNT of the taxes whose tax_rate is zero
*/
IF rec.tax_rate is null THEN
/*
||Indicates qty based taxes
*/
tax_rate_zero_tab(row_count) := 0;
ELSIF rec.tax_rate = 0 THEN
/*
||Indicates 0% tax rate becasue a tax can have a rate as 0%.
*/
tax_rate_zero_tab(row_count) := -9999;
ELSE
tax_rate_zero_tab(row_count) := rec.tax_rate;
END IF;
tax_type_tab(row_count) := rec.tax_type_val;
/*End of bug 4691616 */
-- tax_amt_tab(row_count) := 0;
/*added for bug#6498072, start*/
--Comment out by Kevin Cheng
/*IF p_action = jai_constants.recalculate_taxes AND --recalculate_taxes
NVL(rec.adhoc_flag,'N') = 'Y'
--adhoc_flag='Y'
THEN
tax_amt_tab(row_count) := nvl(rec.tax_amount,0) ;
ELSE
tax_amt_tab(row_count) := 0;
END IF ;*/
/*bug#6498072, end*/
--Added by Kevin Cheng -- for remain unchanged taxes
--1, Ad hoc taxes
--2, UOM based taxes
--3, Assessable value base taxes (Excise/VAT)
--4, Third party taxes
--============================================================================
=====
IF NVL(rec.adhoc_flag,'N') = 'Y' --Ad hoc
THEN
lv_tax_remain_flag := 'Y';
ELSIF tax_rate_tab(row_count) = 0 AND rec.uom_code IS NOT NULL --UOM based
THEN
lv_tax_remain_flag := 'Y';
* p_line_quantity ;
END IF ;
\*added for bug#6498072, end*\
tax_amt_tab(rec.lno):=round(tax_amt_tab(rec.lno),round_factor_tab(rec.lno));
--added by csahoo for bug#6077133
base_tax_amt_tab(rec.lno) := tax_amt_tab(rec.lno);
-- End of bug 3749294
END IF;*/
IF rec.valid_date IS NULL OR rec.valid_date >= SYSDATE THEN
end_date_tab(row_count) := 1;
ELSE
tax_amt_tab(row_count) := 0;
end_date_tab(row_count) := 0;
END IF;
row_count := row_count + 1;
END LOOP;
row_count := row_count - 1;
FOR I IN 1..row_count LOOP
IF end_date_tab(I) <> 0 THEN
IF tax_type_tab(I) = 1 THEN
bsln_amt := p_assessable_value;
ELSIF tax_type_tab(I) = 4 THEN
bsln_amt := p_vat_assessable_value;
/*ELSIF tax_type_tab(I) = 7 THEN
--Added by Jia for GST Bug#10043
656 on 2010/09/10
bsln_amt := pn_gst_assessable_value; --Added by Jia for GST Bug
#10043656 on 2010/09/10
*/
ELSIF tax_type_tab(I) = 8 THEN
--Added by Bo Li for Bug#11684111
BOE Ehancement
bsln_amt := pn_customs_assessable_value; --Added by Bo Li for
Bug#11684111 BOE Ehancement
ELSE
bsln_amt := p_tax_amount;
END IF;
IF tax_rate_tab(I) <> 0 THEN
IF P1(I) < I AND P1(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(P1(I)),0);
ELSIF P1(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p2(I) < I AND p2(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p2(I)),0);
ELSIF p2(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p3(I) < I AND p3(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p3(I)),0);
ELSIF p3(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p4(I) < I AND p4(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p4(I)),0);
ELSIF p4(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p5(I) < I AND p5(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p5(I)),0);
ELSIF p5(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
-- Date 31/10/2006 Bug 5228046 added by SACSETHI ( added column from Precedence
6 to 10 )
-- start bug 5228046
IF P6(I) < I AND P6(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(P6(I)),0);
ELSIF P6(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p7(I) < I AND p7(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p7(I)),0);
ELSIF p7(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p8(I) < I AND p8(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p8(I)),0);
ELSIF p8(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p9(I) < I AND p9(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p9(I)),0);
ELSIF p9(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
IF p10(I) < I AND p10(I) NOT IN (-1,0) THEN
vamt := vamt + NVL(tax_amt_tab(p10(I)),0);
ELSIF p10(I) = 0 THEN
vamt := vamt + bsln_amt;
END IF;
-- end bug 5228046
v_tax_amt := v_tax_amt + (vamt * (tax_rate_tab(I)/100));
base_tax_amt_tab(I) := vamt;
tax_amt_tab(I) := NVL(tax_amt_tab(I),0) + v_tax_amt;
tax_amt_tab(I) := round(tax_amt_tab(I) ,round_factor_tab(I)); --added by c
sahoo for bug#6077133
vamt := 0;
v_tax_amt := 0;
END IF;
ELSE
tax_amt_tab(I) := 0;
base_tax_amt_tab(I) := 0;
END IF;
END LOOP;
FOR I IN 1..row_count LOOP
IF end_date_tab( I ) <> 0 THEN
IF tax_rate_tab(I) <> 0 THEN
IF P1(I) > I THEN
vamt := vamt + NVL(tax_amt_tab(P1(I)),0);
END IF;
ull
|| i.e when tax_rate is null, tax_rate_tab(i) is 0.
*/
IF ( tax_rate_tab( i )
<> 0
OR
tax_rate_zero_tab(I) = -9999
)
AND
end_date_tab( I ) <> 0
THEN
IF tax_type_tab( I ) = 1 THEN
v_amt := p_assessable_value;
ELSIF tax_type_tab(I) = 4 THEN
v_amt := p_vat_assessable_value;
/*ELSIF tax_type_tab(I) = 7 THEN -- Added by Jia for GST Bug#10043
656 on 2010/09/10
v_amt := pn_gst_assessable_value; -- Added by Jia for GST Bug#
10043656 on 2010/09/10
*/
ELSIF tax_type_tab(I) = 8 THEN
--Added by Bo Li for Bug#11684111
BOE Ehancement
v_amt := pn_customs_assessable_value;
--Added by Bo Li for Bu
g#11684111 BOE Ehancement
ELSE
IF p_assessable_value IN ( 0, -1 ) OR tax_type_tab( I ) <> 1 THEN
v_amt := p_tax_amount;
ELSIF p_vat_assessable_value IN ( 0, -1 ) OR tax_type_tab( I ) <>
4 THEN
v_amt := p_tax_amount;
/*ELSIF pn_gst_assessable_value IN ( 0, -1 ) OR tax_type_tab( I )
<> 7 THEN -- Added by Jia for GST Bug#10043656 on 2010/09/10
v_amt := p_tax_amount; -- Added by Jia for GST Bug#10043656 o
n 2010/09/10
*/
ELSIF pn_customs_assessable_value IN ( 0, -1 ) OR tax_type_tab( I )
<> 8 THEN --Added by Bo Li for Bug#11684111 BOE Ehancement
v_amt := p_tax_amount; --Added by Bo Li for Bug#11684111 BOE
Ehancement
END IF;
END IF;
IF P1( i ) <> -1 THEN
IF P1( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( P1( I ) );
ELSIF P1(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p2( i ) <> -1 THEN
IF p2( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p2( I ) );
ELSIF p2(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p3( i ) <> -1 THEN
IF p3( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p3( I ) );
ELSIF p3(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p4( i ) <> -1 THEN
IF p4( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p4( i ) );
ELSIF p4(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p5( i ) <> -1 THEN
IF p5( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p5( i ) );
ELSIF p5(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
-- Date 31/10/2006 Bug 5228046 added by SACSETHI ( added column from Precedence
6 to 10 )
-- start bug 5228046
IF P6( i ) <> -1 THEN
IF P6( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( P6( I ) );
ELSIF P6(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p7( i ) <> -1 THEN
IF p7( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p7( I ) );
ELSIF p7(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p8( i ) <> -1 THEN
IF p8( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p8( I ) );
ELSIF p8(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p9( i ) <> -1 THEN
IF p9( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p9( i ) );
ELSIF p9(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
IF p10( i ) <> -1 THEN
IF p10( i ) <> 0 THEN
vamt := vamt + tax_amt_tab( p10( i ) );
ELSIF p10(i) = 0 THEN
vamt := vamt + v_amt;
END IF;
END IF;
--==============================================================================
=============================
row_count := 1;
-- this is the place where you hv to add your insert statements for transact
ion specific tables
rec := null ; -- added by ssumaith - code review comments for TCS buG#610994
1
FOR i in 1.. lt_tax_table.count LOOP
rec := lt_tax_table(i);
-- ends additions by ssumaith - code review comments for TCS bug# 6109941
IF tax_type_tab(row_count) <> 2 THEN
v_tax_amt := v_tax_amt + NVL(tax_amt_tab(row_count),0);
END IF;
/** bgowrava for forward porting bug# 5631784 */
if rec.mod_cr_percentage is not null and rec.mod_cr_percentage > 0 the
n
v_modvat_flag := 'Y';
elsif rec.mod_cr_percentage is null then
v_modvat_flag := 'N';
end if;
/*end bug# 5631784 */
if v_debug then fnd_file.put_line(fnd_file.log, 'Before tr_name -> '||transa
ction_name); end if;
-- Vijay Shankar for Bug# 2837970
IF transaction_name = 'CRM_QUOTE' THEN
if v_debug then fnd_file.put_line(fnd_file.log, 'Before insert into of t
r_name -> '||transaction_name); end if;
INSERT INTO JAI_CRM_QUOTE_TAXES(quote_line_id, quote_header_id, shipment
_id, tax_line_no,
precedence_1, precedence_2, precedence_3, precedence_4, precedence_5
,
precedence_6, precedence_7, precedence_8, precedence_9, precedence_1
0, -- Date 31/10/2006 Bug 5228046 added by SACSETHI
tax_id, tax_amount,
base_tax_amount,
func_tax_amount,
creation_date, created_by, last_update_date,
last_updated_by, last_update_login)
VALUES ( p_line_id, p_header_id, p_operation_flag, row_count,
rec.p_1, rec.p_2, rec.p_3, rec.p_4, rec.p_5,
rec.p_6, rec.p_7, rec.p_8, rec.p_9, rec.p_10,
rec.tax_id, ROUND(nvl(tax_amt_tab(row_count),0),REC.ROUNDING_FACTOR)
,
decode(nvl(base_tax_amt_tab(row_count), 0), 0, nvl(tax_amt_tab(row_c
ount),0), nvl(base_tax_amt_tab(row_count), 0)),
(nvl(func_tax_amt_tab(row_count),0) * v_currency_conv_factor),
nvl(p_creation_date, SYSDATE), nvl(p_created_by,1), nvl(p_last_updat
e_date,SYSDATE) ,
nvl(p_last_updated_by,1), nvl(p_last_update_login,1) );
-- end, Vijay Shankar for Bug# 2837970
ELSIF transaction_name = 'SALES_ORDER' THEN
END IF;
END IF;
update JAI_OM_OE_SO_TAXES
set tax_amount = tax_amount * v_conversion_rate,
base_tax_amount = base_tax_amount * v_conversion_rate,
func_tax_amount = func_tax_amount * v_conversion_rate
where header_id=p_header_id
and line_id = p_line_id
and tax_id = rec.tax_id
and tax_line_no = i;
jai_cmn_utils_pkg.write_fnd_log_msg('JAI_CMN_TAX_DEFAULTATION_PKG
.JA_IN_CALC_PREC_TAXES','3545 after update JAI_OM_OE_SO_TAXES p_header_id '||p_
header_id||
'p_line_id '||p_l
ine_id||
'v_conversion_rate '||v_conversion_rate);
END IF;
/* Additions for bug 17831734 ends */
ELSIF transaction_name='INTERORG_XFER' THEN
/*added by rchandan for bug#6030615*/
BEGIN
DECLARE
v_modvat_flag VARCHAR2(1);
BEGIN
IF rec.mod_cr_percentage IS NOT NULL AND rec.mod_cr_per
centage > 0 THEN
v_modvat_flag := 'Y';
ELSIF rec.mod_cr_percentage IS NULL THEN
v_modvat_flag := 'N';
END IF;
-- bug 6436825
IF REC.TAX_TYPE NOT IN ('Service', JAI_CONSTANTS.TAX_T
YPE_SH_SERVICE_EDU_CESS,
JAI_CONSTANTS.TAX_TYPE_SERVICE_EDU_CESS,
JAI_CONSTANTS.TAX_TYPE_SH_CUSTOMS_EDU_CESS,
JAI_CONSTANTS.TAX_TYPE_CUSTOMS_EDU_CESS,
'CVD_EDUCATION_CESS', JAI_CONSTANTS.TAX_TYPE_SH_C
VD_EDU_CESS,
'Customs', 'CVD', 'ADDITIONAL_CVD' ,'TDS' , 'Modv
at Recovery') THEN
INSERT INTO jai_cmn_document_taxes(
DOC_TAX_ID,
tax_line_no,
tax_id ,
tax_type,
currency_code ,
tax_rate ,
qty_rate ,
uom
,
tax_amt ,
func_tax_amt,
modvat_flag,
tax_category_id,
source_doc_type ,
source_doc_id ,
source_doc_line_id ,
source_table_name ,
TAX_MODIFIED_BY ,
adhoc_flag ,
precedence_1 ,
precedence_2 ,
precedence_3 ,
precedence_4 ,
precedence_5 ,
precedence_6 ,
precedence_7 ,
precedence_8 ,
precedence_9 ,
precedence_10 ,
creation_date ,
created_by
,
last_update_date ,
last_updated_by ,
last_update_login )
VALUES (
jai_cmn_document_taxes_s.nextval ,
v_line_num,
rec.tax_id,
rec.tax_type,
p_currency,
rec.tax_rate,
rec.tax_amount,
rec.uom_code,
round(nvl(tax_amt_tab(row_count),0),rec.roundin
g_factor),
round(NVL(func_tax_amt_tab(row_count),0) * v_cu
rrency_conv_factor,rec.rounding_factor),
v_modvat_flag,
p_tax_category_id ,
'INTERORG_XFER',
p_header_id,
p_line_id,
'MTL_MATERIAL_TRANSACTIONS_TEMP',
NULL,
rec.adhoc_flag,
rec.p_1,
rec.p_2,
rec.p_3,
rec.p_4,
rec.p_5,
rec.p_6,
rec.p_7,
rec.p_8,
rec.p_9,
rec.p_10,
p_creation_date,
p_created_by,
p_last_update_date,
p_last_updated_by,
p_last_update_login
);
v_line_num:=nvl(v_line_num,1)+1;
END IF;
END;
END;
rec.p_5,
rec.p_6,
rec.p_7,
rec.p_8,
rec.p_9,
rec.p_10,
rec.tax_id,
lv_tax_type,-- Add by Qiong Liu for bug#11684111 BOE Ehancement
lv_boe_flag,-- Add by Wenqiong for bug#12611347
rec.tax_rate,
rec.tax_amount,
rec.uom_code,
round(nvl(tax_amt_tab(row_count), 0), rec.rounding_factor),
decode(nvl(base_tax_amt_tab(row_count), 0),
0,
nvl(tax_amt_tab(row_count), 0),
nvl(base_tax_amt_tab(row_count), 0)),
(nvl(func_tax_amt_tab(row_count), 0) * v_currency_conv_factor),
p_creation_date,
p_created_by,
p_last_update_date,
p_last_updated_by,
p_last_update_login,
p_tax_category_id -- cbabu for EnhancementBug# 2427465
);
ELSIF transaction_name = 'BOE_INVOICE_UPDATE' THEN
UPDATE jai_boe_detail_taxes
SET tax_amount
= round(nvl(tax_amt_tab(row_count), 0),
rec.rounding_factor),
base_tax_amount = decode(nvl(base_tax_amt_tab(row_count), 0),
0,
nvl(tax_amt_tab(row_count), 0),
nvl(base_tax_amt_tab(row_count), 0)),
func_tax_amount = nvl(func_tax_amt_tab(row_count), 0) *
v_currency_conv_factor,
last_update_date = p_last_update_date,
last_updated_by = p_last_updated_by,
last_update_login = p_last_update_login
WHERE boe_detail_id = p_line_id
AND tax_line_no = row_count;
----------------------------------------------------------------Added by Bo Li for bug#11684111 BOE Ehancement End
ELSIF transaction_name = 'AR_LINES' THEN
--2001/03/30 Manohar Mishra
-- Added the following IF condition
--if (v_register_code='BOND_REG') --and (rec.tax_type_val<>1))
--then
--if (rec.tax_type_val<>1) then
/*Bug 8371741 - Start*/
get_created_from(p_header_id, l_created_from);
if (l_created_from = 'ARXTWMAI' and p_max_rgm_tax_line>0
) then
end if;
else
INSERT INTO JAI_AR_TRX_TAX_LINES(customer_trx_line_id,
link_to_cust_trx_line_id,
tax_line_no,
precedence_1,precedence_2, precedence_3, precedence_4,preced
ence_5,
precedence_6,precedence_7, precedence_8, precedence_9,preced
ence_10, -- Date 31/10/2006 Bug 5228046 added by SACSETHI
tax_id, tax_rate, qty_rate, uom,
tax_amount,
base_tax_amount,
func_tax_amount,
creation_date, created_by, last_update_date,
last_updated_by, last_update_login)
VALUES(ra_customer_trx_lines_s.nextval, p_line_id, row_count,
rec.p_1, rec.p_2, rec.p_3, rec.p_4, rec.p_5,
rec.p_6, rec.p_7, rec.p_8, rec.p_9, rec.p_10,
rec.tax_id, rec.tax_rate, rec.tax_amount, rec.uom_code,
ROUND(nvl(tax_amt_tab(row_count), 0), REC.ROUNDING_FACTOR),
decode(nvl(base_tax_amt_tab(row_count), 0), 0, nvl(tax_amt_t
ab(row_count),0), nvl(base_tax_amt_tab(row_count), 0)),
(nvl(func_tax_amt_tab(row_count),0) * v_currency_conv_facto
r),
p_creation_date, p_created_by, p_last_update_date,
p_last_updated_by, p_last_update_login);
end if;
*/
ELSIF transaction_name = 'AR_LINES_UPDATE' THEN
--2001/03/30 Manohar Mishra
-- Added the following IF condition
--if ((v_register_code<>'BOND_REG') and (rec.tax_type_val<>1)) then
UPDATE JAI_AR_TRX_TAX_LINES
SET tax_amount
= ROUND(NVL(tax_amt_tab(row_count), 0), REC.ROUN
DING_FACTOR),
base_tax_amount = DECODE(NVL(base_tax_amt_tab(row_count), 0),
0, NVL(tax_amt_tab(row_count),0), NVL(base_tax_amt_tab(row_count), 0)),
func_tax_amount = NVL(func_tax_amt_tab(row_count),0) * v_curr
ency_conv_factor,
last_update_date = p_last_update_date,
last_updated_by = p_last_updated_by,
last_update_login = p_last_update_login
WHERE link_to_cust_trx_line_id = P_line_id
AND
tax_line_no = row_count;
--end if;
ELSIF SUBSTR( transaction_name, 1,
SUBSTR( transaction_name, 1, 9
SUBSTR( transaction_name, 1, 7
SUBSTR( transaction_name, 1, 8
SUBSTR( transaction_name, 1, 6
SUBSTR( transaction_name, 1, 9
3
)
)
)
)
)
)
=
=
=
=
=
= 'RFQ' OR
'QUOTATION' OR
'BLANKET' OR
'BLANKETR' OR
'OTHERS' OR
'SCHEDULED' THEN
/*
Since there is no provision of line location id as one of the parame
ter,
Line location Id is passed in place of line id, Line Id is concatina
ted
to transaction name.
If proportioning has to be done, then operation variable takes value
U
else takes I. This is also concatenated with transaction name with a
preceding $.
*/
BEGIN
-- MBEGIN
DECLARE
-- NDECLARE
v_seq_val
NUMBER;
v_modvat_flag VARCHAR2(1);
v_vendor_id
NUMBER;
v_vendor1_id
NUMBER;
v_vendor2_id
NUMBER;
v_currency
VARCHAR2(15);
v_transaction_name VARCHAR2(100);
v_mod_cr
NUMBER;
v_tax_type
VARCHAR2(30);
v_start
NUMBER;
v_line_id
NUMBER;
operation
VARCHAR2(2);
CURSOR fetch_mod_cr_cur( taxid IN NUMBER ) IS
SELECT Tax_Type, Mod_Cr_Percentage, Vendor_Id
FROM JAI_CMN_TAXES_ALL
WHERE Tax_Id = taxid;
CURSOR fetch_vendor2_cur IS
SELECT vendor_id
FROM JAI_PO_REQ_LINE_TAXES
WHERE Requisition_Line_Id = ( SELECT Requisition_Line_Id
FROM Po_Requisition_Lines_All
WHERE Line_Location_Id = p_line_id );
CURSOR fetch_focus_id IS
SELECT Line_Focus_Id
FROM JAI_PO_LINE_LOCATIONS
WHERE Po_Line_Id = p_line_id
AND Po_Header_Id = p_header_id
AND Line_Location_Id IS NULL;
CURSOR fetch_focus1_id( line_id IN NUMBER ) IS
SELECT Line_Focus_Id
FROM JAI_PO_LINE_LOCATIONS
WHERE Po_Line_Id = p_line_id
AND Po_Header_Id = p_header_id
AND Line_Location_Id = line_id;
/*Added by Vkavulur for bug#16686950 begin*/
CURSOR fetch_item_class(pn_po_line_id IN VARCHAR2)
IS
/*
commented and added the below definition for bug
#17574176
SELECT attribute_value
FROM jai_rgm_itm_regns jrtr,
JAI_RGM_ITM_TMPL_ATTRS jrita,
jai_po_rfqqt_v pla
upper(regime_code)
= 'EXCISE';
lv_item_class JAI_RGM_ITM_TMPL_ATTRS.attribute_value%TYPE;
/*Added by Vkavulur for bug#16686950 end*/
BEGIN
-- NBEGIN
mentBug# 2427465
END IF;
OPEN Fetch_Mod_Cr_Cur( rec.tax_id );
FETCH Fetch_Mod_Cr_Cur INTO v_tax_type, v_mod_cr, v_vendor1_id;
CLOSE Fetch_Mod_Cr_Cur;
IF rec.mod_cr_percentage IS NOT NULL AND rec.mod_cr_percentage >
0 THEN
v_modvat_flag := 'Y';
ELSIF rec.mod_cr_percentage IS NULL THEN
v_modvat_flag := 'N';
END IF;
/*Added by Vkavulur for bug#16686950 begin*/
jai_cmn_utils_pkg.write_fnd_log_msg('JAI_CMN_TAX
_DEFAULTATION_PKG','v_transaction_name '||v_transaction_name);
jai_cmn_utils_pkg.write_fnd_log_msg('JAI_CMN_TAX
_DEFAULTATION_PKG','p_line_id '||p_line_id);
OPEN fetch_item_class(p_line_id);
FETCH fetch_item_class INTO lv_item_class;
CLOSE fetch_item_class;
jai_cmn_utils_pkg.write_fnd_log_msg('JAI
_CMN_TAX_DEFAULTATION_PKG','lv_item_class '||lv_item_class|| ' TAX TYPE '||uppe
r(rec.tax_type));
--ADDED nvl condition for bug#17574176
IF NVL(lv_item_class,'OTIN') IN ('OTIN','OTEX')
AND (upper(rec.tax_type) like '%EXCISE%' OR upper(rec.tax_type)
like '%CVD%' ) THEN
v_modvat_flag := 'N';
END IF;
jai_cmn_utils_pkg.write_fnd_log_msg('JAI_CMN_TAX
_DEFAULTATION_PKG','MODVAT FALG IS '||v_modvat_flag);
/*Added by Vkavulur for bug#16686950 end*/
IF v_transaction_name IN ( 'OTHERS', 'QUOTATION', 'BLANKET' ) TH
EN
IF upper(rec.tax_type) IN ( 'CVD',
jai_constants.tax_type_add_cvd ,
-- Da
te 31/10/2006 Bug 5228046 added by SACSETHI
'CUSTOMS' ,
JAI_CONSTANTS.TAX_TYPE_SH_CVD_EDU_CESS,/*bduvarag for the bug#59897
40*/
jai_constants.tax_type_cvd_edu_cess ,
JAI_CONSTANTS.TAX_TYPE_SH_CUSTOMS_EDU_CESS,/*bduvarag for the bug#5
989740*/
jai_constants.tax_type_customs_edu_cess
) THEN
v_vendor_id := NULL;
ELSIF UPPER( rec.tax_type ) LIKE UPPER( '%EXCISE%' ) THEN
v_vendor_id := p_vendor_id;
ELSE
v_vendor_id := NVL( v_vendor1_id, p_vendor_id );
END IF;
END IF;
IF rec.tax_type = 'TDS' THEN
v_vendor_id := v_vendor1_id;
END IF;
IF operation = 'I' THEN
IF p_operation_flag <> -1 THEN
INSERT INTO JAI_PO_TAXES(
line_focus_id, line_location_id, po_line_id, po_hea
der_id,
tax_line_no,
precedence_1, precedence_2, precedence_3, precedence_4, precedence_5,
precedence_6, precedence_7, precedence_8, precedence_9, precedence_10,
-- Date 31/10/2006 Bug 5228046 added by SACSETHI
tax_id, tax_type, tax_rate, qty_rate, uom, tax_amoun
t, tax_target_amount,
currency, modvat_flag, vendor_id,
creation_date, created_by,
last_update_date, last_updated_by, last_update_login
,
tax_category_id
-- cbabu for EnhancementBug# 242
7465
) VALUES (
v_seq_val, v_line_id, p_line_id, p_header_id,
row_count,
rec.p_1, rec.p_2,rec.p_3, rec.p_4, rec.p_5,
rec.p_6, rec.p_7,rec.p_8, rec.p_9, rec.p_10,
rec.tax_id, rec.tax_type, rec.tax_rate, rec.tax_amo
unt, rec.uom_code,
ROUND(NVL(tax_amt_tab(row_count),0), REC.ROUNDING_FA
CTOR),
DECODE(NVL(base_tax_amt_tab(row_count), 0), 0, NVL(t
ax_amt_tab(row_count),0),
NVL(base_tax_amt_tab(row_count), 0)) * p_currency_co
nv_factor ,
p_currency, v_modvat_flag, v_vendor_id,
p_creation_date, p_created_by,
p_last_update_date, p_last_updated_by, p_last_update
_login,
p_tax_category_id -- cbabu for EnhancementBug# 242
7465
);
=>
=>
=>
g
=>
sage =>
last_update_date = p_last_update_date,
last_update_login = p_last_update_login
WHERE po_line_id = p_line_id
AND line_location_id = v_line_id;
ELSE
UPDATE JAI_PO_TAXES
SET Tax_Amount = ROUND(NVL( tax_amt_tab(row_count), 0 ),
REC.ROUNDING_FACTOR),
tax_target_amount = DECODE(NVL(base_tax_amt_tab(row_
count), 0), 0, NVL(tax_amt_tab(row_count),0),
NVL(base_tax_amt_tab(row_count), 0)) * p_currenc
y_conv_factor ,
last_updated_by = p_last_updated_by,
last_update_date = p_last_update_date,
last_update_login = p_last_update_login
WHERE Po_Line_Id = p_line_id
AND Line_Location_Id IS NULL;
END IF;
END IF;
v_vendor_id := NULL;
END;
-- NDECLARE, NBEGIN
END;
-- MBEGIN
ER/RELEASES
ELSIF transaction_name = 'PO_REQN' THEN
BEGIN
DECLARE
v_modvat_flag
v_vendor_id
v_currency
VARCHAR2(1);
NUMBER;
VARCHAR2(15);
BEGIN
IF rec.mod_cr_percentage IS NOT NULL AND rec.mod_cr_percentage >
0 THEN
v_modvat_flag := 'Y';
ELSIF rec.mod_cr_percentage IS NULL THEN
v_modvat_flag := 'N';
END IF;
IF rec.tax_type = 'TDS' THEN
v_vendor_id := rec.vendor_id;
ELSIF UPPER(rec.tax_type) IN ('CVD',
jai_constants.tax_type_add_cvd , -- Date 31/1
0/2006 Bug 5228046 added by SACSETHI
'CUSTOMS',
JAI_CONSTANTS.TAX_TYPE_SH_CVD_EDU_CESS,/*bduvarag for the bug#5989740*/
jai_constants.tax_type_cvd_edu_cess ,
JAI_CONSTANTS.TAX_TYPE_SH_CUSTOMS_EDU_CESS,/*bduvarag for the bug#5989740*/
jai_constants.tax_type_customs_edu_cess
) THEN
v_vendor_id := NULL;
ELSIF UPPER( rec.tax_type ) LIKE '%EXCISE%' THEN
v_vendor_id := p_vendor_id;
ELSE
, jai_constants.G_AP_STANDALONE_INVOICE
-- Added by Jason Liu on 2007/08/23
)
and p_action = jai_constants.default_taxes )
OR (p_source_trx_type = jai_constants.ar_cash)
then
-- Added by Jason Liu for standalone invoice on 2007/08/23
---------------------------------------------------------------------IF p_source_trx_type = jai_constants.G_AP_STANDALONE_INVOICE
AND rec.tax_type IN ( jai_constants.tax_type_value_added
, jai_constants.tax_type_sales
, jai_constants.tax_type_cst
, jai_constants.tax_type_other)
THEN
v_modvat_flag := 'N';
END IF; --p_source_trx_type = jai_constants.AP_STANDALONE_INVOICE
---------------------------------------------------------------------/*
|| When currency conversion rate is null it means the transaction is
in the INR only
*/
if v_currency_conv_factor is null then
v_currency_conv_factor := 1;
end if;
/*
jai_cmn_debug_contexts_pkg.print
(ln_reg_id
,'Values before insert into jai_cmn_document_taxes'
||chr(10)
|| ',tax_line_no
-> '||row_count
||CHR(10)
|| ',tax_id
-> '||rec.tax_id
||CHR(10)
|| ',tax_type
-> '||rec.tax_type
||CHR(10)
|| ',currency_code
-> '||p_currency
||CHR(10)
|| ',tax_rate
-> '||rec.tax_rate
||CHR(10)
|| ',qty_rate
-> '||rec.tax_amount
||CHR(10)
|| ',uom
-> '||rec.uom_code
||CHR(10)
|| ',tax_amt
-> '||round( nvl(tax_amt_tab(row_coun
t),0) , rec.rounding_factor ) ||CHR(10)
|| ',func_tax_amt
-> '||nvl(func_tax_amt_tab(row_count)
,0) * v_currency_conv_factor
||CHR(10)
|| ',modvat_flag
-> '||v_modvat_flag
||CHR(10)
|| ',adhoc_flag
-> '||rec.adhoc_flag
||CHR(10)
|| ',tax_category_id
-> '||rec.tax_category_id
||CHR(10)
|| ',source_doc_type
-> '||p_source_trx_type
||CHR(10)
|| ',source_doc_id
-> '||p_header_id
||CHR(10)
|| ',source_doc_line_id
-> '||p_line_id
||CHR(10)
ystem
|| ',source_table_name
-> '||p_source_table_name
||CHR(10)
|| ',tax_modified_by
-> '||jai_constants.tax_modified_by_s
||CHR(10)
|| ',precedence_1
-> '||rec.p_1
||CHR(10)
|| ',precedence_2
-> '||rec.p_2
||CHR(10)
|| ',precedence_3
-> '||rec.p_3
||CHR(10)
|| ',precedence_4
-> '||rec.p_4
||CHR(10)
|| ',precedence_5
-> '||rec.p_5
||CHR(10)
|| ',precedence_6
-> '||rec.p_6
||CHR(10)
|| ',precedence_7
-> '||rec.p_7
||CHR(10)
|| ',precedence_8
-> '||rec.p_8
||CHR(10)
|| ',precedence_9
-> '||rec.p_9
||CHR(10)
|| ',precedence_10
-> '||rec.p_10
||CHR(10)
|| ',creation_date
-> '||p_creation_date
||CHR(10)
|| ',created_by
-> '||p_created_by
||CHR(10)
|| ',last_update_date
-> '||p_last_update_date
||CHR(10)
|| ',last_updated_by
-> '||p_last_updated_by
||CHR(10)
|| ',last_update_login
-> '||p_last_update_login
||CHR(10)
); */ --commented by bgowrava for bug#5631784
-- Added by Eric Ma for standalone invoice on 2007/09/27
--------------------------------------------------------------------
, tax_modified_by
, precedence_1
, precedence_2
, precedence_3
, precedence_4
, precedence_5
, precedence_6
, precedence_7
, precedence_8
, precedence_9
, precedence_10
, creation_date
, created_by
, last_update_date
, last_updated_by
, last_update_login
)
VALUES
( jai_cmn_document_taxes_s.nextval
-- doc_tax_id
, row_count
-- tax_line_no
, rec.tax_id
-- tax_id
, rec.tax_type
-- tax_type
, p_currency
-- currency
, rec.tax_rate
-- tax_rate
, rec.tax_amount
-- qty_rate
, rec.uom_code
-- uom
, round( nvl(tax_amt_tab(row_count),0)
-- tax_amount
, rec.rounding_factor
)
, nvl(func_tax_amt_tab(row_count),0)
* v_currency_conv_factor
-- func_tax_amount
, v_modvat_flag
-- modvat_flag
, rec.adhoc_flag
-- adhoc_flag
, rec.tax_category_id
-- tax_category_id
, p_source_trx_type
-- source_doc_type
, p_header_id
-- source_doc_id
, p_line_id
-- source_doc_line_id
, p_line_id
-- source_doc_parent_line_no,added by Eric Ma
, p_source_table_name
-- source_table_name
, jai_constants.tax_modified_by_system
--tax_modified_by(SYSTEM=system defaulted, MANUAL=User Modified)
, rec.p_1
-- precedence_1
, rec.p_2
-- precedence_2
, rec.p_3
-- precedence_3
, rec.p_4
-- precedence_4
, rec.p_5
-- precedence_5
, rec.p_6
-- precedence_6
, rec.p_7
-- precedence_7
, rec.p_8
-- precedence_8
, rec.p_9
-- precedence_9
, rec.p_10
-- precedence_10
, p_creation_date
-- creation_date
, p_created_by
-- created_by
, p_last_update_date
-- last_update_date
, p_last_updated_by
-- last_updated_by
, p_last_update_login
-- last_update_login
);
ELSE --(p_source_trx_type <>jai_constants.G_AP_STANDALONE_INVOICE );
------------------------------------------------------------------
-- d
oc_tax_id
,
row_count
-- tax_l
rec.tax_id
-- tax_i
rec.tax_type
-- tax_t
p_currency
-- curre
rec.tax_rate
-- tax_r
rec.tax_amount
-- qty_r
,
,
rec.uom_code
round( nvl(tax_amt_tab(row_count),0)
-- uom
-- tax_a
ine_no
d
ype
ncy
ate
ate
mount
, rec.rounding_factor
)
/* ,
nvl(func_tax_amt_tab(row_count),0)
* v_currency_conv_factor*/
,
round(round(nvl(func_tax_amt_tab(row_count),0)
,rec.rounding_factor) * v_currency_conv_factor,
rec.rounding_factor)
-- func_
tax_amount
--Modified by Qinglei on 16-Jan-2012 for bug#135472
39
,
v_modvat_flag
-- modva
rec.adhoc_flag
-- adhoc
rec.tax_category_id
-- tax_c
p_source_trx_type
-- sourc
p_header_id
-- sourc
p_line_id
-- sourc
p_source_table_name
-- sourc
t_flag
_flag
ategory_id
e_doc_type
e_doc_id
e_doc_line_id
e_table_name
,
jai_constants.tax_modified_by_system
-- tax_m
odified_by (SYSTEM=system defaulted, MANUAL=User Modified)
,
rec.p_1
-- prece
dence_1
,
rec.p_2
-- prece
dence_2
,
rec.p_3
-- prece
dence_3
,
rec.p_4
-- prece
dence_4
,
rec.p_5
-- prece
dence_5
,
rec.p_6
-- prece
dence_6
,
rec.p_7
-- prece
dence_7
,
rec.p_8
-- prece
dence_8
,
rec.p_9
-- prece
dence_9
,
rec.p_10
-- prece
dence_10
,
p_creation_date
-- creat
ion_date
,
p_created_by
-- creat
ed_by
,
p_last_update_date
-- last_
update_date
,
p_last_updated_by
-- last_
updated_by
,
p_last_update_login
-- last_
update_login
);
END IF; --(p_source_trx_type = jai_constants.G_AP_STANDALONE_INVOICE
)
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id, 'Record inserted int
o jai_cmn_document_taxes');*/ --commented by bgowrava for bug#5631784
/* Date 22-feb-2007 Added by SACSETHI for bug 6012570 (5876390)
in This , Recalculation will be happen in Draft invoice
*/
elsif
p_source_trx_type = jai_constants.pa_draft_invoice
jai_cmn_document_taxes
tax_amt
= tax_amt_tab(row_count)
,func_tax_amt = nvl(func_tax_amt_tab(row_count),0) * nvl(v_
currency_conv_factor ,1)
,last_update_date = p_last_update_date
,last_updated_by = p_last_updated_by
,last_update_login = p_last_update_login
where source_doc_line_id = p_line_id
and
tax_id
= rec.tax_id
and
source_doc_type
= jai_constants.pa_draft_invoice;
elsif p_source_trx_type = jai_constants.source_ttype_delivery
then
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id
,'Value of variables used for updating ja_in_so_
picking_tax_lines'||chr(10)
||'tax_amount
= '|| tax_amt_tab(row_count
)
||chr(10)
||'func_tax_amount = '||nvl(func_tax_amt_tab(r
ow_count),0) * v_currency_conv_factor ||chr(10)
||'base_tax_amount = '||round( nvl(tax_amt_tab
(row_count),0), rec.rounding_factor) ||chr(10)
||'tax_id
= '||rec.tax_id
); */ --commented by bgowrava for bug#5631784
if p_action = jai_constants.recalculate_taxes then
--Used base_tax_amt_tab instead of tax_amt_tab to update column base_tax_amount
for bug#8905076 by JMEENA
update JAI_OM_WSH_LINE_TAXES
set
tax_amount
= tax_amt_tab(row_count)
,func_tax_amount = nvl(func_tax_amt_tab(row_count),0) * nv
l(v_currency_conv_factor ,1)
,base_tax_amount = round( nvl(base_tax_amt_tab(row_count),
0), rec.rounding_factor)
,last_update_date = p_last_update_date
,last_updated_by = p_last_updated_by
,last_update_login = p_last_update_login
where delivery_detail_id = p_line_id
and
tax_id
= rec.tax_id;
end if;
--Added by Zhiwei Hou for Bug#13359892 DTC enhancement on 20111128 begin
------------------------------------------------------------------------------elsif
p_source_trx_type = 'TDS INVOICE'--jai_constants.pa_draft_invoice
and p_action = jai_constants.recalculate_taxes
then
if v_currency_conv_factor is null then
v_currency_conv_factor := 1;
end if;
update
JAI_AP_TDS_INV_TAXES
set
TAX_AMOUNT
= tax_amt_tab(row_count)
,calc_tax_amount
= tax_amt_tab(row_count)
,base_tax_amount
= round(nvl(tax_amt_tab(row_count),0)/nvl
(v_currency_conv_factor ,1),2) --Added By zhiwei hou for Bug#13787158 on 2012030
5
,func_tax_amount
= tax_amt_tab(row_count)
--Added By zhiwei hou for Bug#13787158 on 2012030
5
--,func_tax_amount = nvl(func_tax_amt_tab(row_count),0) * n
vl(v_currency_conv_factor ,1) --Commented By zhiwei hou for Bug#13787158 on 201
20305
,last_update_date = p_last_update_date
,last_updated_by = p_last_updated_by
,last_update_login = p_last_update_login
where invoice_id = p_header_id
and
invoice_distribution_id = p_line_id
and
actual_tax_id = rec.tax_id;
--------------------------------------------------------------------------------Added by Zhiwei Hou for Bug#13359892 DTC enhancement on 20111128 end
elsif p_source_trx_type = jai_constants.bill_only_invoice then
/*
|| When currency conversion rate is null it means the transaction is
in the INR only
*/
if v_currency_conv_factor is null then
v_currency_conv_factor := 1;
end if;
/*
jai_cmn_debug_contexts_pkg.print (ln_reg_id
,'Value of variables used for updating JA_IN_R
A_CUST_TRX_TAX_LINES'||chr(10)
||'tax_amount
= '|| tax_amt_tab(row_cou
nt)
||chr(10)
||'func_tax_amount = '||nvl(func_tax_amt_tab
(row_count),0) * v_currency_conv_factor ||chr(10)
||'base_tax_amount = '||round( nvl(tax_amt_t
ab(row_count),0), rec.rounding_factor) ||chr(10)
||'tax_id
= '||rec.tax_id
); */ --commented by bgowrava for bug#563178
4
if p_action = jai_constants.recalculate_taxes then
update
set
JAI_AR_TRX_TAX_LINES
tax_amount
,func_tax_amount
t),0) * nvl(v_currency_conv_factor ,1)
,base_tax_amount
unt),0), rec.rounding_factor)
,last_update_date
,last_updated_by
,last_update_login
where link_to_cust_trx_line_id
and
tax_id
= tax_amt_tab(row_count)
= nvl(func_tax_amt_tab(row_coun
= round( nvl(tax_amt_tab(row_co
=
=
=
=
=
p_last_update_date
p_last_updated_by
p_last_update_login
p_line_id
rec.tax_id;
end if;
/** End Bug 5631784 */
END IF;
-- p_transaction_type
row_count := row_count + 1;
END LOOP;
-- Start, cbabu for EnhancementBug# 2427465
IF SUBSTR( transaction_name, 1, 3 ) = 'RFQ'
OR
SUBSTR( transaction_name, 1, 9 ) = 'QUOTATION' OR
SUBSTR( transaction_name, 1, 7 ) = 'BLANKET' OR
SUBSTR( transaction_name, 1, 8 ) = 'BLANKETR' OR
SUBSTR( transaction_name, 1, 6 ) = 'OTHERS'
OR
SUBSTR( transaction_name, 1, 9 ) = 'SCHEDULED'
THEN
BEGIN
UPDATE JAI_PO_LINE_LOCATIONS
SET tax_category_id = p_tax_category_id
WHERE line_focus_id = v_line_focus_id_holder;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR( -20101, '1 Exception raised in jai_cmn_
tax_defaultation_pkg:JIPLL '||SQLERRM, TRUE);
END;
ELSIF transaction_name = 'PO_REQN' THEN
BEGIN
UPDATE JAI_PO_REQ_LINES
SET tax_category_id = p_tax_category_id
WHERE requisition_line_id = p_line_id;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR( -20101, '2 Exception raised in jai_cmn_
tax_defaultation_pkg:JIRL '||SQLERRM, TRUE);
END;
/* End, cbabu for EnhancementBug# 2427465 */
END IF;
p_tax_amount := nvl(v_tax_amt,0);
/* Added by Ramananda for bug#4407165 */
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.SET_NAME('JA','JAI_EXCEPTION_OCCURED');
FND_MESSAGE.SET_TOKEN('JAI_PROCESS_MSG', lv_object_name ||'. Err:'||sqlerr
m );
app_exception.raise_exception;
END ja_in_calc_prec_taxes;
, (p_max_tax_line + a.li
ne_no)
)
lno
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_1
, decode (a.precedence_1
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_1))
)
p_1
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_2
, decode (a.precedence_2
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_2))
)
p_2
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_3
, decode (a.precedence_3
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_3))
)
p_3
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_4
, decode (a.precedence_4
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_4))
)
p_4
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_5
, decode (a.precedence_5
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_5))
)
p_5
/* Bug 5094130. Added by Lakshmi Gopalsami Included
precedences 6 to 10*/
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_6
, decode (a.precedence_6
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_6))
)
p_6
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_7
, decode (a.precedence_7
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_7))
)
p_7
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_8
, decode (a.precedence_8
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_8))
)
p_8
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_9
, decode (a.precedence_9
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_9))
)
p_9
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_10
, decode (a.precedence_1
0, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_10))
)
p_10
, b.tax_rate
, b.tax_amount
, b.tax_amount qty_rate /*Added b.tax_amount qty_ra
te by murtuza for bug 14675629*/
, b.uom_code
, b.end_date valid_date
, DECODE(rgm_tax_types.regime_Code,jai_constants.va
t_regime, 4, /* added by ssumaith - bug# 4245053*/
/*jai_constants.
cgst_regime, 7,*/ /* Added by Jia for GST Bug#10043656 on 2010/09/10 */
/*jai_constants.
sgst_regime, 7, *//* Added by Jia for GST Bug#10043656 on 2010/09/10 */
jai_constants.c
ustoms_regime, 8, /* Added by Bo Li for Bug#11684111 BOE Ehancement */
DECODE(UPPER(b.tax_type),
'EXCISE',
1,
'ADDL. EXCISE',
1,
'OTHER EXCISE',
1,
'TDS',
2,
'EXCISE_EDUCATION_CESS' ,6, --modifie
d by walton for inclusive tax
JAI_CONSTANTS.TAX_TYPE_SH_EXC_EDU_CESS , 6 , /*bduvarag for t
he bug#5989740*/ --modified by walton for inclusive tax
'CVD_EDUCATION_CESS'
,6, --modifie
d by walton for inclusive tax
JAI_CONSTANTS.TAX_TYPE_SH_CVD_EDU_CESS, 6 , /*bduvarag for
the bug#5989740*/--modified by walton for inclusive tax
0
)
) tax_type_val
, b.mod_cr_percentage
, b.vendor_id
, b.tax_type
, nvl(b.rounding_factor,0) rounding_factor
, b.adhoc_flag
, a.tax_category_id
, b.inclusive_tax_flag --added by walton for inclusive tax on 08-Dev
-07
from JAI_CMN_TAX_CTG_LINES a
, JAI_CMN_TAXES_ALL b
, jai_regime_tax_types_v rgm_tax_types /* added by
ssumaith - bug# 4245053*/
where a.tax_category_id in (p_tax_category_id, nvl(p_thr
eshold_tax_cat_id,-1))
and rgm_tax_types.tax_type (+) = b.tax_type /* added b
y ssumaith - bug# 4245053*/
and a.tax_id = b.tax_id
order by decode (a.tax_category_id, p_tax_category_id,
a.line_no
, (p_max_tax_line + a.li
ne_no)
);
--Added by Kevin Cheng for Retroactive Price 2008/01/13
--=====================================================
ELSIF pv_retroprice_changed = 'Y'
THEN
open ref_tax_cur
for
select a.tax_id
, decode (a.tax_category_id, p_tax_category_id, a.l
ine_no
, (p_max_tax_line + a.li
ne_no)
)
lno
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_1
, decode (a.precedence_1
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_1))
)
p_1
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_2
, decode (a.precedence_2
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_2))
)
p_2
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_3
, decode (a.precedence_3
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_3))
)
p_3
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_4
, decode (a.precedence_4
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_4))
)
p_4
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_5
, decode (a.precedence_5
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_5))
)
p_5
/* Bug 5094130. Added by Lakshmi Gopalsami Included
precedences 6 to 10*/
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_6
, decode (a.precedence_6
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_6))
)
p_6
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_7
, decode (a.precedence_7
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_7))
)
p_7
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_8
, decode (a.precedence_8
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_8))
)
p_8
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_9
, decode (a.precedence_9
, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_9))
)
p_9
, decode (a.tax_category_id, p_tax_category_id, a.p
recedence_10
, decode (a.precedence_1
0, p_base, p_max_rgm_tax_line, (p_max_tax_line + a.precedence_10))
)
p_10
, b.tax_rate
, b.tax_amount
, b.uom_code
, b.end_date valid_date
, DECODE(rgm_tax_types.regime_Code,jai_constants.va
t_regime, 4, /* added by ssumaith - bug# 4245053*/
/*jai_constants.
cgst_regime, 7, *//* Added by Jia for GST Bug#10043656 on 2010/09/10 */
/*jai_constants.