工业版K3 10版本物流系统反结账

工业版K3 10版本物流系统在月底期末处理时,会提示一旦结账到下一期,就不能反结账,(⊙o⊙)哦以前也吃过这个亏,结账前没有认真查各业务部门的单据,结完帐财务发现了,上期的单据不能生成凭证,恢复帐套,补单据,还好那时候是刚开始用,单据量少。

--把以下的SQL语句拷贝,粘贴到K3数据库端-SQLSERVER查询分析器中,就行了。
Declare @CurYear Int, --当前年份
@CurPeriod int, --当前会计期间
@staryear int, --启用年份
@starperiod int, --启用期间
@totalmonth int --每个会计年度的总的期间数
Select @CurPeriod=FValue From t_Systemprofile Where FKey='CurrentPeriod' And FCategory='IC'
Select @CurYear=FValue From t_Systemprofile Where FKey='CurrentYear' And FCategory='IC'
Select @staryear=FValue From t_Systemprofile Where FKey='StartYear' And FCategory='IC'
Select @starperiod=FValue From t_Systemprofile Where FKey='StartPeriod' And FCategory='IC'
Select @totalmonth=FValue From t_Systemprofile Where FKey='PeriodCount' And FCategory='gl'
--Select * From t_systemprofile Where fcategory='ic'

if @CurPeriod=@starperiod and @CurYear=@staryear-----如果目前为启用期间不能反结账
begin
print '目前为启用期间不需要反结账'
end
else

if @CurPeriod <>1------中间期间
begin
Update t_systemprofile Set FValue=@CurPeriod-1 Where FKey='CurrentPeriod' and fcategory='IC'
Delete Icbal Where FPeriod=@CurPeriod And Fyear=@CurYear
Delete IcInvbal Where FPeriod=@CurPeriod And Fyear=@CurYear
Delete Poinvbal Where FPeriod=@CurPeriod And Fyear=@CurYear
print '反结账后目前物流处于'+convert(varchar(10),@CurYear)+'年第'+convert(varchar(10),@CurPeriod-1)+'期'
end
else---------下一年转到上年

begin
Update t_systemprofile Set FValue=@totalmonth Where FKey='CurrentPeriod' and fcategory='IC'
Update t_systemprofile Set FValue=@CurYear-1 Where FKey='CurrentYear' and fcategory='IC'
Delete Icbal Where FPeriod=@CurPeriod And Fyear=@CurYear
Delete IcInvbal Where FPeriod=@CurPeriod And Fyear=@CurYear
Delete Poinvbal Where FPeriod=@CurPeriod And Fyear=@CurYear
print '反结账后目前物流处于'+convert(varchar(10),@CurYear-1)+'年第'++convert(varchar(10),@totalmonth)+'期'
end

注:请将对应的账套执行以下语句进行反结账,执行一次反结一期,请谨慎使用,如
果使用了计划价核算的账套(可能存在计划价调价),不能使用以下语句反结账.

使用物流反结账语句如帐套跨年度,如2012年第一期反结到2011年第十二期,反结账语句要加一条:
Update t_systemprofile Set FValue=@Curyear-1 Where FKey='Currentyear' and fcategory='IC'
并且原来的Update t_systemprofile Set FValue=@CurPeriod-1 Where FKey='CurrentPeriod' and fcategory='IC'中的FValue=@CurPeriod-1要改为FValue=@CurPeriod+11,不然反结后帐套期间为2012年第0期,并且无期初数据。

此方法经过在外帐帐套测试,没有问题。

你可能感兴趣的:(工业,K3物流系统)