src-db/database/model/triggers/MA_WRPHASE_TRG.xml
author rafaeldemiguel <rdm@openbravo.com>
Thu, 22 Sep 2011 18:28:46 +0200
changeset 14983 fcf3ccf492f3
parent 14979 da3863fa640f
child 25175 9e11efa4229f
permissions -rw-r--r--
[Production-Development] Triggers, DisplayLogics and ReadonlyLogics for windows WorkEffort and Production Run
<?xml version="1.0"?>
  <database name="TRIGGER MA_WRPHASE_TRG">
    <trigger name="MA_WRPHASE_TRG" table="MA_WRPHASE" fires="after" insert="true" update="true" delete="true" foreach="row">
      <body><![CDATA[
/*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************/

    
BEGIN
    
    IF AD_isTriggerEnabled()='N' THEN RETURN;
    END IF;

IF (INSERTING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
END IF;

IF (UPDATING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME - :OLD.RUNTIME
	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
END IF;

IF (DELETING) THEN
	UPDATE MA_WORKREQUIREMENT 
	SET ESTIMATEDTIME = ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME - :OLD.RUNTIME
	WHERE MA_WORKREQUIREMENT_ID = :OLD.MA_WORKREQUIREMENT_ID;
END IF;

END MA_WRPHASE_TRG
]]></body>
    </trigger>
  </database>