解决方案: |
/*1、 在库存中,单号为9900040995的销售出库单中,货物10202不能设货位。
原因是货物10202批次20021023在rdrecord/s表中相应记录的dvdate失效日期2003-10-22与invposition表中的dvdate失效日期2003-10-23不一致造成的,将其改为2003-10-23后删除原出库单重新生成即可。请检查货物10202批次20021023是否已超该批次出货*/
select * from rdrecord join rdrecords on rdrecord.id=rdrecords.id where cinvcode=‘10202‘ and cbatch=‘20021023‘ and cvouchtype=‘34‘ and brdflag=‘1‘
select * from invposition where cinvcode=‘10202‘ and cbatch=‘20021023‘
/*2、 批次期初不对,如发票0500988844中,存货10104批次中批号为20021226的数量应为0。
经检查发现st_totalaccount表中批次存货结存数与rdrecord/s表中对应的批次存货结存数不一致造成。请与用户协商后或根据上年末批次结存数 ,据语句所计算的期初数量qichushuliang可适当修正rdrecords表的iquantity字段值,
调整后请将isoutquantity累积发出数与期初数量qichushuliang相等的记录相应在mainbatch表中对该记录的bisnull改为true*/
--有规律的:
select cinvcode as bm,cbatch as pc,ibeginquantity as pcjcs into bb from st_totalaccount where ibeginquantity<>0 and imonth=‘1‘and cinvcode <>‘10202
‘ and cbatch<>‘20021023‘and cinvcode<>‘10302‘ and cbatch<>‘20020925‘ order by cinvcode,cbatch
select rdrecords.autoid,bb.bm,bb.pc,bb.pcjcs into cc from rdrecord join rdrecords on rdrecord.id=rdrecords.id join bb on rdrecords.cinvcode=bb.bm and rdrecords.cbatch=bb.pc where cvouchtype=‘34‘ and brdflag=‘1‘ and rdrecords.iquantity<>bb.pcjcs
select rdrecords.cinvcode,rdrecords.cbatch,sumrdrecords.iquantityas qcfcs,rdrecords.cvouchcode into qcfc
from rdrecord join rdrecords on rdrecord.id=rdrecords.id join cc on rdrecords.cvouchcode=cc.autoid and rdrecords.cinvcode=cc.bm and rdrecords.cbatch=cc.pc
where rdrecord.cvouchtype=‘34‘ and rdrecord.brdflag=‘0‘
group by rdrecords.cinvcode,rdrecords.cbatch,rdrecords.cvouchcode
select cc.autoid,cc.bm,cc.pc,cc.pcjcs+qcfc.qcfcs as qichushuliang into ff from
cc join qcfc on cc.bm=qcfc.cinvcode and cc.pc=qcfc.cbatch and cc.autoid=qcfc.cvouchcode
/*与用户协商后或根据上年末批次结存数 ,据期初数量qichushuliang适当修正rdrecords表的iquantity字段值,
调整后请将isoutquantity累积发出数与期初数量qichushuliang相等的记录其autoid在mainbatch表中相应记录的bisnull改为true*/
select rdrecords.autoid,rdrecords.cinvcode,rdrecords.cbatch,rdrecords.iquantity,rdrecords.isoutquantity,ff.autoid,ff.qichushuliang from rdrecord join rdrecords on rdrecord.id=rdrecords.id join ff on ff.autoid=rdrecords.autoid
and ff.bm=rdrecords.cinvcode and ff.pc=rdrecords.cbatch
where rdrecord.cvouchtype=‘34‘ and rdrecord.brdflag=‘1‘
and rdrecords.iquantity<>ff.qichushuliang
order by cinvcode,cbatch
--以下可检测该批次本期发出数与该批次结存数的对比注意:存货10303 批次20020906本期发出数已超过该批次结存数
select rdrecords.cinvcode,
rdrecords.cbatch,sumrdrecords.iquantityas bqfcs,cc.pcjcs from rdrecord join rdrecords on rdrecord.id=rdrecords.id join cc on rdrecords.cinvcode=cc.bm and rdrecords.cbatch=cc.pc and cc.autoid=rdrecords.cvouchcode where cvouchtype<>‘34‘ and brdflag=‘0‘
group by rdrecords.cinvcode,rdrecords.cbatch,rdrecords.cvouchcode,cc.pcjcs
having sumrdrecords.iquantity>=cc.pcjcs
/*没有规律的:由于在库存批次帐中以下两存货对应的批次只有一条记录,但rd表中均存在两条记录。
请与用户协商后或根据上年末批次结存数 ,据上述方法进行调整即可*/
select cinvcode,cbatch,ibeginquantity from st_totalaccount where ibeginquantity<>0 and imonth=‘1‘and cinvcode=‘10202‘ and cbatch=‘20021023‘or cinvcode=‘10302‘ and cbatch=‘20020925‘
select * from rdrecord join rdrecords on rdrecord.id=rdrecords.id where cinvcode=‘10202‘ and cbatch=‘20021023‘ and cvouchtype=‘34‘ and brdflag=‘1‘ or cinvcode=‘10302‘ and cbatch=‘20020925‘ and cvouchtype=‘34‘ and brdflag=‘1‘ order by cinvcode,cbatch |