解决方案: |
应收系统的预收冲应收不能制单问题的解决方法:
1、因为在SALEBILLVOUCHS表中的记录中期初的单据的CMAKER 和CCHECKER字段为空,导致不能制单。
如:UPDATE SALEBILLVOUCH SET CMAKER =‘DEMO‘WHERE CMAKER IS NULL
UPDATE SALEBILLVOUCH SET CCHECKER=‘DEMO‘ WHERE CCHECKER IS NULL
2、在AP_detail表中有很多因为以上原因不能正常转帐而产生的单据号为空的记录,要先取消转帐,再进行空单据号的删除。
DELETE FROM AP_DETAIL WHERE CVOUCHTYPE=‘‘
3、发现在SALEBILLVOUCHS表中有39条记录的累计收款金额不正确。要用脚本把单据的累计收款金额替换成正确的,但因为该用户的数据很不正常,有的发票在AP_DETAIL表中有的记录,在SALEBILLVOUCHS表中并没有,造成AP_DETAIL 表的中的记录的收款金额大于应收金额,因此在调整SALEBILLVOUCHS表时,应按正确的AP_detail表的数据替换Salebillvouchs表的IMONEYSUM。
具体脚本如下:
--
if exists(select * from sysobjects where name=‘c‘)
drop table c
if exists(select * from sysobjects where name=‘d‘)
drop table d
if exists(select * from sysobjects where name=‘e‘)
drop table e
SELECT sum(icamount_f) as icamount_f,sum(icamount) as icamount,ibvid
INTO c
FROM Ap_Detail
WHERE (cFlag = ‘ar‘) AND (cCoVouchType IN (‘26‘, ‘27‘,‘28‘,‘29‘))
and (iFlag <> ‘5‘ or cprocstyle<>‘xj‘)
group by ibvid --包括了核销、预收冲应收、应收冲应付操作。
SELECT iBVid, -(SUM(idAmount)) AS bb, -(SUM(idAmount_f)) AS wb
into d
FROM Ap_Detail
WHERE (cProcStyle = ‘9n‘)
GROUP BY iBVid --红票对冲操作
select isnull(c.icamount_f,0)+isnull(d.wb,0) as wblj,isnull(c.icamount,0)+isnull(d.bb,0) as bblj,ibvid=
case
when c.ibvid is not null then c.ibvid else d.ibvid
end into e
from c full outer join d on c.ibvid=d.ibvid
UPDATE salebillvouchs
SET salebillvouchs.iexchsum = e.wblj,salebillvouchs.imoneysum = e.bblj
from salebillvouchs join e on e.ibvid = salebillvouchs.autoid
where e.bbljsalebillvouchs.imoneysum or e.wblj<>salebillvouchs.iexchsum
|