ALTER TABLE COBROS ADD NRO_TIPO_COBRO INTEGER;
-----
ALTER TABLE COBROS ADD ANULADO BOOLEAN NOT NULL;
-----
ALTER TABLE COBROS ADD ANULADO_FECHA TIMESTAMP;
-----
CREATE OR ALTER TRIGGER COBROS_BI FOR COBROS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.NRO_COBRO IS NULL) THEN BEGIN
    NEW.NRO_COBRO = GEN_ID(ORDEN_GEN, 1);
  END
  NEW.NUMERO = 'REC-' || LPAD(NEW.NRO_PUNTO_COBRO, 3, '0') || '-' || LPAD(NEW.NRO_RECIBO, 8, '0');
  NEW.ANULADO = FALSE;
END
-----
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;
  END
END