业务场景:库存模块以及应付模块先启用,存货核算后启用,
部分存货启用前的标准采购入库单/采购退料单已下推应付单未下推发票,启用存货后下推发票核销有差异金额,核算无法自动生成成本调整单
解决方案:
方案1、修改库存跟存货同期间启用
方案2、未下推发票的应付新增期初应付单据再下推发票或者财务应付
方案3、可以使用以下脚本修复通过采购入库单/采购退料单C表成本后,当期在入库钩稽明细表过滤采购入库单/采购退料单——业务操作——应付关闭出单生成成本调整单调整
--1、查询组织内码以及维度内码
select b.FORGID,--组织内码
FDIMENSIONID --维度内码
from T_HS_CALDIMENSIONS a
join T_ORG_ORGANIZATIONS b on a.FFINORGID =b.FORGID where FNUMBER='核算组织编码'
--2、根据1的查询结果为条件执行更新
declare @date1 datetime ;
declare @orgid int ;
declare @dimensionid int;
set @date1 = convert(datetime,'2020/1/1');--存货启用的日期
set @orgid = 1;--组织内码
set @dimensionid = 1;--维度内码
--采购人库单
insert into T_STK_INSTOCKENTRY_C(FENTRYID,FLOCALCURRID,FAMOUNT_LC,FPRICE,FDIMENSIONID,FPROCESSFEE,FMATERIALCOSTS,FISACCTGBILL,FISSETTLE,FACCTGPRICESOURCE)
select b.FENTRYID
,max(e.FMAINBOOKSTDCURRID)FMAINBOOKSTDCURRID,
sum(case f.FISTAXINCOST when '0' then d.FNOTAXAMOUNT else d.FALLAMOUNT end )FNOTAXAMOUNT,
round( sum(case f.FISTAXINCOST when '0' then d.FNOTAXAMOUNT else d.FALLAMOUNT end )/sum(b.FBASEUNITQTY),6) fprice,1,0,0,0,'0','0'
from T_STK_INSTOCK a
inner join T_STK_INSTOCKENTRY b on a.fid= b.FID
inner join T_BD_MATERIALBASE mat on b.FMATERIALID=mat.FMATERIALID and mat.FERPCLSID not in ('6','10','11')
inner join T_STK_INSTOCKFIN af on a.fid = af.fid
inner join T_AP_PAYABLE_LK c on b.FENTRYID = c.FSID
inner join T_BF_TABLEDEFINE BF on c.FSTABLENAME=BF.FTABLENUMBER and BF.FFORMID in ('STK_InStock')
inner join T_AP_PAYABLEENTRY d on c.FENTRYID = d.FENTRYID
inner join T_AP_PAYABLEFIN e on d.FID = e.FID
inner join T_AP_PAYABLE f on d.FID = f.FID
inner join T_BD_STOCKSTATUS STA on STA.FSTOCKSTATUSID=b.FSTOCKSTATUSID and STA.FTYPE<>'8'
left join T_STK_INSTOCKENTRY_C tc on b.fentryid =tc.fentryid and tc.FDIMENSIONID = @dimensionid
where a.FDATE<@date1 and f.fdate<@date1 and af.FSETTLEORGID = @orgid and tc.fentryid is null
group by b.fentryid
--采购退料单
insert into T_PUR_MRBENTRY_C(FENTRYID,FLOCALCURRID,FAMOUNT_LC,FPRICE,FDIMENSIONID,FPROCESSFEE,FMATERIALCOSTS,FISACCTGBILL,FISSETTLE,FACCTGPRICESOURCE)
select b.FENTRYID
,max(e.FMAINBOOKSTDCURRID)FMAINBOOKSTDCURRID,
sum(case f.FISTAXINCOST when '0' then d.FNOTAXAMOUNT else d.FALLAMOUNT end )*-1 FNOTAXAMOUNT,
round( sum(case f.FISTAXINCOST when '0' then d.FNOTAXAMOUNT else d.FALLAMOUNT end )*-1/sum(b.FBASEUNITQTY),6) fprice,1,0,0,0,'0','0'
from T_PUR_MRB a
inner join T_PUR_MRBENTRY b on a.fid= b.FID
inner join T_BD_MATERIALBASE mat on b.FMATERIALID=mat.FMATERIALID and mat.FERPCLSID not in ('6','10','11')
inner join T_PUR_MRBFIN af on a.fid = af.fid
inner join T_AP_PAYABLE_LK c on b.FENTRYID = c.FSID
inner join T_BF_TABLEDEFINE BF on c.FSTABLENAME=BF.FTABLENUMBER and BF.FFORMID in ('PUR_MRB')
inner join T_AP_PAYABLEENTRY d on c.FENTRYID = d.FENTRYID
inner join T_AP_PAYABLEFIN e on d.FID = e.FID
inner join T_AP_PAYABLE f on d.FID = f.FID
inner join T_BD_STOCKSTATUS STA on STA.FSTOCKSTATUSID=b.FSTOCKSTATUSID and STA.FTYPE<>'8'
推荐阅读