src-db/database/model/triggers/C_CASHLINE_CHK_RESTRICT_TRG.xml
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 2078 cf88ca44cdd2
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
    22     * All portions are Copyright (C) 2001-2006 Openbravo SL
    22     * All portions are Copyright (C) 2001-2006 Openbravo SL
    23     * All Rights Reserved.
    23     * All Rights Reserved.
    24     * Contributor(s):  ______________________________________.
    24     * Contributor(s):  ______________________________________.
    25     ************************************************************************/
    25     ************************************************************************/
    26   v_Processed CHAR(1) ;
    26   v_Processed CHAR(1) ;
    27   v_C_CASH_ID NUMBER(10) ;
    27   v_C_CASH_ID VARCHAR2(32) ;
    28 BEGIN
    28 BEGIN
    29   IF INSERTING THEN
    29   IF INSERTING THEN
    30     v_C_CASH_ID:=:NEW.C_CASH_ID;
    30     v_C_CASH_ID:=:NEW.C_CASH_ID;
    31   ELSE
    31   ELSE
    32     v_C_CASH_ID:=:OLD.C_CASH_ID;
    32     v_C_CASH_ID:=:OLD.C_CASH_ID;
    34   SELECT PROCESSED INTO v_Processed FROM C_CASH WHERE C_CASH_ID=v_C_CASH_ID;
    34   SELECT PROCESSED INTO v_Processed FROM C_CASH WHERE C_CASH_ID=v_C_CASH_ID;
    35   IF UPDATING THEN
    35   IF UPDATING THEN
    36     IF(v_Processed='Y'
    36     IF(v_Processed='Y'
    37       AND (
    37       AND (
    38         (COALESCE(:OLD.LINE, 0) <> COALESCE(:NEW.LINE, 0))
    38         (COALESCE(:OLD.LINE, 0) <> COALESCE(:NEW.LINE, 0))
    39         OR(COALESCE(:OLD.C_CHARGE_ID, 0) <> COALESCE(:NEW.C_CHARGE_ID, 0))
    39         OR(COALESCE(:OLD.C_CHARGE_ID, '0') <> COALESCE(:NEW.C_CHARGE_ID, '0'))
    40         OR(COALESCE(:OLD.CASHTYPE, '.') <> COALESCE(:NEW.CASHTYPE, '.'))
    40         OR(COALESCE(:OLD.CASHTYPE, '.') <> COALESCE(:NEW.CASHTYPE, '.'))
    41         OR(COALESCE(:OLD.AMOUNT, 0) <> COALESCE(:NEW.AMOUNT, 0))
    41         OR(COALESCE(:OLD.AMOUNT, 0) <> COALESCE(:NEW.AMOUNT, 0))
    42         OR(COALESCE(:OLD.DISCOUNTAMT, 0) <> COALESCE(:NEW.DISCOUNTAMT, 0))
    42         OR(COALESCE(:OLD.DISCOUNTAMT, 0) <> COALESCE(:NEW.DISCOUNTAMT, 0))
    43         OR(COALESCE(:OLD.WRITEOFFAMT, 0) <> COALESCE(:NEW.WRITEOFFAMT, 0))
    43         OR(COALESCE(:OLD.WRITEOFFAMT, 0) <> COALESCE(:NEW.WRITEOFFAMT, 0))
    44         OR(
    44         OR(
    45           COALESCE(:OLD.C_DEBT_PAYMENT_ID, 0) <> COALESCE(:NEW.C_DEBT_PAYMENT_ID, 0)
    45           COALESCE(:OLD.C_DEBT_PAYMENT_ID, '0') <> COALESCE(:NEW.C_DEBT_PAYMENT_ID, '0')
    46           AND(:OLD.C_ORDER_ID IS NULL))
    46           AND(:OLD.C_ORDER_ID IS NULL))
    47         OR(COALESCE(:OLD.C_ORDER_ID, 0) <> COALESCE(:NEW.C_ORDER_ID, 0))
    47         OR(COALESCE(:OLD.C_ORDER_ID, '0') <> COALESCE(:NEW.C_ORDER_ID, '0'))
    48         OR(COALESCE(:old.AD_CLIENT_ID, 0) <> COALESCE(:new.AD_CLIENT_ID, 0)))) THEN
    48         OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')))) THEN
    49       RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
    49       RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
    50     END IF;
    50     END IF;
    51   END IF;
    51   END IF;
    52   IF((DELETING OR INSERTING) AND v_Processed='Y') THEN
    52   IF((DELETING OR INSERTING) AND v_Processed='Y') THEN
    53     RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
    53     RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;