if exists ( select * from sysobjects where name = ' p_rz_prepare_lf ' and xtype = ' p ' )
drop procedure p_rz_prepare_lf
go
create procedure p_rz_prepare_lf
(
@ 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_jopaysoa_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
set @ psmsg = ' '
return ( 1 )
end
go
if exists ( select * from sysobjects where name = ' p_rz_lf ' and xtype = ' p ' )
drop procedure p_rz_lf
go
create procedure p_rz_lf
(
@ 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 @ ssql varchar ( 2000 )
declare @ svbktablename varchar ( 20 )
declare @ bgndate varchar ( 10 )
declare @ enddate varchar ( 10 )
declare @ bgnyear int
declare @ endyear int
declare @ salerpttablename varchar ( 20 )
select @ scurdate = convert ( varchar ( 100 ) , getdate ( ) , 23 ) , @ scurtime = convert ( varchar ( 100 ) , getdate ( ) , 108 )
- - AlterVendor
select @ ssupcode = supcode , @ dztotal = dztotal , @ bczrtotal = bczrtotal , @ feetotal = feetotal , @ bcjstotal = bcjstotal ,
@ bgndate = bgndate , @ enddate = enddate
from t_jopaysoa_head
where billno = @ psbillno
update t_supplier
set dztotal = dztotal + @ dztotal , dzrtotal = dzrtotal + @ bczrtotal , feetotal = feetotal + @ feetotal
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 = amount - tctotal , @ 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
- - AlterJsLxSaleRpt
if @ bgndate < > ' '
begin
set @ bgnyear = datepart ( year , @ bgndate ) - 1
end
else
begin
select @ bgnyear = convert ( int , substring ( isnull ( min ( name ) , ' t_jopay_salerpt_ ' + convert ( varchar ( 4 ) , getdate ( ) , 120 ) ) , 17 , 4 ) ) from sysobjects
where xtype = ' u ' and name like ' t_jopay_salerpt_[0-9][0-9][0-9][0-9] '
end
set @ endyear = datepart ( year , @ enddate )
while ( @ bgnyear < = @ endyear )
begin
set @ salerpttablename = ' t_jopay_salerpt_ ' + convert ( varchar , @ bgnyear )
if exists ( select * from sysobjects where name = @ salerpttablename )
begin
set @ ssql = ' update a set a.isfinished= '' 1 '' '
+ ' from ' + @ salerpttablename + ' a,t_jopaysoa_body b '
+ ' where a.accdate=b.accdate and a.orgcode=b.orgcode and a.serialno=b.serialno '
+ ' and a.supcode= '' ' + @ ssupcode + ' '' '
+ ' and b.billno= '' ' + @ psbillno + ' '' '
exec ( @ ssql )
end
set @ bgnyear = @ bgnyear + 1
end
set @ psmsg = ' '
return ( 1 )
end
go