|
|
|
|
--<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if exists(select * from sysobjects where name='p_soa_getenddate' and xtype='p')
|
|
|
|
|
drop procedure p_soa_getenddate
|
|
|
|
|
go
|
|
|
|
|
create procedure p_soa_getenddate
|
|
|
|
|
(
|
|
|
|
|
@psjscode varchar(1), --0-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2-<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>3-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psfinacode varchar(10),
|
|
|
|
|
@pssupcode varchar(15),
|
|
|
|
|
@pscontrno varchar(40),
|
|
|
|
|
@psenddate varchar(10) output,
|
|
|
|
|
@psmsg varchar(2000) output
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
declare @nssql nvarchar(4000)
|
|
|
|
|
declare @nswhere nvarchar(4000)
|
|
|
|
|
declare @optpaysoabyshop varchar(1)
|
|
|
|
|
declare @optpaysoabyfina varchar(1)
|
|
|
|
|
declare @sHasDz varchar(1)
|
|
|
|
|
declare @slastdzdate varchar(10)
|
|
|
|
|
declare @smonthlastday varchar(10) --<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
declare @snextmonth1st varchar(10) --<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD><EFBFBD>µ<EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
declare @stheday varchar(2)
|
|
|
|
|
declare @slastday varchar(2)
|
|
|
|
|
declare @sjsperiod varchar(1)
|
|
|
|
|
begin
|
|
|
|
|
set @psenddate = ''
|
|
|
|
|
set @nswhere = ''
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|
|
|
|
select @optpaysoabyshop=itemvalue from t_syscfg where section='SYSTEM' and itemname='PaySoaByShop'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|
|
|
|
select @optpaysoabyfina=itemvalue from t_syscfg where section='SYSTEM' and itemname='PaySoaByFina'
|
|
|
|
|
|
|
|
|
|
if @optpaysoabyshop = '1'
|
|
|
|
|
set @nswhere = @nswhere + ' and (orgcode=''' + @psorgcode + ''' or orgcode=''*'')'
|
|
|
|
|
else if @optpaysoabyfina = '1'
|
|
|
|
|
set @nswhere = @nswhere + ' and (finacode=''' + @psfinacode + ''' or finacode=''*'')'
|
|
|
|
|
else
|
|
|
|
|
set @nswhere = @nswhere + ' and orgcode=''*'' and finacode=''*'''
|
|
|
|
|
if isnull(@pscontrno,'') <> ''
|
|
|
|
|
set @nswhere = @nswhere + ' and contrno=''' + @pscontrno + ''''
|
|
|
|
|
set @nswhere = @nswhere + ' and rzdate<>'''' and rzdate is not null'
|
|
|
|
|
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @nssql = 'select @slastdzdate=isnull(max(enddate),'''') from t_paysoa_head where supcode=''' + @pssupcode + '''' + @nswhere
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @nssql = 'select @slastdzdate=isnull(max(enddate),'''') from t_jopaysoa_head where supcode=''' + @pssupcode + '''' + @nswhere
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD>Ҹú<EFBFBD>ͬ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
exec sp_executesql @nssql,N'@slastdzdate varchar(10) output',@slastdzdate out
|
|
|
|
|
if @@error<>0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD>ͬû<EFBFBD>жԹ<EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>̵Ŀ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
if @slastdzdate = ''
|
|
|
|
|
begin
|
|
|
|
|
set @sHasDz = '0'
|
|
|
|
|
if isnull(@pscontrno,'') <> ''
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @slastdzdate=bgndate from t_contract where contrno = @pscontrno
|
|
|
|
|
else
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD>Ӧ<EFBFBD>̿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @slastdzdate=opendate from t_supplier where supcode = @pssupcode
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
set @sHasDz = '1'
|
|
|
|
|
if isnull(@slastdzdate,'') = ''
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = 'δ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>*/
|
|
|
|
|
if isnull(@pscontrno,'') = ''
|
|
|
|
|
begin
|
|
|
|
|
select @psenddate=convert(varchar(10),getdate(),120)
|
|
|
|
|
set @psmsg = '<EFBFBD>ɹ<EFBFBD>'
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD>еĽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
|
|
|
|
|
select @sjsperiod=jsperiod from t_contract where contrno=@pscontrno
|
|
|
|
|
/*0-<2D><> 1-<2D>½<EFBFBD> 2-<2D><><EFBFBD>½<EFBFBD> 3-Ѯ<><D1AE> 4-<2D>ܽ<EFBFBD>*/
|
|
|
|
|
if @sjsperiod = '0'
|
|
|
|
|
begin
|
|
|
|
|
select @psenddate=convert(varchar(10),getdate(),120)
|
|
|
|
|
set @psmsg = '<EFBFBD>ɹ<EFBFBD>'
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD>IJ<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㱾<EFBFBD>ζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
|
|
|
|
|
--ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @smonthlastday=convert(varchar(10),dateadd(day,-day(dateadd(month,1,convert(datetime,@slastdzdate,120))),dateadd(month,1,convert(datetime,@slastdzdate,120))),120)
|
|
|
|
|
--ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @snextmonth1st=convert(varchar(10),dateadd(m, 1, convert(datetime,substring(@slastdzdate, 1, 8)+'01',120)),120)
|
|
|
|
|
|
|
|
|
|
if @sjsperiod = '1'
|
|
|
|
|
begin
|
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD>½ᣬ<EFBFBD><EFBFBD><EFBFBD>ֺ<EFBFBD>ͬ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Թ<EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ϴν<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>죬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>жԹ<EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
if (@sHasDz = '1') and (@slastdzdate = @smonthlastday)
|
|
|
|
|
select @psenddate = convert(varchar(10),dateadd(day,-day(convert(datetime,@snextmonth1st,120)),dateadd(month,1,convert(datetime,@snextmonth1st,120))),120)
|
|
|
|
|
else
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if @sjsperiod = '2'
|
|
|
|
|
begin
|
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>½ᣬ<EFBFBD><EFBFBD><EFBFBD>鿴<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>Թ<EFBFBD><EFBFBD>˵ĺ<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>俪ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD><EFBFBD>»<EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><EFBFBD>£<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڶԹ<EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>15<EFBFBD>Ż<EFBFBD><EFBFBD>µģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>δ<EFBFBD>Թ<EFBFBD><EFBFBD>˵ĺ<EFBFBD>ͬ<EFBFBD><EFBFBD>ͬ
|
|
|
|
|
*/
|
|
|
|
|
if (@sHasDz = '1') and ((@slastdzdate = @smonthlastday) or (@slastdzdate = substring(@slastdzdate, 1, 8) + '15'))
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µף<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>¸<EFBFBD><EFBFBD>µ<EFBFBD>15<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>*/
|
|
|
|
|
if (@slastdzdate = @smonthlastday)
|
|
|
|
|
set @psenddate = substring(@snextmonth1st, 1, 8) + '15'
|
|
|
|
|
else
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
else
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>15<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>*/
|
|
|
|
|
if (@slastdzdate > (substring(@slastdzdate, 1, 8) + '15')) and (@slastdzdate <= @smonthlastday)
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
else
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '15'
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if @sjsperiod = '3'
|
|
|
|
|
begin
|
|
|
|
|
/*Ѯ<EFBFBD>ᣬ<EFBFBD><EFBFBD>ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>죬<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
set @stheday = substring(@slastdzdate, 9, 2)
|
|
|
|
|
set @slastday = substring(@smonthlastday, 9, 2)
|
|
|
|
|
if (@sHasDz = '1') and (@stheday in ( '10', '20', @slastday ))
|
|
|
|
|
if @stheday = '10'
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>20<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '20'
|
|
|
|
|
|
|
|
|
|
else if @stheday = '20'
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>20<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
else
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>죬<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>10<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = substring(@snextmonth1st, 1, 8) + '10'
|
|
|
|
|
else
|
|
|
|
|
if @stheday <= '10'
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>10<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '10'
|
|
|
|
|
else if (@stheday > '10') and (@stheday <= '20')
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>20<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '20'
|
|
|
|
|
else
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>*/
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
/*<EFBFBD>ܽᣬ<EFBFBD><EFBFBD>7<EFBFBD>սᣬ<EFBFBD><EFBFBD>ʼʱ<EFBFBD><EFBFBD>Ϊÿ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>8<EFBFBD><EFBFBD>16<EFBFBD><EFBFBD>23<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊÿ<EFBFBD><EFBFBD>7<EFBFBD><EFBFBD>15<EFBFBD><EFBFBD>22<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>졣*/
|
|
|
|
|
set @stheday = substring(@slastdzdate, 9, 2)
|
|
|
|
|
set @slastday = substring(@smonthlastday, 9, 2)
|
|
|
|
|
if (@sHasDz = '1') and (@stheday in ( '07', '15', '22', @slastday ))
|
|
|
|
|
if @stheday = '07'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>07<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>15<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '15'
|
|
|
|
|
else if @stheday = '15'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>15<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>22<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '22'
|
|
|
|
|
else if @stheday = '22'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>22<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
else
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>죬<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>07<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@snextmonth1st, 1, 8) + '07'
|
|
|
|
|
else
|
|
|
|
|
if @stheday <= '07'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>07<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '07'
|
|
|
|
|
else if (@stheday > '07') and (@stheday <= '15')
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵڶ<EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>15<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '15'
|
|
|
|
|
else if (@stheday > '15') and (@stheday <= '22')
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>22<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = substring(@slastdzdate, 1, 8) + '22'
|
|
|
|
|
else
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
set @psenddate = @smonthlastday
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
set @psmsg = '<EFBFBD>ɹ<EFBFBD>'
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if exists(select * from sysobjects where name='p_soa_computefeeclause' and xtype='p')
|
|
|
|
|
drop procedure p_soa_computefeeclause
|
|
|
|
|
go
|
|
|
|
|
create procedure p_soa_computefeeclause
|
|
|
|
|
(
|
|
|
|
|
@psbillno varchar(20),
|
|
|
|
|
@psjscode varchar(1), --<EFBFBD><EFBFBD><EFBFBD>㷽ʽ 0-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2-<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psfinacode varchar(10),
|
|
|
|
|
@pssupcode varchar(15),
|
|
|
|
|
@pscontrno varchar(40),
|
|
|
|
|
@psenddate varchar(10),
|
|
|
|
|
@psmsg varchar(2000) output
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
declare @nssql nvarchar(4000)
|
|
|
|
|
declare @nswhere nvarchar(4000)
|
|
|
|
|
declare @optpaysoabyshop varchar(1)
|
|
|
|
|
declare @optpaysoabyfina varchar(1)
|
|
|
|
|
declare @sHasDz varchar(1)
|
|
|
|
|
declare @slastdzdate varchar(10)
|
|
|
|
|
declare @sbgndate varchar(10)
|
|
|
|
|
declare @feejumpflag varchar(1)
|
|
|
|
|
declare @feemaxenddate varchar(10)
|
|
|
|
|
declare @feemaxdzlrdate varchar(10)
|
|
|
|
|
declare @feesoamaxdate varchar(10)
|
|
|
|
|
declare @feepnflag int --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ϵ<EFBFBD><EFBFBD>
|
|
|
|
|
declare @feebgndate varchar(10) --ʵ<EFBFBD>ʷ<EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD>㿪ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @feeenddate varchar(10) --ʵ<EFBFBD>ʷ<EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @feebasetotal numeric(19,4) --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱȡ<EFBFBD><EFBFBD>ʵ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @feeclausetotal numeric(19,4) --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @icnt int
|
|
|
|
|
declare @iserialno int
|
|
|
|
|
declare @tablename varchar(20)
|
|
|
|
|
declare @tablebgnname varchar(20)
|
|
|
|
|
declare @tableendname varchar(20)
|
|
|
|
|
declare @kxclauseorg varchar(10)
|
|
|
|
|
declare @kxorgcode varchar(10)
|
|
|
|
|
declare @kxorgname varchar(30)
|
|
|
|
|
declare @kxitemcode varchar(4)
|
|
|
|
|
declare @kxitemno varchar(10)
|
|
|
|
|
declare @kxbgndate varchar(10)
|
|
|
|
|
declare @kxenddate varchar(10)
|
|
|
|
|
declare @kxbasetype varchar(4)
|
|
|
|
|
declare @kxbasetypename varchar(20)
|
|
|
|
|
declare @kxfeetotal numeric(19,4)
|
|
|
|
|
declare @kxfeerate numeric(19,4)
|
|
|
|
|
declare @kxcltype varchar(1) --0-һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-ÿ<EFBFBD><EFBFBD> 2-ÿ<EFBFBD><EFBFBD> 3-ÿ<EFBFBD><EFBFBD>
|
|
|
|
|
declare @kxcldate varchar(20)
|
|
|
|
|
declare @kxcalmode varchar(1) --0-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @kxcalbgndate varchar(10)
|
|
|
|
|
declare @kxcalenddate varchar(10)
|
|
|
|
|
declare @kxclausetype varchar(1) --0-Ӧ<EFBFBD><EFBFBD> 1-Ӧ<EFBFBD><EFBFBD>
|
|
|
|
|
declare @kxzftype varchar(1)
|
|
|
|
|
declare @kxiscalprofit varchar(1)
|
|
|
|
|
declare @kxisinvoice varchar(1)
|
|
|
|
|
declare @kxmidclscode varchar(10)
|
|
|
|
|
declare @kxtendcode varchar(10)
|
|
|
|
|
declare @kxplucode varchar(20)
|
|
|
|
|
declare @kxclscode varchar(10)
|
|
|
|
|
declare @kxbrandcode varchar(10)
|
|
|
|
|
declare @kxisladderrate varchar(1)
|
|
|
|
|
declare @kxladdercaltype varchar(1) --0-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare @kxlrdate varchar(10)
|
|
|
|
|
declare @kxext1 varchar(500)
|
|
|
|
|
declare @kxext2 varchar(500)
|
|
|
|
|
declare @kxext3 varchar(500)
|
|
|
|
|
declare @kxext4 varchar(500)
|
|
|
|
|
declare @kxext5 varchar(500)
|
|
|
|
|
declare @kxremark varchar(200)
|
|
|
|
|
declare @kxladderrate numeric(19,4)
|
|
|
|
|
declare @tmptotal numeric(19,4)
|
|
|
|
|
declare @mintotal numeric(19,4)
|
|
|
|
|
declare @maxtotal numeric(19,4)
|
|
|
|
|
begin
|
|
|
|
|
set @iserialno = 0
|
|
|
|
|
set @nswhere = ''
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|
|
|
|
select @optpaysoabyshop=itemvalue from t_syscfg where section='SYSTEM' and itemname='PaySoaByShop'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|
|
|
|
select @optpaysoabyfina=itemvalue from t_syscfg where section='SYSTEM' and itemname='PaySoaByFina'
|
|
|
|
|
|
|
|
|
|
if @optpaysoabyshop = '1'
|
|
|
|
|
set @nswhere = @nswhere + ' and (a.orgcode=''' + @psorgcode + ''' or a.orgcode=''*'')'
|
|
|
|
|
else if @optpaysoabyfina = '1'
|
|
|
|
|
set @nswhere = @nswhere + ' and (a.finacode=''' + @psfinacode + ''' or a.finacode=''*'')'
|
|
|
|
|
else
|
|
|
|
|
set @nswhere = @nswhere + ' and a.orgcode=''*'' and a.finacode=''*'''
|
|
|
|
|
if isnull(@pscontrno,'') <> ''
|
|
|
|
|
set @nswhere = @nswhere + ' and a.contrno=''' + @pscontrno + ''''
|
|
|
|
|
if isnull(@psbillno,'') <> ''
|
|
|
|
|
set @nswhere = @nswhere + ' and a.billno<>''' + @psbillno + ''''
|
|
|
|
|
set @nswhere = @nswhere + ' and a.rzdate<>'''' and a.rzdate is not null'
|
|
|
|
|
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
if isnull(@psbillno,'') <> ''
|
|
|
|
|
delete from t_paysoa_clause where billno = @psbillno
|
|
|
|
|
|
|
|
|
|
set @nssql = 'select @slastdzdate=isnull(max(enddate),'''') from t_paysoa_head a where a.supcode=''' + @pssupcode + '''' + @nswhere
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD>Ҹú<EFBFBD>ͬ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
exec sp_executesql @nssql,N'@slastdzdate varchar(10) output',@slastdzdate out
|
|
|
|
|
if @@error<>0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD>ͬû<EFBFBD>жԹ<EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>̵Ŀ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
if @slastdzdate = ''
|
|
|
|
|
begin
|
|
|
|
|
set @sHasDz = '0'
|
|
|
|
|
if isnull(@pscontrno,'') <> ''
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @slastdzdate=bgndate from t_contract where contrno = @pscontrno
|
|
|
|
|
else
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD>Ӧ<EFBFBD>̿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @slastdzdate=opendate from t_supplier where supcode = @pssupcode
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
set @sHasDz = '1'
|
|
|
|
|
if isnull(@slastdzdate,'') = ''
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = 'δ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
--ȡ<EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
select @sbgndate = convert(varchar(10),dateadd(day,1, convert(datetime,@slastdzdate,120)),120)
|
|
|
|
|
/*----<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----*/
|
|
|
|
|
declare
|
|
|
|
|
curclause cursor local forward_only for
|
|
|
|
|
select a.orgcode as clauseorg,b.orgcode,b.orgname,a.itemcode,a.itemno,a.bgndate,a.enddate,a.basetype,c.valuename as basetypename,a.feetotal,a.feerate,
|
|
|
|
|
a.cltype,a.cldate,a.calmode,a.calbgndate,a.calenddate,a.clausetype,a.zftype,a.iscalprofit,a.isinvoice,a.midclscode,a.tendcode,a.plucode,a.clscode,
|
|
|
|
|
a.brandcode,a.isladderrate,a.laddercaltype,a.lrdate,a.ext1,a.ext2,a.ext3,a.ext4,a.ext5,a.remark
|
|
|
|
|
from t_contr_clause a, t_shop b, t_enum_value c
|
|
|
|
|
where a.basetype=c.valuecode and c.enumcode='100013'
|
|
|
|
|
and a.contrno=@pscontrno and a.supcode=@pssupcode
|
|
|
|
|
and (a.orgcode='*' or a.orgcode=b.orgcode)
|
|
|
|
|
and ((@psorgcode='*' or @psorgcode='') or (@psorgcode<>'*' and @psorgcode<>'' and b.orgcode=@psorgcode))
|
|
|
|
|
--and ((@psfinacode='*' or @psfinacode='') or (@psfinacode<>'*' and @psfinacode<>'' and b.finacode=@psfinacode))
|
|
|
|
|
--and a.basetype in ('000','001','002','003','004','005','006','007','011','100','101')
|
|
|
|
|
and (a.calmode='0' and ((@psenddate between a.bgndate and a.enddate) or (a.enddate between @sbgndate and @psenddate)) or
|
|
|
|
|
a.calmode='1' and ((@psenddate between a.calbgndate and a.calenddate) or (a.calenddate between @sbgndate and @psenddate)))
|
|
|
|
|
|
|
|
|
|
open curclause
|
|
|
|
|
while 1=1
|
|
|
|
|
begin
|
|
|
|
|
fetch curclause into @kxclauseorg,@kxorgcode,@kxorgname,@kxitemcode,@kxitemno,@kxbgndate,@kxenddate,@kxbasetype,@kxbasetypename,@kxfeetotal,
|
|
|
|
|
@kxfeerate,@kxcltype,@kxcldate,@kxcalmode,@kxcalbgndate,@kxcalenddate,@kxclausetype,@kxzftype,@kxiscalprofit,@kxisinvoice,@kxmidclscode,
|
|
|
|
|
@kxtendcode,@kxplucode,@kxclscode,@kxbrandcode,@kxisladderrate,@kxladdercaltype,@kxlrdate,@kxext1,@kxext2,@kxext3,@kxext4,@kxext5,@kxremark
|
|
|
|
|
if @@fetch_status<>0
|
|
|
|
|
break
|
|
|
|
|
set @feebgndate = ''
|
|
|
|
|
set @feeenddate = ''
|
|
|
|
|
set @feebasetotal = 0
|
|
|
|
|
set @feeclausetotal = 0
|
|
|
|
|
set @feejumpflag = '0'
|
|
|
|
|
|
|
|
|
|
if @kxclausetype = '0'
|
|
|
|
|
set @feepnflag = 1 --Ӧ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
|
|
|
|
|
else
|
|
|
|
|
set @feepnflag = -1; --Ӧ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @nssql = 'select @feemaxenddate=isnull(max(enddate),'''') from t_paysoa_head a, t_paysoa_clause b '
|
|
|
|
|
+ ' where a.billno=b.billno and a.supcode=''' + @pssupcode + ''' and b.itemcode=''' + @kxitemcode
|
|
|
|
|
+ ''' and b.itemno=''' + @kxitemno + ''''
|
|
|
|
|
+ @nswhere
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
exec sp_executesql @nssql,N'@feemaxenddate varchar(10) output',@feemaxenddate out
|
|
|
|
|
if @@error<>0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ȡ<EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @nssql = 'select @feemaxdzlrdate=isnull(max(lrdate),'''') from t_paysoa_head a, t_paysoa_clause b '
|
|
|
|
|
+ ' where a.billno=b.billno and a.supcode=''' + @pssupcode + ''' and b.itemcode=''' + @kxitemcode
|
|
|
|
|
+ ''' and b.itemno=''' + @kxitemno + ''''
|
|
|
|
|
+ @nswhere
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
exec sp_executesql @nssql,N'@feemaxdzlrdate varchar(10) output',@feemaxdzlrdate out
|
|
|
|
|
if @@error<>0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ȡ<EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>˵<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @feemaxenddate > @feemaxdzlrdate
|
|
|
|
|
set @feesoamaxdate = @feemaxdzlrdate
|
|
|
|
|
else
|
|
|
|
|
set @feesoamaxdate = @feemaxenddate
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @feesoamaxdate <> ''
|
|
|
|
|
set @feebgndate = convert(varchar(10),dateadd(day,1, convert(datetime,@feesoamaxdate,120)),120)
|
|
|
|
|
if @kxcalmode = '0'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feesoamaxdate = '') or (@kxbgndate > @feebgndate)
|
|
|
|
|
set @feebgndate = @kxbgndate
|
|
|
|
|
if @kxcltype = '0'
|
|
|
|
|
set @feeenddate = @kxenddate --һ<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if @psenddate > @kxenddate
|
|
|
|
|
set @feeenddate = @kxenddate
|
|
|
|
|
else
|
|
|
|
|
set @feeenddate = @psenddate
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feesoamaxdate = '') or (@kxcalbgndate > @feebgndate)
|
|
|
|
|
set @feebgndate = @kxcalbgndate
|
|
|
|
|
if @kxcltype = '0'
|
|
|
|
|
set @feeenddate = @kxcalenddate --һ<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if @psenddate > @kxcalenddate
|
|
|
|
|
set @feeenddate = @kxcalenddate
|
|
|
|
|
else
|
|
|
|
|
set @feeenddate = @psenddate
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ζ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Ѿ<EFBFBD><EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @feesoamaxdate <> ''
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD> 0-һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-ÿ<EFBFBD><EFBFBD> 2-ÿ<EFBFBD><EFBFBD> 3-ÿ<EFBFBD><EFBFBD>
|
|
|
|
|
if @kxcltype = '0'
|
|
|
|
|
begin
|
|
|
|
|
--0-һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @feejumpflag = '1' --һ<EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
--else if @kxcltype = '1'
|
|
|
|
|
--begin
|
|
|
|
|
--1-ÿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>ϴν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ϴν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĵڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--end
|
|
|
|
|
else if @kxcltype = '2'
|
|
|
|
|
begin
|
|
|
|
|
--2-ÿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>жϱ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if substring(@feeenddate,1,7) = substring(@feesoamaxdate,1,7)
|
|
|
|
|
set @feejumpflag = '1'
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if @kxbasetype = '000'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʿ<EFBFBD>ʼ<EFBFBD>±<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ϴζ<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @feebgndate=convert(varchar(10),dateadd(m, 1, convert(datetime,substring(@feesoamaxdate, 1, 8)+'01',120)),120)
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ϴν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĵڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else if @kxcltype = '3'
|
|
|
|
|
begin
|
|
|
|
|
--3-ÿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>жϱ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD>꣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if substring(@feeenddate,1,4) = substring(@feesoamaxdate,1,4)
|
|
|
|
|
set @feejumpflag = '1'
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if @kxbasetype = '000'
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʿ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @feebgndate=convert(varchar(10),dateadd(yy, 1, convert(datetime,substring(@feesoamaxdate, 1, 4)+'-01-01',120)),120)
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ϴν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĵڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @kxcltype = '0'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҷǹ̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֻ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxbasetype <> '000'
|
|
|
|
|
begin
|
|
|
|
|
if @psenddate < @feeenddate
|
|
|
|
|
set @feejumpflag = '1'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @feejumpflag = '1'
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
----<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--
|
|
|
|
|
--000-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxbasetype = '000'
|
|
|
|
|
begin
|
|
|
|
|
set @icnt = 1
|
|
|
|
|
--ÿ<EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxcltype = '2'
|
|
|
|
|
begin
|
|
|
|
|
select @icnt = (cast(substring(@feeenddate, 1, 4) as int) - cast(substring(@feebgndate, 1, 4) as int)) * 12 + (cast(substring(@feeenddate, 6, 2) as int) - cast(substring(@feebgndate, 6, 2) as int)) + 1
|
|
|
|
|
end
|
|
|
|
|
--ÿ<EFBFBD>꣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxcltype = '3'
|
|
|
|
|
begin
|
|
|
|
|
select @icnt = (cast(substring(@feeenddate, 1, 4) as int) - cast(substring(@feebgndate, 1, 4) as int)) + 1
|
|
|
|
|
end
|
|
|
|
|
set @feeclausetotal = @kxfeetotal * @icnt
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--002-<EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxbasetype = '002'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD>ϼƺ<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ĺϼƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @feebasetotal=isnull(sum(a.bcjstotal),0)-isnull(sum(a.bczrtotal),0) from t_paysoa_body a
|
|
|
|
|
where a.billno=@psbillno and a.orgcode=@kxorgcode
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㱾<EFBFBD>οۿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxfeerate / 100, 2)
|
|
|
|
|
--to do ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>귵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--003-<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxbasetype = '003'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Ԫ)<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>feerate
|
|
|
|
|
select @feebasetotal=isnull(sum(b.counts),0) from t_paysoa_body a, t_accept_body b, t_accept_head c
|
|
|
|
|
where a.billno=@psbillno and a.orgcode=@kxorgcode and b.plucode=@kxplucode
|
|
|
|
|
and a.billtype in ('0','3')
|
|
|
|
|
and c.rzdate between @feebgndate and @feeenddate
|
|
|
|
|
and a.ywbillno=b.billno and b.billno=c.billno
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxfeerate, 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--017-<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxbasetype = '017'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Ԫ)<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>feerate
|
|
|
|
|
set @tablebgnname = 't_plusale_' + substring(@feebgndate, 1, 4) + substring(@feebgndate, 6, 2)
|
|
|
|
|
set @tableendname = 't_plusale_' + substring(@feeenddate, 1, 4) + substring(@feeenddate, 6, 2)
|
|
|
|
|
set @feebasetotal = 0
|
|
|
|
|
declare cur017 cursor local for select name from sysobjects where name between @tablebgnname and @tableendname
|
|
|
|
|
open cur017
|
|
|
|
|
fetch next from cur017 into @tablename
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
set @tmptotal = 0
|
|
|
|
|
set @nssql = 'select @tmptotal=isnull(sum(counts),0) from ' + @tablename + ' a
|
|
|
|
|
where a.orgcode=''' + @kxorgcode + '''
|
|
|
|
|
and a.supcode=''' + @pssupcode + '''
|
|
|
|
|
and a.plucode=''' + @kxplucode + '''
|
|
|
|
|
and a.accdate between ''' + @feebgndate + ''' and ''' + @feeenddate + ''''
|
|
|
|
|
exec sp_executesql @nssql,N'@tmptotal numeric(19,4) output',@tmptotal out
|
|
|
|
|
set @feebasetotal = @feebasetotal + @tmptotal
|
|
|
|
|
fetch next from cur017 into @tablename
|
|
|
|
|
end
|
|
|
|
|
close cur017
|
|
|
|
|
deallocate cur017
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxfeerate, 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--100-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[ר<EFBFBD><EFBFBD>](<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD><EFBFBD>)
|
|
|
|
|
if @kxbasetype = '100'
|
|
|
|
|
begin
|
|
|
|
|
select @feebasetotal=isnull(sum(c.cost),0) from t_paysoa_body a, t_accept_head b, t_order_head c
|
|
|
|
|
where a.billno=@psbillno and a.orgcode=@kxorgcode
|
|
|
|
|
and a.billtype in ('0','3')
|
|
|
|
|
and a.ywbillno=b.billno and b.orderno=c.billno
|
|
|
|
|
--and c.state='2'
|
|
|
|
|
and round(c.dhcount/c.counts,2)*100<cast((case when isnull(@kxext1,'')='' then '0' else @kxext1 end) as numeric(19,2))
|
|
|
|
|
--and b.rzdate between @feebgndate and @feeenddate
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxfeerate / 100, 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--101-<EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[ר<EFBFBD><EFBFBD>]<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD>귵ͨ<EFBFBD>㣩
|
|
|
|
|
if @kxbasetype = '101'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>ֶ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒʹ<EFBFBD><EFBFBD>|<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磺000001|000002|000003
|
|
|
|
|
if isnull(@kxext1, '') <> ''
|
|
|
|
|
begin
|
|
|
|
|
set @kxext1 = '(''' + REPLACE(@kxext1,'|',''',''') + ''')'
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD>ۼƾ<EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>۽<EFBFBD><EFBFBD><EFBFBD>=<EFBFBD>ۼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>۽<EFBFBD><EFBFBD><EFBFBD>-<EFBFBD>ۼ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>۽<EFBFBD><EFBFBD><EFBFBD>+<EFBFBD>ۼƺ<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @tmptotal = 0
|
|
|
|
|
--<EFBFBD>ϼƺ<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @nssql = 'select @tmptotal=isnull(sum(c.cost),0) from t_paysoa_body a, t_accept_head b, t_accept_body c
|
|
|
|
|
where a.billno=''' + @psbillno + ''' and a.orgcode=''' + @kxorgcode + '''
|
|
|
|
|
and a.billtype in (''0'',''3'')
|
|
|
|
|
and a.ywbillno=b.billno and b.billno=c.billno'
|
|
|
|
|
if isnull(@kxext1, '') <> ''
|
|
|
|
|
set @nssql = @nssql + ' and c.plucode not in ' + @kxext1
|
|
|
|
|
exec sp_executesql @nssql,N'@tmptotal numeric(19,4) output',@tmptotal out
|
|
|
|
|
set @feebasetotal = @tmptotal
|
|
|
|
|
--<EFBFBD>ϼƺ<EFBFBD>˰<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @nssql = 'select @tmptotal=isnull(sum(c.cost),0) from t_paysoa_body a, t_return_head b, t_return_body c
|
|
|
|
|
where a.billno=''' + @psbillno + ''' and a.orgcode=''' + @kxorgcode + '''
|
|
|
|
|
and a.billtype in (''1'',''4'')
|
|
|
|
|
and a.ywbillno=b.billno and b.billno=c.billno'
|
|
|
|
|
if isnull(@kxext1, '') <> ''
|
|
|
|
|
set @nssql = @nssql + ' and c.plucode not in ' + @kxext1
|
|
|
|
|
exec sp_executesql @nssql,N'@tmptotal numeric(19,4) output',@tmptotal out
|
|
|
|
|
set @feebasetotal = @feebasetotal - @tmptotal
|
|
|
|
|
--<EFBFBD>ϼƺ<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @nssql = 'select @tmptotal=isnull(sum(c.cjcost),0) from t_paysoa_body a, t_adjbuyprice_head b, t_adjbuyprice_body c
|
|
|
|
|
where a.billno=''' + @psbillno + ''' and a.orgcode=''' + @kxorgcode + '''
|
|
|
|
|
and a.billtype in (''2'',''5'')
|
|
|
|
|
and a.ywbillno=b.billno and b.billno=c.billno'
|
|
|
|
|
if isnull(@kxext1, '') <> ''
|
|
|
|
|
set @nssql = @nssql + ' and c.plucode not in ' + @kxext1
|
|
|
|
|
exec sp_executesql @nssql,N'@tmptotal numeric(19,4) output',@tmptotal out
|
|
|
|
|
set @feebasetotal = @feebasetotal + @tmptotal
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㱾<EFBFBD>οۿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxfeerate / 100, 2)
|
|
|
|
|
--to do ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>귵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--102-<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[ר<EFBFBD><EFBFBD>](<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD><EFBFBD>)
|
|
|
|
|
if @kxbasetype = '102'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۡ<EFBFBD><EFBFBD>ֶ<EFBFBD>feerate
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ext1
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ext2
|
|
|
|
|
set @tablebgnname = 't_plusale_' + substring(@feebgndate, 1, 4) + substring(@feebgndate, 6, 2)
|
|
|
|
|
set @tableendname = 't_plusale_' + substring(@feeenddate, 1, 4) + substring(@feeenddate, 6, 2)
|
|
|
|
|
set @feebasetotal = 0
|
|
|
|
|
declare cur102 cursor local for select name from sysobjects where name between @tablebgnname and @tableendname
|
|
|
|
|
open cur102
|
|
|
|
|
fetch next from cur102 into @tablename
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
set @tmptotal = 0
|
|
|
|
|
set @nssql = 'select @tmptotal=isnull(sum(counts),0) from ' + @tablename + ' a
|
|
|
|
|
where a.orgcode=''' + @kxorgcode + '''
|
|
|
|
|
and a.supcode=''' + @pssupcode + '''
|
|
|
|
|
and a.plucode=''' + @kxplucode + '''
|
|
|
|
|
and a.accdate between ''' + @feebgndate + ''' and ''' + @feeenddate + ''''
|
|
|
|
|
exec sp_executesql @nssql,N'@tmptotal numeric(19,4) output',@tmptotal out
|
|
|
|
|
set @feebasetotal = @feebasetotal + @tmptotal
|
|
|
|
|
fetch next from cur102 into @tablename
|
|
|
|
|
end
|
|
|
|
|
close cur102
|
|
|
|
|
deallocate cur102
|
|
|
|
|
if @feebasetotal > convert(numeric(19,4), @kxext2)
|
|
|
|
|
begin
|
|
|
|
|
set @feeclausetotal = round(floor(@feebasetotal / @kxext1) * @kxfeerate, 2)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @kxisladderrate = '1'
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺϷ<EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
select @mintotal=isnull(min(mintotal),0),@maxtotal=isnull(min(maxtotal),0)
|
|
|
|
|
from t_contr_clause_rate
|
|
|
|
|
where contrno = @pscontrno and supcode = @pssupcode
|
|
|
|
|
and itemcode = @kxitemcode and itemno = @kxitemno
|
|
|
|
|
and (orgcode = @kxclauseorg or orgcode = '*')
|
|
|
|
|
if @mintotal <> 0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD>0<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><EFBFBD>ˣ<EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
if @maxtotal <> 0
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><EFBFBD>ˣ<EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
declare curclauserate cursor local for
|
|
|
|
|
select mintotal,maxtotal,rate
|
|
|
|
|
from t_contr_clause_rate
|
|
|
|
|
where contrno = @pscontrno and supcode = @pssupcode
|
|
|
|
|
and itemcode = @kxitemcode and itemno = @kxitemno
|
|
|
|
|
and (orgcode = @kxclauseorg or orgcode = '*')
|
|
|
|
|
order by mintotal
|
|
|
|
|
open curclauserate
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
set @tmptotal = @maxtotal
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
if @@fetch_status<>0
|
|
|
|
|
break
|
|
|
|
|
if @mintotal <> @tmptotal
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><EFBFBD>ˣ<EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
set @tmptotal = @maxtotal
|
|
|
|
|
end
|
|
|
|
|
close curclauserate
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @mintotal = 0
|
|
|
|
|
set @maxtotal = 0
|
|
|
|
|
set @kxladderrate = 0
|
|
|
|
|
--<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣬<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @feeclausetotal = 0
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxladdercaltype='0'
|
|
|
|
|
begin
|
|
|
|
|
open curclauserate
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>0ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal<0 and @mintotal=0)
|
|
|
|
|
begin
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxladderrate / 100, 2)
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal>@mintotal and @feebasetotal>=@maxtotal and @maxtotal<>0)
|
|
|
|
|
begin
|
|
|
|
|
set @feeclausetotal = @feeclausetotal + round((@maxtotal - @mintotal) * @kxladderrate / 100, 2)
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal>=@mintotal and @feebasetotal<@maxtotal)
|
|
|
|
|
begin
|
|
|
|
|
set @feeclausetotal = @feeclausetotal + round((@feebasetotal - @mintotal) * @kxladderrate / 100, 2)
|
|
|
|
|
break;
|
|
|
|
|
end
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal>=@mintotal and @maxtotal=0)
|
|
|
|
|
begin
|
|
|
|
|
set @feeclausetotal = @feeclausetotal + round((@feebasetotal - @mintotal) * @kxladderrate / 100, 2)
|
|
|
|
|
break;
|
|
|
|
|
end
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
end
|
|
|
|
|
close curclauserate
|
|
|
|
|
--<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,@kxfeerate<EFBFBD><EFBFBD>ֵ<EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ0<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>t_paysoa_clause<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<EFBFBD><EFBFBD>
|
|
|
|
|
end
|
|
|
|
|
--ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @kxladdercaltype='1'
|
|
|
|
|
begin
|
|
|
|
|
open curclauserate
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal>=@mintotal and @feebasetotal<@maxtotal)
|
|
|
|
|
break;
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0ʱ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (@feebasetotal>=@mintotal and @maxtotal=0)
|
|
|
|
|
break;
|
|
|
|
|
fetch next from curclauserate into @mintotal,@maxtotal,@kxladderrate
|
|
|
|
|
end
|
|
|
|
|
close curclauserate
|
|
|
|
|
set @feeclausetotal = round(@feebasetotal * @kxladderrate / 100, 2)
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>@kxfeerate<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@kxfeerate<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>Ϊ0
|
|
|
|
|
set @kxfeerate = @kxladderrate
|
|
|
|
|
end
|
|
|
|
|
deallocate curclauserate
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>/Ӧ<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
set @feeclausetotal = @feeclausetotal * @feepnflag
|
|
|
|
|
if isnull(@psbillno,'') <> ''
|
|
|
|
|
begin
|
|
|
|
|
if @feeclausetotal<>0
|
|
|
|
|
begin
|
|
|
|
|
set @iserialno = @iserialno + 1
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
insert into t_paysoa_clause(billno,serialno,contrno,supcode,orgcode,itemcode,itemno,basetype,feetotal,clausefee,ratebase,feerate,cltype,
|
|
|
|
|
cldate,zftype,iscalprofit,calmode,calbgndate,calenddate,isinvoice,midclscode,clausetype,tendcode,plucode,clscode,brandcode,isladderrate,
|
|
|
|
|
laddercaltype,ext1,ext2,ext3,ext4,ext5,remark)
|
|
|
|
|
values(@psbillno,@iserialno,@pscontrno,@pssupcode,@kxorgcode,@kxitemcode,@kxitemno,@kxbasetype,@feeclausetotal,@kxfeetotal,@feebasetotal,
|
|
|
|
|
@kxfeerate,@kxcltype,convert(varchar(19),getdate(),120),@kxzftype,@kxiscalprofit,@kxcalmode,@feebgndate,@feeenddate,@kxisinvoice,@kxmidclscode,
|
|
|
|
|
@kxclausetype,@kxtendcode,@kxplucode,@kxclscode,@kxbrandcode,@kxisladderrate,@kxladdercaltype,@kxext1,@kxext2,@kxext3,@kxext4,@kxext5,@kxremark)
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--else
|
|
|
|
|
--begin
|
|
|
|
|
--to do <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㲻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
--end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if isnull(@psbillno,'') <> ''
|
|
|
|
|
begin
|
|
|
|
|
if @psjscode in ('0', '1') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
update t_paysoa_head set feetotal = isnull((select sum(feetotal) from t_paysoa_clause where billno = @psbillno),0)
|
|
|
|
|
where billno = @psbillno
|
|
|
|
|
update t_paysoa_head set dztotal = bcjstotal - feetotal where billno = @psbillno
|
|
|
|
|
end
|
|
|
|
|
else if @psjscode = '2' --<EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg = '<EFBFBD><EFBFBD>δ֧<EFBFBD>ָý<EFBFBD><EFBFBD>㷽ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
set @psmsg = '<EFBFBD>ɹ<EFBFBD>'
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|