Commit 12e61430 authored by kdabholkar's avatar kdabholkar

commited to add DB2 function


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106364 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3484cec8
...@@ -375,3 +375,103 @@ begin ...@@ -375,3 +375,103 @@ begin
end; end;
/ /
-------------------------------------------------------------------------------------------------------------
--- db2 function
create function fn_get_gst_rate(as_trancode varchar(6),as_tranid varchar(10), al_lineno decimal(3,0))
returns decimal(14,3)
deterministic
begin atomic
declare lc_gstrate decimal(6,2);
declare ls_lineno char(3);
begin
-- get IGST rate
set ls_lineno = right(' '|| rtrim(cast(al_lineno as char(3))),3);
-- get IGST rate
lc_gstrate = (select tax_perc from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type = 'I'
and tt.tran_code = as_trancode
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno );
if lc_gstrate = 0 then
-- if IGST rate is 0 then get sum of SGST and CGST rate
set lc_gstrate = (select sum(tax_perc) from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type in ('G','H')
and tt.tran_code = as_trancode
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno);
end if;
return lc_gstrate;
end
@
create function fn_get_hsn_no(as_sitecode varchar(5),as_itemcode varchar(10))
returns varchar(20)
deterministic
begin atomic
declare ls_hsnno varchar(20);
begin
set ls_hsnno = (select hsn_no from siteitem
where site_code = as_sitecode
and item_code = as_itemcode);
if ls_hsnno is null or length(trim(ls_hsnno)) = 0 then
ls_hsnno = (select hsn_no from item
where item_code = as_itemcode);
end if;
return ls_hsnno;
end
@
create function fn_gst_rate_amt(as_trancode varchar(6),as_tranid varchar(10), al_lineno decimal(3,0), as_type char(1), as_rateoramt char(1))
returns decimal(14,3)
deterministic
begin atomic
declare lc_rateoramt decimal(16,2);
declare ls_lineno char(3);
-- as_type : G (sgst), H (cgst), I (igst) and J (cess)
-- as_rateoramt : R or A
begin
set ls_lineno = right(' '|| rtrim(cast(al_lineno as char(3))),3);
if as_rateoramt = 'T' then
-- taxable amount
set lc_rateoramt = (select taxable_amt from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type in ('G','H','I')
and tt.tran_code = as_trancode
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno
and taxable_amt <> 0
and fetch first row only );
else
if as_rateoramt = 'R' then
-- rate
set lc_rateoramt = (select tax_perc from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type = as_type
and tt.tran_code = as_trancode
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno);
else
-- rate
set lc_rateoramt = (select sum(tax_amt) from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type = as_type
and tt.tran_code = as_trancode
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno);
end if;
end if;
return lc_rateoramt;
end
@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment