|
|
|
|
if exists(select * from sysobjects where name='p_rz_prepare_dz' and xtype='p')
|
|
|
|
|
drop procedure p_rz_prepare_dz
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
create procedure p_rz_prepare_dz
|
|
|
|
|
(
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psbillno varchar(20),
|
|
|
|
|
@psparams varchar(200),
|
|
|
|
|
@psmsg varchar(2000) out
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
begin
|
|
|
|
|
declare @optoverstatus varchar(10)
|
|
|
|
|
declare @ssupcode varchar(15)
|
|
|
|
|
declare @ssupstatus varchar(1)
|
|
|
|
|
declare @ssupvalidstatus varchar(1)
|
|
|
|
|
|
|
|
|
|
select @ssupcode=supcode from t_paysoa_head where billno=@psbillno
|
|
|
|
|
|
|
|
|
|
select @optoverstatus=itemvalue from t_syscfg where section='SYSTEM' and itemname='OVER'
|
|
|
|
|
if @optoverstatus<>'STOP'
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD>Ӫҵ<EFBFBD>սᣬ<EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not exists(select * from t_supplier where supcode=@ssupcode)
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>Ӧ<EFBFBD>̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
select @ssupstatus=supstatus,
|
|
|
|
|
@ssupvalidstatus=case when (isnull(validdate,'')='' or validdate>=convert(varchar(100),getdate(),23)) then '1' else '0' end
|
|
|
|
|
from t_supplier where supcode=@ssupcode
|
|
|
|
|
if @ssupstatus<>'0'
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
if @ssupvalidstatus='0'
|
|
|
|
|
begin
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--CheckBillBatch
|
|
|
|
|
select @psmsg=isnull(@psmsg+char(13),'')+billname+':' + ywbillno +
|
|
|
|
|
' ʵ<><CAB5>δ<EFBFBD><CEB4><EFBFBD>ˣ<EFBFBD>' + convert(varchar(20),convert(numeric(19,2),wftotal)) +
|
|
|
|
|
' <20><><EFBFBD>˽<EFBFBD><CBBD>'+convert(varchar(20),convert(numeric(19,2),bcjstotal))
|
|
|
|
|
from (select a.cost-a.jscost-a.zrcost as wftotal,b.bcjstotal,b.ywbillno,
|
|
|
|
|
case b.billtype
|
|
|
|
|
when '0' then '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>' when '1' then '<EFBFBD>ɹ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>' when '2' then '<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
when '3' then 'ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>' when '4' then 'ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>' when '5' then 'ֱ<EFBFBD>ͽ<EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
when '6' then '<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>' when '7' then '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>' when '8' then '<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
else 'δ֪<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>' end as billname
|
|
|
|
|
from t_pay_bill a,t_paysoa_body b
|
|
|
|
|
where a.billno=b.ywbillno and a.billtype=b.billtype and a.orgcode=b.orgcode
|
|
|
|
|
and b.billno=@psbillno
|
|
|
|
|
and ((a.jscost<>b.jstotal) or (a.zrcost<>b.zrtotal))) a
|
|
|
|
|
if isnull(@psmsg,'')<>''
|
|
|
|
|
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>'+char(13)+@psmsg
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--UCheckHisPayBill
|
|
|
|
|
set @psmsg=''
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
if exists(select * from sysobjects where name='p_rz_dz' and xtype='p')
|
|
|
|
|
drop procedure p_rz_dz
|
|
|
|
|
go
|
|
|
|
|
|
|
|
|
|
create procedure p_rz_dz
|
|
|
|
|
(
|
|
|
|
|
@psorgcode varchar(10),
|
|
|
|
|
@psbillno varchar(20),
|
|
|
|
|
@psparams varchar(200),
|
|
|
|
|
@psmsg varchar(2000) out
|
|
|
|
|
)
|
|
|
|
|
as
|
|
|
|
|
begin
|
|
|
|
|
declare @scurdate varchar(10)
|
|
|
|
|
declare @scurtime varchar(8)
|
|
|
|
|
declare @ssupcode varchar(15)
|
|
|
|
|
declare @sup_payable numeric(19,4)
|
|
|
|
|
declare @sup_prepaytotal numeric(19,4)
|
|
|
|
|
declare @dztotal numeric(19,4)
|
|
|
|
|
declare @bczrtotal numeric(19,4)
|
|
|
|
|
declare @feetotal numeric(19,4)
|
|
|
|
|
declare @bcjstotal numeric(19,4)
|
|
|
|
|
declare @xscost numeric(19,4)
|
|
|
|
|
declare @ssql varchar(2000)
|
|
|
|
|
declare @svbktablename varchar(20)
|
|
|
|
|
declare @bodycount int
|
|
|
|
|
|
|
|
|
|
select @scurdate=convert(varchar(100),getdate(),23),@scurtime=convert(varchar(100),getdate(),108)
|
|
|
|
|
select @bodycount=count(billno) from t_paysoa_body where billno=@psbillno
|
|
|
|
|
if @bodycount=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>
|
|
|
|
|
--todo CheckPayForm
|
|
|
|
|
--todo UAutoCreateJsPayBillDetail
|
|
|
|
|
set @psmsg='<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>û<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>ҵ<EFBFBD>ݣ<EFBFBD>'
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--CircleProcedure
|
|
|
|
|
update b set b.jscost=b.jscost+a.bcjstotal,b.zrcost=b.zrcost+a.bczrtotal,
|
|
|
|
|
b.isaccounted=case when a.total-a.jstotal-a.zrtotal-a.bcjstotal-a.bczrtotal=0 then '1' else '0' end
|
|
|
|
|
from t_pay_bill b,t_paysoa_body a
|
|
|
|
|
where a.billno=@psbillno and b.billtype=a.billtype and b.orgcode=a.orgcode and b.billno=a.ywbillno
|
|
|
|
|
|
|
|
|
|
--AlterVendor
|
|
|
|
|
select @ssupcode=supcode,@dztotal=dztotal,@bczrtotal=bczrtotal,@feetotal=feetotal,@bcjstotal=bcjstotal,@xscost=xscost
|
|
|
|
|
from t_paysoa_head
|
|
|
|
|
where billno=@psbillno
|
|
|
|
|
|
|
|
|
|
update t_supplier
|
|
|
|
|
set dztotal=dztotal+@dztotal,dzrtotal=dzrtotal+@bczrtotal,feetotal=feetotal+@feetotal,
|
|
|
|
|
dywtotal=dywtotal+@bcjstotal,xscost=xscost+@xscost
|
|
|
|
|
where supcode=@ssupcode
|
|
|
|
|
|
|
|
|
|
--WriteVendorBook
|
|
|
|
|
set @svbktablename='t_vbk_'+substring(convert(varchar(100),getdate(),112),1,6)
|
|
|
|
|
exec p_create_vbk @svbktablename,@psmsg out
|
|
|
|
|
if isnull(@psmsg,'')<>''
|
|
|
|
|
begin
|
|
|
|
|
return(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
select @sup_payable=jhtotal-thtotal+tjtotal,@sup_prepaytotal=prepay from t_supplier where supcode=@ssupcode
|
|
|
|
|
if (@feetotal<>0)
|
|
|
|
|
begin
|
|
|
|
|
set @ssql='insert into t_vbk_'+ substring(convert(varchar(100),getdate(),112),1,6)+'(orgcode,bookdate,booktime,supcode ,billno,billtype,fsamount,yfjytotal,prejytotal)'
|
|
|
|
|
+' values('''+@psorgcode+''','''+@scurdate+''','''+@scurtime+''','''+@ssupcode+''','''+@psbillno+''',''8'','+convert(varchar(20),-@feetotal)+','+convert(varchar(20),@sup_payable-@feetotal)+','+convert(varchar(20),@sup_prepaytotal)+')'
|
|
|
|
|
exec(@ssql)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if (@bczrtotal<>0)
|
|
|
|
|
begin
|
|
|
|
|
set @ssql='insert into t_vbk_'+ substring(convert(varchar(100),getdate(),112),1,6)+'(orgcode,bookdate,booktime,supcode ,billno,billtype,fsamount,yfjytotal,prejytotal)'
|
|
|
|
|
+' values('''+@psorgcode+''','''+@scurdate+''','''+@scurtime+''','''+@ssupcode+''','''+@psbillno+''',''9'','+convert(varchar(20),-@bczrtotal)+','+convert(varchar(20),@sup_payable-@feetotal-@bczrtotal)+','+convert(varchar(20),@sup_prepaytotal)+')'
|
|
|
|
|
exec(@ssql)
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴδ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
update b set b.cldate=convert(varchar(19),getdate(),120)
|
|
|
|
|
from t_contr_clause b, t_paysoa_clause a
|
|
|
|
|
where a.billno=@psbillno and b.contrno=a.contrno and b.supcode=a.supcode and b.orgcode=a.orgcode
|
|
|
|
|
and b.itemcode=a.itemcode and b.itemno=a.itemno
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ֹ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
update c set c.state='9',statedate=convert(varchar(10),getdate(),21),statetime=convert(varchar(8),getdate(),108)
|
|
|
|
|
from t_order_head c,t_paysoa_body a,t_accept_head b
|
|
|
|
|
where a.ywbillno=b.billno and b.orderno=c.billno
|
|
|
|
|
and a.billtype in ('0','3') and a.billno=@psbillno
|
|
|
|
|
|
|
|
|
|
set @psmsg=''
|
|
|
|
|
return(1)
|
|
|
|
|
end
|
|
|
|
|
go
|