src-db/database/model/triggers/MA_WRPHASE_TRG.xml
changeset 25175 9e11efa4229f
parent 14983 fcf3ccf492f3
equal deleted inserted replaced
25174:b112216b499b 25175:9e11efa4229f
    12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    13 * License for the specific  language  governing  rights  and  limitations
    13 * License for the specific  language  governing  rights  and  limitations
    14 * under the License.
    14 * under the License.
    15 * The Original Code is Openbravo ERP.
    15 * The Original Code is Openbravo ERP.
    16 * The Initial Developer of the Original Code is Openbravo SLU
    16 * The Initial Developer of the Original Code is Openbravo SLU
    17 * All portions are Copyright (C) 2011 Openbravo SLU
    17 * All portions are Copyright (C) 2011-2014 Openbravo SLU
    18 * All Rights Reserved.
    18 * All Rights Reserved.
    19 * Contributor(s):  ______________________________________.
    19 * Contributor(s):  ______________________________________.
    20 ************************************************************************/
    20 ************************************************************************/
    21 
    21 
    22     
    22     
    24     
    24     
    25     IF AD_isTriggerEnabled()='N' THEN RETURN;
    25     IF AD_isTriggerEnabled()='N' THEN RETURN;
    26     END IF;
    26     END IF;
    27 
    27 
    28 IF (INSERTING) THEN
    28 IF (INSERTING) THEN
    29 	UPDATE MA_WORKREQUIREMENT 
    29 	UPDATE MA_WORKREQUIREMENT SET 
    30 	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME
    30   ENDDATE = ADD_HMS(STARTDATE, ESTIMATEDTIME + :NEW.ESTIMATEDTIME, 0, 0),
       
    31   ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME, 
       
    32   RUNTIME = RUNTIME + :NEW.RUNTIME
    31 	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
    33 	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
    32 END IF;
    34 END IF;
    33 
    35 
    34 IF (UPDATING) THEN
    36 IF (UPDATING) THEN
    35 	UPDATE MA_WORKREQUIREMENT 
    37 	UPDATE MA_WORKREQUIREMENT SET 
    36 	SET ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME - :OLD.RUNTIME
    38   ENDDATE = ADD_HMS(STARTDATE, ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME, 0, 0),
       
    39   ESTIMATEDTIME = ESTIMATEDTIME + :NEW.ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME + :NEW.RUNTIME - :OLD.RUNTIME
    37 	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
    40 	WHERE MA_WORKREQUIREMENT_ID = :NEW.MA_WORKREQUIREMENT_ID;
    38 END IF;
    41 END IF;
    39 
    42 
    40 IF (DELETING) THEN
    43 IF (DELETING) THEN
    41 	UPDATE MA_WORKREQUIREMENT 
    44 	UPDATE MA_WORKREQUIREMENT SET 
    42 	SET ESTIMATEDTIME = ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME - :OLD.RUNTIME
    45   ENDDATE = ADD_HMS(STARTDATE, ESTIMATEDTIME - :OLD.ESTIMATEDTIME, 0, 0),
       
    46   ESTIMATEDTIME = ESTIMATEDTIME - :OLD.ESTIMATEDTIME, RUNTIME = RUNTIME - :OLD.RUNTIME
    43 	WHERE MA_WORKREQUIREMENT_ID = :OLD.MA_WORKREQUIREMENT_ID;
    47 	WHERE MA_WORKREQUIREMENT_ID = :OLD.MA_WORKREQUIREMENT_ID;
    44 END IF;
    48 END IF;
       
    49 
    45 
    50 
    46 END MA_WRPHASE_TRG
    51 END MA_WRPHASE_TRG
    47 ]]></body>
    52 ]]></body>
    48     </trigger>
    53     </trigger>
    49   </database>
    54   </database>