发货通知单对库存进行控制

栏目:k3wise知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:2

发货通知单对库存进行控制

发货通知单进行保存、审核时,如果即时库存数量不足,单据不可以保存、审核
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;


多行记录,有一行库存满足时,可以审核。

发货通知单对库存进行控制

发货通知单进行保存、审核时,如果即时库存数量不足,单据不可以保存、审核IF OBJECT_ID(N'FHTZD', 'TR') IS NOT NULL DROP T...
点击下载文档
分享:
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息