使用SQL語句在K3裡進行反結帳

2022-08-04 21:39:19 字數 2139 閱讀 1650

使用sql語句在k3裡進行反結帳

declare @curyear int, --當前年份

@curperiod int, --當前會計期間

@staryear int, --啟用年份

@starperiod int, --啟用期間

@totalmonth int --每個會計年度的總的期間數

使用sql語句在k3裡進行反結帳

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 '目前為啟用期間不需要反結賬'

endelse 

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)+'期'

endelse---------下一年轉到上年

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注:請將對應的賬套執行以下語句進行反結賬,執行一次反結一期,請謹慎使用,如

果使用了計畫價核算的賬套(可能存在計畫價調價),不能使用以下語句反結賬.

在Python裡使用SQL語句操作Pandas

安裝pandasql的方法非常簡單,你只需要在你的shell中鍵入pip install u pandasql,即 pip install u pandasqlimport pandas as pd from pandasql import sqldf books pd.dataframe 這裡為了...

金蝶K3批量禁用物料的語句

批量禁用物料 update t set t.fdeleted 1 from t icitemcore t 將物料標示為禁用 inner join portal dbo ttgi28e t111 on t111.f3j00xc t.fnumber 關聯物料編碼清單 update t set t.fde...

金蝶K3批量禁用物料的語句

批量禁用物料 update t set t.fdeleted 1 from t icitemcore t 將物料標示為禁用 inner join portal dbo ttgi28e t111 on t111.f3j00xc t.fnumber 關聯物料編碼清單 update t set t.fde...