销售增值税专用发票报错
金蝶云社区-云社区用户1lN01718
云社区用户1lN01718
0人赞赏了该文章 614次浏览 未经作者许可,禁止转载编辑于2018年08月22日 10:01:07

cloud6.2版本7月12日最新补丁,版本号6.2.1012.4

场景描述:销售增值税专用发票下推生成后,由于与纸质发票有尾差,故调整不含税金额-0.01~0.01的尾差后审核提示如下报错,不修改金额则可以审核通过。未打补丁前同样操作下发票会修正应收单的金额,形成应收调整单。目前这种状况导致客户很多业务都无法进行处理,请总部老师帮忙看下谢谢。
parse error. detail message is :
Error
source sql is :
DELETE T_CRE_CREDITBILLDATA
DELETE T_CRE_CREDITBILLALLDATA
DELETE T_CRE_CRESRCBILLDATA
INSERT INTO #TM_CRE_ARCHIVEDATA(FBILLFORMID,FCTRLSCOPE,FARCHIVEENTRYID,FORGID,FDEPTID,FOBJECTTYPE,FOBJECTID,FCREDITSTATUS,FBILLTYPEID,FCHECKPOINT)
SELECT tcl.FBILLFORMID,a.FCTRLSCOPE,b.FENTRYID as FARCHIVEENTRYID,a.FORGID,a.FDEPTID,a.FOBJECTTYPE,
b.FOBJECTID,b.FCREDITSTATUS,tcl.FBILLTYPEID ,tcl.FCHECKPOINT
FROM T_CRE_CUSTARCHIVES a
join T_CRE_CUSTARCHIVESENTRY b on a.FID=b.FID
join T_CRE_CHECKRULEENTRY tcl on b.FCHECKRULEID = tcl.FID
WHERE b.frowauditstatus='A' and (tcl.FBILLFORMID = 'AR_receivable' OR b.fcheckruleid = 10147)
INSERT INTO T_CRE_CREDITBILLDATA (FBILLFORMID,FBILLTYPEID,FBILLID,FENTRYID,FORGID,FCUSTID,FDEPTID,FSALERID,FSALEGROUPID,
FCURRENCYID,FBASEUNITQTY,FSRCTYPE,FBILLCREDITAMOUNT,FDOCUMENTSTATUS,FORIENT)

SELECT distinct 'AR_receivable'
,t0.FBILLTYPEID As FBILLTYPEID
,t0.FID
,t1.FENTRYID
,t0.FSALEORGID As FSALEORGID
,t0.FCUSTOMERID As FCUSTOMERID
,t0.FSALEDEPTID As FSALEDEPTID
,t0.FSALEERID As FSALEERID
,t0.FSALEGROUPID As FSALEGROUPID
,t0.FCURRENCYID As FCURRENCYID
,t1_O.FSALBASEQTY As FSALBASEQTY
,t1.FSOURCETYPE As FSOURCETYPE
,t1.FALLAMOUNTFOR As FALLAMOUNTFOR_D
,FDocumentStatus,'+'
FROM
t_AR_receivable t0 LEFT JOIN t_AR_receivableEntry t1
ON (t0.FID = t1.FID ) LEFT JOIN t_AR_receivableEntry_O t1_O
ON (t1.FENTRYID = t1_O.FENTRYID ) WHERE ((t0.FID IN (106474) AND t0.FCASHSALE = 0) AND (t0.FSETACCOUNTTYPE <> '2'))
AND t1.FENTRYID is not null

INSERT INTO T_CRE_CREDITUSEDETAIL(FROWID,FORGID,FOBJECTTYPE,FOBJECTID,FCURRENCYID,FCTRLSCOPE,FARCHIVEENTRYID,FDEPTID,FTYPE,FFORMID,FBILLID,FCREDITAMOUNT,FDATETIME)
SELECT NEWID(),TC.FORGID,TC.FOBJECTTYPE,TCE.FOBJECTID,T1.FCURRENCYID,TC.FCTRLSCOPE,T1.FARCHIVEENTRYID,TC.FDEPTID,
'UNOCCUPY',T2.FBILLFORMID,T2.FBILLID,-1*SUM(CASE WHEN T1.FORIENT='+' THEN T1.FBILLCREDITAMOUNT - T1.FSRCCREDITAMOUNT ELSE T1.FSRCCREDITAMOUNT - T1.FBILLCREDITAMOUNT END) AS FDIFFAMOUNT,{ts'2018-08-22 09:51:58'}
FROM T_AR_RECEIVABLEENTRY_CRE T1
JOIN T_CRE_CREDITBILLDATA T2 ON T1.FENTRYID = T2.FENTRYID
join T_CRE_CUSTARCHIVESENTRY TCE ON T1.FARCHIVEENTRYID = TCE.FENTRYID
JOIN T_CRE_CUSTARCHIVES TC ON TCE.FID = TC.FID
GROUP BY TC.FORGID,TC.FOBJECTTYPE,TCE.FOBJECTID,T1.FCURRENCYID,TC.FCTRLSCOPE,T1.FARCHIVEENTRYID,TC.FDEPTID,T2.FBILLFORMID,T2.FBILLID
DELETE FROM T_AR_RECEIVABLEENTRY_CRE
WHERE exists(SELECT 1 from T_CRE_CREDITBILLDATA t1 WHERE T_AR_RECEIVABLEENTRY_CRE.FENTRYID = t1.FENTRYID )

INSERT INTO #TM_CRE_CREDITBILLDATA(FORGID, FBILLID, FENTRYID, FARCHIVEENTRYID, FCURRENCYID, FBASEUNITQTY, FBILLCREDITAMOUNT, FSRCCREDITAMOUNT, FORIENT )
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, to_decimal(0,23,10) AS FSRCCREDITAMOUNT, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN T_ORG_ORGANIZATIONS torg ON t1.FORGID = torg.FORGID
INNER JOIN T_BD_CUSTOMER tc ON t1.FCUSTID = tc.FCUSTID
LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = torg.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_Customer' AND tt.FOBJECTID = tc.FMASTERID )
UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, to_decimal(0,23,10) AS FSRCCREDITAMOUNT, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN(
SELECT distinct TORG.FPARENTID,TMC.FCUSTIDOLD,TC.FGROUPCUSTID,TORG.FORGID
FROM T_BD_CUSTOMER TC
INNSER JOIN T_ORG_ORGANIZATIONS TORG ON TORG.FORGID = TC.FUSEORGID
INNER JOIN (SELECT TC1.FMASTERID,T2.FCUSTID AS FCUSTIDOLD FROM T_BD_CUSTOMER TC1
INNER JOIN T_CRE_CREDITBILLDATA T2 ON TC1.FCUSTID=T2.FCUSTID ) TMC ON TC.FMASTERID=TMC.FMASTERID
) TCO ON (TCO.FORGID=T1.FORGID AND t1.FCUSTID=TCO.FCUSTIDOLD)
INNER JOIN T_BD_CUSTOMER tcg ON tcg.FCUSTID = TCO.FGROUPCUSTID
LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = TCO.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_GroupCustomer' AND tt.FOBJECTID = tcg.FMASTERID )
UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tn3.FENTRYID as FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, to_decimal(0,23,10) AS FSRCCREDITAMOUNT, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN(
SELECT distinct TORG.FPARENTID,TMC.FCUSTIDOLD,TC.FGROUPCUSTID,TORG.FORGID
FROM T_BD_CUSTOMER TC
INNSER JOIN T_ORG_ORGANIZATIONS TORG ON TORG.FORGID = TC.FUSEORGID
INNER JOIN (SELECT TC1.FMASTERID,T2.FCUSTID AS FCUSTIDOLD FROM T_BD_CUSTOMER TC1
INNER JOIN T_CRE_CREDITBILLDATA T2 ON TC1.FCUSTID=T2.FCUSTID ) TMC ON TC.FMASTERID=TMC.FMASTERID
) TCO ON (TCO.FORGID=T1.FORGID AND t1.FCUSTID=TCO.FCUSTIDOLD)
INNER JOIN T_BD_CUSTOMER tn1 ON tn1.FCUSTID = TCO.FGROUPCUSTID

LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN v_CRE_CreditObjectInfo tt ON (tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = TCO.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_Customer' AND tt.FOBJECTID = tc.FMASTERID )
AND tt.FBILLFORMID = 'AR_receivable' AND tt.FUPDATECREDITAMOUNT = '1'
INNER JOIN T_CRE_CUSTARCHIVESENTRY tn3 ON tn3.FOBJECTID = tn1.FMASTERID AND tn3.FCHECKRULEID=10147
INNER JOIN T_CRE_CUSTARCHIVES tn2 ON tt.FORGID = tn2.FORGID AND tn3.FID = tn2.FID AND (tn2.FORGID = t1.FORGID OR tn2.FORGID = torg.FPARENTID OR tn2.FORGID = 1) AND tn2.FOBJECTTYPE = 'BD_GroupCustomer'
UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, 0, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN T_ORG_ORGANIZATIONS torg ON t1.FORGID = torg.FORGID
INNER JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = torg.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_Department' AND tt.FOBJECTID = td.FMASTERID) UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, 0, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN T_ORG_ORGANIZATIONS torg ON t1.FORGID = torg.FORGID
LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = torg.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'ORG_Organizations' AND tt.FOBJECTID = t1.FORGID) UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, 0, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN T_ORG_ORGANIZATIONS torg ON t1.FORGID = torg.FORGID
LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = torg.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_Saler' AND tt.FOBJECTID = t1.FSALERID) UNION ALL
SELECT tt.FORGID, t1.FBILLID, t1.FENTRYID, tt.FARCHIVEENTRYID, t1.FCURRENCYID, t1.FBASEUNITQTY, t1.FBILLCREDITAMOUNT, 0, FORIENT
FROM T_CRE_CREDITBILLDATA t1
INNER JOIN T_ORG_ORGANIZATIONS torg ON t1.FORGID = torg.FORGID
LEFT JOIN T_BD_DEPARTMENT td ON t1.FDEPTID = td.FDEPTID
INNER JOIN #TM_CRE_ARCHIVEDATA tt ON
(tt.FBILLTYPEID = '8F7BFAF1AB0A4DCFBCE09A540F19C5C3' OR tt.FBILLTYPEID = t1.FBILLTYPEID)
AND (tt.FCHECKPOINT = '1' OR (tt.FCHECKPOINT = '2' AND t1.FDOCUMENTSTATUS = 'C'))
AND (tt.FORGID = t1.FORGID OR tt.FORGID = torg.FPARENTID OR tt.FORGID = 1)
AND (tt.FDEPTID = 0 OR tt.FDEPTID=td.FMASTERID)
AND (tt.FOBJECTTYPE = 'BD_SaleGroup' AND tt.FOBJECTID = t1.FSALEGROUPID)
INSERT INTO T_AR_RECEIVABLEENTRY_CRE(FENTRYID,FARCHIVEENTRYID,FCURRENCYID,FORIENT,FBASEUNITQTY,FBILLCREDITAMOUNT,FSRCCREDITAMOUNT,FEXECCREDITAMOUNT,FCLOSECREDITAMOUNT,FCREDITSRCFORMID,FCREDITTARGETFORMID)
SELECT FENTRYID,FARCHIVEENTRYID,FCURRENCYID,FORIENT,SUM(FBASEUNITQTY),SUM(FBILLCREDITAMOUNT),SUM(FSRCCREDITAMOUNT),0,0,' ',' '
FROM #TM_CRE_CREDITBILLDATA
GROUP BY FENTRYID,FARCHIVEENTRYID,FCURRENCYID,FORIENT

DELETE T_CRE_SRCBILLDATA
DELETE T_CRE_SRCBILLDATASIMPLE
INSERT INTO T_CRE_SRCBILLDATA(FID,FBILLENTRYID,FARCHIVEENTRYID,FCHECKRULEID,FSRCALLFORMID)
SELECT NEWID(),t1.FENTRYID,t2.FARCHIVEENTRYID,t2.FCHECKRULEID,t1.FSRCALLFORMID
FROM(
SELECT distinct FARENTRYID AS FENTRYID,FARSRCFORMID AS FSRCALLFORMID FROM T_CRE_TRACK WHERE FARSRCFORMID<>' '
) t1
join
(
SELECT t1.FENTRYID,t1.FARCHIVEENTRYID,t2.FCHECKRULEID
FROM T_AR_RECEIVABLEENTRY_CRE t1
join T_CRE_CUSTARCHIVESENTRY t2 on t1.FARCHIVEENTRYID = t2.FENTRYID) t2 on t1.FENTRYID=t2.FENTRYID
join T_CRE_CREDITBILLDATA t3 on t1.FENTRYID = t3.FENTRYID
UPDATE T_CRE_SRCBILLDATA SET FCHARINDEX1 = charindex('|', FSRCALLFORMID, 1)
UPDATE T_CRE_SRCBILLDATA SET FCHARINDEX2 = charindex('|', FSRCALLFORMID, FCHARINDEX1 + 1) WHERE FCHARINDEX1 > 0
UPDATE T_CRE_SRCBILLDATA SET FCHARINDEX3 = charindex('|', FSRCALLFORMID, FCHARINDEX2 + 1) WHERE FCHARINDEX2 > 0
UPDATE T_CRE_SRCBILLDATA SET FCHARINDEX4 = charindex('|', FSRCALLFORMID, FCHARINDEX3 + 1) WHERE FCHARINDEX3 > 0
UPDATE T_CRE_SRCBILLDATA SET FCHARINDEX5 = charindex('|', FSRCALLFORMID, FCHARINDEX4 + 1) WHERE FCHARINDEX4 > 0
UPDATE T_CRE_SRCBILLDATA SET FSRCFORMID1 = RTRIM(LTRIM(substring(FSRCALLFORMID,1,FCHARINDEX1 - 1 ))) WHERE FCHARINDEX1 > 0
UPDATE T_CRE_SRCBILLDATA SET FSRCFORMID2 = RTRIM(LTRIM(substring(FSRCALLFORMID,FCHARINDEX1 + 1,FCHARINDEX2 - FCHARINDEX1 - 1))) WHERE FCHARINDEX2 > 0
UPDATE T_CRE_SRCBILLDATA SET FSRCFORMID3 = RTRIM(LTRIM(substring(FSRCALLFORMID,FCHARINDEX2 + 1,FCHARINDEX3 - FCHARINDEX2 - 1))) WHERE FCHARINDEX3 > 0
UPDATE T_CRE_SRCBILLDATA SET FSRCFORMID4 = RTRIM(LTRIM(substring(FSRCALLFORMID,FCHARINDEX3 + 1,FCHARINDEX4 - FCHARINDEX3 - 1))) WHERE FCHARINDEX4 > 0
UPDATE T_CRE_SRCBILLDATA SET FSRCFORMID5 = RTRIM(LTRIM(substring(FSRCALLFORMID,FCHARINDEX4 + 1,FCHARINDEX5 - FCHARINDEX4 - 1))) WHERE FCHARINDEX5 > 0