CREATE TRIGGER trigger_insertar_FENumeroDocumento
ON SharedDB.InfoVentas
AFTER INSERT
AS
BEGIN
DECLARE @FENumeroFactura VARCHAR(50) = (SELECT FENumeroFactura FROM inserted)
DECLARE @idInfoVenta INT  = (SELECT idInfoVenta FROM inserted)
DECLARE @idTipoTransaccion INT  = (SELECT idTipoTransaccion FROM inserted)
DECLARE @FENumeroDocumento VARCHAR(20) = (SELECT FENumeroDocumento FROM inserted)

IF @FENumeroFactura IS NULL AND @idTipoTransaccion = 1 AND @FENumeroDocumento IS NULL
BEGIN
	UPDATE SharedDB.InfoVentas SET FENumeroDocumento = '22222222222' WHERE idInfoVenta = @idInfoVenta
END
END

