應(yīng)用場(chǎng)景:客戶(hù)想將原來(lái)的賬套數(shù)據(jù)清空,重新更改賬套的啟用年度和月份
注 意:會(huì)計(jì)期間的刪除只保留當(dāng)前啟用年度的期間;
另外執(zhí)行完語(yǔ)句,模塊的啟用到軟件中重新啟用。
declare @UFTSystemName nvarchar(100)='UFTSystemDec' --注意系統(tǒng)數(shù)據(jù)庫(kù)名稱(chēng),如果是舊版本T+,沒(méi)有Dec
declare @UFTdataName nvarchar(100)='UFTData787759_000999' --輸入要更改的賬套數(shù)據(jù)庫(kù)名稱(chēng)
declare @cAcc_Num int=999 --輸入要更改的賬套號(hào),注意前面沒(méi)有0,如:000001賬套,就輸入1
declare @iYear int=2021 --輸入要重新啟用的會(huì)計(jì)年度
declare @iMonth int=2 --輸入要重新啟用的會(huì)計(jì)期間
--更改系統(tǒng)數(shù)據(jù)庫(kù)賬套表中的啟用年度和啟用期間
EXEC('update '+ @UFTSystemName+'..EAP_Account set iYear='+@iYear+',iDuration='+@iMonth+' where cAcc_Num='+@cAcc_Num)
--更改賬套數(shù)據(jù)庫(kù)里的啟用年度
EXEC('update '+ @UFTdataName+'..EAP_AccInformation set Value='+@iYear+' where (InfoID=''500'' and name=''EnableYear'' and Caption=''啟用年度'')')
--更改賬套數(shù)據(jù)庫(kù)里的啟用期間
EXEC('update '+@UFTdataName+'..EAP_AccInformation set Value='+@iMonth+' where (InfoID=''501'' and name=''EnablePeriod'' and Caption=''啟用期間'')')
--刪除賬套庫(kù)里啟用年度之前年度無(wú)用的會(huì)計(jì)期間記錄
EXEC('delete from '+@UFTdataName+'..SM_Period where currentyear<'+@iYear)
--更改會(huì)計(jì)期間表字段
EXEC('update '+ @UFTdataName+'..SM_Period set BizTerminalState=1,FiTerminalState=1 where currentyear='+@iYear+' and currentperiod<'+@iMonth)
EXEC('update '+ @UFTdataName+'..SM_Period set BizTerminalState=0,FiTerminalState=0 where currentyear='+@iYear +' and currentperiod>='+@iMonth)
--修正賬套庫(kù)里模塊啟用對(duì)應(yīng)的會(huì)計(jì)期間ID
EXEC('update '+ @UFTdataName+'..EAP_AccInformation set idEnablePeriod=(select id from '+@UFTdataName+'..SM_Period where currentyear='+@iYear+' and currentperiod='+@iMonth+') where OptionType=1 and idEnablePeriod>0')