
if exists(select * from sys.objects where name ='_tarifasNoasignadas') drop procedure _tarifasNoasignadas
GO

create procedure _tarifasNoasignadas
	@p_alquiler int
as
begin


select id,itemdocumento
from doc_itemdocumento 
where id_documento=@p_alquiler and id_catalogo>0
	and id_catalogo not in (
		select id_catalogo_tarifa
		from cat_tarifacatalogo CONF, equ_detalleAlquiler DA
		where CONF.id_catalogo_elemento=DA.id_catalogo
		and CONF.active=1 and DA.active=1
		and DA.[id_documento.alquiler]=@p_alquiler)
	and id_catalogo in (
		select id 
		from [cat_catalogo.otro] CATOTRO
		where periodoAlquiler>0 and CATOTRO.active=1)

end
go

