内部往来:
由于与GL相反,IC存的是当期发生数,所以可以从凭证分录取数或余额表取数,凭证分录和余额表的区别在于余额有期初而凭证分录没有,凭证分录记账更细。
如何取得客户供应商?
第一种办法: 根据核算id和核算标识(FFLEX6标识客户、FFLEX4标识供应商)在核算项目表t_bd_flexitem里找到对应客商id,在客户表里根据客户id找到客户描述,在供应 商表里根据供应商id找到供应商描述。
第二种办法:根据核算id直接在核算项目明细表t_bd_flexitemdetailv里找到FFLEX6字段里是客户id,FFLEX4字段是供应商id,在根据客商id分别取找客商描述。
select b.fyear,
b.fperiod,
b.fdetailid,
decode(ftd.fflex6,0,ftd.Fflex4,ftd.fflex6) custcode,
decode(c.fname,null,s.fname,c.fname) custsppname,
t1.fnumber subjcode,
t.fname subjname,
t1.flevel subjlev,
t2.fnumber companycode,
t3.fname companyname,
b.fbeginbalance beginbalance,
b.fdebit localdebitamount,
b.fcredit localcreditamount,
b.fendbalance endbalance,
t1.fmodifydate,b.fcurrencyid
from wkerp.T_GL_Balance b
left join wkerp.t_bd_account t1 on t1.facctid = b.faccountid
left join wkerp.t_bd_account_l t on t.facctid = t1.facctid
inner join wkerp.t_bd_accountbook t2 on b.faccountbookid = t2.fbookid
left join wkerp.t_bd_accountbook_l t3 on t3.fbookid = t2.fbookid
left join wkerp.t_bd_flexitem ft on ft.fdetailid = b.fdetailid and ft.fdatafieldname = 'FFLEX6' --cust
LEFT JOIN wkerp.T_BD_FLEXITEM FT2 ON FT2.FDETAILID = B.FDETAILID AND FT2.FDATAFIELDNAME = 'FFLEX4' --supp
left join wkerp.t_bd_flexitemdetailv ftd on ftd.fid = b.fdetailid
left join wkerp.t_bd_customer_l c on c.fcustid = ftd.fflex6
left join wkerp.t_bd_supplier_l s on s.fsupplierid = ftd.fflex4
order by b.fyear, b.fperiod,t1.fnumber,t.fname
损益科目发生额:
金蝶系统每期的期末会将损益科目结转到本年利润,导致损益科目期末余额为0,无法通过科目余额表取数的问题解决方案一:3.筛选条件2:取科目5开头的损益科目凭证行,根据科目主数据上标记的借贷方,借方取凭证行借方发生额,贷方取凭证行贷方发生额。
create or replace view v_mr_income as
select b.fyear,
b.fperiod,
t1.fnumber subjcode,
t.fname subjname ,
t1.flevel subjlev,
t2.fnumber companycode,
t3.fname companyname,
v.fdebit,
v.fcredit,
v.fcurrencyid
from t_gl_voucher b
left join t_gl_voucherentry v on v.fvoucherid = b.fvoucherid
left join t_bd_account t1 on t1.facctid = v.faccountid
left join t_bd_account_l t on t.facctid = t1.facctid
inner join t_bd_accountbook t2 on b.faccountbookid = t2.fbookid
left join t_bd_accountbook_l t3 on t3.fbookid = t2.fbookid
where t1.fnumber like '5%' and (fexplanation is null or fexplanation <>'结转本期损益')
方案二:从损益表T_GL_BALANCEPROFIT取数。