📄 m_matchpo_trg.sql
字号:
CREATE OR REPLACE TRIGGER M_MatchPO_Trg
AFTER DELETE OR INSERT OR UPDATE
ON M_MatchPO
FOR EACH ROW
DECLARE
/*************************************************************************
* The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.compiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Compiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: M_MatchPO_Trg.sql,v 1.1 2002/05/29 04:25:38 jjanke Exp $
***
* Title: Update PO Invoiced/Delivered Quantity
* Description:
************************************************************************/
v_Qty NUMBER := 0;
v_InvoiceLine_ID NUMBER;
V_OrderLine_ID NUMBER;
BEGIN
IF (DELETING OR UPDATING) THEN
v_Qty := v_Qty - :old.Qty;
v_OrderLine_ID := :old.C_OrderLine_ID;
v_InvoiceLine_ID := :old.C_InvoiceLine_ID;
END IF;
IF (INSERTING OR UPDATING) THEN
v_Qty := v_Qty + :new.Qty;
v_OrderLine_ID := :new.C_OrderLine_ID;
v_InvoiceLine_ID := :new.C_InvoiceLine_ID;
END IF;
-- We need to update
IF (v_Qty <> 0) THEN
IF (v_InvoiceLine_ID IS NULL) THEN
-- Update Received
UPDATE C_OrderLine
SET QtyDelivered = QtyDelivered + v_Qty
WHERE C_OrderLine_ID=v_OrderLine_ID;
ELSE
-- Update Invoiced
UPDATE C_OrderLine
SET QtyInvoiced = QtyInvoiced + v_Qty
WHERE C_OrderLine_ID=v_OrderLine_ID;
END IF;
END IF;
END M_MatchPO_Trg;
/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -