財務憑證查詢

2021-09-11 06:04:37 字數 4159 閱讀 6176

if object_id('tempdb..#pz') is not null begin

drop table #pz

endselect * into #pz from (

select a.fdate ,a.fyear,a.fnumber as fpznum,b.fexplanation  ,

case when charindex('.',replace(replace(b.fexplanation,',','.'),'(','.'))= 0 

then replace(replace(substring(b.fexplanation  ,charindex('g' ,b.fexplanation) ,16),',','.'),'(','.')

else substring(replace(replace(replace(b.fexplanation,'收款',''),',','.'),'(','.'),1,charindex('.',replace(replace(b.fexplanation,',','.'),'(','.'))-1 ) 

end as 'seorderno',

--case 

--when charindex('款',b.fexplanation) > 0 then substring(b.fexplanation, charindex('款',b.fexplanation)+1,99)

--when charindex(',',b.fexplanation) > 0 then substring(b.fexplanation,1, charindex(',',b.fexplanation)-1)

--when charindex('(',b.fexplanation) > 0 then substring(b.fexplanation,1, charindex('(',b.fexplanation)-1)

--when charindex(' ',b.fexplanation) > 0 then substring(b.fexplanation,1, charindex(' ',b.fexplanation)-1)

--else b.fexplanation end,

t1.fname ,t3.fnumber ,b.famountfor , 

case when b.fdc = 1  then b.famountfor else 0  end  as '借方金額',case when b.fdc = 0  then b.famountfor else 0  end  as '貸方金額',

case when b.fdc = 1  then b.famountfor else 0  end - case when b.fdc = 0  then b.famountfor else 0  end  as '餘額'

from t_voucher a

inner join t_voucherentry b on a.fvoucherid = b.fvoucherid 

inner join t_account t1 on b.faccountid = t1.faccountid

left join t_itemdetail t2 on b.fdetailid = t2.fdetailid

left join t_organization t3 on t2.f1 = t3.fitemid

where 

a.fvoucherid in (select fvoucherid  from t_voucherentry  where faccountid  = '1018' )  and t1.fname = '應收賬款'

and a.fexplanation <> '結轉匯兌損益'

--and t3.fnumber = '203'

) a-------

select * from (

select *  from (

select fdate,fyear,fpznum,fexplanation,

case 

when charindex('.',seorderno) > 0 then substring(seorderno,1, charindex('.',seorderno)-1)

when charindex('  ',seorderno) > 0 then substring(seorderno,1, charindex('  ',seorderno)-1)

when charindex('餘',seorderno) > 0 then substring(seorderno,1, charindex('餘',seorderno)-1)

when charindex('部',seorderno) > 0 then substring(seorderno,1, charindex('部',seorderno)-1)

when charindex('訂',seorderno) > 0 then substring(seorderno,1, charindex('訂',seorderno)-1)

when charindex('全',seorderno) > 0 then substring(seorderno,1, charindex('全',seorderno)-1)

when charindex('未',seorderno) > 0 then substring(seorderno,1, charindex('未',seorderno)-1)

when charindex('樣',seorderno) > 0 then substring(seorderno,1, charindex('樣',seorderno)-1)

when charindex('收款',seorderno) > 0 then substring(seorderno, charindex('收款',seorderno),99)

else seorderno 

end as fseorderno,

fname,fnumber,借方金額,貸方金額,餘額 from #pz

) aunion all

select max(fdate),2018,0,'',fseorderno,'小計',max(fnumber) as fnumber,sum(借方金額),sum(貸方金額),sum(餘額)  from (

select fdate,fyear,fexplanation,

case 

when charindex('.',seorderno) > 0 then substring(seorderno,1, charindex('.',seorderno)-1)

when charindex('  ',seorderno) > 0 then substring(seorderno,1, charindex('  ',seorderno)-1)

when charindex('餘',seorderno) > 0 then substring(seorderno,1, charindex('餘',seorderno)-1)

when charindex('部',seorderno) > 0 then substring(seorderno,1, charindex('部',seorderno)-1)

when charindex('訂',seorderno) > 0 then substring(seorderno,1, charindex('訂',seorderno)-1)

when charindex('全',seorderno) > 0 then substring(seorderno,1, charindex('全',seorderno)-1)

when charindex('未',seorderno) > 0 then substring(seorderno,1, charindex('未',seorderno)-1)

when charindex('樣',seorderno) > 0 then substring(seorderno,1, charindex('樣',seorderno)-1)

when charindex('收款',seorderno) > 0 then substring(seorderno, charindex('收款',seorderno),99)

else seorderno 

end as fseorderno,

fname,fnumber,借方金額,貸方金額,餘額 from #pz

) agroup by fseorderno

) border by fnumber,fseorderno,fname desc

財務業務 會計憑證的審核

原始憑證審核的內容和要求 1 審核原始憑證的真實性 包括日期是否真實 業務內容是否真實 資料是否真實等。2 審核原始憑證的合法性 經濟業務是否符合國家有關政策 法規 制度的規定,是否有違法亂紀等行為。3 審核原始憑證的合理性 原始憑證所記錄經濟業務是否符合企業生產經營活動的需要 是否符合有關的計畫和...

使用程式生成財務預製憑證的方法(一)

使用程式生成財務預製憑證的方法 data lv flag type xfeld,lv name type char30.field symbols type bkpf.call function preliminary posting fb01 exporting i xcmpl i tcode i...

智點財務軟體記賬憑證的錄入

目前的財務軟體市場中,有大家熟知的大眾會計軟體,像智點等,也有新興起的小眾軟體。越來越多的會計軟體在充斥著這個市場,所以,難免企業在選擇記賬軟體的時候,就顯得非常的謹慎而又困難,因為有些軟體的穩定性和效能,在企業沒有充分了解的前提下,是沒有乙個判定的,我們來看下在智點財務軟體中,記賬憑證的錄入功能是...