采购订单序时簿订单总金额与采购订单总金额不相等
金蝶云社区-云小爱
云小爱
0人赞赏了该文章 1,354次浏览 未经作者许可,禁止转载编辑于2015年02月10日 09:17:17

软件版本:商贸高级版6.0
操作系统:windows2003
数据库:sql2005
问题描述:
序时簿中心单独查询采购订单显示的单个订单金额列与原订单金额合计数不相等
,而是显示采购订单最后一条分录的金额。其他单据没有这个问题。
以下是问题重现图片:

补充说明:我们在保存采购订单单据时在数据库做的跟踪
采购订单有两条分录 每一条商品价税合计都是25元,总合计数是50。
以下是插入序时簿表代码:
INSERT INTO
t_cg_order
(FBillNo,FDate,FSupplyID,FContact,FPhone,FPOStyle,FJHDate,FFax,Faddres
s,FExplanation,FCGDeposit,FUserDefine1,FUserDefine2,FUserDefine3,FUser
Define4,FUserDefine5,FUserDefine6,FEmpID,FDeptID,FBillerID,FCheckerID,
FID,FClassTypeID,FCheckDate,FPrintCounts,FStatus,FAllAmount)
Values('CGDD20150200034','2015-02-10',5881,'','',0,'2015-02-
10','','','',0,'','','','','','',0,0,16394,0,1042,1020001,NULL,0,'0',5
0)
以及插入明细序时簿的代码:
INSERT INTO
t_cg_orderEntry
(FID,FIndex,FItemID,FAuxPropID,FShowUnitID,FShowQty,FSecUnitID,FSecCoe
fficient,FSecQty,FPrice,FDiscountRate,FDiscountPrice,FTaxRate,FSecPric
e,FTaxPrice,FDiscountAmount,FAmount,FTaxAmount,FInTaxAmount,FNOTE,FSto
ckInQty,FSecStockInQty,FTotalQty,FCgOrderQty,FXsOrderQty,FInTotalQty,F
BillUserText1,FBillUserText2,FBillUserText3,FUserFormula1,FUserFormula
2,FUserFormula3,FUnStockInQty,FSecUnStockInQty,FQty,FUnitID,FCoefficie
nt,FID_SRC)
Values
(1042,1,3732,0,69,1,0,0,0,25,100,25,0,0,25,0,25,0,25,'',0,0,0,2,0,2,''
,'','',0,0,0,0,0,1,69,1,0)
INSERT INTO
t_cg_orderEntry
(FID,FIndex,FItemID,FAuxPropID,FShowUnitID,FShowQty,FSecUnitID,FSecCoe
fficient,FSecQty,FPrice,FDiscountRate,FDiscountPrice,FTaxRate,FSecPric
e,FTaxPrice,FDiscountAmount,FAmount,FTaxAmount,FInTaxAmount,FNOTE,FSto
ckInQty,FSecStockInQty,FTotalQty,FCgOrderQty,FXsOrderQty,FInTotalQty,F
BillUserText1,FBillUserText2,FBillUserText3,FUserFormula1,FUserFormula
2,FUserFormula3,FUnStockInQty,FSecUnStockInQty,FQty,FUnitID,FCoefficie
nt,FID_SRC)
Values
(1042,2,3732,0,69,1,0,0,0,25,100,25,0,0,25,0,25,0,25,'',0,0,0,2,0,2,''
,'','',0,0,0,0,0,1,69,1,0)
通过代码发现序时簿中心取数是在t_cg_order表中,而在代码中插入的数是50这
个合计数,但是现在再查采购订单序时簿,数据显示是25.
后来我们发现在插入的明细序时簿t_cg_orderentry表与t_cg_order表有依赖关
系,t_cg_orderentry表里有一个触发器。
以下是触发器代码:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
--商贸标准版3.0--PT045914--ChenJingJing--20110329--End
-----PT047755 --beg--插件m_BillInterface_BeforeSave里面会把FTaxAmount
的FModify改为1
----------------------------------------------------------------------
---------------------------------------------------------
--------------------------------------------------------触发器、存储过
程等--------------------------------------------------------
ALTER TRIGGER [UpdateorderEntry] ON [dbo].[t_cg_orderEntry]
FOR INSERT, UPDATE
AS
If Update(FShowQty) Or Update(FSecQty)
Begin
Update u Set
u.FUnStockInQty=u.FShowQty,u.FSecUnStockInQty=u.FSecQty
From t_cg_orderEntry u Inner Join Inserted i On u.FID=i.FID
And u.FEntryID=i.FEntryID
End
If Update(FInTaxAmount) or Update(FTaxAmount) -----PT047755 插件
m_BillInterface_BeforeSave里面会把FTaxAmount的FModify改为1
Begin
Update v Set v.FAllAmount=(Select Sum(u.FInTaxAmount) From
T_CG_OrderEntry u Inner Join Inserted i1 On i1.FID=u.FID)
From T_CG_order v Inner Join Inserted i2 On i2.FID=v.FID
End
If Update(FUnstockInQty) Or Update(FSecUnstockInQty)
Begin
update t_CG_Order set FStatus=1
where FID in (select distinct y.FID from Inserted y inner join
t_CG_OrderEntry x on x.FID=y.FID where IsNUll(x.FUnstockInQty,0)>0 )
AND FStatus=2

update t_CG_Order set FStatus=2
where FID in (select distinct FID from Inserted) and FID not
in
(select distinct y.FID from Inserted y inner
join t_CG_OrderEntry x on x.FID=y.FID where IsNUll(x.FUnstockInQty,0)
>0 ) AND FStatus=1
End
最后我们筛选出把 插入的50这个数改变成最后一跳分录数的代码是:
If Update(FInTaxAmount) or Update(FTaxAmount) -----PT047755 插件
m_BillInterface_BeforeSave里面会把FTaxAmount的FModify改为1
Begin
Update v Set v.FAllAmount=(Select Sum(u.FInTaxAmount) From
T_CG_OrderEntry u Inner Join Inserted i1 On i1.FID=u.FID)
From T_CG_order v Inner Join Inserted i2 On i2.FID=v.FID
End
把这个删了的话就把问题解决了。
现在我们不知道把这个语句删了会有什么影响。所以想问一下总部这边,这个语
句删了会对原帐套造成什么影响,会影响以后的什么问题。