EAS版本:750问题:采购发票核销记录反核销失败
描述:采购发票核销记录,点击反核销,提示“核销期间小于本期,不允许反核销”,但是我们的核销期间查看就是和总账在同一个期间,并且在数据库里面查看总账的期间和核销记录这个数据库的期间也在一个期间,不知道到底是哪里的问题,烦请帮助解决
分析: T_CL_WriteOffGroup表的FWriteOffYear,FWriteOffPeriod,T_CL_WriteOffRecord 表的FCompanyOrgUnitID
如果T_CL_WriteOffRecord 表的FCompanyOrgUnitID字段为null会出现上述提示:
库存组织当前期间的年份:currYear,
库存组织当前期间的月份:currPeriod,
如果FWriteOffYear小于currYear或者 FWriteOffYear等于currYear并且FWriteOffPeriod小于currPeriod
这个条件成立 也会报出上述错误
查询语句:
select
bill.FWriteOffYear,bill.FWriteOffPeriod,material.fnumber as materialNumber,
costAdjustBill.fnumber as billNumber,costAdjustBill.ffivouchered,entry.FCompanyOrgUnitID as companyOrgUnitID,
bill.ffivouchered as writeOffVoucher, bill.FIsDischarged as isDischarged
from T_CL_WriteOffGroup bill
inner join T_CL_WriteOffRecord entry on bill.fid=entry.fparentid
inner join T_BD_Material material on entry.fmaterialid=material.fid
left join T_CL_CostAdjustBill costAdjustBill on entry.fbillID=costAdjustBill.fid
where 1=1
and bill.fid in (‘核销记录id’)
-- and entry.fcompanyorgunitid is null
group by bill.FWriteOffYear,bill.fwriteOffPeriod,material.fnumber,
costAdjustBill.fnumber,costAdjustBill.ffivouchered,entry.FCompanyOrgUnitID,
bill.ffivouchered, bill.FIsDischarged
核销记录分录的财务组织id为空修复语句:
--备份
select *
into t_cl_writeoffrecord_0825
from t_cl_writeoffrecord
where fcompanyorgunitid is null
--修复
update t_cl_writeoffrecord set fcompanyorgunitid = (
select a.fcompanyorgunitid from t_cl_writeoffgroup a where a.fid = t_cl_writeoffrecord.fparentid
)where fcompanyorgunitid is null and fid in (select fid from t_cl_writeoffrecord_0825)
推荐阅读