
EAS中途启用会计科目的 往来科目属性,历史凭证不会自动生成往来账,需要根据凭证t_gl_voucherentry的fentrydc借方为1贷方为0,再根据不同的科目,分别挂账T_GL_AcctCussent和销账T_GL_ACCTVERIFY插入历史凭证,再去查看往来账,余额和科目余额表表就对得上了。
```language
2202 应付账款 贷方0 写入 挂账凭证
insert T_GL_AcctCussent
select newbosid('CE2D850A') as fid,t2.FCOMPANYID,t2.FACCOUNTID,t2.FPERIODID,t2.FCURRENCYID,t1.fid as FVOUCHERID,t2.fid as FENTRYID,t3.fid as FVCHASSISTRECORDID,t3.FASSGRPID,t3.FBIZDATE as FVARBIZDATE,t3.FENDDATE,t3.FBIZNUMBER,'0' as FISVIERIFIED,'0' as FISINIT,'0' as FISINITCLOSED,t3.FORIGINALAMOUNT as FUNVERIFIEDAMTFOR,t3.FORIGINALAMOUNT,now() as FLASTUPDATETIME,t1.FVOUCHERTYPEID,t1.fnumber as FVCHNUMBER,t1.fbookeddate,'1' as fispost,t1.FCreatorID,t1.FCreateTime,t1.FLastUpdateUserID,t1.FControlUnitID,t1.FNumber,t1.FBizDate,t1.FHandlerID,case when t3.FDescription is not null then t3.FDescription else t2.FDescription end as FDescription,'' as FHasEffected,'' as FAuditorID,'' as FSourceBillID,'' as FSourceFunction,0 as FUnVerifiedQty,0 as FUnHoldedQty,0 as FUnVerifiedStdQty,0 as FUnHoldedStdQty,t3.FORIGINALAMOUNT as FUnHoldedAmtFor,t3.FLOCALAMOUNT as FUnVerifiedAmtLocal,t3.FLOCALAMOUNT as FUnHoldedAmtLocal,0 as FUnVerifiedAmtRpt,0 as FUnHoldedAmtRpt,'' as FMeasureUnitID,'' as FArPrintBillID,'' as FArPrintBillEntryID,'' as FArRefundmentBillID,'' as FArRefundmentBillEntryID,t3.FSEQ,t3.FQUANTITY,t3.FLOCALAMOUNT,t3.FREPORTINGAMOUNT,t3.FSETTLEMENTTYPEID,t3.FSETTLEMENTCODE,t3.FCUSTOMERID,t3.FSUPPLIERID,t3.FORGUNITID,t3.FMATERIALID,t3.FTICKETNUMBER,t3.FINVOICENUMBER,t3.FFEETYPE,t2.FENTRYDC
from t_gl_voucher t1 join t_gl_voucherentry t2 on t1.fid = t2.fbillid join t_gl_voucherassistrecord t3 on t3.fentryid = t2.fid join t_bd_accountview km on t2.FACCOUNTID = km.fid and km.fnumber like '2202%' and km.fac = 1 and t2.fentrydc = 0 where t3.fid not in (select fvchassistrecordid from t_GL_AcctCussent) and t1.fbizdate <={ts'2022-12-31'}
```
详见附件。
EAS重新生成往来账SQL.rar
初始化余额我没搞定插入挂账和核销表,需要反结账反初始化,重做 往来账初始化余额