解决方案: |
存货结转失败,是由于数据本身的问题。先进先出算法的辅助记价表中,出现入库金额和出库金额同时为空的记录,需要修正,脚本如下: --1.可用如下语句检查: SELECT count(*) FROM (IA_valuationass left join (select * from ia_subsidiary where (isnull(iainquantity,0)-isnull(iaoutquantity,0))>0 ) IA_SubTab on IA_SubTab.id=IA_valuationass.inid left join warehouse on IA_SubTab.cwhcode=warehouse.cwhcode) WHERE IA_valuationass.dikeepdate=IA_SubTab.dkeepdate and (Warehouse.cWhvaluestyle='先进先出法' or Warehouse.cWhvaluestyle='后进先出法') And (IA_SubTab.iMonth>0 or (IA_SubTab.iMonth=0 and IA_SubTab.cVouType='34')) and IA_valuationass.cinvcode=IA_SubTab.cinvcode and (IA_valuationass.dIKeepDate is null Or IA_valuationass.dOKeepDate is null) and ioPrice is null and iiPrice is null --2.根据明细账,更新错误记录 update ia_valuationass Set iIprice = iIquantity * Isnull(iinCost,ioutcost) from ia_valuationass left join ia_subsidiary on ia_valuationass.inid = ia_subsidiary.id and ia_valuationass.cinvcode = ia_subsidiary.cinvcode Where iIprice is null update ia_valuationass Set iOPrice = iOquantity * Isnull(iinCost,ioutcost) from ia_valuationass left join ia_subsidiary on ia_valuationass.Outid = ia_subsidiary.id and ia_valuationass.cinvcode = ia_subsidiary.cinvcode Where iOPrice is null |