Commit 12a7e8c5 authored by kdabholkar's avatar kdabholkar

addinf new functions for DB2 and Oracle

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@137735 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f7932097
...@@ -417,6 +417,164 @@ begin ...@@ -417,6 +417,164 @@ begin
end; end;
/ /
/* added by kaustubh on 6 sep
*
*/
create or replace
function fn_gst_rate_gp_amt(as_trancode in taxtran.tran_code%type,as_tranid in taxtran.tran_id%type, al_lineno number, as_type in char, as_rateoramt in char,as_taxgroup in char)
return number is
lc_rateoramt number(16,2) := 0;
ls_lineno char(3);
-- as_type : G (sgst), H (cgst), I (igst) and J (cess)
-- as_rateoramt : R or A
begin
begin
-- get IGST rate
select lpad(trim(to_char(al_lineno)),3, ' ') into ls_lineno from dual;
exception when others then
ls_lineno := ' ';
end;
if as_rateoramt = 'T' then
begin
-- taxable amount
select taxable_amt into lc_rateoramt 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 tm.tax_group = as_taxgroup
and taxable_amt <> 0
and rownum = 1;
exception when others then
lc_rateoramt := 0;
end;
else
if as_rateoramt = 'R' then
begin
-- rate
select tax_perc into lc_rateoramt 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 tm.tax_group = as_taxgroup
and tt.line_no = ls_lineno;
exception when others then
lc_rateoramt := 0;
end;
else
begin
-- rate
select sum(tax_amt) into lc_rateoramt 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 tm.tax_group = as_taxgroup
and tt.line_no = ls_lineno;
exception when others then
lc_rateoramt := 0;
end;
end if;
end if;
return lc_rateoramt;
end;
create or replace
function fn_get_gst_gp_rate(as_trancode in taxtran.tran_code%type,as_tranid in taxtran.tran_id%type, al_lineno number,as_taxgroup in char)
return number is
lc_gstrate number(6,2) := 0;
ls_lineno char(3);
begin
begin
-- get IGST rate
select lpad(trim(to_char(al_lineno)),3, ' ') into ls_lineno from dual;
exception when others then
ls_lineno := ' ';
end;
begin
-- get IGST rate
select tax_perc into lc_gstrate from taxtran tt, tax tm
where tm.tax_code = tt.tax_code
and tm.tax_type = 'I'
and tt.tran_code = as_trancode
and tm.tax_group = as_taxgroup
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno;
exception when others then
lc_gstrate := 0;
end;
if lc_gstrate = 0 then
-- if IGST rate is 0 then get sum of SGST and CGST rate
begin
select sum(tax_perc) into lc_gstrate 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 tm.tax_group = as_taxgroup
and tt.tran_id = as_tranid
and tt.line_no = ls_lineno;
exception when others then
lc_gstrate := 0;
end;
end if;
return lc_gstrate;
end;
create or replace FUNCTION fn_sundry_gst_info (as_sundrytype varchar2, as_code varchar2, as_coltype varchar2)
RETURN varchar2 AS
ls_strsql varchar2 (2000);
ls_colname varchar2(30);
ls_colval varchar2(2000);
BEGIN
begin
-- as_coltype 'N' - name , 'S' state_code 'G' - tax_reg_2
IF as_sundrytype = 'S' THEN
IF as_coltype='N' then
ls_colname := 'SUPP_NAME' ;
elsif as_coltype='S' then
ls_colname := 'STATE_CODE' ;
else
ls_colname := 'TAX_REG_2' ;
END if;
ls_strsql := 'select '||ls_colname||' from supplier Where supp_code= '''||as_code||'''' ;
elsif as_sundrytype = 'T' then
IF as_coltype='N' then
ls_colname := 'TRAN_NAME' ;
elsif as_coltype='S' then
ls_colname := 'STATE_CODE' ;
else
ls_colname := 'TAX_REG_2' ;
END if;
ls_strsql := 'select '||ls_colname||' from transporter Where tran_code= '''||as_code||'''' ;
else
ls_strsql := 'select '''' from dual' ;
end if;
EXECUTE IMMEDIATE ls_strsql into ls_colval;
exception when others then
ls_colval := ' ';
end;
RETURN ls_colval ;
END;
/
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
/* updated by kaustubh on 25-07-2017*/ /* updated by kaustubh on 25-07-2017*/
--- db2 function --- db2 function
...@@ -540,4 +698,211 @@ declare ls_lineno char(3); ...@@ -540,4 +698,211 @@ declare ls_lineno char(3);
return lc_rateoramt; return lc_rateoramt;
end end
@ @
\ No newline at end of file
/*added by kaustubh on 6 sep 2017*/
CREATE FUNCTION fn_get_gst_gp_rate(as_trancode VARCHAR(6),as_tranid VARCHAR(10),al_lineno CHAR(3),as_taxgrouop char(5))
returns DECIMAL(6,2)
BEGIN
ATOMIC
DECLARE
lc_gstrate DECIMAL(6,2);
DECLARE
ls_lineno CHAR(3);
IF(
LENGTH(
LTRIM(
RTRIM(
al_lineno))) = 1) THEN
SET ls_lineno = concat(
' ',
LTRIM(
RTRIM(
al_lineno)));
END IF;
IF (LENGTH(LTRIM(RTRIM(al_lineno))) = 2) THEN
SET ls_lineno = concat(' ',LTRIM(RTRIM(al_lineno)));
END IF;
IF (LENGTH(LTRIM(RTRIM(al_lineno))) = 3) THEN
SET ls_lineno = LTRIM(RTRIM(al_lineno));
END IF;
SET (lc_gstrate) =
(
SELECT
COALESCE(MAX(tax_perc),0)
FROM
taxtran tt,
tax tm
WHERE
tm.tax_code = tt.tax_code
AND tm.tax_type = 'I'
AND tt.tran_code = as_trancode
and tm.tax_group = as_taxgrouop
AND tt.tran_id = as_tranid
AND tt.line_no = ls_lineno
)
;
IF lc_gstrate = 0 THEN
SET lc_gstrate =
(
SELECT
COALESCE(SUM(tax_perc),0)
FROM
taxtran tt,
tax tm
WHERE
tm.tax_code = tt.tax_code
AND tm.tax_type IN ('G','H')
and tm.tax_group = as_taxgrouop
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_GST_RATE_gp_AMT(as_trancode VARCHAR(6),as_tranid VARCHAR(10),al_lineno CHAR(3),as_type VARCHAR(1),as_rateoramt VARCHAR(1),as_taxgrouop char(5))
returns DECIMAL(17,6)
BEGIN
ATOMIC
DECLARE
lc_rateoramt DECIMAL(17,6);
DECLARE
ls_lineno CHAR(3);
IF(
LENGTH(
LTRIM(
RTRIM(
al_lineno))) = 1) THEN
SET ls_lineno = concat(
' ',
LTRIM(
RTRIM(
al_lineno)));
END IF;
IF (LENGTH(LTRIM(RTRIM(al_lineno))) = 2) THEN
SET ls_lineno = concat(' ',LTRIM(RTRIM(al_lineno)));
END IF;
IF (LENGTH(LTRIM(RTRIM(al_lineno))) = 3) THEN
SET ls_lineno = LTRIM(RTRIM(al_lineno));
END IF;
IF as_rateoramt = 'T' THEN
SET (lc_rateoramt) =
(
SELECT
COALESCE(taxable_amt,0)
FROM
taxtran tt,
tax tm
WHERE
tm.tax_code = tt.tax_code
AND tm.tax_type IN ('G','H','I')
and tm.tax_group = as_taxgrouop
AND tt.tran_code = as_trancode
AND tt.tran_id = as_tranid
AND tt.line_no = ls_lineno
AND tt.taxable_amt <> 0
FETCH
FIRST row only
)
;
END IF;
IF as_rateoramt = 'R' THEN
SET (lc_rateoramt) =
(
SELECT
COALESCE(MAX(tax_perc),0)
FROM
taxtran tt,
tax tm
WHERE
tm.tax_code = tt.tax_code
AND tm.tax_type = as_type
and tm.tax_group = as_taxgrouop
AND tt.tran_code = as_trancode
AND tt.tran_id = as_tranid
AND tt.line_no = ls_lineno
)
;
END IF;
IF as_rateoramt = 'A' THEN
SET (lc_rateoramt) =
(
SELECT
COALESCE(SUM(tax_amt),0)
FROM
taxtran tt,
tax tm
WHERE
tm.tax_code = tt.tax_code
AND tm.tax_type = as_type
and tm.tax_group = as_taxgrouop
AND tt.tran_code = as_trancode
AND tt.tran_id = as_tranid
AND tt.line_no = ls_lineno
)
;
END IF;
RETURN lc_rateoramt;
END
create FUNCTION fn_sundry_gst_info (as_sundrytype char(1), as_code varchar(10), as_coltype char(1))
RETURNS varchar(2000)
deterministic
begin atomic
declare ls_strsql varchar(2000);
declare ls_colname varchar(30);
declare ls_colval varchar(2000);
-- as_coltype 'N' - name , 'S' state_code 'G' - tax_reg_2
if as_sundrytype = 'S' then
if as_coltype='N' then
set ls_colval = (select supp_name from supplier where supp_code = as_code) ;
else
if as_coltype='S' then
set ls_colval = (select STATE_CODE from supplier where supp_code = as_code) ;
else
set ls_colval = (select TAX_REG_2 from supplier where supp_code = as_code) ;
end if;
end if;
else
if as_sundrytype = 'T' then
if as_coltype='N' then
set ls_colval = (select tran_name from transporter where tran_code = as_code) ;
else
if as_coltype='S' then
set ls_colval = (select STATE_CODE from transporter where tran_code = as_code) ;
else
set ls_colval = (select TAX_REG_2 from transporter where tran_code = as_code) ;
end if;
end if;
else
set ls_colval = ' ';
end if;
end if;
RETURN ls_colval ;
END
@
------------------------------------------------------
/*added by kaustubh on 2 sep 2017*/
INSERT INTO OBJ_ITEMCHANGE (OBJ_NAME,FORM_NO,FIELD_NAME,MANDATORY) VALUES ('gstdata_prc','1 ','prd_code',NULL);
Insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION) values ('VMDTGTR ','greater date','from date greater than to date','E',null,null,null,null,to_date('27-04-06','DD-MM-RR'),'BASE ','BASE ',null,null);
Insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION) values ('VMDATNULL ','Date empty','From / to date cannot be null','E','Y',null,null,null,to_date('12-02-09','DD-MM-RR'),'pankaj ','pankaj ',null,null);
Insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION) values ('CNDIPRDINV','Invalid period!','Period does not exist','E','Y',null,null,null,to_date('01-04-09','DD-MM-RR'),'BIPIN ','SUN ',null,null);
------------------------------------------------------
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