日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

金蝶K3 SQL报表系列-供应商应付/预付账款明细表

發(fā)布時間:2023/12/20 数据库 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 金蝶K3 SQL报表系列-供应商应付/预付账款明细表 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、創(chuàng)建供應(yīng)商應(yīng)付預(yù)付賬款明細(xì)總表存儲過程:sp_getAccount_detail,代碼如下:

create procedure [dbo].[sp_getAccount_detail]@StartYear int,@StartPeriod int,@EndYear int,@EndPeriod int,@FAcctNumber nvarchar(20),@FItemNumber nvarchar(200) as set nocount ondeclare @curYear int declare @curPeriod intselect @curYear=FValue from t_SystemProfile where Fkey='CurrentYear' and FCategory='GL' select @curPeriod=FValue from t_SystemProfile where Fkey='CurrentPeriod' and FCategory='GL'create table #report_sum ( FID int identity(1,1), FSuppID int, FAcctountID int, FDC int, FIndex int, FYear int, FPeriod int, FDate datetime, FTrnasDate datetime, FVoucherID int, FExplanation nvarchar(1000), FDebit decimal(21,10), FCredit decimal(21,10), FEndBalance decimal(21,10) )insert into #report_sum (FSuppID,FAcctountID,FDC,FIndex,FYear,FPeriod,FEndBalance) select F8,u1.FAccountID,t3.FDC,-1,u1.FYear,u1.FPeriod,u1.FBeginBalance*t3.FDC from t_Balance u1 inner join t_ItemDetail t1 on u1.FDetailID=t1.FDetailID inner join t_Item t2 on t2.FItemID=t1.F8 inner join t_Account t3 on t3.FAccountID=u1.FAccountID where u1.FCurrencyID=0 and u1.FYear*12+u1.FPeriod>=@StartYear*12+@StartPeriod and u1.FYear*12+u1.FPeriod<=@EndYear*12+@EndPeriod and u1.FYear*12+u1.FPeriod<=@curYear*12+@curPeriod and t2.FNumber=@FItemNumber and t3.FNumber like @FAcctNumber and t3.FDetail=1insert into #report_sum (FSuppID,FAcctountID,FDC,FIndex,FYear,FPeriod,FEndBalance) select F8,u1.FAccountID,t3.FDC,1,u1.FYear,u1.FPeriod,u1.FEndBalance*t3.FDC from t_Balance u1 inner join t_ItemDetail t1 on u1.FDetailID=t1.FDetailID inner join t_Item t2 on t2.FItemID=t1.F8 inner join t_Account t3 on t3.FAccountID=u1.FAccountID where u1.FCurrencyID=0 and u1.FYear*12+u1.FPeriod>=@StartYear*12+@StartPeriod and u1.FYear*12+u1.FPeriod<@EndYear*12+@EndPeriod and u1.FYear*12+u1.FPeriod<@curYear*12+@curPeriod and t2.FNumber=@FItemNumber and t3.FNumber like @FAcctNumber and t3.FDetail=1insert into #report_sum (FSuppID,FAcctountID,FDc,FIndex,FYear,FPeriod,FDate,FTrnasDate,FVoucherID,FExplanation,FDebit,FCredit) select F8,t1.FAccountID,t4.FDC,0,u1.FYear,u1.FPeriod,u1.FDate,u1.FTransDate,u1.FVoucherID,t1.FExplanation, CASE WHEN t1.FDC=1 THEN t1.FAmount ELSE 0 END as FDebit, CASE WHEN t1.FDC=0 THEN t1.FAmount ELSE 0 END as FCredit from t_Voucher u1 inner join t_VoucherEntry t1 on u1.FVoucherID=t1.FVoucherID inner join t_ItemDetail t2 on t2.FDetailID=t1.FDetailID inner join t_Item t3 on t3.FItemID=t2.F8 inner join t_Account t4 on t4.FAccountID=t1.FAccountID where u1.FYear*12+u1.FPeriod>=@StartYear*12+@StartPeriod and u1.FYear*12+u1.FPeriod<=@EndYear*12+@EndPeriod and t4.FNumber like @FAcctNumberand t3.FNumber=@FItemNumberand t4.FDetail=1 order by u1.FYear,u1.FPeriod,u1.Fdate,u1.FVoucherIDdeclare @FID int, @Findex int,@FDC int,@FYear int,@FPeriod int,@FDebit decimal(21,10), @FCredit decimal(21,10),@FEndBalance decimal(21,10),@FCurBanalce decimal(21,10), @FOldAccountID int,@FCurAccountID intset @FCurBanalce=0 set @FEndBalance=0 set @FOldAccountID=0declare cur_list cursor for select FAcctountID,FID,FIndex,FDC,FYear,FPeriod,isnull(FDebit,0),isnull(FCredit,0),FEndBalance from #report_sum order by FAcctountID,FYear,FPeriod,FIndex,FIDopen cur_listfetch next from cur_list into @FCurAccountID,@FID,@Findex, @FDC,@FYear,@FPeriod,@FDebit,@FCredit,@FEndBalancewhile @@FETCH_STATUS=0 beginif @FOldAccountID<>@FCurAccountIDbeginset @FCurBanalce=0set @FOldAccountID=@FCurAccountIDendif @Findex=-1beginset @FCurBanalce=@FEndBalanceendif @Findex=0beginset @FCurBanalce=@FCurBanalce+@FDC*@FDebit-@FDC*@FCreditupdate u1set u1.FEndBalance=@FCurBanalcefrom #report_sum u1where u1.FID=@FIDendfetch next from cur_listinto @FCurAccountID,@FID,@Findex, @FDC,@FYear,@FPeriod,@FDebit,@FCredit,@FEndBalance end close cur_list deallocate cur_listselect t4.FNumber 供應(yīng)商代碼, t4.FName 供應(yīng)商名稱, u1.FYear 年度, u1.FPeriod 期間, t1.FNumber 科目代碼, t1.FName 科目名稱, u1.FDate 憑證日期, u1.FTrnasDate 業(yè)務(wù)日期, t3.FName+'-'+convert(nvarchar(20),t2.FNumber) 憑證字號, isnull(u1.FExplanation,'')+(case when u1.FIndex=-1 then '期初' when u1.FIndex=1 then '結(jié)存' else '' end ) 摘要, u1.FDebit 借方金額, u1.FCredit 貸方金額, u1.FEndBalance 余額 from #report_sum u1 inner join t_account t1 on u1.FAcctountID=t1.FAccountID left join t_Voucher t2 on t2.FVoucherID=u1.FVoucherID left join t_VoucherGroup t3 on t3.FGroupID=t2.FGroupID left join t_Item t4 on t4.FItemID=u1.FSuppID order by u1.FAcctountID,u1.FYear,u1.FPeriod,u1.FIndex,u1.FIDdrop table #report_sum
2、創(chuàng)建供應(yīng)商應(yīng)付明細(xì)賬存儲過程:sp_getAccount_detail_2202,代碼如下:

create procedure [dbo].[sp_getAccount_detail_2202]@StartYear int,@StartPeriod int,@EndYear int,@EndPeriod int,@FItemNumber nvarchar(200)asbeginexec sp_getAccount_detail @StartYear,@StartPeriod,@EndYear,@EndPeriod,'2202%',@FItemNumberend


3、創(chuàng)建供應(yīng)商預(yù)付明細(xì)賬存儲過程:sp_getAccount_detail_1123,代碼如下:
create procedure [dbo].[sp_getAccount_detail_1123]@StartYear int,@StartPeriod int,@EndYear int,@EndPeriod int,@FItemNumber nvarchar(200)asbeginexec sp_getAccount_detail @StartYear,@StartPeriod,@EndYear,@EndPeriod,'1123%',@FItemNumberend

4、K3查詢分析工具先創(chuàng)建如下SQL關(guān)鍵字:

關(guān)鍵字 ?標(biāo)題 ?數(shù)據(jù)類型 ?數(shù)據(jù)來源 ?字段 ?是否允許錄入
*StartYear* ?開始年度 ?數(shù)字型 ?手工錄入 ?無 ?允許錄入
*StartPeriod* ?開始期間 ?數(shù)字型 ?手工錄入 ?無 ?允許錄入
#EndYear# ?截止年度 ?數(shù)字型 ?手工錄入 ?無 ?允許錄入
#EndPeriod# ?截止期間 ?數(shù)字型 ?手工錄入 ?無 ?允許錄入
@SuppNumber@ ?供應(yīng)商代碼 ?字符串 ?供應(yīng)商 ?代碼 允許錄入

5、K3查詢分析工具創(chuàng)建供應(yīng)商應(yīng)付賬款明細(xì)表,sql語句為:

exec sp_getAccount_detail_2202 *StartYear*,*StartPeriod*,#EndYear#,#EndPeriod#,'@SuppNumber@'


6、K3查詢分析工具創(chuàng)建供應(yīng)商預(yù)付賬款明細(xì)表,sql語句為:
exec sp_getAccount_detail_1123 *StartYear*,*StartPeriod*,#EndYear#,#EndPeriod#,'@SuppNumber@'



開發(fā)完畢。



總結(jié)

以上是生活随笔為你收集整理的金蝶K3 SQL报表系列-供应商应付/预付账款明细表的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。