|
|
|
|
if exists(select * from sysobjects where name='p_rz_prepare_cla' and xtype='p')
|
|
|
|
|
drop procedure p_rz_prepare_cla
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
create procedure p_rz_prepare_cla
|
|
|
|
|
(
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psbillno varchar(20),
|
|
|
|
|
@psparams varchar(200),
|
|
|
|
|
@psmsg varchar(2000) out
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
begin
|
|
|
|
|
declare @contrno varchar(40)
|
|
|
|
|
declare @contrstatus varchar(1)
|
|
|
|
|
|
|
|
|
|
select @contrno=contrno from t_adjclause_head where billno=@psbillno
|
|
|
|
|
|
|
|
|
|
if not exists(select contrstatus from t_contract where contrno=@contrno)
|
|
|
|
|
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>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
select @contrstatus=contrstatus from t_contract where contrno=@contrno;
|
|
|
|
|
if @contrstatus='9'
|
|
|
|
|
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>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not exists(select billno from t_adjclause_body where billno=@psbillno and optype <> '3')
|
|
|
|
|
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>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
set @psmsg=''
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
if exists(select * from sysobjects where name='p_rz_cla' and xtype='p')
|
|
|
|
|
drop procedure p_rz_cla
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
create procedure p_rz_cla
|
|
|
|
|
(
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psbillno varchar(20),
|
|
|
|
|
@psparams varchar(200),
|
|
|
|
|
@psmsg varchar(2000) out
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
begin
|
|
|
|
|
declare @contrno varchar(40)
|
|
|
|
|
declare @supcode varchar(15)
|
|
|
|
|
declare @lrdate varchar(10)
|
|
|
|
|
declare @usercode varchar(6)
|
|
|
|
|
declare @username varchar(10)
|
|
|
|
|
declare @orgcode varchar(10)
|
|
|
|
|
declare @itemcode varchar(4)
|
|
|
|
|
declare @itemno varchar(10)
|
|
|
|
|
declare @endjsdate varchar(10)
|
|
|
|
|
declare @optype varchar(1)
|
|
|
|
|
declare @calmode varchar(1)
|
|
|
|
|
declare @enddate varchar(10)
|
|
|
|
|
declare @calenddate varchar(10)
|
|
|
|
|
declare @sup_payable numeric(19,4)
|
|
|
|
|
declare @ssql varchar(2000)
|
|
|
|
|
|
|
|
|
|
select @contrno=contrno,@supcode=supcode,@lrdate=lrdate,@usercode=usercode,@username=username from t_adjclause_head where billno=@psbillno
|
|
|
|
|
|
|
|
|
|
--ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>Ӧ<EFBFBD>̵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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 @endjsdate=isnull(enddate,'') from t_paysoa_head where contrno=@contrno
|
|
|
|
|
|
|
|
|
|
declare cur cursor local for select orgcode,itemcode,itemno,optype,calmode,enddate,calenddate from t_adjclause_body where billno=@psbillno and optype<>'3'
|
|
|
|
|
open cur
|
|
|
|
|
fetch next from cur into @orgcode,@itemcode,@itemno,@optype,@calmode,@enddate,@calenddate
|
|
|
|
|
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><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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 (@optype in ('0','1') and @endjsdate is not null)
|
|
|
|
|
begin
|
|
|
|
|
if (@calmode='0' and @enddate<=@endjsdate)
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:'+@endjsdate+',Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´ζ<C2B4><CEB6>˼<EFBFBD><CBBC>㲻<EFBFBD><E3B2BB><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
if (@calmode = '1' and @calenddate<=@endjsdate)
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:'+@endjsdate+',Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´ζ<C2B4><CEB6>˼<EFBFBD><CBBC>㲻<EFBFBD><E3B2BB><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if exists(select contrno from t_contr_clause where contrno=@contrno and supcode=@supcode and orgcode=@orgcode and itemcode=@itemcode and itemno=@itemno)
|
|
|
|
|
begin
|
|
|
|
|
if (@optype='0')
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>'+@itemcode+',<2C><>֯'+@orgcode+',<2C><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>'+@itemno+'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
fetch next from cur into @orgcode,@itemcode,@itemno,@optype,@calmode,@enddate,@calenddate
|
|
|
|
|
end
|
|
|
|
|
close cur
|
|
|
|
|
deallocate cur
|
|
|
|
|
|
|
|
|
|
delete a from t_contr_clause a, t_adjclause_body b
|
|
|
|
|
where a.contrno=b.contrno and a.supcode=b.supcode and a.orgcode=b.orgcode and a.itemcode=b.itemcode and a.itemno=b.itemno
|
|
|
|
|
and b.billno=@psbillno and b.optype<> '3'
|
|
|
|
|
|
|
|
|
|
insert into t_contr_clause(contrno,supcode,orgcode,itemcode,itemno,bgndate,enddate,basetype,feetotal,feerate,
|
|
|
|
|
cltype,zftype,iscalprofit,calmode,calbgndate,calenddate,isinvoice,midclscode,clausetype,tendcode,plucode,cldate,
|
|
|
|
|
clscode,brandcode,isladderrate,laddercaltype,lrdate,usercode,username,ext1,ext2,ext3,ext4,ext5,remark)
|
|
|
|
|
select contrno,supcode,orgcode,itemcode,itemno,bgndate,enddate,basetype,feetotal,feerate,
|
|
|
|
|
cltype,zftype,iscalprofit,calmode,calbgndate,calenddate,isinvoice,midclscode,clausetype,tendcode,plucode,cldate,
|
|
|
|
|
clscode,brandcode,isladderrate,laddercaltype,@lrdate as lrdate,@usercode as usercode,@username as username,ext1,ext2,ext3,ext4,ext5,remark
|
|
|
|
|
from t_adjclause_body
|
|
|
|
|
where billno=@psbillno and optype not in ('2','3')
|
|
|
|
|
|
|
|
|
|
set @psmsg=''
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|