select ap.dVouchDate as 单据日期,ap.cPZNum as 凭证编号,case bStartFlag when 1 then '期初余额' end as 摘要/*数据属性*/,ap.cDwCode as 供应商编码,ap.cVouchID as 票据号,ap.cVouchType as 票据类型,ap.cexch_name as 币种,ap.iAmount as 期初余额,ap.cFlag as 应收应付标志,ap.cOperator as 操作人,ap.bStartFlag as 期初标志 from Ap_Vouch ap where bStartFlag=1/*期初余额表,数据正确*/ union all select pb.dpbvdate as 开票日期,pbs.cPZNum as 凭证号,pb.cPBVMemo as 摘要,sum(isum)as 本期应付 /*本期应付*/ ,pb.cVenCode as 供应商编码,cPBVCode as 单据号 ,pb.cPBVVerifier as 审核人,cPBVMaker as 制单人,pb.cPBVCode as 订单号,pb.dGatheringDate as 到期日,pbs.PBVID as 采购发票号 from PurBillVouch pb,PurBillVouchs pbs,Vendor v where pb.pbvid=pbs.PBVID and pb.cVenCode=v.cvencode group by cPBVCode,pb.cPBVMemo ,pbs.cPZNum ,pb.cVenCode ,pb.cPBVVerifier ,cPBVMaker ,pb.cPBVCode ,pb.dGatheringDate ,pbs.PBVID,dpbvdate/*发票*/ union all select ap.dvouchdate as 票据日期,ap.cVouchID as 单据号,ap.cdigest as 摘要,aps.iApplyAmt as 本期付款申请金额 ,case cVouchType when 'AP40' then '付款申请单'end as 票据类型, ap.cdwcode as 供应商编码,v.cVenName as 供应商名称,ap.cexch_name as 币种,ss.cSSName as 结算方式,ap.cCheckMan as 检查人,ap.cFlag from AP_ApplyPayVouch ap,AP_ApplyPayVouchs aps,Vendor v,SettleStyle ss where ap.PID=aps.pid and ap.cDwCode=v.cVenCode and ap.cSSCode=ss.cSSCode/*付款申请表*/ |