CREATE OR ALTER TRIGGER COBROS_BU FOR COBROS
ACTIVE BEFORE UPDATE POSITION 0
AS
BEGIN
  NEW.NUMERO = 'REC-' || LPAD(NEW.NRO_PUNTO_COBRO, 3, '0') || '-' || LPAD(NEW.NRO_RECIBO, 8, '0');
  IF (NEW.ANULADO) THEN BEGIN
    NEW.ANULADO_FECHA = CURRENT_TIMESTAMP;
    NEW.IMPORTE = 0;
    NEW.DESCUENTO = 0;
    DELETE FROM RELACION_CUENTA_CORRIENTE
      WHERE
        RELACION_CUENTA_CORRIENTE.NRO_HABER = NEW.NRO_COBRO;
  END
END