发货通知单对库存进行控制
发货通知单进行保存、审核时,如果即时库存数量不足,单据不可以保存、审核
IF OBJECT_ID(N'FHTZD', 'TR') IS NOT NULL
DROP TRIGGER FHTZD;--发货通知单
GO
CREATE TRIGGER FHTZD
ON dbo.SEOutStock
FOR UPDATE--INSERT:单据保存时触发;UPDATE:单据审核时触发
AS
DECLARE @Finterid INT;
DECLARE @FTranType INT;
SELECT DISTINCT @Finterid = FInterID
FROM Inserted;
SELECT DISTINCT @FTranType = FTranType
FROM Inserted;
IF NOT EXISTS ( SELECT 1
FROM dbo.SEOutStockEntry A
INNER JOIN dbo.SEOutStock B ON A.FInterID = B.FInterID
INNER JOIN ( SELECT FItemID ,
FStockID ,
FBatchNo ,
SUM(FQty) AS FQTY
FROM dbo.ICInventory
WHERE FQty > 0
GROUP BY FItemID ,
FStockID ,
FBatchNo ) C ON A.FItemID = C.FItemID
WHERE C.FQTY >= A.FQty
AND C.FStockID = A.FStockID
AND C.FBatchNo = A.FBatchNo
AND B.FTranType = @FTranType
AND B.FInterID = @Finterid )
BEGIN
SET NOCOUNT ON;
RAISERROR('出库数量超出对应仓库,对应批次数量,请核实!', 16, 1);
ROLLBACK;
END;
多行记录,有一行库存满足时,可以审核。
发货通知单对库存进行控制
本文2024-09-16 15:51:54发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-5556.html