您好,登錄后才能下訂單哦!
業務場景:
上線時,客戶往往在財務軟件中還有個人借款余額,通常希望能導入到費控系統,這樣填寫報銷單時,能夠沖銷原來手工借支的款項。基于此目的,我們提供了下面的標準實施方案來解決。
1、確保數據庫中有借款余額表(TLOAN_INIT)
CREATE TABLE [dbo].[TLOAN_INIT]( [LI_ID] [varchar](50) NOT NULL, [LI_USER] [varchar](50) NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_USER] DEFAULT (''), [LI_SUBJECT_FEE] [varchar](50) NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_SUBJECT_FEE] DEFAULT (''), [LI_AMOUNT] [numeric](18, 2) NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_AMOUNT] DEFAULT ((0)), [LI_REMARK] [varchar](2000) NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_REMARK] DEFAULT (''), [LI_CREATE_DATETIME] [datetime] NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_CREATE_DATETIME] DEFAULT (getdate()), [LI_ACTIVE] [char](1) NOT NULL CONSTRAINT [DF_TLOAN_INIT_LI_ACTIVE] DEFAULT ('N'), CONSTRAINT [PK_TLOAN_INIT] PRIMARY KEY CLUSTERED ( [LI_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
2、通過自定義擴展頁面導入,或者excel提單導入的方式,把客戶整理好的借款余額數據,導入到上面的表中
3、執行存儲過程(p_uf_InitLoanAmount),處理借款余額表,把數據寫入單據主表和明細表,基本原理是虛擬一張借款單出來。
CREATE proc p_uf_InitLoanAmount as begin declare @li_id varchar(50)='' declare @user_id varchar(50)='' declare @fee_id varchar(50)='' declare @amount float=0 declare @remark varchar(50)='' declare @bill_id varchar(50)='' declare @bill_no varchar(50)='' declare @project_id varchar(50)='' declare @i int=0 --創建虛擬單號 set @bill_no='LI'+CAST(DATEPART(year,GETDATE()) AS VARCHAR(50))+'-'+CAST(DATEPART(MONTH,GETDATE()) AS VARCHAR(50))+'-'+CAST(DATEPART(DAY,GETDATE()) AS VARCHAR(50)) +'-'+CAST(DATEPART(HOUR,GETDATE()) AS VARCHAR(50))+'-'+CAST(DATEPART(minute,GETDATE()) AS VARCHAR(50))+'-'+CAST(DATEPART(second,GETDATE()) AS VARCHAR(50)) --循環寫入,并改寫標志位,避免重復導入 select * from tloan_init DECLARE loan_init_Cursor CURSOR FOR SELECT li_user,li_subject_fee,li_amount,li_remark,li_id ,LI_PROJECT from tloan_init where li_active='N'; OPEN loan_init_Cursor; FETCH NEXT FROM loan_init_Cursor into @user_id,@fee_id,@amount,@remark,@li_id,@project_id; WHILE @@FETCH_STATUS = 0 BEGIN set @i=@i+1 set @bill_id=NEWID() --寫入表表 insert into TBILL (BILL_NO,BILL_ID,BILL_TEMPLATE_TYPE,BILL_USER,BILL_AMOUNT,BILL_FLAG,BILL_REMARK,bill_project) values (@bill_no+RIGHT(@bill_id,4),@bill_id,'T-L',@user_id,@amount,'CLOSE',@remark,@project_id) --寫入明細表 insert into TBILL_CONTENT (BILLC_BILL_ID,BILLC_SEQ,BILLC_USER,BILLC_SUBJECT_FEE,BILLC_AMOUNT,BILLC_LAMOUNT,BILLC_TYPE,billc_project) values (@bill_id,1,@user_id,@fee_id,@amount,@amount,'臨時借款',@project_id) --更新標志位 update tloan_init set li_active='Y' where li_id=@li_id FETCH NEXT FROM loan_init_Cursor into @user_id,@fee_id,@amount,@remark,@li_id,@project_id; END; CLOSE loan_init_Cursor; DEALLOCATE loan_init_Cursor; select CAST(@i as varchar(50))+' 行數據導入完成' end
4、完成,在報銷單中即可沖銷上面的借款。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。